From b861602ae80954c5559dd00ea216677315d11414 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 13 Sep 2023 01:35:20 +0200 Subject: [PATCH] More configuration options for time tick density --- history-explorer-card.js | 10 +++++----- src/history-explorer-card.js | 15 +++++++++++---- src/history-info-panel.js | 4 +++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/history-explorer-card.js b/history-explorer-card.js index 91d34af..86596fa 100644 --- a/history-explorer-card.js +++ b/history-explorer-card.js @@ -1,4 +1,4 @@ -(function(){var __f=function(e,t){window.HXLocal_moment=t()};__f(this,function(){"use strict";var e;function h(){return e.apply(null,arguments)}function a(e){return e instanceof Array||"[object Array]"===Object.prototype.toString.call(e)}function o(e){return null!=e&&"[object Object]"===Object.prototype.toString.call(e)}function r(e){return void 0===e}function u(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function s(e){return e instanceof Date||"[object Date]"===Object.prototype.toString.call(e)}function i(e,t){for(var n=[],s=0;s>>0,s=0;sLe(e)?(r=e+1,i-Le(e)):(r=e,i);return{year:r,dayOfYear:i}}function Ie(e,t,n){var s,i,r=Ee(e.year(),t,n),r=Math.floor((e.dayOfYear()-r-1)/7)+1;return r<1?s=r+Ze(i=e.year()-1,t,n):r>Ze(e.year(),t,n)?(s=r-Ze(e.year(),t,n),i=e.year()+1):(i=e.year(),s=r),{week:s,year:i}}function Ze(e,t,n){var s=Ee(e,t,n),n=Ee(e+1,t,n);return(Le(e)-s+n)/7}Z("w",["ww",2],"wo","week"),Z("W",["WW",2],"Wo","isoWeek"),R("week","w"),R("isoWeek","W"),H("week",5),H("isoWeek",5),he("w",K),he("ww",K,J),he("W",K),he("WW",K,J),ye(["w","ww","W","WW"],function(e,t,n,s){t[s.substr(0,1)]=S(e)});Z("d",0,"do","day"),Z("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),Z("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),Z("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),Z("e",0,0,"weekday"),Z("E",0,0,"isoWeekday"),R("day","d"),R("weekday","e"),R("isoWeekday","E"),H("day",11),H("weekday",11),H("isoWeekday",11),he("d",K),he("e",K),he("E",K),he("dd",function(e,t){return t.weekdaysMinRegex(e)}),he("ddd",function(e,t){return t.weekdaysShortRegex(e)}),he("dddd",function(e,t){return t.weekdaysRegex(e)}),ye(["dd","ddd","dddd"],function(e,t,n,s){s=n._locale.weekdaysParse(e,s,n._strict);null!=s?t.d=s:f(n).invalidWeekday=e}),ye(["d","e","E"],function(e,t,n,s){t[s]=S(e)});var ze="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_");var $e="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_");var qe="Su_Mo_Tu_We_Th_Fr_Sa".split("_");var Je=le;var Be=le;var Qe=le;function Xe(){function e(e,t){return t.length-e.length}for(var t,n,s,i=[],r=[],a=[],o=[],u=0;u<7;u++)s=d([2e3,1]).day(u),t=this.weekdaysMin(s,""),n=this.weekdaysShort(s,""),s=this.weekdays(s,""),i.push(t),r.push(n),a.push(s),o.push(t),o.push(n),o.push(s);for(i.sort(e),r.sort(e),a.sort(e),o.sort(e),u=0;u<7;u++)r[u]=fe(r[u]),a[u]=fe(a[u]),o[u]=fe(o[u]);this._weekdaysRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+r.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+i.join("|")+")","i")}function Ke(){return this.hours()%12||12}function et(e,t){Z(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}function tt(e,t){return t._meridiemParse}Z("H",["HH",2],0,"hour"),Z("h",["hh",2],0,Ke),Z("k",["kk",2],0,function(){return this.hours()||24}),Z("hmm",0,0,function(){return""+Ke.apply(this)+N(this.minutes(),2)}),Z("hmmss",0,0,function(){return""+Ke.apply(this)+N(this.minutes(),2)+N(this.seconds(),2)}),Z("Hmm",0,0,function(){return""+this.hours()+N(this.minutes(),2)}),Z("Hmmss",0,0,function(){return""+this.hours()+N(this.minutes(),2)+N(this.seconds(),2)}),et("a",!0),et("A",!1),R("hour","h"),H("hour",13),he("a",tt),he("A",tt),he("H",K),he("h",K),he("k",K),he("HH",K,J),he("hh",K,J),he("kk",K,J),he("hmm",ee),he("hmmss",te),he("Hmm",ee),he("Hmmss",te),_e(["H","HH"],ve),_e(["k","kk"],function(e,t,n){e=S(e);t[ve]=24===e?0:e}),_e(["a","A"],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),_e(["h","hh"],function(e,t,n){t[ve]=S(e),f(n).bigHour=!0}),_e("hmm",function(e,t,n){var s=e.length-2;t[ve]=S(e.substr(0,s)),t[Me]=S(e.substr(s)),f(n).bigHour=!0}),_e("hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[ve]=S(e.substr(0,s)),t[Me]=S(e.substr(s,2)),t[Se]=S(e.substr(i)),f(n).bigHour=!0}),_e("Hmm",function(e,t,n){var s=e.length-2;t[ve]=S(e.substr(0,s)),t[Me]=S(e.substr(s))}),_e("Hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[ve]=S(e.substr(0,s)),t[Me]=S(e.substr(s,2)),t[Se]=S(e.substr(i))});var nt,Oe=L("Hours",!0),st={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Pe,monthsShort:We,week:{dow:0,doy:6},weekdays:ze,weekdaysMin:qe,weekdaysShort:$e,meridiemParse:/[ap]\.?m?\.?/i},it={},rt={};function at(e){return e&&e.toLowerCase().replace("_","-")}function ot(e){var t;if(!it[e]&&"undefined"!=typeof module&&module&&module.exports)try{t=nt._abbr,require("./locale/"+e),ut(t)}catch(e){}return it[e]}function ut(e,t){var n;return(nt=e&&(n=r(t)?dt(e):lt(e,t))?n:nt)._abbr}function lt(e,t){if(null===t)return delete it[e],null;var n=st;if(t.abbr=e,null!=it[e])O("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=it[e]._config;else if(null!=t.parentLocale){if(null==it[t.parentLocale])return rt[t.parentLocale]||(rt[t.parentLocale]=[]),rt[t.parentLocale].push({name:e,config:t}),null;n=it[t.parentLocale]._config}return it[e]=new b(x(n,t)),rt[e]&&rt[e].forEach(function(e){lt(e.name,e.config)}),ut(e),it[e]}function dt(e){var t;if(!(e=e&&e._locale&&e._locale._abbr?e._locale._abbr:e))return nt;if(!a(e)){if(t=ot(e))return t;e=[e]}return function(e){for(var t,n,s,i,r=0;r=t&&k(i,n,!0)>=t-1)break;t--}r++}return null}(e)}function ht(e){var t=e._a;return t&&-2===f(e).overflow&&(t=t[we]<0||11xe(t[ge],t[we])?pe:t[ve]<0||24Ze(n,r,a)?f(e)._overflowWeeks=!0:null!=o?f(e)._overflowWeekday=!0:(a=Ae(n,s,i,r,a),e._a[ge]=a.year,e._dayOfYear=a.dayOfYear)}(e),null!=e._dayOfYear&&(i=Mt(e._a[ge],n[ge]),(e._dayOfYear>Le(i)||0===e._dayOfYear)&&(f(e)._overflowDayOfYear=!0),i=je(i,0,e._dayOfYear),e._a[we]=i.getUTCMonth(),e._a[pe]=i.getUTCDate()),t=0;t<3&&null==e._a[t];++t)e._a[t]=r[t]=n[t];for(;t<7;t++)e._a[t]=r[t]=null==e._a[t]?2===t?1:0:e._a[t];24===e._a[ve]&&0===e._a[Me]&&0===e._a[Se]&&0===e._a[ke]&&(e._nextDay=!0,e._a[ve]=0),e._d=(e._useUTC?je:Ne).apply(null,r),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[ve]=24)}}function kt(e){if(e._f!==h.ISO_8601)if(e._f!==h.RFC_2822){e._a=[],f(e).empty=!0;for(var t,n,s,i,r,a=""+e._i,o=a.length,u=0,l=$(e._f,e._locale).match(j)||[],d=0;de.valueOf():e.valueOf()this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},Q.isLocal=function(){return!!this.isValid()&&!this._isUTC},Q.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},Q.isUtc=Lt,Q.isUTC=Lt,Q.zoneAbbr=function(){return this._isUTC?"UTC":""},Q.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},Q.dates=n("dates accessor is deprecated. Use date instead.",ze),Q.months=n("months accessor is deprecated. Use month instead",Ce),Q.years=n("years accessor is deprecated. Use year instead",Ve),Q.zone=n("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?(this.utcOffset(e="string"!=typeof e?-e:e,t),this):-this.utcOffset()}),Q.isDSTShifted=n("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!r(this._isDSTShifted))return this._isDSTShifted;var e,t={};return w(t,this),(t=Dt(t))._a?(e=(t._isUTC?d:Ot)(t._a),this._isDSTShifted=this.isValid()&&0');var t=t.data,i=t.datasets,n=t.labels;if(i.length)for(var o=0;o'),n[o]&&e.push(n[o]),e.push("");return e.push(""),e.join("")},legend:{labels:{generateLabels:function(s){var l=s.data;return l.labels.length&&l.datasets.length?l.labels.map(function(t,e){var i=s.getDatasetMeta(0),n=l.datasets[0],o=i.data[e],a=o&&o.custom||{},r=b.valueAtIndexOrDefault,o=s.options.elements.arc;return{text:t,fillStyle:a.backgroundColor||r(n.backgroundColor,e,o.backgroundColor),strokeStyle:a.borderColor||r(n.borderColor,e,o.borderColor),lineWidth:a.borderWidth||r(n.borderWidth,e,o.borderWidth),hidden:isNaN(n.data[e])||i.data[e].hidden,index:e}}):[]}},onClick:function(t,e){for(var i,n=e.index,o=this.chart,a=0,r=(o.data.datasets||[]).length;a=Math.PI?-1:n<-Math.PI?1:0))+v,t=Math.cos(n),e=Math.sin(n),o=Math.cos(a),l=Math.sin(a),d=n<=0&&0<=a||n<=2*Math.PI&&2*Math.PI<=a,u=n<=.5*Math.PI&&.5*Math.PI<=a||n<=2.5*Math.PI&&2.5*Math.PI<=a,v=n<=-Math.PI&&-Math.PI<=a||n<=Math.PI&&Math.PI<=a,n=n<=.5*-Math.PI&&.5*-Math.PI<=a||n<=1.5*Math.PI&&1.5*Math.PI<=a,a=m/100,v=v?-1:Math.min(t*(t<0?1:a),o*(o<0?1:a)),n=n?-1:Math.min(e*(e<0?1:a),l*(l<0?1:a)),o=d?1:Math.max(t*(0');var t=t.data,i=t.datasets,n=t.labels;if(i.length)for(var o=0;o'),n[o]&&e.push(n[o]),e.push("");return e.push(""),e.join("")},legend:{labels:{generateLabels:function(s){var l=s.data;return l.labels.length&&l.datasets.length?l.labels.map(function(t,e){var i=s.getDatasetMeta(0),n=l.datasets[0],o=i.data[e].custom||{},a=b.valueAtIndexOrDefault,r=s.options.elements.arc;return{text:t,fillStyle:o.backgroundColor||a(n.backgroundColor,e,r.backgroundColor),strokeStyle:o.borderColor||a(n.borderColor,e,r.borderColor),lineWidth:o.borderWidth||a(n.borderWidth,e,r.borderWidth),hidden:isNaN(n.data[e])||i.data[e].hidden,index:e}}):[]}},onClick:function(t,e){for(var i,n=e.index,o=this.chart,a=0,r=(o.data.datasets||[]).length;a=e.numSteps?(a.callback(e.onAnimationComplete,[e],i),i.animating=!1,n.splice(o,1)):++o}},Object.defineProperty(t.Animation.prototype,"animationObject",{get:function(){return this}}),Object.defineProperty(t.Animation.prototype,"chartInstance",{get:function(){return this.chart},set:function(t){this.chart=t}})}},{25:25,26:26,45:45}],23:[function(t,e,i){"use strict";var l=t(25),u=t(45),n=t(28),d=t(48);e.exports=function(r){var s=r.plugins;function a(t){return"top"===t||"bottom"===t}r.types={},r.instances={},r.controllers={},u.extend(r.prototype,{construct:function(t,e){var i=this;(o=(a=(a=e)||{}).data=a.data||{}).datasets=o.datasets||[],o.labels=o.labels||[],a.options=u.configMerge(l.global,l[a.type],a.options||{}),e=a;var n=d.acquireContext(t,e),o=n&&n.canvas,a=o&&o.height,t=o&&o.width;i.id=u.uid(),i.ctx=n,i.canvas=o,i.config=e,i.width=t,i.height=a,i.aspectRatio=a?t/a:null,i.options=e.options,i._bufferedRender=!1,(i.chart=i).controller=i,r.instances[i.id]=i,Object.defineProperty(i,"data",{get:function(){return i.config.data},set:function(t){i.config.data=t}}),n&&o?(i.initialize(),i.update()):console.error("Failed to create chart: can't acquire context from the given item")},initialize:function(){var t=this;return s.notify(t,"beforeInit"),u.retinaScale(t,t.options.devicePixelRatio),t.bindEvents(),t.options.responsive&&t.resize(!0),t.ensureScalesHaveIDs(),t.buildScales(),t.initToolTip(),s.notify(t,"afterInit"),t},clear:function(){return u.canvas.clear(this),this},stop:function(){return r.animationService.cancelAnimation(this),this},resize:function(t,e){var i=this,n=i.options,o=i.canvas,a=n.maintainAspectRatio&&i.aspectRatio||null,r=Math.max(0,Math.floor(u.getMaximumWidth(o))),a=Math.max(0,Math.floor(a?r/a:u.getMaximumHeight(o)));e&&(a=e),i.width===r&&i.height===a||(o.width=i.width=r,o.height=i.height=a,o.style.width=r+"px",o.style.height=a+"px",u.retinaScale(i,n.devicePixelRatio),t||(s.notify(i,"resize",[a={width:r,height:a}]),i.options.onResize&&i.options.onResize(i,a),i.stop(),i.update(i.options.responsiveAnimationDuration)))},ensureScalesHaveIDs:function(){var t=this.options,e=t.scales||{},t=t.scale;u.each(e.xAxes,function(t,e){t.id=t.id||"x-axis-"+e}),u.each(e.yAxes,function(t,e){t.id=t.id||"y-axis-"+e}),t&&(t.id=t.id||"scale")},buildScales:function(){var n=this,t=n.options,o=n.scales={},e=[];t.scales&&(e=e.concat((t.scales.xAxes||[]).map(function(t){return{options:t,dtype:"category",dposition:"bottom"}}),(t.scales.yAxes||[]).map(function(t){return{options:t,dtype:"linear",dposition:"left"}}))),t.scale&&e.push({options:t.scale,dtype:"radialLinear",isDefault:!0,dposition:"chartArea"}),u.each(e,function(t){var e=t.options,i=u.valueOrDefault(e.type,t.dtype),i=r.scaleService.getScaleConstructor(i);i&&(a(e.position)!==a(t.dposition)&&(e.position=t.dposition),e=new i({id:e.id,options:e,ctx:n.ctx,chart:n}),(o[e.id]=e).mergeTicksOptions(),t.isDefault&&(n.scale=e))}),r.scaleService.addScalesToLayout(this)},buildOrUpdateControllers:function(){var n=this,o=[],a=[];return u.each(n.data.datasets,function(t,e){var i=n.getDatasetMeta(e),t=t.type||n.config.type;if(i.type&&i.type!==t&&(n.destroyDatasetMeta(e),i=n.getDatasetMeta(e)),i.type=t,o.push(i.type),i.controller)i.controller.updateIndex(e);else{t=r.controllers[i.type];if(void 0===t)throw new Error('"'+i.type+'" is not a chart type.');i.controller=new t(n,e),a.push(i.controller)}},n),a},resetElements:function(){var i=this;u.each(i.data.datasets,function(t,e){i.getDatasetMeta(e).controller.reset()},i)},reset:function(){this.resetElements(),this.tooltip.initialize()},update:function(t){var e,i,n=this;t&&"object"==typeof t||(t={duration:t,lazy:arguments[1]}),(i=(e=n).options).scale?e.scale.options=i.scale:i.scales&&i.scales.xAxes.concat(i.scales.yAxes).forEach(function(t){e.scales[t.id].options=t}),e.tooltip._options=i.tooltips,!1!==s.notify(n,"beforeUpdate")&&(n.tooltip._data=n.data,i=n.buildOrUpdateControllers(),u.each(n.data.datasets,function(t,e){n.getDatasetMeta(e).controller.buildOrUpdateElements()},n),n.updateLayout(),u.each(i,function(t){t.reset()}),n.updateDatasets(),n.tooltip.initialize(),n.lastActive=[],s.notify(n,"afterUpdate"),n._bufferedRender?n._bufferedRequest={duration:t.duration,easing:t.easing,lazy:t.lazy}:n.render(t))},updateLayout:function(){!1!==s.notify(this,"beforeLayout")&&(r.layoutService.update(this,this.width,this.height),s.notify(this,"afterScaleUpdate"),s.notify(this,"afterLayout"))},updateDatasets:function(){if(!1!==s.notify(this,"beforeDatasetsUpdate")){for(var t=0,e=this.data.datasets.length;t=e[t].length&&e[t].push({}),!e[t][o].type||r.type&&r.type!==e[t][o].type?h.merge(e[t][o],[l.scaleService.getScaleDefaults(a),r]):h.merge(e[t][o],r)}else h._merger(t,e,i,n)}})},h.where=function(t,e){if(h.isArray(t)&&Array.prototype.filter)return t.filter(e);var i=[];return h.each(t,function(t){e(t)&&i.push(t)}),i},h.findIndex=Array.prototype.findIndex?function(t,e,i){return t.findIndex(e,i)}:function(t,e,i){i=void 0===i?t:i;for(var n=0,o=t.length;n=t.length-1?t[0]:t[e+1]:e>=t.length-1?t[t.length-1]:t[e+1]},h.previousItem=function(t,e,i){return i?e<=0?t[t.length-1]:t[e-1]:e<=0?t[0]:t[e-1]},h.niceNum=function(t,e){var i=Math.floor(h.log10(t)),t=t/Math.pow(10,i),t=e?t<1.5?1:t<3?2:t<7?5:10:t<=1?1:t<=2?2:t<=5?5:10;return t*Math.pow(10,i)},h.requestAnimFrame="undefined"==typeof window?function(t){t()}:window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)},h.getRelativePosition=function(t,e){var i=t.originalEvent||t,n=t.currentTarget||t.srcElement,o=n.getBoundingClientRect(),a=i.touches,r=a&&0i.length){for(var l=0;le&&(e=t.length)}),e},h.color=n?function(t){return t instanceof CanvasGradient&&(t=o.global.defaultColor),n(t)}:function(t){return console.error("Color.js not found!"),t},h.getHoverColor=function(t){return t instanceof CanvasPattern?t:h.color(t).saturate(.5).darken(.1).rgbString()}}},{25:25,3:3,45:45}],28:[function(t,e,i){"use strict";var n=t(45);function r(t,e){return t.native?{x:t.x,y:t.y}:n.getRelativePosition(t,e)}function s(t,e){for(var i,n,o,a=0,r=t.data.datasets.length;at.maxHeight){a--;break}a++,s=d*r}t.labelRotation=a},afterCalculateTickRotation:function(){B.callback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){B.callback(this.options.beforeFit,[this])},fit:function(){var t,e=this,i=e.minSize={width:0,height:0},n=f(e._ticks),o=e.options,a=o.ticks,r=o.scaleLabel,s=o.gridLines,l=o.display,u=e.isHorizontal(),d=g(a),c=o.gridLines.tickMarkLength;i.width=u?e.isFullWidth()?e.maxWidth-e.margins.left-e.margins.right:e.maxWidth:l&&s.drawTicks?c:0,i.height=u?l&&s.drawTicks?c:0:e.maxHeight,r.display&&l&&(t=p(r)+B.options.toPadding(r.padding).height,u?i.height+=t:i.width+=t),a.display&&l&&(s=B.longestText(e.ctx,d.font,n,e.longestTextCache),c=B.numberOfLabelLines(n),r=.5*d.size,t=e.options.ticks.padding,u?(e.longestLabelWidth=s,l=B.toRadians(e.labelRotation),u=Math.cos(l),c=Math.sin(l)*s+d.size*c+r*(c-1)+r,i.height=Math.min(e.maxHeight,i.height+c+t),e.ctx.font=d.font,c=h(e.ctx,n[0],d.font),n=h(e.ctx,n[n.length-1],d.font),0!==e.labelRotation?(e.paddingLeft="bottom"===o.position?u*c+3:u*r+3,e.paddingRight="bottom"===o.position?u*r+3:u*n+3):(e.paddingLeft=c/2+3,e.paddingRight=n/2+3)):(a.mirror?s=0:s+=t+r,i.width=Math.min(e.maxWidth,i.width+s),e.paddingTop=d.size/2,e.paddingBottom=d.size/2)),e.handleMargins(),e.width=i.width,e.height=i.height},handleMargins:function(){var t=this;t.margins&&(t.paddingLeft=Math.max(t.paddingLeft-t.margins.left,0),t.paddingTop=Math.max(t.paddingTop-t.margins.top,0),t.paddingRight=Math.max(t.paddingRight-t.margins.right,0),t.paddingBottom=Math.max(t.paddingBottom-t.margins.bottom,0))},afterFit:function(){B.callback(this.options.afterFit,[this])},isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},isFullWidth:function(){return this.options.fullWidth},getRightValue:function(t){if(B.isNullOrUndef(t))return NaN;if("number"==typeof t&&!isFinite(t))return NaN;if(t)if(this.isHorizontal()){if(void 0!==t.x)return this.getRightValue(t.x)}else if(void 0!==t.y)return this.getRightValue(t.y);return t},getLabelForIndex:B.noop,getPixelForValue:B.noop,getValueForPixel:B.noop,getPixelForTick:function(t){var e=this,i=e.options.offset;if(e.isHorizontal()){var n=(e.width-(e.paddingLeft+e.paddingRight))/Math.max(e._ticks.length-(i?0:1),1),o=n*t+e.paddingLeft;i&&(o+=n/2);o=e.left+Math.round(o);return o+=e.isFullWidth()?e.margins.left:0}o=e.height-(e.paddingTop+e.paddingBottom);return e.top+t*(o/(e._ticks.length-1))},getPixelForDecimal:function(t){var e=this;if(e.isHorizontal()){var i=(e.width-(e.paddingLeft+e.paddingRight))*t+e.paddingLeft,i=e.left+Math.round(i);return i+=e.isFullWidth()?e.margins.left:0}return e.top+t*e.height},getBasePixel:function(){return this.getPixelForValue(this.getBaseValue())},getBaseValue:function(){var t=this.min,e=this.max;return this.beginAtZero?0:t<0&&e<0?e:0a.width-(a.paddingLeft+a.paddingRight)&&(e=1+Math.floor((u+s.autoSkipPadding)*l/(a.width-(a.paddingLeft+a.paddingRight)))),o&&oo.height-e.height-l&&(s="bottom");var u=(a.left+a.right)/2,d=(a.top+a.bottom)/2,c="center"===s?(i=function(t){return t<=u},function(t){return u=o.width-e.width/2}),h=function(t){return t+e.width>o.width},l=function(t){return t-e.width<0},a=function(t){return t<=d?"top":"bottom"};return i(n.x)?(r="left",h(n.x)&&(r="center",s=a(n.y))):c(n.x)&&(r="right",l(n.x)&&(r="center",s=a(n.y))),{xAlign:(t=t._options).xAlign||r,yAlign:t.yAlign?"nocenter"==t.yAlign?"center"==s?"top":s:t.yAlign:s}}(this,k=A(this,m)),i=k,n=x,o=(e=m).x,a=e.y,r=e.caretSize,s=e.caretPadding,p=e.cornerRadius,e=n.xAlign,n=n.yAlign,r+=s,s=p+s,"right"===e?o-=i.width:"center"===e&&(o-=i.width/2),"top"===n?a+=r:a-="bottom"===n?i.height+r:i.height/2,"center"===n?"left"===e?o+=r:"right"===e&&(o-=r):"left"===e?o-=s:"right"===e&&(o+=s),y={x:o,y:a}}else m.opacity=0;return m.xAlign=x.xAlign,m.yAlign=x.yAlign,m.x=y.x,m.y=y.y,m.width=k.width,m.height=k.height,m.caretX=w.x,m.caretY=w.y,f._model=m,t&&g.custom&&g.custom.call(f,m),f},drawCaret:function(t,e){var i=this._chart.ctx,n=this._view,n=this.getCaretPosition(t,e,n);i.lineTo(n.x1,n.y1),i.lineTo(n.x2,n.y2),i.lineTo(n.x3,n.y3)},getCaretPosition:function(t,e,i){var n,o,a,r,s,l,u=i.caretSize,d=i.cornerRadius,c=i.xAlign,h=i.yAlign,f=t.x,i=t.y,t=e.width,e=e.height;return"center"===h?(a=i+e/2,r="left"===c?(n=(l=f)-u,s=l,o=a+u,a-u):(n=(l=f+t)+u,s=l,o=a-u,a+u)):(s=(l="left"===c?(n=f+d+u)-u:"right"===c?(n=f+t-d-u)-u:(n=f+t/2)-u,n+u),"top"===h?(a=(o=i)-u,r=o):(a=(o=i+e)+u,r=o,u=s,s=l,l=u)),{x1:l,x2:n,x3:s,y1:o,y2:a,y3:r}},drawTitle:function(t,e,i,n){var o=e.title;if(o.length){i.textAlign=e._titleAlign,i.textBaseline="top";var a,r,s=e.titleFontSize,l=e.titleSpacing;for(i.fillStyle=c(e.titleFontColor,n),i.font=T.fontString(s,e._titleFontStyle,e._titleFontFamily),a=0,r=o.length;a=i.innerRadius&&e<=i.outerRadius;return o<=n&&n<=a&&i}return!1},getCenterPoint:function(){var t=this._view,e=(t.startAngle+t.endAngle)/2,i=(t.innerRadius+t.outerRadius)/2;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},getArea:function(){var t=this._view;return Math.PI*((t.endAngle-t.startAngle)/(2*Math.PI))*(Math.pow(t.outerRadius,2)-Math.pow(t.innerRadius,2))},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view,i=e.startAngle,n=e.endAngle;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,i,n),t.arc(e.x,e.y,e.innerRadius,n,i,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})},{25:25,26:26,45:45}],37:[function(t,e,i){"use strict";var n=t(25),o=t(26),d=t(45),c=n.global;n._set("global",{elements:{line:{tension:.4,backgroundColor:c.defaultColor,borderWidth:3,borderColor:c.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",capBezierPoints:!0,fill:!0}}}),e.exports=o.extend({draw:function(){var t,e,i,n,o=this._view,a=this._chart.ctx,r=o.spanGaps,s=this._children.slice(),l=c.elements.line,u=-1;for(this._loop&&s.length&&s.push(s[0]),a.save(),a.lineCap=o.borderCapStyle||l.borderCapStyle,a.setLineDash&&a.setLineDash(o.borderDash||l.borderDash),a.lineDashOffset=o.borderDashOffset||l.borderDashOffset,a.lineJoin=o.borderJoinStyle||l.borderJoinStyle,a.lineWidth=o.borderWidth||l.borderWidth,a.strokeStyle=o.borderColor||c.defaultColor,a.beginPath(),u=-1,t=0;t=(i=o(this)).left&&t<=i.right&&e>=i.top&&e<=i.bottom:n},inLabelRange:function(t,e){if(!this._view)return!1;var i=o(this);return r(this)?t>=i.left&&t<=i.right:e>=i.top&&e<=i.bottom},inXRange:function(t){var e=o(this);return t>=e.left&&t<=e.right},inYRange:function(t){var e=o(this);return t>=e.top&&t<=e.bottom},getCenterPoint:function(){var t,e=this._view,e=r(this)?(t=e.x,(e.y+e.base)/2):(t=(e.x+e.base)/2,e.y);return{x:t,y:e}},getArea:function(){var t=this._view;return t.width*Math.abs(t.y-t.base)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y}}})},{25:25,26:26}],40:[function(t,e,i){"use strict";e.exports={},e.exports.Arc=t(36),e.exports.Line=t(37),e.exports.Point=t(38),e.exports.Rectangle=t(39)},{36:36,37:37,38:38,39:39}],41:[function(t,e,i){"use strict";t=t(42),i=e.exports={clear:function(t){t.ctx.clearRect(0,0,t.width,t.height)},roundedRect:function(t,e,i,n,o,a){var r;a?(r=Math.min(a,n/2),a=Math.min(a,o/2),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+a),t.lineTo(e+n,i+o-a),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+r,i)):t.rect(e,i,n,o)},drawPoint:function(t,e,i,n,o){var a,r,s,l;if(!e||"object"!=typeof e||"[object HTMLImageElement]"!==(a=e.toString())&&"[object HTMLCanvasElement]"!==a){if(!(isNaN(i)||i<=0)){switch(e){default:t.beginPath(),t.arc(n,o,i,0,2*Math.PI),t.closePath(),t.fill();break;case"triangle":t.beginPath(),c=(d=3*i/Math.sqrt(3))*Math.sqrt(3)/2,t.moveTo(n-d/2,o+c/3),t.lineTo(n+d/2,o+c/3),t.lineTo(n,o-2*c/3),t.closePath(),t.fill();break;case"rect":l=1/Math.SQRT2*i,t.beginPath(),t.fillRect(n-l,o-l,2*l,2*l),t.strokeRect(n-l,o-l,2*l,2*l);break;case"rectRounded":var u=i/Math.SQRT2,d=n-u,c=o-u,u=Math.SQRT2*i;t.beginPath(),this.roundedRect(t,d,c,u,u,i/2),t.closePath(),t.fill();break;case"rectRot":l=1/Math.SQRT2*i,t.beginPath(),t.moveTo(n-l,o),t.lineTo(n,o+l),t.lineTo(n+l,o),t.lineTo(n,o-l),t.closePath(),t.fill();break;case"cross":t.beginPath(),t.moveTo(n,o+i),t.lineTo(n,o-i),t.moveTo(n-i,o),t.lineTo(n+i,o),t.closePath();break;case"crossRot":t.beginPath(),r=Math.cos(Math.PI/4)*i,s=Math.sin(Math.PI/4)*i,t.moveTo(n-r,o-s),t.lineTo(n+r,o+s),t.moveTo(n-r,o+s),t.lineTo(n+r,o-s),t.closePath();break;case"star":t.beginPath(),t.moveTo(n,o+i),t.lineTo(n,o-i),t.moveTo(n-i,o),t.lineTo(n+i,o),r=Math.cos(Math.PI/4)*i,s=Math.sin(Math.PI/4)*i,t.moveTo(n-r,o-s),t.lineTo(n+r,o+s),t.moveTo(n-r,o+s),t.lineTo(n+r,o-s),t.closePath();break;case"line":t.beginPath(),t.moveTo(n-i,o),t.lineTo(n+i,o),t.closePath();break;case"dash":t.beginPath(),t.moveTo(n,o),t.lineTo(n+i,o),t.closePath()}t.stroke()}}else t.drawImage(e,n-e.width/2,o-e.height/2,e.width,e.height)},clipArea:function(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()},unclipArea:function(t){t.restore()},lineTo:function(t,e,i,n){if(i.steppedLine)return"after"===i.steppedLine&&!n||"after"!==i.steppedLine&&n?t.lineTo(e.x,i.y):t.lineTo(i.x,e.y),void t.lineTo(i.x,i.y);i.tension?t.bezierCurveTo(n?e.controlPointPreviousX:e.controlPointNextX,n?e.controlPointPreviousY:e.controlPointNextY,n?i.controlPointNextX:i.controlPointPreviousX,n?i.controlPointNextY:i.controlPointPreviousY,i.x,i.y):t.lineTo(i.x,i.y)}};t.clear=i.clear,t.drawRoundedRectangle=function(t){t.beginPath(),i.roundedRect.apply(i,arguments),t.closePath()}},{42:42}],42:[function(t,e,i){"use strict";var n,d={noop:function(){},uid:(n=0,function(){return n++}),isNullOrUndef:function(t){return null==t},isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)},valueOrDefault:function(t,e){return void 0===t?e:t},valueAtIndexOrDefault:function(t,e,i){return d.valueOrDefault(d.isArray(t)?t[e]:t,i)},callback:function(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)},each:function(t,e,i,n){var o,a,r;if(d.isArray(t))if(a=t.length,n)for(o=a-1;0<=o;o--)e.call(i,t[o],o);else for(o=0;o
';var o=e.childNodes[0],a=e.childNodes[1];function r(){e._reset(),t()}return e._reset=function(){o.scrollLeft=1e6,o.scrollTop=1e6,a.scrollLeft=1e6,a.scrollTop=1e6},x(o,"scroll",r.bind(o,"expand")),x(a,"scroll",r.bind(a,"shrink")),e}((n=function(){if(c.resizer)return t(y("resize",i))},r=!1,function(){a=Array.prototype.slice.call(arguments),o=o||this,r||(r=!0,f.requestAnimFrame.call(window,function(){r=!1,n.apply(o,a)}))}));l=function(){var t;c.resizer&&((t=e.parentNode)&&t!==h.parentNode&&t.insertBefore(h,t.firstChild),h._reset())},u=(s=e)[g]||(s[g]={}),d=u.renderProxy=function(t){t.animationName===v&&l()},f.each(b,function(t){x(s,t,d)}),u.reflow=!!s.offsetParent,s.classList.add(m)}function o(t){var e,i,n=t[g]||{},o=n.resizer;delete n.resizer,t=(e=t)[g]||{},(i=t.renderProxy)&&(f.each(b,function(t){a(e,t,i)}),delete t.renderProxy),e.classList.remove(m),o&&o.parentNode&&o.parentNode.removeChild(o)}e.exports={_enabled:"undefined"!=typeof window&&"undefined"!=typeof document,initialize:function(){var t,e,i="from{opacity:0.99}to{opacity:1}";e="@-webkit-keyframes "+v+"{"+i+"}@keyframes "+v+"{"+i+"}."+m+"{-webkit-animation:"+v+" 0.001s;animation:"+v+" 0.001s;}",i=(t=this)._style||document.createElement("style"),t._style||(e="/* Chart.js */\n"+e,(t._style=i).setAttribute("type","text/css"),document.getElementsByTagName("head")[0].appendChild(i)),i.appendChild(document.createTextNode(e))},acquireContext:function(t,e){"string"==typeof t?t=document.getElementById(t):t.length&&(t=t[0]);var i,n,o,a,r=(t=t&&t.canvas?t.canvas:t)&&t.getContext&&t.getContext("2d");return r&&r.canvas===t?(n=e,a=(i=t).style,e=i.getAttribute("height"),t=i.getAttribute("width"),i[g]={initial:{height:e,width:t,style:{display:a.display,height:a.height,width:a.width}}},a.display=a.display||"block",null!==t&&""!==t||void 0!==(o=s(i,"width"))&&(i.width=o),null!==e&&""!==e||(""===i.style.height?i.height=i.width/(n.options.aspectRatio||2):(n=s(i,"height"),void 0!==o&&(i.height=n))),r):null},releaseContext:function(t){var i,n=t.canvas;n[g]&&(i=n[g].initial,["height","width"].forEach(function(t){var e=i[t];f.isNullOrUndef(e)?n.removeAttribute(t):n.setAttribute(t,e)}),f.each(i.style||{},function(t,e){n.style[e]=t}),n.width=n.width,delete n[g])},addEventListener:function(o,t,a){var e,i=o.canvas;"resize"!==t?x(i,t,((e=a[g]||(a[g]={})).proxies||(e.proxies={}))[o.id+"_"+t]=function(t){var e,i,n;a((i=o,n=r[(e=t).type]||e.type,t=f.getRelativePosition(e,i),y(n,i,t.x,t.y,e)))}):l(i,a,o)},removeEventListener:function(t,e,i){var n=t.canvas;"resize"!==e?(t=((i[g]||{}).proxies||{})[t.id+"_"+e])&&a(n,e,t):o(n)}},f.addEvent=x,f.removeEvent=a},{45:45}],48:[function(t,e,i){"use strict";var n=t(45),o=t(46),t=t(47),o=t._enabled?t:o;e.exports=n.extend({initialize:function(){},acquireContext:function(){},releaseContext:function(){},addEventListener:function(){},removeEventListener:function(){}},o)},{45:45,46:46,47:47}],49:[function(t,e,i){"use strict";var s=t(25),f=t(40),l=t(45);s._set("global",{plugins:{filler:{propagate:!0}}}),e.exports=function(){var h={dataset:function(t){var e=t.fill,i=t.chart,t=i.getDatasetMeta(e),n=t&&i.isDatasetVisible(e)&&t.dataset._children||[],o=n.length||0;return o?function(t,e){return e');for(var i=0;i'),t.data.datasets[i].label&&e.push(t.data.datasets[i].label),e.push("");return e.push(""),e.join("")}}),e.exports=function(n){var o=n.layoutService,t=P.noop;function D(t,e){return t.usePointStyle?e*Math.SQRT2:t.boxWidth}function a(t,e){var i=new n.Legend({ctx:t.ctx,options:e,chart:t});o.configure(t,i,e),o.addBox(t,i),t.legend=i}return n.Legend=r.extend({initialize:function(t){P.extend(this,t),this.legendHitBoxes=[],this.doughnutMode=!1},beforeUpdate:t,update:function(t,e,i){var n=this;return n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n.margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate(),n.minSize},afterUpdate:t,beforeSetDimensions:t,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:t,beforeBuildLabels:t,buildLabels:function(){var e=this,i=e.options.labels||{},t=P.callback(i.generateLabels,[e.chart],e)||[];i.filter&&(t=t.filter(function(t){return i.filter(t,e.chart.data)})),e.options.reverse&&t.reverse(),e.legendItems=t},afterBuildLabels:t,beforeFit:t,fit:function(){var i,n,o,a,r,s,l,u=this,t=u.options,d=t.labels,e=t.display,c=u.ctx,h=I.global,f=P.valueOrDefault,g=f(d.fontSize,h.defaultFontSize),t=f(d.fontStyle,h.defaultFontStyle),h=f(d.fontFamily,h.defaultFontFamily),t=P.fontString(g,t,h),p=u.legendHitBoxes=[],m=u.minSize,h=u.isHorizontal();h?(m.width=u.maxWidth,m.height=e?10:0):(m.width=e?10:0,m.height=u.maxHeight),e&&(c.font=t,h?(i=u.lineWidths=[0],n=u.legendItems.length?g+d.padding:0,c.textAlign="left",c.textBaseline="top",P.each(u.legendItems,function(t,e){t=D(d,g)+g/2+c.measureText(t.text).width;i[i.length-1]+t+d.padding>=u.width&&(n+=g+d.padding,i[i.length]=u.left),p[e]={left:0,top:0,width:t,height:g},i[i.length-1]+=t+d.padding}),m.height+=n):(h=d.padding,o=u.columnWidths=[],a=d.padding,s=r=0,l=g+h,P.each(u.legendItems,function(t,e){t=D(d,g)+g/2+c.measureText(t.text).width;s+l>m.height&&(a+=r+d.padding,o.push(r),s=r=0),r=Math.max(r,t),s+=l,p[e]={left:0,top:0,width:t,height:g}}),a+=r,o.push(r),m.width+=a)),u.width=m.width,u.height=m.height},afterFit:t,isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},draw:function(){var h,f,t,g,e,i,p,m,v,b,x,y=this,k=y.options,w=k.labels,M=I.global,S=M.elements.line,C=y.width,_=y.lineWidths;k.display&&(h=y.ctx,t=(f=P.valueOrDefault)(w.fontColor,M.defaultFontColor),g=f(w.fontSize,M.defaultFontSize),e=f(w.fontStyle,M.defaultFontStyle),i=f(w.fontFamily,M.defaultFontFamily),i=P.fontString(g,e,i),h.textAlign="left",h.textBaseline="middle",h.lineWidth=.5,h.strokeStyle=t,h.fillStyle=t,h.font=i,p=D(w,g),m=y.legendHitBoxes,v=y.isHorizontal(),b=v?{x:y.left+(C-_[0])/2,y:y.top+w.padding,line:0}:{x:y.left+w.padding,y:y.top+w.padding,line:0},x=g+w.padding,P.each(y.legendItems,function(t,e){var i,n,o,a,r,s,l=h.measureText(t.text).width,u=p+g/2+l,d=b.x,c=b.y;v?C<=d+u&&(c=b.y+=x,b.line++,d=b.x=y.left+(C-_[b.line])/2):c+x>y.bottom&&(d=b.x=d+y.columnWidths[b.line]+w.padding,c=b.y=y.top+w.padding,b.line++),i=d,n=c,o=t,isNaN(p)||p<=0||(h.save(),h.fillStyle=f(o.fillStyle,M.defaultColor),h.lineCap=f(o.lineCap,S.borderCapStyle),h.lineDashOffset=f(o.lineDashOffset,S.borderDashOffset),h.lineJoin=f(o.lineJoin,S.borderJoinStyle),h.lineWidth=f(o.lineWidth,S.borderWidth),h.strokeStyle=f(o.strokeStyle,M.defaultColor),a=0===f(o.lineWidth,S.borderWidth),h.setLineDash&&h.setLineDash(f(o.lineDash,S.borderDash)),k.labels&&k.labels.usePointStyle?(s=(r=g*Math.SQRT2/2)/Math.SQRT2,P.canvas.drawPoint(h,o.pointStyle,r,i+s,n+s)):(a||h.strokeRect(i,n,p,g),h.fillRect(i,n,p,g)),h.restore()),m[e].left=d,m[e].top=c,e=t,t=l,d=p+(l=g/2)+(d=d),l=c+l,h.fillText(e.text,d,l),e.hidden&&(h.beginPath(),h.lineWidth=2,h.moveTo(d,l),h.lineTo(d+t,l),h.stroke()),v?b.x+=u+w.padding:b.y+=x}))},handleEvent:function(t){var e=this,i=e.options,n="mouseup"===t.type?"click":t.type,o=!1;if("mousemove"===n){if(!i.onHover)return}else{if("click"!==n)return;if(!i.onClick)return}var a=t.x,r=t.y;if(a>=e.left&&a<=e.right&&r>=e.top&&r<=e.bottom)for(var s=e.legendHitBoxes,l=0;l=u.left&&a<=u.left+u.width&&r>=u.top&&r<=u.top+u.height){if("click"===n){i.onClick.call(e,t.native,e.legendItems[l]),o=!0;break}if("mousemove"===n){i.onHover.call(e,t.native,e.legendItems[l]),o=!0;break}}}return o}}),{id:"legend",beforeInit:function(t){var e=t.options.legend;e&&a(t,e)},beforeUpdate:function(t){var e=t.options.legend,i=t.legend;e?(P.mergeIf(e,I.global.legend),i?(o.configure(t,i,e),i.options=e):a(t,e)):i&&(o.removeBox(t,i),delete t.legend)},afterEvent:function(t,e){t=t.legend;t&&t.handleEvent(e)}}}},{25:25,26:26,45:45}],51:[function(t,e,i){"use strict";var x=t(25),r=t(26),y=t(45);x._set("global",{title:{display:!1,fontStyle:"bold",fullWidth:!0,lineHeight:1.2,padding:10,position:"top",text:"",weight:2e3}}),e.exports=function(n){var o=n.layoutService,t=y.noop;function a(t,e){var i=new n.Title({ctx:t.ctx,options:e,chart:t});o.configure(t,i,e),o.addBox(t,i),t.titleBlock=i}return n.Title=r.extend({initialize:function(t){y.extend(this,t),this.legendHitBoxes=[]},beforeUpdate:t,update:function(t,e,i){var n=this;return n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n.margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate(),n.minSize},afterUpdate:t,beforeSetDimensions:t,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:t,beforeBuildLabels:t,buildLabels:t,afterBuildLabels:t,beforeFit:t,fit:function(){var t=this,e=y.valueOrDefault,i=t.options,n=i.display,o=e(i.fontSize,x.global.defaultFontSize),a=t.minSize,e=y.isArray(i.text)?i.text.length:1,o=y.options.toLineHeight(i.lineHeight,o),i=n?e*o+2*i.padding:0;t.isHorizontal()?(a.width=t.maxWidth,a.height=i):(a.width=i,a.height=t.maxHeight),t.width=a.width,t.height=a.height},afterFit:t,isHorizontal:function(){var t=this.options.position;return"top"===t||"bottom"===t},draw:function(){var t=this,e=t.ctx,i=y.valueOrDefault,n=t.options,o=x.global;if(n.display){var a,r,s,l=i(n.fontSize,o.defaultFontSize),u=i(n.fontStyle,o.defaultFontStyle),d=i(n.fontFamily,o.defaultFontFamily),c=y.fontString(l,u,d),h=y.options.toLineHeight(n.lineHeight,l),f=h/2+n.padding,g=0,p=t.top,u=t.left,d=t.bottom,l=t.right;e.fillStyle=i(n.fontColor,o.defaultFontColor),e.font=c,t.isHorizontal()?(r=u+(l-u)/2,s=p+f,a=l-u):(r="left"===n.position?u+f:l-f,s=p+(d-p)/2,a=d-p,g=Math.PI*("left"===n.position?-.5:.5)),e.save(),e.translate(r,s),e.rotate(g),e.textAlign="center",e.textBaseline="middle";var m=n.text;if(y.isArray(m))for(var v=0,b=0;br.max)&&(r.max=t))})}),r.min=isFinite(r.min)&&!isNaN(r.min)?r.min:0,r.max=isFinite(r.max)&&!isNaN(r.max)?r.max:1,this.handleTickRangeOptions()},getTickLimit:function(){var t,e=this.options.ticks;return this.isHorizontal()?Math.min(e.maxTicksLimit||11,Math.ceil(this.width/50)):(t=c.valueOrDefault(e.fontSize,n.global.defaultFontSize),Math.min(e.maxTicksLimit||11,Math.ceil(this.height/(2*t))))},handleDirectionalChanges:function(){this.isHorizontal()||this.ticks.reverse()},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForValue:function(t){var e,i=this,n=i.start,o=+i.getRightValue(t),t=i.end-n;return e=i.isHorizontal()?i.left+i.width/t*(o-n):i.bottom-i.height/t*(o-n),Math.round(e)},getValueForPixel:function(t){var e=this,i=e.isHorizontal(),n=i?e.width:e.height,n=(i?t-e.left:e.bottom-t)/n;return e.start+(e.end-e.start)*n},getPixelForTick:function(t){return this.getPixelForValue(this.ticksAsNumbers[t])}});t.scaleService.registerScaleType("linear",i,e)}},{25:25,34:34,45:45}],54:[function(t,e,i){"use strict";var o=t(45),n=t(34);e.exports=function(e){var t=o.noop;e.LinearScaleBase=e.Scale.extend({getRightValue:function(t){return"string"==typeof t?+t:e.Scale.prototype.getRightValue.call(this,t)},handleTickRangeOptions:function(){var t=this,e=t.options.ticks;e.beginAtZero&&(i=o.sign(t.min),n=o.sign(t.max),i<0&&n<0?t.max=0:0=t.max&&(i?t.max=t.min+1:t.min=t.max-1),t.min===t.max&&(t.max++,e.beginAtZero||t.min--)},getTickLimit:t,handleDirectionalChanges:t,buildTicks:function(){var t=this,e=t.options.ticks,i=t.getTickLimit(),i={maxTicks:i=Math.max(2,i),min:e.min,max:e.max,stepSize:o.valueOrDefault(e.fixedStepSize,e.stepSize)},i=t.ticks=n.generators.linear(i,t);t.handleDirectionalChanges(),t.max=o.max(i),t.min=o.min(i),e.reverse?(i.reverse(),t.start=t.max,t.end=t.min):(t.start=t.min,t.end=t.max)},convertTicksToLabels:function(){var t=this;t.ticksAsNumbers=t.ticks.slice(),t.zeroLineIndex=t.ticks.indexOf(0),e.Scale.prototype.convertTicksToLabels.call(t)}})}},{34:34,45:45}],55:[function(t,e,i){"use strict";var d=t(45),n=t(34);e.exports=function(t){var e={position:"left",ticks:{callback:n.formatters.logarithmic}},i=t.Scale.extend({determineDataLimits:function(){var a=this,r=a.options,t=r.ticks,s=a.chart,e=s.data.datasets,i=d.valueOrDefault,n=a.isHorizontal();function l(t){return n?t.xAxisID===a.id:t.yAxisID===a.id}a.min=null,a.max=null,a.minNotZero=null;var u,o=r.stacked;void 0===o&&d.each(e,function(t,e){var i;o||(i=s.getDatasetMeta(e),s.isDatasetVisible(e)&&l(i)&&void 0!==i.stack&&(o=!0))}),r.stacked||o?(u={},d.each(e,function(t,e){var n=s.getDatasetMeta(e),o=[n.type,void 0===r.stacked&&void 0===n.stack?e:"",n.stack].join(".");s.isDatasetVisible(e)&&l(n)&&(void 0===u[o]&&(u[o]=[]),d.each(t.data,function(t,e){var i=u[o],t=+a.getRightValue(t);isNaN(t)||n.data[e].hidden||(i[e]=i[e]||0,r.relativePoints?i[e]=100:i[e]+=t)}))}),d.each(u,function(t){var e=d.min(t),t=d.max(t);a.min=null===a.min?e:Math.min(a.min,e),a.max=null===a.max?t:Math.max(a.max,t)})):d.each(e,function(t,e){var i=s.getDatasetMeta(e);s.isDatasetVisible(e)&&l(i)&&d.each(t.data,function(t,e){t=+a.getRightValue(t);isNaN(t)||i.data[e].hidden||((null===a.min||ta.max)&&(a.max=t),0!=t&&(null===a.minNotZero||to.r&&(o.r=d.end,a.r=l),c.starto.b&&(o.b=c.end,a.b=l)}t.setReductions(n,o,a)}function n(t){var e=t.ctx,i=m.valueOrDefault,n=t.options,o=n.angleLines,a=n.pointLabels;e.lineWidth=o.lineWidth,e.strokeStyle=o.color;var r=t.getDistanceFromCenterForValue(n.ticks.reverse?t.min:t.max),s=p(t);e.textBaseline="top";for(var l,u,d,c,h=g(t)-1;0<=h;h--)o.display&&(d=t.getPointPosition(h,r),e.beginPath(),e.moveTo(t.xCenter,t.yCenter),e.lineTo(d.x,d.y),e.stroke(),e.closePath()),a.display&&(l=t.getPointPosition(h,r+5),c=i(a.fontColor,f.defaultFontColor),e.font=s.font,e.fillStyle=c,u=t.getIndexAngle(h),d=m.toDegrees(u),e.textAlign=0===(c=d)||180===c?"center":c<180?"left":"right",u=d,c=t._pointLabelSizes[h],d=l,90===u||270===u?d.y-=c.h/2:(270>1)-1]||null,a=t[n],!o)return{lo:null,hi:a};if(a[e]i))return{lo:o,hi:a};s=n-1}}return{lo:a,hi:null}}(t,e,i),a=o.lo?o.hi?o.lo:t[t.length-2]:t[0],o=o.lo?o.hi||t[t.length-1]:t[1],t=o[e]-a[e],t=t?(i-a[e])/t:0,t=(o[n]-a[n])*t;return a[n]+t}var n=new Map;function a(t,e){var i=e.parser,e=e.parser||e.format;return"function"==typeof i?i(t):"string"==typeof t&&"string"==typeof e?b(t,e):!(t=!(t instanceof b)?function(t){let e;return void 0!==t&&(n.has(t)?e=n.get(t):(e=b(t),n.set(t,e))),e}(t):t).isValid()&&"function"==typeof e?e(t):t}function M(t,e){if(g.isNullOrUndef(t))return null;var i=e.options.time,t=a(e.getRightValue(t),i);return t.isValid()?(i.round&&t.startOf(i.round),t.valueOf()):null}function S(t){for(var e=y.indexOf(t)+1,i=y.length;e=y.indexOf(e);r--)if(o=y[r],x[o].common&&a.as(o)>=t.length)return o;return y[e?y.indexOf(e):0]}(v,p.minUnit,c.min,c.max),c._majorUnit=S(c._unit),c._table=function(t,e,i,n){if("linear"===n||!t.length)return[{time:e,pos:0},{time:i,pos:1}];for(var o,a,r,s=[],l=[e],u=0,d=t.length;ug){[m,g]=[g,m]}if(i>m&&m){i=m}if(o0){let t=r.getRuler(0);r.barHeight=r.calculateBarHeight(t)+4;helpers.each(e.data,function(t,e){r.updateElement(t,e,a)},r)}},updateElement:function(t,e,a){var i=this;var r=i.getMeta();var o=i.getScaleForId(r.xAxisID);var n=i.getScaleForId(r.yAxisID);var s=i.getDataset();var l=s.data[e];var d=t.custom||{};var h=i.index;var c=i.chart.options;var u=c.elements||Chart.defaults.timeline.elements;var f=u.rectangle;var m=u.textPadding;var g=u.minBarWidth;t._xScale=o;t._yScale=n;t._datasetIndex=i.index;t._index=e;var v=u.textFunction(l[u.keyValue],i.chart.data.datasets,h);var p=o.getPixelForValue(l[u.keyStart]);var x=o.getPixelForValue(l[u.keyEnd]);var y=n.getPixelForValue(l,h,h);var b=x-p;var w=i.barHeight;var _=_color(u.colorFunction(v,l,i.chart.data.datasets,h));var k=u.showText;var C=u.font;if(!C){C='bold 12px "Helvetica Neue", Helvetica, Arial, sans-serif'}var M=y-w/2;t._model={x:a?p-b:p,y:M,width:Math.max(b,g),height:w,base:p+b,backgroundColor:_.rgbaString(),borderSkipped:d.borderSkipped?d.borderSkipped:f.borderSkipped,borderColor:d.borderColor?d.borderColor:helpers.getValueAtIndexOrDefault(s.borderColor,e,f.borderColor),borderWidth:d.borderWidth?d.borderWidth:helpers.getValueAtIndexOrDefault(s.borderWidth,e,f.borderWidth),label:i.chart.data.labels[e],datasetLabel:s.label,text:v,textColor:_.luminosity()>.5?"#333333":"#ffffff"};t.draw=function(){var t=this._chart.ctx;var e=this._view;var a=t.globalAlpha;var r=t.globalCompositeOperation;t.fillStyle=e.backgroundColor;t.lineWidth=e.borderWidth;t.globalCompositeOperation="destination-over";t.fillRect(e.x,e.y,e.width,e.height);t.globalAlpha=.5;t.globalCompositeOperation="source-over";t.fillRect(e.x,e.y,e.width,e.height);t.globalAlpha=a;t.globalCompositeOperation=r;if(k){t.beginPath();var i=t.measureText(e.text);if(i.width>0&&i.width+m+2=e.left&&t<=e.right};t.tooltipPosition=function(){var t=this.getCenterPoint();return{x:t.x,y:t.y}};t.getCenterPoint=function(){var t=this._view;var e,a;e=t.x+t.width/2;a=t.y+t.height/2;return{x:e,y:a}};t.inRange=function(t,e){var a=false;if(this._view){var r=i.getBarBounds(this);a=t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom}return a};t.pivot()},getBarCount:function(){var r=this;var i=0;helpers.each(r.chart.data.datasets,function(t,e){var a=r.chart.getDatasetMeta(e);if(a.bar&&r.chart.isDatasetVisible(e)){++i}},r);return i},draw:function(t){var e,a;var r=this.getMeta().data;for(e=0,a=r.length;eg){[m,g]=[g,m]}if(i>m&&m){i=m}if(o0){let t=r.getRuler(0);r.barHeight=r.calculateBarHeight(t)+4;helpers.each(e.data,function(t,e){r.updateElement(t,e,a)},r)}},updateElement:function(t,e,a){var i=this;var r=i.getMeta();var o=i.getScaleForId(r.xAxisID);var n=i.getScaleForId(r.yAxisID);var s=i.getDataset();var l=s.data[e];var d=t.custom||{};var h=i.index;var c=i.chart.options;var u=c.elements||Chart.defaults.timeline.elements;var f=u.rectangle;var m=u.minBarWidth;t._xScale=o;t._yScale=n;t._datasetIndex=i.index;t._index=e;var g=l[u.keyValue];var v=o.getPixelForValue(l[u.keyStart]);var p=o.getPixelForValue(l[u.keyEnd]);var x=n.getPixelForValue(l,h,h);var y=p-v;var b=i.barHeight;var w=x-b/2;t._model={x:a?v-y:v,y:w,width:Math.max(y,m),height:b,base:v+y,backgroundColor:"#000000",borderSkipped:d.borderSkipped?d.borderSkipped:f.borderSkipped,borderColor:d.borderColor?d.borderColor:helpers.getValueAtIndexOrDefault(s.borderColor,e,f.borderColor),borderWidth:d.borderWidth?d.borderWidth:helpers.getValueAtIndexOrDefault(s.borderWidth,e,f.borderWidth),label:i.chart.data.labels[e],datasetLabel:s.label,text:g,textColor:"#ffffff"};t.getPosition=function(t){return this._view.x+(t?this._view.width:0)};t.getMidPosition=function(){return this._view.y+this._view.height/2};t.getValue=function(){return this._view.text};t.inXRange=function(t){var e=i.getBarBounds(this);return t>=e.left&&t<=e.right};t.tooltipPosition=function(){var t=this.getCenterPoint();return{x:t.x,y:t.y}};t.getCenterPoint=function(){var t=this._view;var e,a;e=t.x+t.width/2;a=t.y+t.height/2;return{x:e,y:a}};t.inRange=function(t,e){var a=false;if(this._view){var r=i.getBarBounds(this);a=t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom}return a};t.pivot()},getBarCount:function(){var r=this;var i=0;helpers.each(r.chart.data.datasets,function(t,e){var a=r.chart.getDatasetMeta(e);if(a.bar&&r.chart.isDatasetVisible(e)){++i}},r);return i},draw:function(t){let o=this.index`;let e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});let a=window.URL||window.webkitURL||window;let r=a.createObjectURL(e);let i=new Image;i.onload=()=>{arrowImageMap.set(o,i)};i.src=r}var r=this.getMeta().data;if(!r.length||!arrowImageMap.has(o))return;const i=arrowImageMap.get(o);const n=this.chart.chartArea;const s=30;const a=Math.ceil((n.right-n.left)/s);const l=r[0].getMidPosition();if(e){const m=l-i.height/2;this.chart.ctx.fillStyle=e;this.chart.ctx.lineWidth=0;this.chart.ctx.fillRect(n.left,m-3,n.right-n.left,i.height+6)}const d=this.chart.ctx.getTransform();let h=this.getScaleForId(this.getMeta().xAxisID);let c=h.getPixelForValue(moment().startOf("day"));let u=c%s;let f=0;for(let t=0;tv){if(v>=g){a=r[f].getValue()*1}break}}if(a!=null){let t=g+i.width/2;let e=m+i.height/2;this.chart.ctx.setTransform(d);this.chart.ctx.translate(t,e);this.chart.ctx.rotate((a+180)/180*Math.PI);this.chart.ctx.translate(-t,-e);this.chart.ctx.drawImage(i,g,m,i.width,i.height)}}this.chart.ctx.setTransform(d)},calculateBarHeight:function(t){var e=this;var a=e.getScaleForId(e.getMeta().yAxisID);if(a.options.barThickness){return a.options.barThickness}return a.options.stacked?t.categoryHeight:t.barHeight},removeHoverStyle:function(t){},setHoverStyle:function(t){}});Chart.defaults.arrowline={elements:{minBarWidth:1,keyStart:0,keyEnd:1,keyValue:2},layout:{padding:{left:0,right:0,top:0,bottom:0}},legend:{display:false},scales:{xAxes:[{type:"timeline",position:"bottom",distribution:"linear",categoryPercentage:.8,barPercentage:.9,gridLines:{display:true,drawBorder:true,drawTicks:true},ticks:{maxRotation:0},unit:"day"}],yAxes:[{type:"category",position:"left",barThickness:20,categoryPercentage:.8,barPercentage:.9,offset:true,gridLines:{display:true,offsetGridLines:true,drawBorder:true,drawTicks:true}}]}};!function(n){function e(n,r){var t=n[0],o=n[1],u=n[2],e=n[3],t=c(t,o,u,e,r[0],7,-680876936),e=c(e,t,o,u,r[1],12,-389564586),u=c(u,e,t,o,r[2],17,606105819),o=c(o,u,e,t,r[3],22,-1044525330);t=c(t,o,u,e,r[4],7,-176418897),e=c(e,t,o,u,r[5],12,1200080426),u=c(u,e,t,o,r[6],17,-1473231341),o=c(o,u,e,t,r[7],22,-45705983),t=c(t,o,u,e,r[8],7,1770035416),e=c(e,t,o,u,r[9],12,-1958414417),u=c(u,e,t,o,r[10],17,-42063),o=c(o,u,e,t,r[11],22,-1990404162),t=c(t,o,u,e,r[12],7,1804603682),e=c(e,t,o,u,r[13],12,-40341101),u=c(u,e,t,o,r[14],17,-1502002290),o=c(o,u,e,t,r[15],22,1236535329),t=f(t,o,u,e,r[1],5,-165796510),e=f(e,t,o,u,r[6],9,-1069501632),u=f(u,e,t,o,r[11],14,643717713),o=f(o,u,e,t,r[0],20,-373897302),t=f(t,o,u,e,r[5],5,-701558691),e=f(e,t,o,u,r[10],9,38016083),u=f(u,e,t,o,r[15],14,-660478335),o=f(o,u,e,t,r[4],20,-405537848),t=f(t,o,u,e,r[9],5,568446438),e=f(e,t,o,u,r[14],9,-1019803690),u=f(u,e,t,o,r[3],14,-187363961),o=f(o,u,e,t,r[8],20,1163531501),t=f(t,o,u,e,r[13],5,-1444681467),e=f(e,t,o,u,r[2],9,-51403784),u=f(u,e,t,o,r[7],14,1735328473),o=f(o,u,e,t,r[12],20,-1926607734),t=i(t,o,u,e,r[5],4,-378558),e=i(e,t,o,u,r[8],11,-2022574463),u=i(u,e,t,o,r[11],16,1839030562),o=i(o,u,e,t,r[14],23,-35309556),t=i(t,o,u,e,r[1],4,-1530992060),e=i(e,t,o,u,r[4],11,1272893353),u=i(u,e,t,o,r[7],16,-155497632),o=i(o,u,e,t,r[10],23,-1094730640),t=i(t,o,u,e,r[13],4,681279174),e=i(e,t,o,u,r[0],11,-358537222),u=i(u,e,t,o,r[3],16,-722521979),o=i(o,u,e,t,r[6],23,76029189),t=i(t,o,u,e,r[9],4,-640364487),e=i(e,t,o,u,r[12],11,-421815835),u=i(u,e,t,o,r[15],16,530742520),o=i(o,u,e,t,r[2],23,-995338651),t=a(t,o,u,e,r[0],6,-198630844),e=a(e,t,o,u,r[7],10,1126891415),u=a(u,e,t,o,r[14],15,-1416354905),o=a(o,u,e,t,r[5],21,-57434055),t=a(t,o,u,e,r[12],6,1700485571),e=a(e,t,o,u,r[3],10,-1894986606),u=a(u,e,t,o,r[10],15,-1051523),o=a(o,u,e,t,r[1],21,-2054922799),t=a(t,o,u,e,r[8],6,1873313359),e=a(e,t,o,u,r[15],10,-30611744),u=a(u,e,t,o,r[6],15,-1560198380),o=a(o,u,e,t,r[13],21,1309151649),t=a(t,o,u,e,r[4],6,-145523070),e=a(e,t,o,u,r[11],10,-1120210379),u=a(u,e,t,o,r[2],15,718787259),o=a(o,u,e,t,r[9],21,-343485551),n[0]=g(t,n[0]),n[1]=g(o,n[1]),n[2]=g(u,n[2]),n[3]=g(e,n[3])}function c(n,r,t,o,u,e,c){return h(r&t|~r&o,n,r,u,e,c)}function f(n,r,t,o,u,e,c){return h(r&o|t&~o,n,r,u,e,c)}function i(n,r,t,o,u,e,c){return h(r^t^o,n,r,u,e,c)}function a(n,r,t,o,u,e,c){return h(t^(r|~o),n,r,u,e,c)}var h=function(n,r,t,o,u,e){return r=g(g(r,n),g(o,e)),g(r<>>32-u,t)},d=(n.md5hx=function(n){for(var r=n.length,t=[1732584193,-271733879,-1732584194,271733878],o=64;o<=n.length;o+=64)e(t,d(n.substring(o-64,o)));n=n.substring(o-64);var u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(o=0;o>2]|=n.charCodeAt(o)<<(o%4<<3);if(u[o>>2]|=128<<(o%4<<3),55>2]=n.charCodeAt(t)+(n.charCodeAt(t+1)<<8)+(n.charCodeAt(t+2)<<16)+(n.charCodeAt(t+3)<<24);return r}),g=function(n,r){return n+r&4294967295}}(window);var _global="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:this;function bom(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e}function download(e,t,o){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.onload=function(){saveAs(n.response,t,o)},n.onerror=function(){console.error("could not download file")},n.send()}function corsEnabled(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&t.status<=299}function click(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(e){var o=document.createEvent("MouseEvents");o.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(o)}}var isMacOSWebView=_global.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),saveAs=_global.saveAs||("object"!=typeof window||window!==_global?function(){}:"download"in HTMLAnchorElement.prototype&&!isMacOSWebView?function(e,t,o){var n=_global.URL||_global.webkitURL,a=document.createElement("a");t=t||e.name||"download",a.download=t,a.rel="noopener","string"==typeof e?(a.href=e,a.origin!==location.origin?corsEnabled(a.href)?download(e,t,o):click(a,a.target="_blank"):click(a)):(a.href=n.createObjectURL(e),setTimeout(function(){n.revokeObjectURL(a.href)},4e4),setTimeout(function(){click(a)},0))}:"msSaveOrOpenBlob"in navigator?function(e,t,o){var n;t=t||e.name||"download","string"==typeof e?corsEnabled(e)?download(e,t,o):((n=document.createElement("a")).href=e,n.target="_blank",setTimeout(function(){click(n)})):navigator.msSaveOrOpenBlob(bom(e,o),t)}:function(e,t,o,n){if((n=n||open("","_blank"))&&(n.document.title=n.document.body.innerText="downloading..."),"string"==typeof e)return download(e,t,o);var a,l,i,t="application/octet-stream"===e.type,o=/constructor/i.test(_global.HTMLElement)||_global.safari,r=/CriOS\/[\d]+/.test(navigator.userAgent);(r||t&&o||isMacOSWebView)&&"undefined"!=typeof FileReader?((a=new FileReader).onloadend=function(){var e=a.result,e=r?e:e.replace(/^data:[^;]*;/,"data:attachment/file;");n?n.location.href=e:location=e,n=null},a.readAsDataURL(e)):(l=_global.URL||_global.webkitURL,i=l.createObjectURL(e),n?n.location=i:location.href=i,n=null,setTimeout(function(){l.revokeObjectURL(i)},4e4))});_global.saveAs=saveAs.saveAs=saveAs,"undefined"!=typeof module&&(module.exports=saveAs);const lang_en={ui:{label:{type_to_search:"Type to search for an entity to add",error_retreiving:"Could not retrieve available entities !",loading:"Loading available entities..."},popup:{remove_all:"Remove all dynamically added graphs ?",enable_panel:"Enable entity history info panel ?",disable_panel:"Disable entity history info panel ?"},menu:{export_csv:"Export as CSV",export_stats:"Export statistics as CSV",remove_all:"Remove all added graphs",enable_panel:"Enable history info panel",disable_panel:"Disable history info panel"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 Day",n_days:"%1 Days",week:"1 Week",n_weeks:"%1 Weeks",month:"1 Month",n_months:"%1 Months",year:"1 Year"},interval:{_10m:"10 min",hourly:"Hourly",daily:"Daily",monthly:"Monthly",rawline:"As line"}}};const lang_fr={ui:{label:{type_to_search:"Tapez ici pour rechercher une entité à ajouter",error_retreiving:"Impossible de récupérer les entités !",loading:"Chargement des entités disponibles..."},popup:{remove_all:"Supprimer tous les graphiques ajoutés dynamiquement ?",enable_panel:"Activer le panneau d'historique des entités ?",disable_panel:"Déactiver le panneau d'historique des entités ?"},menu:{export_csv:"Exporter le CSV",export_stats:"Exporter le CSV des statistiques",remove_all:"Supprimer tous les graphiques",enable_panel:"Activer le panneau d'historique",disable_panel:"Déactiver le panneau d'historique"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 Jour",n_days:"%1 Jours",week:"1 Sem",n_weeks:"%1 Sem",month:"1 Mois",n_months:"%1 Mois",year:"1 An"},interval:{_10m:"10 min",hourly:"Heure",daily:"Journée",monthly:"Mensuel",rawline:"Linéaire"}}};const lang_de={ui:{label:{type_to_search:"Entität suchen oder auswählen",error_retreiving:"Entitäten konnten nicht geladen werden !",loading:"Lade verfügbare Entitäten..."},popup:{remove_all:"Alle dynamisch hinzugefügten Diagramme entfernen ?",enable_panel:"Verlaufsinfo für Entitäten aktivieren ?",disable_panel:"Verlaufsinfo für Entitäten deaktivieren ?"},menu:{export_csv:"Als CSV exportieren",export_stats:"Statistik als CSV exportieren",remove_all:"Alle Diagramme entfernen",enable_panel:"Verlaufsinfo aktivieren",disable_panel:"Verlaufsinfo deaktivieren"},ranges:{l_hour:"< 1 Std",hour:"1 Stunde",n_hours:"%1 Stdn.",day:"1 Tag",n_days:"%1 Tage",week:"1 Woche",n_weeks:"%1 Wo.",month:"1 Monat",n_months:"%1 Monate",year:"1 Jahr"},interval:{_10m:"10 Min",hourly:"Stündlich",daily:"Täglich",monthly:"Monatlich",rawline:"Als Linie"}}};const lang_es={ui:{label:{type_to_search:"Seleccionar entidad a añadir",error_retreiving:"No se encuentran entidades disponibles!",loading:"Cargando entidades ..."},popup:{remove_all:"Borrar gráficos añadidos dinámicamente ?",enable_panel:"Habilitar panel info historia entidades ?",disable_panel:"Deshabilitar panel info historia entidades ?"},menu:{export_csv:"Exportar como CSV",export_stats:"Exportar estadísticas como CSV",remove_all:"Borrar gráficos añadidos",enable_panel:"Activar panel info historia",disable_panel:"Desactivar panel info historia"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 Día",n_days:"%1 Días",week:"1 Sem.",n_weeks:"%1 Sem.",month:"1 Mes",n_months:"%1 Meses",year:"1 Año"},interval:{_10m:"10 min",hourly:"Horario",daily:"Diario",monthly:"Mensual",rawline:"Línea"}}};const lang_nl={ui:{label:{type_to_search:"Typ om te zoeken naar een entiteit om toe te voegen",error_retreiving:"Kan beschikbare entiteiten niet ophalen !",loading:"Beschikbare entiteiten laden..."},popup:{remove_all:"Alle dynamisch toegevoegde grafieken verwijderen ?",enable_panel:"Schakel het informatiepaneel over de geschiedenis van de entiteit in ?",disable_panel:"Schakel het informatiepaneel over de geschiedenis van de entiteit uit ?"},menu:{export_csv:"Exporteren als CSV",export_stats:"Exporteer statistieken als CSV",remove_all:"Verwijder alle toegevoegde grafieken",enable_panel:"Deelvenster Geschiedenisinfo inschakelen",disable_panel:"Schakel geschiedenisinfopaneel uit"},ranges:{l_hour:"< 1 u",hour:"1 u",n_hours:"%1 u",day:"1 Dag",n_days:"%1 Dagen",week:"1 Week",n_weeks:"%1 Weken",month:"1 Maand",n_months:"%1 Maand",year:"1 Jaar"},interval:{_10m:"10 minuten",hourly:"Per uur",daily:"Dagelijks",monthly:"Maandelijks",rawline:"Lijngrafiek"}}};const lang_pl={ui:{label:{type_to_search:"Wpisz, aby wyszukać i dodać encję",error_retreiving:"Nie można pobrać dostępnych elementów !",loading:"Ładowanie dostępnych elementów..."},popup:{remove_all:"Usuń wszystkie wykresy ?",enable_panel:"Włącz panel informacji o historii ?",disable_panel:"Wyłącz panel informacji o historii ?"},menu:{export_csv:"Eksportuj w CSV",export_stats:"Eksportuj statystyki w CSV",remove_all:"Usuń wszystkie dodane grafiki",enable_panel:"Włącz panel historia",disable_panel:"Wyłącz panel historia"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 Dzień",n_days:"%1 Dni",week:"1 Tydzień",n_weeks:"%1 Tyg",month:"1 Miesiąc",n_months:"%1 Mies",year:"1 Rok"},interval:{_10m:"10 minut",hourly:"Godzina",daily:"Dzień",monthly:"Miesiąc",rawline:"As line"}}};const lang_sv={ui:{label:{type_to_search:"Skriv för att söka efter en enhet att lägga till",error_retreiving:"Kunde inte hämta tillgängliga enheter!",loading:"Laddar tillgängliga enheter..."},popup:{remove_all:"Ta bort alla dynamiskt tillagda grafer?",enable_panel:"Aktivera panelen för enhetens historikinformation?",disable_panel:"Inaktivera panelen för enhetens historikinformation?"},menu:{export_csv:"Exportera som CSV",export_stats:"Exportera statistik som CSV",remove_all:"Ta bort alla tillagda grafer",enable_panel:"Aktivera historikinfo-panelen",disable_panel:"Inaktivera historikinfo-panelen"},ranges:{l_hour:"< 1 tim",hour:"1 tim",n_hours:"%1 timmar",day:"1 dag",n_days:"%1 dagar",week:"1 vecka",n_weeks:"%1 veckor",month:"1 månad",n_months:"%1 månader",year:"1 år"},interval:{_10m:"10 min",hourly:"Varje timme",daily:"Varje dag",monthly:"Varje månad",rawline:"As line"}}};const lang_da={ui:{label:{type_to_search:"Indtast for at søge efter en entitet, der skal tilføjes",error_retreiving:"Fejl ved indlæsning af entiteter !",loading:"Indlæser tilgængelige entiteter..."},popup:{remove_all:"Fjern alle dynamisk tilføjede grafer ?",enable_panel:"Brug historik graf som standard ?",disable_panel:"Fravælg historik graf som standard ?"},menu:{export_csv:"Eksporter som CSV",export_stats:"Eksporter statistik som CSV",remove_all:"Fjern alle tilføjede grafer ",enable_panel:"Brug historik graf som standard",disable_panel:"Deaktivér historik graf som standard"},ranges:{l_hour:"< 1 T",hour:"1 T",n_hours:"%1 T",day:"1 dag",n_days:"%1 dage",week:"1 uge",n_weeks:"%1 uger",month:"1 måned",n_months:"%1 måneder",year:"1 år"},interval:{_10m:"10 min",hourly:"Hver time",daily:"Daglig",monthly:"Månedlig",rawline:"As line"}}};const lang_sk={ui:{label:{type_to_search:"Napíšte, ak chcete vyhľadať entitu, ktorú chcete pridať",error_retreiving:"Nepodarilo sa načítať dostupné entity !",loading:"Načitavanie dostupných entít..."},popup:{remove_all:"Odstrániť všetky dynamicky pridané grafy ?",enable_panel:"Povoliť informačný panel histórie ?",disable_panel:"Zakázať informačný panel histórie ?"},menu:{export_csv:"Export ako CSV",export_stats:"Export štatistiky ako CSV",remove_all:"Odstrániť všetky pridané grafy",enable_panel:"Povoliť informačný panel histórie",disable_panel:"Zakázať informačný panel histórie"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 deň",n_days:"%1 dní",week:"1 týždeň",n_weeks:"%1 týždňov",month:"1 mesiac",n_months:"%1 mesiacov",year:"1 rok"},interval:{_10m:"10 min",hourly:"Hodinovo",daily:"Denne",monthly:"Mesačné",rawline:"Ako čiara"}}};const lang_ru={ui:{label:{type_to_search:"Начните поиск объекта для добавления",error_retreiving:"Невозможно загрузить доступные объекты!",loading:"Загрузка доступных объектов..."},popup:{remove_all:"Очистить все добавленные графики?",enable_panel:"Активировать историю в панели информации",disable_panel:"Деактивировать историю в панели информации"},menu:{export_csv:"Экспортировать как CSV",export_stats:"Экспортировать статистику как CSV",remove_all:"Очистить все добавленные графики",enable_panel:"Активировать историю в панели информации",disable_panel:"Деактивировать историю в панели информации"},ranges:{l_hour:"< 1 Ч",hour:"1 Ч",n_hours:"%1 Ч",day:"1 День",n_days:"%1 Дн",week:"1 Неделя",n_weeks:"%1 Нед",month:"1 Месяц",n_months:"%1 Мес",year:"1 Год"},interval:{_10m:"10 мин",hourly:"По часам",daily:"По дням",monthly:"По месяцам",rawline:"Линия"}}};var languages={en:lang_en,fr:lang_fr,de:lang_de,es:lang_es,nl:lang_nl,pl:lang_pl,sv:lang_sv,da:lang_da,sk:lang_sk,ru:lang_ru};var language="en";function setLanguage(e){language="en";let a=e.replace("-","_").split("_");if(a&&a.length>0&&languages[a[0]])language=a[0]}function i18n(e,a){let n=e.split(".").reduce((e,a)=>e[a],languages[language]);if(n===undefined)n=e.split(".").reduce((e,a)=>e[a],languages["en"]);if(n&&a)n=n.replace("%1",a);return n}const Version="1.0.50 dev";var isMobile=navigator.appVersion.indexOf("Mobi")>-1||navigator.userAgent.indexOf("HomeAssistant")>-1;const ranges=[1,2,6,12,24,48,72,96,120,144,168,336,504,720,2184,4368,8760];var panstate={};panstate.mx=0;panstate.lx=0;panstate.my=0;panstate.ly=0;panstate.tc=0;panstate.g=null;panstate.overlay=null;panstate.st0=null;panstate.st1=null;let infoPanelEnabled=!!JSON.parse(window.localStorage.getItem("history-explorer-info-panel"));class HistoryCardState{constructor(){this.colorMap=new Map;this.timeCache=new Map;this.stateTexts=new Map;this.stateMap=new Map;this.csvExporter=new HistoryCSVExporter;this.statsExporter=new StatisticsCSVExporter;this.stateColors=stateColors;this.stateColorsDark=stateColorsDark;this.ui={};this.ui.dateSelector=[];this.ui.rangeSelector=[];this.ui.zoomButton=[];this.ui.inputField=[];this.ui.darkMode=false;this.ui.spinOverlay=null;this.ui.optionStyle="";this.ui.hideHeader=false;this.ui.hideInterval=false;this.ui.hideSelector=false;this.ui.stickyTools=0;this.ui.wideInterval=false;this.i18n={};this.i18n.valid=false;this.i18n.styleDateSelector="";this.i18n.styleTimeTicks="";this.i18n.styleDateTicks="";this.i18n.styleDateTimeTooltip="";this.pconfig={};this.pconfig.graphLabelColor="#333";this.pconfig.graphGridColor="#00000000";this.pconfig.lineGraphHeight=250;this.pconfig.barGraphHeight=150;this.pconfig.timelineBarHeight=24;this.pconfig.timelineBarSpacing=40;this.pconfig.labelAreaWidth=65;this.pconfig.labelsVisible=true;this.pconfig.showTooltipColors=[true,true];this.pconfig.tooltipSize="auto";this.pconfig.tooltipShowDuration=false;this.pconfig.tooltipShowLabel=true;this.pconfig.tooltipStateTextMode="raw";this.pconfig.closeButtonColor=undefined;this.pconfig.customStateColors=undefined;this.pconfig.colorSeed=137;this.pconfig.stateTextMode="raw";this.pconfig.graphConfig=[];this.pconfig.entityOptions=undefined;this.pconfig.lockAllGraphs=false;this.pconfig.combineSameUnits=false;this.pconfig.recordedEntitiesOnly=false;this.pconfig.filterEntities=undefined;this.pconfig.decimation="fast";this.pconfig.roundingPrecision=2;this.pconfig.defaultLineMode=undefined;this.pconfig.nextDefaultColor=0;this.pconfig.showUnavailable=true;this.pconfig.showCurrentValues=false;this.pconfig.axisAddMarginMin=true;this.pconfig.axisAddMarginMax=true;this.pconfig.defaultTimeRange="24";this.pconfig.defaultTimeOffset=undefined;this.pconfig.timeTickDensity="high";this.pconfig.refreshEnabled=false;this.pconfig.refreshInterval=undefined;this.pconfig.exportSeparator=undefined;this.pconfig.exportTimeFormat=undefined;this.pconfig.exportStatsPeriod=undefined;this.pconfig.entities=[];this.pconfig.infoPanelConfig=null;this.loader={};this.loader.startTime=0;this.loader.endTime=0;this.loader.startIndex=-1;this.loader.endIndex=-1;this.loader.loadingStats=false;this.state={};this.state.drag=false;this.state.selecting=false;this.state.updateCanvas=null;this.state.loading=false;this.state.zoomMode=false;this.state.altGraph=null;this.state.autoScroll=false;this.activeRange={};this.activeRange.timeRangeHours=24;this.activeRange.timeRangeMinutes=0;this.activeRange.tickStepSize=1;this.activeRange.tickStepUnit="hour";this.activeRange.dataClusterSize=0;this.statistics={};this.statistics.enabled=false;this.statistics.retention=undefined;this.statistics.mode="";this.statistics.period="hour";this.id="";this.graphs=[];this.g_id=0;this.firstDynamicId=0;this.startTime;this.endTime;this.limitSlot=0;this.cacheSize=365+1;this.cache=[];this._hass=null;this._this=null;this.version=[];this.contentValid=false;this.entitiesPopulated=false;this.iid=0;this.tid=0;this.lastWidth=0;this.defocusCall=this.entitySelectorDefocus.bind(this);this.databaseCallback=null}getNextDefaultColor(){let t=this.pconfig.nextDefaultColor++;this.pconfig.nextDefaultColor=this.pconfig.nextDefaultColor%defaultColors.length;return defaultColors[t]}getStateColor(t,e,i,s){let a;if(s===undefined||s===null||s==="")s="unknown";if(i){const n=i+"."+s;a=this.pconfig.customStateColors?.[n];if(!a)a=this.pconfig.customStateColors?.[i]}if(!a&&e){const n=e+"."+s;a=this.pconfig.customStateColors?.[n];if(!a)a=this.pconfig.customStateColors?.[e]}if(!a&&t){const n=t+"."+s;a=this.pconfig.customStateColors?.[n];if(!a)a=this.pconfig.customStateColors?.[t]}if(!a){a=this.pconfig.customStateColors?.[s]}if(!a&&e){const n=e+"."+s;a=this.ui.darkMode&&this.stateColorsDark[n]?this.stateColorsDark[n]:this.stateColors[n]}if(!a&&t){const n=t+"."+s;a=this.ui.darkMode&&this.stateColorsDark[n]?this.stateColorsDark[n]:this.stateColors[n]}if(!a){a=this.ui.darkMode&&this.stateColorsDark[s]?this.stateColorsDark[s]:this.stateColors[s]}if(!a){if(!this.colorMap.has(s)){const o=md5hx(s);const r=(o[0]&2147483647)*this.pconfig.colorSeed%359;const l=Math.ceil(45+30*((o[1]&2147483647)%255/255))-(this.ui.darkMode?13:0);const h=Math.ceil(55+10*((o[1]&2147483647)%255/255))-(this.ui.darkMode?5:0);a="hsl("+r+","+l+"%,"+h+"%)";this.colorMap.set(s,a)}else a=this.colorMap.get(s)}return a}getLocalizedState(t,e,i,s){const a=s+t;let n=this.stateTexts.get(a);if(!n){n=i&&this._hass.localize(`component.${e}.entity_component.${i}.state.${t}`)||this._hass.localize(`component.${e}.entity_component._.state.${t}`)||i&&this._hass.localize(`component.${e}.state.${i}.${t}`)||this._hass.localize(`component.${e}.state._.${t}`)||t;this.stateTexts.set(a,n)}return n}today(e=false){if(!this.state.loading){if(e)this.setTimeRangeFromString(String(this.pconfig.defaultTimeRange));let t=moment();if(this.pconfig.defaultTimeOffset){const i=this.pconfig.defaultTimeOffset.slice(0,-1);switch(this.pconfig.defaultTimeOffset.slice(-1)[0]){case"m":t=t.add(i,"minute");break;case"h":t=t.add(i,"hour");break;case"d":t=t.add(i,"day");break;case"w":t=t.add(i,"week");break;case"o":t=t.add(i,"month");break;case"H":t=moment(t.format("YYYY-MM-DDTHH:00:00")).add(i,"hour");break;case"D":t=moment(t.format("YYYY-MM-DDT00:00:00")).add(i,"day");break;case"O":t=moment(t.format("YYYY-MM-01T00:00:00")).add(i,"month");break}}this.endTime=t.format("YYYY-MM-DDTHH:mm:ss");this.startTime=moment(this.endTime).subtract(this.activeRange.timeRangeHours,"hour").subtract(this.activeRange.timeRangeMinutes,"minute").format("YYYY-MM-DDTHH:mm:ss");this.updateHistory()}this.state.autoScroll=true}todayNoReset(){this.today(false)}todayReset(){this.today(true)}subDay(){if(!this.state.loading){if(this.activeRange.timeRangeHours<24)this.setTimeRange(24,false);let t=moment(this.startTime).subtract(1,this.activeRange.timeRangeHours<720?"day":"month");let e=moment(t).add(this.activeRange.timeRangeHours,"hour");this.startTime=t.format("YYYY-MM-DD")+"T00:00:00";this.endTime=e.format("YYYY-MM-DD")+"T00:00:00";this.updateHistory()}}addDay(){if(!this.state.loading){if(this.activeRange.timeRangeHours<24)this.setTimeRange(24,false);let t=moment(this.startTime).add(1,this.activeRange.timeRangeHours<720?"day":"month");let e=moment(t).add(this.activeRange.timeRangeHours,"hour");this.startTime=t.format("YYYY-MM-DD")+"T00:00:00";this.endTime=e.format("YYYY-MM-DD")+"T00:00:00";this.updateHistory()}}toggleZoom(){this.state.zoomMode=!this.state.zoomMode;for(let t of this.ui.zoomButton)if(t)t.style.backgroundColor=this.state.zoomMode?this.ui.darkMode?"#ffffff3a":"#0000003a":"#0000";if(panstate.overlay){panstate.overlay.remove();panstate.overlay=null}}decZoom(){this.decZoomStep()}incZoom(){this.incZoomStep()}timeRangeSelected(t){this.setTimeRange(t.target.value,true)}exportFile(){this.menuSetVisibility(0,false);this.menuSetVisibility(1,false);this.csvExporter.exportFile(this)}exportStatistics(){this.menuSetVisibility(0,false);this.menuSetVisibility(1,false);this.statsExporter.exportFile(this)}toggleInfoPanel(){this.menuSetVisibility(0,false);this.menuSetVisibility(1,false);if(confirm(infoPanelEnabled?i18n("ui.popup.disable_panel"):i18n("ui.popup.enable_panel"))){infoPanelEnabled=!infoPanelEnabled;this.writeInfoPanelConfig(true);location.reload()}}decZoomStep(e=null,i=.5){if(!this.activeRange.timeRangeHours){this.activeRange.timeRangeMinutes*=2;if(this.activeRange.timeRangeMinutes>=60){this.activeRange.timeRangeMinutes=0;this.activeRange.timeRangeHours=0}}if(!this.activeRange.timeRangeMinutes){let t=ranges.findIndex(t=>t>=this.activeRange.timeRangeHours);if(t>=0){if(ranges[t]>this.activeRange.timeRangeHours)t--;if(tt>=this.activeRange.timeRangeHours);if(i>0)this.setTimeRange(ranges[i-1],true,t,e);else this.setTimeRangeMinutes((this.activeRange.timeRangeHours*60+this.activeRange.timeRangeMinutes)/2,true,t,e)}selectBarInterval(t){const i=t.target.id.substr(t.target.id.indexOf("-")+1);for(let e=0;e +(function(){var __f=function(e,t){window.HXLocal_moment=t()};__f(this,function(){"use strict";var e;function h(){return e.apply(null,arguments)}function a(e){return e instanceof Array||"[object Array]"===Object.prototype.toString.call(e)}function o(e){return null!=e&&"[object Object]"===Object.prototype.toString.call(e)}function r(e){return void 0===e}function u(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function s(e){return e instanceof Date||"[object Date]"===Object.prototype.toString.call(e)}function i(e,t){for(var n=[],s=0;s>>0,s=0;sLe(e)?(r=e+1,i-Le(e)):(r=e,i);return{year:r,dayOfYear:i}}function Ie(e,t,n){var s,i,r=Ee(e.year(),t,n),r=Math.floor((e.dayOfYear()-r-1)/7)+1;return r<1?s=r+Ze(i=e.year()-1,t,n):r>Ze(e.year(),t,n)?(s=r-Ze(e.year(),t,n),i=e.year()+1):(i=e.year(),s=r),{week:s,year:i}}function Ze(e,t,n){var s=Ee(e,t,n),n=Ee(e+1,t,n);return(Le(e)-s+n)/7}Z("w",["ww",2],"wo","week"),Z("W",["WW",2],"Wo","isoWeek"),R("week","w"),R("isoWeek","W"),H("week",5),H("isoWeek",5),he("w",K),he("ww",K,J),he("W",K),he("WW",K,J),ye(["w","ww","W","WW"],function(e,t,n,s){t[s.substr(0,1)]=S(e)});Z("d",0,"do","day"),Z("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),Z("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),Z("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),Z("e",0,0,"weekday"),Z("E",0,0,"isoWeekday"),R("day","d"),R("weekday","e"),R("isoWeekday","E"),H("day",11),H("weekday",11),H("isoWeekday",11),he("d",K),he("e",K),he("E",K),he("dd",function(e,t){return t.weekdaysMinRegex(e)}),he("ddd",function(e,t){return t.weekdaysShortRegex(e)}),he("dddd",function(e,t){return t.weekdaysRegex(e)}),ye(["dd","ddd","dddd"],function(e,t,n,s){s=n._locale.weekdaysParse(e,s,n._strict);null!=s?t.d=s:f(n).invalidWeekday=e}),ye(["d","e","E"],function(e,t,n,s){t[s]=S(e)});var ze="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_");var $e="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_");var qe="Su_Mo_Tu_We_Th_Fr_Sa".split("_");var Je=le;var Be=le;var Qe=le;function Xe(){function e(e,t){return t.length-e.length}for(var t,n,s,i=[],r=[],a=[],o=[],u=0;u<7;u++)s=d([2e3,1]).day(u),t=this.weekdaysMin(s,""),n=this.weekdaysShort(s,""),s=this.weekdays(s,""),i.push(t),r.push(n),a.push(s),o.push(t),o.push(n),o.push(s);for(i.sort(e),r.sort(e),a.sort(e),o.sort(e),u=0;u<7;u++)r[u]=fe(r[u]),a[u]=fe(a[u]),o[u]=fe(o[u]);this._weekdaysRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+a.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+r.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+i.join("|")+")","i")}function Ke(){return this.hours()%12||12}function et(e,t){Z(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}function tt(e,t){return t._meridiemParse}Z("H",["HH",2],0,"hour"),Z("h",["hh",2],0,Ke),Z("k",["kk",2],0,function(){return this.hours()||24}),Z("hmm",0,0,function(){return""+Ke.apply(this)+N(this.minutes(),2)}),Z("hmmss",0,0,function(){return""+Ke.apply(this)+N(this.minutes(),2)+N(this.seconds(),2)}),Z("Hmm",0,0,function(){return""+this.hours()+N(this.minutes(),2)}),Z("Hmmss",0,0,function(){return""+this.hours()+N(this.minutes(),2)+N(this.seconds(),2)}),et("a",!0),et("A",!1),R("hour","h"),H("hour",13),he("a",tt),he("A",tt),he("H",K),he("h",K),he("k",K),he("HH",K,J),he("hh",K,J),he("kk",K,J),he("hmm",ee),he("hmmss",te),he("Hmm",ee),he("Hmmss",te),_e(["H","HH"],ve),_e(["k","kk"],function(e,t,n){e=S(e);t[ve]=24===e?0:e}),_e(["a","A"],function(e,t,n){n._isPm=n._locale.isPM(e),n._meridiem=e}),_e(["h","hh"],function(e,t,n){t[ve]=S(e),f(n).bigHour=!0}),_e("hmm",function(e,t,n){var s=e.length-2;t[ve]=S(e.substr(0,s)),t[Me]=S(e.substr(s)),f(n).bigHour=!0}),_e("hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[ve]=S(e.substr(0,s)),t[Me]=S(e.substr(s,2)),t[Se]=S(e.substr(i)),f(n).bigHour=!0}),_e("Hmm",function(e,t,n){var s=e.length-2;t[ve]=S(e.substr(0,s)),t[Me]=S(e.substr(s))}),_e("Hmmss",function(e,t,n){var s=e.length-4,i=e.length-2;t[ve]=S(e.substr(0,s)),t[Me]=S(e.substr(s,2)),t[Se]=S(e.substr(i))});var nt,Oe=L("Hours",!0),st={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Pe,monthsShort:We,week:{dow:0,doy:6},weekdays:ze,weekdaysMin:qe,weekdaysShort:$e,meridiemParse:/[ap]\.?m?\.?/i},it={},rt={};function at(e){return e&&e.toLowerCase().replace("_","-")}function ot(e){var t;if(!it[e]&&"undefined"!=typeof module&&module&&module.exports)try{t=nt._abbr,require("./locale/"+e),ut(t)}catch(e){}return it[e]}function ut(e,t){var n;return(nt=e&&(n=r(t)?dt(e):lt(e,t))?n:nt)._abbr}function lt(e,t){if(null===t)return delete it[e],null;var n=st;if(t.abbr=e,null!=it[e])O("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=it[e]._config;else if(null!=t.parentLocale){if(null==it[t.parentLocale])return rt[t.parentLocale]||(rt[t.parentLocale]=[]),rt[t.parentLocale].push({name:e,config:t}),null;n=it[t.parentLocale]._config}return it[e]=new b(x(n,t)),rt[e]&&rt[e].forEach(function(e){lt(e.name,e.config)}),ut(e),it[e]}function dt(e){var t;if(!(e=e&&e._locale&&e._locale._abbr?e._locale._abbr:e))return nt;if(!a(e)){if(t=ot(e))return t;e=[e]}return function(e){for(var t,n,s,i,r=0;r=t&&k(i,n,!0)>=t-1)break;t--}r++}return null}(e)}function ht(e){var t=e._a;return t&&-2===f(e).overflow&&(t=t[we]<0||11xe(t[ge],t[we])?pe:t[ve]<0||24Ze(n,r,a)?f(e)._overflowWeeks=!0:null!=o?f(e)._overflowWeekday=!0:(a=Ae(n,s,i,r,a),e._a[ge]=a.year,e._dayOfYear=a.dayOfYear)}(e),null!=e._dayOfYear&&(i=Mt(e._a[ge],n[ge]),(e._dayOfYear>Le(i)||0===e._dayOfYear)&&(f(e)._overflowDayOfYear=!0),i=je(i,0,e._dayOfYear),e._a[we]=i.getUTCMonth(),e._a[pe]=i.getUTCDate()),t=0;t<3&&null==e._a[t];++t)e._a[t]=r[t]=n[t];for(;t<7;t++)e._a[t]=r[t]=null==e._a[t]?2===t?1:0:e._a[t];24===e._a[ve]&&0===e._a[Me]&&0===e._a[Se]&&0===e._a[ke]&&(e._nextDay=!0,e._a[ve]=0),e._d=(e._useUTC?je:Ne).apply(null,r),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[ve]=24)}}function kt(e){if(e._f!==h.ISO_8601)if(e._f!==h.RFC_2822){e._a=[],f(e).empty=!0;for(var t,n,s,i,r,a=""+e._i,o=a.length,u=0,l=$(e._f,e._locale).match(j)||[],d=0;de.valueOf():e.valueOf()this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},Q.isLocal=function(){return!!this.isValid()&&!this._isUTC},Q.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},Q.isUtc=Lt,Q.isUTC=Lt,Q.zoneAbbr=function(){return this._isUTC?"UTC":""},Q.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},Q.dates=n("dates accessor is deprecated. Use date instead.",ze),Q.months=n("months accessor is deprecated. Use month instead",Ce),Q.years=n("years accessor is deprecated. Use year instead",Ve),Q.zone=n("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?(this.utcOffset(e="string"!=typeof e?-e:e,t),this):-this.utcOffset()}),Q.isDSTShifted=n("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!r(this._isDSTShifted))return this._isDSTShifted;var e,t={};return w(t,this),(t=Dt(t))._a?(e=(t._isUTC?d:Ot)(t._a),this._isDSTShifted=this.isValid()&&0');var t=t.data,i=t.datasets,n=t.labels;if(i.length)for(var o=0;o'),n[o]&&e.push(n[o]),e.push("");return e.push(""),e.join("")},legend:{labels:{generateLabels:function(s){var l=s.data;return l.labels.length&&l.datasets.length?l.labels.map(function(t,e){var i=s.getDatasetMeta(0),n=l.datasets[0],o=i.data[e],a=o&&o.custom||{},r=b.valueAtIndexOrDefault,o=s.options.elements.arc;return{text:t,fillStyle:a.backgroundColor||r(n.backgroundColor,e,o.backgroundColor),strokeStyle:a.borderColor||r(n.borderColor,e,o.borderColor),lineWidth:a.borderWidth||r(n.borderWidth,e,o.borderWidth),hidden:isNaN(n.data[e])||i.data[e].hidden,index:e}}):[]}},onClick:function(t,e){for(var i,n=e.index,o=this.chart,a=0,r=(o.data.datasets||[]).length;a=Math.PI?-1:n<-Math.PI?1:0))+v,t=Math.cos(n),e=Math.sin(n),o=Math.cos(a),l=Math.sin(a),d=n<=0&&0<=a||n<=2*Math.PI&&2*Math.PI<=a,u=n<=.5*Math.PI&&.5*Math.PI<=a||n<=2.5*Math.PI&&2.5*Math.PI<=a,v=n<=-Math.PI&&-Math.PI<=a||n<=Math.PI&&Math.PI<=a,n=n<=.5*-Math.PI&&.5*-Math.PI<=a||n<=1.5*Math.PI&&1.5*Math.PI<=a,a=m/100,v=v?-1:Math.min(t*(t<0?1:a),o*(o<0?1:a)),n=n?-1:Math.min(e*(e<0?1:a),l*(l<0?1:a)),o=d?1:Math.max(t*(0');var t=t.data,i=t.datasets,n=t.labels;if(i.length)for(var o=0;o'),n[o]&&e.push(n[o]),e.push("");return e.push(""),e.join("")},legend:{labels:{generateLabels:function(s){var l=s.data;return l.labels.length&&l.datasets.length?l.labels.map(function(t,e){var i=s.getDatasetMeta(0),n=l.datasets[0],o=i.data[e].custom||{},a=b.valueAtIndexOrDefault,r=s.options.elements.arc;return{text:t,fillStyle:o.backgroundColor||a(n.backgroundColor,e,r.backgroundColor),strokeStyle:o.borderColor||a(n.borderColor,e,r.borderColor),lineWidth:o.borderWidth||a(n.borderWidth,e,r.borderWidth),hidden:isNaN(n.data[e])||i.data[e].hidden,index:e}}):[]}},onClick:function(t,e){for(var i,n=e.index,o=this.chart,a=0,r=(o.data.datasets||[]).length;a=e.numSteps?(a.callback(e.onAnimationComplete,[e],i),i.animating=!1,n.splice(o,1)):++o}},Object.defineProperty(t.Animation.prototype,"animationObject",{get:function(){return this}}),Object.defineProperty(t.Animation.prototype,"chartInstance",{get:function(){return this.chart},set:function(t){this.chart=t}})}},{25:25,26:26,45:45}],23:[function(t,e,i){"use strict";var l=t(25),u=t(45),n=t(28),d=t(48);e.exports=function(r){var s=r.plugins;function a(t){return"top"===t||"bottom"===t}r.types={},r.instances={},r.controllers={},u.extend(r.prototype,{construct:function(t,e){var i=this;(o=(a=(a=e)||{}).data=a.data||{}).datasets=o.datasets||[],o.labels=o.labels||[],a.options=u.configMerge(l.global,l[a.type],a.options||{}),e=a;var n=d.acquireContext(t,e),o=n&&n.canvas,a=o&&o.height,t=o&&o.width;i.id=u.uid(),i.ctx=n,i.canvas=o,i.config=e,i.width=t,i.height=a,i.aspectRatio=a?t/a:null,i.options=e.options,i._bufferedRender=!1,(i.chart=i).controller=i,r.instances[i.id]=i,Object.defineProperty(i,"data",{get:function(){return i.config.data},set:function(t){i.config.data=t}}),n&&o?(i.initialize(),i.update()):console.error("Failed to create chart: can't acquire context from the given item")},initialize:function(){var t=this;return s.notify(t,"beforeInit"),u.retinaScale(t,t.options.devicePixelRatio),t.bindEvents(),t.options.responsive&&t.resize(!0),t.ensureScalesHaveIDs(),t.buildScales(),t.initToolTip(),s.notify(t,"afterInit"),t},clear:function(){return u.canvas.clear(this),this},stop:function(){return r.animationService.cancelAnimation(this),this},resize:function(t,e){var i=this,n=i.options,o=i.canvas,a=n.maintainAspectRatio&&i.aspectRatio||null,r=Math.max(0,Math.floor(u.getMaximumWidth(o))),a=Math.max(0,Math.floor(a?r/a:u.getMaximumHeight(o)));e&&(a=e),i.width===r&&i.height===a||(o.width=i.width=r,o.height=i.height=a,o.style.width=r+"px",o.style.height=a+"px",u.retinaScale(i,n.devicePixelRatio),t||(s.notify(i,"resize",[a={width:r,height:a}]),i.options.onResize&&i.options.onResize(i,a),i.stop(),i.update(i.options.responsiveAnimationDuration)))},ensureScalesHaveIDs:function(){var t=this.options,e=t.scales||{},t=t.scale;u.each(e.xAxes,function(t,e){t.id=t.id||"x-axis-"+e}),u.each(e.yAxes,function(t,e){t.id=t.id||"y-axis-"+e}),t&&(t.id=t.id||"scale")},buildScales:function(){var n=this,t=n.options,o=n.scales={},e=[];t.scales&&(e=e.concat((t.scales.xAxes||[]).map(function(t){return{options:t,dtype:"category",dposition:"bottom"}}),(t.scales.yAxes||[]).map(function(t){return{options:t,dtype:"linear",dposition:"left"}}))),t.scale&&e.push({options:t.scale,dtype:"radialLinear",isDefault:!0,dposition:"chartArea"}),u.each(e,function(t){var e=t.options,i=u.valueOrDefault(e.type,t.dtype),i=r.scaleService.getScaleConstructor(i);i&&(a(e.position)!==a(t.dposition)&&(e.position=t.dposition),e=new i({id:e.id,options:e,ctx:n.ctx,chart:n}),(o[e.id]=e).mergeTicksOptions(),t.isDefault&&(n.scale=e))}),r.scaleService.addScalesToLayout(this)},buildOrUpdateControllers:function(){var n=this,o=[],a=[];return u.each(n.data.datasets,function(t,e){var i=n.getDatasetMeta(e),t=t.type||n.config.type;if(i.type&&i.type!==t&&(n.destroyDatasetMeta(e),i=n.getDatasetMeta(e)),i.type=t,o.push(i.type),i.controller)i.controller.updateIndex(e);else{t=r.controllers[i.type];if(void 0===t)throw new Error('"'+i.type+'" is not a chart type.');i.controller=new t(n,e),a.push(i.controller)}},n),a},resetElements:function(){var i=this;u.each(i.data.datasets,function(t,e){i.getDatasetMeta(e).controller.reset()},i)},reset:function(){this.resetElements(),this.tooltip.initialize()},update:function(t){var e,i,n=this;t&&"object"==typeof t||(t={duration:t,lazy:arguments[1]}),(i=(e=n).options).scale?e.scale.options=i.scale:i.scales&&i.scales.xAxes.concat(i.scales.yAxes).forEach(function(t){e.scales[t.id].options=t}),e.tooltip._options=i.tooltips,!1!==s.notify(n,"beforeUpdate")&&(n.tooltip._data=n.data,i=n.buildOrUpdateControllers(),u.each(n.data.datasets,function(t,e){n.getDatasetMeta(e).controller.buildOrUpdateElements()},n),n.updateLayout(),u.each(i,function(t){t.reset()}),n.updateDatasets(),n.tooltip.initialize(),n.lastActive=[],s.notify(n,"afterUpdate"),n._bufferedRender?n._bufferedRequest={duration:t.duration,easing:t.easing,lazy:t.lazy}:n.render(t))},updateLayout:function(){!1!==s.notify(this,"beforeLayout")&&(r.layoutService.update(this,this.width,this.height),s.notify(this,"afterScaleUpdate"),s.notify(this,"afterLayout"))},updateDatasets:function(){if(!1!==s.notify(this,"beforeDatasetsUpdate")){for(var t=0,e=this.data.datasets.length;t=e[t].length&&e[t].push({}),!e[t][o].type||r.type&&r.type!==e[t][o].type?h.merge(e[t][o],[l.scaleService.getScaleDefaults(a),r]):h.merge(e[t][o],r)}else h._merger(t,e,i,n)}})},h.where=function(t,e){if(h.isArray(t)&&Array.prototype.filter)return t.filter(e);var i=[];return h.each(t,function(t){e(t)&&i.push(t)}),i},h.findIndex=Array.prototype.findIndex?function(t,e,i){return t.findIndex(e,i)}:function(t,e,i){i=void 0===i?t:i;for(var n=0,o=t.length;n=t.length-1?t[0]:t[e+1]:e>=t.length-1?t[t.length-1]:t[e+1]},h.previousItem=function(t,e,i){return i?e<=0?t[t.length-1]:t[e-1]:e<=0?t[0]:t[e-1]},h.niceNum=function(t,e){var i=Math.floor(h.log10(t)),t=t/Math.pow(10,i),t=e?t<1.5?1:t<3?2:t<7?5:10:t<=1?1:t<=2?2:t<=5?5:10;return t*Math.pow(10,i)},h.requestAnimFrame="undefined"==typeof window?function(t){t()}:window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)},h.getRelativePosition=function(t,e){var i=t.originalEvent||t,n=t.currentTarget||t.srcElement,o=n.getBoundingClientRect(),a=i.touches,r=a&&0i.length){for(var l=0;le&&(e=t.length)}),e},h.color=n?function(t){return t instanceof CanvasGradient&&(t=o.global.defaultColor),n(t)}:function(t){return console.error("Color.js not found!"),t},h.getHoverColor=function(t){return t instanceof CanvasPattern?t:h.color(t).saturate(.5).darken(.1).rgbString()}}},{25:25,3:3,45:45}],28:[function(t,e,i){"use strict";var n=t(45);function r(t,e){return t.native?{x:t.x,y:t.y}:n.getRelativePosition(t,e)}function s(t,e){for(var i,n,o,a=0,r=t.data.datasets.length;at.maxHeight){a--;break}a++,s=d*r}t.labelRotation=a},afterCalculateTickRotation:function(){B.callback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){B.callback(this.options.beforeFit,[this])},fit:function(){var t,e=this,i=e.minSize={width:0,height:0},n=f(e._ticks),o=e.options,a=o.ticks,r=o.scaleLabel,s=o.gridLines,l=o.display,u=e.isHorizontal(),d=g(a),c=o.gridLines.tickMarkLength;i.width=u?e.isFullWidth()?e.maxWidth-e.margins.left-e.margins.right:e.maxWidth:l&&s.drawTicks?c:0,i.height=u?l&&s.drawTicks?c:0:e.maxHeight,r.display&&l&&(t=p(r)+B.options.toPadding(r.padding).height,u?i.height+=t:i.width+=t),a.display&&l&&(s=B.longestText(e.ctx,d.font,n,e.longestTextCache),c=B.numberOfLabelLines(n),r=.5*d.size,t=e.options.ticks.padding,u?(e.longestLabelWidth=s,l=B.toRadians(e.labelRotation),u=Math.cos(l),c=Math.sin(l)*s+d.size*c+r*(c-1)+r,i.height=Math.min(e.maxHeight,i.height+c+t),e.ctx.font=d.font,c=h(e.ctx,n[0],d.font),n=h(e.ctx,n[n.length-1],d.font),0!==e.labelRotation?(e.paddingLeft="bottom"===o.position?u*c+3:u*r+3,e.paddingRight="bottom"===o.position?u*r+3:u*n+3):(e.paddingLeft=c/2+3,e.paddingRight=n/2+3)):(a.mirror?s=0:s+=t+r,i.width=Math.min(e.maxWidth,i.width+s),e.paddingTop=d.size/2,e.paddingBottom=d.size/2)),e.handleMargins(),e.width=i.width,e.height=i.height},handleMargins:function(){var t=this;t.margins&&(t.paddingLeft=Math.max(t.paddingLeft-t.margins.left,0),t.paddingTop=Math.max(t.paddingTop-t.margins.top,0),t.paddingRight=Math.max(t.paddingRight-t.margins.right,0),t.paddingBottom=Math.max(t.paddingBottom-t.margins.bottom,0))},afterFit:function(){B.callback(this.options.afterFit,[this])},isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},isFullWidth:function(){return this.options.fullWidth},getRightValue:function(t){if(B.isNullOrUndef(t))return NaN;if("number"==typeof t&&!isFinite(t))return NaN;if(t)if(this.isHorizontal()){if(void 0!==t.x)return this.getRightValue(t.x)}else if(void 0!==t.y)return this.getRightValue(t.y);return t},getLabelForIndex:B.noop,getPixelForValue:B.noop,getValueForPixel:B.noop,getPixelForTick:function(t){var e=this,i=e.options.offset;if(e.isHorizontal()){var n=(e.width-(e.paddingLeft+e.paddingRight))/Math.max(e._ticks.length-(i?0:1),1),o=n*t+e.paddingLeft;i&&(o+=n/2);o=e.left+Math.round(o);return o+=e.isFullWidth()?e.margins.left:0}o=e.height-(e.paddingTop+e.paddingBottom);return e.top+t*(o/(e._ticks.length-1))},getPixelForDecimal:function(t){var e=this;if(e.isHorizontal()){var i=(e.width-(e.paddingLeft+e.paddingRight))*t+e.paddingLeft,i=e.left+Math.round(i);return i+=e.isFullWidth()?e.margins.left:0}return e.top+t*e.height},getBasePixel:function(){return this.getPixelForValue(this.getBaseValue())},getBaseValue:function(){var t=this.min,e=this.max;return this.beginAtZero?0:t<0&&e<0?e:0a.width-(a.paddingLeft+a.paddingRight)&&(e=1+Math.floor((u+s.autoSkipPadding)*l/(a.width-(a.paddingLeft+a.paddingRight)))),o&&oo.height-e.height-l&&(s="bottom");var u=(a.left+a.right)/2,d=(a.top+a.bottom)/2,c="center"===s?(i=function(t){return t<=u},function(t){return u=o.width-e.width/2}),h=function(t){return t+e.width>o.width},l=function(t){return t-e.width<0},a=function(t){return t<=d?"top":"bottom"};return i(n.x)?(r="left",h(n.x)&&(r="center",s=a(n.y))):c(n.x)&&(r="right",l(n.x)&&(r="center",s=a(n.y))),{xAlign:(t=t._options).xAlign||r,yAlign:t.yAlign?"nocenter"==t.yAlign?"center"==s?"top":s:t.yAlign:s}}(this,k=A(this,m)),i=k,n=x,o=(e=m).x,a=e.y,r=e.caretSize,s=e.caretPadding,p=e.cornerRadius,e=n.xAlign,n=n.yAlign,r+=s,s=p+s,"right"===e?o-=i.width:"center"===e&&(o-=i.width/2),"top"===n?a+=r:a-="bottom"===n?i.height+r:i.height/2,"center"===n?"left"===e?o+=r:"right"===e&&(o-=r):"left"===e?o-=s:"right"===e&&(o+=s),y={x:o,y:a}}else m.opacity=0;return m.xAlign=x.xAlign,m.yAlign=x.yAlign,m.x=y.x,m.y=y.y,m.width=k.width,m.height=k.height,m.caretX=w.x,m.caretY=w.y,f._model=m,t&&g.custom&&g.custom.call(f,m),f},drawCaret:function(t,e){var i=this._chart.ctx,n=this._view,n=this.getCaretPosition(t,e,n);i.lineTo(n.x1,n.y1),i.lineTo(n.x2,n.y2),i.lineTo(n.x3,n.y3)},getCaretPosition:function(t,e,i){var n,o,a,r,s,l,u=i.caretSize,d=i.cornerRadius,c=i.xAlign,h=i.yAlign,f=t.x,i=t.y,t=e.width,e=e.height;return"center"===h?(a=i+e/2,r="left"===c?(n=(l=f)-u,s=l,o=a+u,a-u):(n=(l=f+t)+u,s=l,o=a-u,a+u)):(s=(l="left"===c?(n=f+d+u)-u:"right"===c?(n=f+t-d-u)-u:(n=f+t/2)-u,n+u),"top"===h?(a=(o=i)-u,r=o):(a=(o=i+e)+u,r=o,u=s,s=l,l=u)),{x1:l,x2:n,x3:s,y1:o,y2:a,y3:r}},drawTitle:function(t,e,i,n){var o=e.title;if(o.length){i.textAlign=e._titleAlign,i.textBaseline="top";var a,r,s=e.titleFontSize,l=e.titleSpacing;for(i.fillStyle=c(e.titleFontColor,n),i.font=T.fontString(s,e._titleFontStyle,e._titleFontFamily),a=0,r=o.length;a=i.innerRadius&&e<=i.outerRadius;return o<=n&&n<=a&&i}return!1},getCenterPoint:function(){var t=this._view,e=(t.startAngle+t.endAngle)/2,i=(t.innerRadius+t.outerRadius)/2;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},getArea:function(){var t=this._view;return Math.PI*((t.endAngle-t.startAngle)/(2*Math.PI))*(Math.pow(t.outerRadius,2)-Math.pow(t.innerRadius,2))},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,i=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*i,y:t.y+Math.sin(e)*i}},draw:function(){var t=this._chart.ctx,e=this._view,i=e.startAngle,n=e.endAngle;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,i,n),t.arc(e.x,e.y,e.innerRadius,n,i,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})},{25:25,26:26,45:45}],37:[function(t,e,i){"use strict";var n=t(25),o=t(26),d=t(45),c=n.global;n._set("global",{elements:{line:{tension:.4,backgroundColor:c.defaultColor,borderWidth:3,borderColor:c.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",capBezierPoints:!0,fill:!0}}}),e.exports=o.extend({draw:function(){var t,e,i,n,o=this._view,a=this._chart.ctx,r=o.spanGaps,s=this._children.slice(),l=c.elements.line,u=-1;for(this._loop&&s.length&&s.push(s[0]),a.save(),a.lineCap=o.borderCapStyle||l.borderCapStyle,a.setLineDash&&a.setLineDash(o.borderDash||l.borderDash),a.lineDashOffset=o.borderDashOffset||l.borderDashOffset,a.lineJoin=o.borderJoinStyle||l.borderJoinStyle,a.lineWidth=o.borderWidth||l.borderWidth,a.strokeStyle=o.borderColor||c.defaultColor,a.beginPath(),u=-1,t=0;t=(i=o(this)).left&&t<=i.right&&e>=i.top&&e<=i.bottom:n},inLabelRange:function(t,e){if(!this._view)return!1;var i=o(this);return r(this)?t>=i.left&&t<=i.right:e>=i.top&&e<=i.bottom},inXRange:function(t){var e=o(this);return t>=e.left&&t<=e.right},inYRange:function(t){var e=o(this);return t>=e.top&&t<=e.bottom},getCenterPoint:function(){var t,e=this._view,e=r(this)?(t=e.x,(e.y+e.base)/2):(t=(e.x+e.base)/2,e.y);return{x:t,y:e}},getArea:function(){var t=this._view;return t.width*Math.abs(t.y-t.base)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y}}})},{25:25,26:26}],40:[function(t,e,i){"use strict";e.exports={},e.exports.Arc=t(36),e.exports.Line=t(37),e.exports.Point=t(38),e.exports.Rectangle=t(39)},{36:36,37:37,38:38,39:39}],41:[function(t,e,i){"use strict";t=t(42),i=e.exports={clear:function(t){t.ctx.clearRect(0,0,t.width,t.height)},roundedRect:function(t,e,i,n,o,a){var r;a?(r=Math.min(a,n/2),a=Math.min(a,o/2),t.moveTo(e+r,i),t.lineTo(e+n-r,i),t.quadraticCurveTo(e+n,i,e+n,i+a),t.lineTo(e+n,i+o-a),t.quadraticCurveTo(e+n,i+o,e+n-r,i+o),t.lineTo(e+r,i+o),t.quadraticCurveTo(e,i+o,e,i+o-a),t.lineTo(e,i+a),t.quadraticCurveTo(e,i,e+r,i)):t.rect(e,i,n,o)},drawPoint:function(t,e,i,n,o){var a,r,s,l;if(!e||"object"!=typeof e||"[object HTMLImageElement]"!==(a=e.toString())&&"[object HTMLCanvasElement]"!==a){if(!(isNaN(i)||i<=0)){switch(e){default:t.beginPath(),t.arc(n,o,i,0,2*Math.PI),t.closePath(),t.fill();break;case"triangle":t.beginPath(),c=(d=3*i/Math.sqrt(3))*Math.sqrt(3)/2,t.moveTo(n-d/2,o+c/3),t.lineTo(n+d/2,o+c/3),t.lineTo(n,o-2*c/3),t.closePath(),t.fill();break;case"rect":l=1/Math.SQRT2*i,t.beginPath(),t.fillRect(n-l,o-l,2*l,2*l),t.strokeRect(n-l,o-l,2*l,2*l);break;case"rectRounded":var u=i/Math.SQRT2,d=n-u,c=o-u,u=Math.SQRT2*i;t.beginPath(),this.roundedRect(t,d,c,u,u,i/2),t.closePath(),t.fill();break;case"rectRot":l=1/Math.SQRT2*i,t.beginPath(),t.moveTo(n-l,o),t.lineTo(n,o+l),t.lineTo(n+l,o),t.lineTo(n,o-l),t.closePath(),t.fill();break;case"cross":t.beginPath(),t.moveTo(n,o+i),t.lineTo(n,o-i),t.moveTo(n-i,o),t.lineTo(n+i,o),t.closePath();break;case"crossRot":t.beginPath(),r=Math.cos(Math.PI/4)*i,s=Math.sin(Math.PI/4)*i,t.moveTo(n-r,o-s),t.lineTo(n+r,o+s),t.moveTo(n-r,o+s),t.lineTo(n+r,o-s),t.closePath();break;case"star":t.beginPath(),t.moveTo(n,o+i),t.lineTo(n,o-i),t.moveTo(n-i,o),t.lineTo(n+i,o),r=Math.cos(Math.PI/4)*i,s=Math.sin(Math.PI/4)*i,t.moveTo(n-r,o-s),t.lineTo(n+r,o+s),t.moveTo(n-r,o+s),t.lineTo(n+r,o-s),t.closePath();break;case"line":t.beginPath(),t.moveTo(n-i,o),t.lineTo(n+i,o),t.closePath();break;case"dash":t.beginPath(),t.moveTo(n,o),t.lineTo(n+i,o),t.closePath()}t.stroke()}}else t.drawImage(e,n-e.width/2,o-e.height/2,e.width,e.height)},clipArea:function(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()},unclipArea:function(t){t.restore()},lineTo:function(t,e,i,n){if(i.steppedLine)return"after"===i.steppedLine&&!n||"after"!==i.steppedLine&&n?t.lineTo(e.x,i.y):t.lineTo(i.x,e.y),void t.lineTo(i.x,i.y);i.tension?t.bezierCurveTo(n?e.controlPointPreviousX:e.controlPointNextX,n?e.controlPointPreviousY:e.controlPointNextY,n?i.controlPointNextX:i.controlPointPreviousX,n?i.controlPointNextY:i.controlPointPreviousY,i.x,i.y):t.lineTo(i.x,i.y)}};t.clear=i.clear,t.drawRoundedRectangle=function(t){t.beginPath(),i.roundedRect.apply(i,arguments),t.closePath()}},{42:42}],42:[function(t,e,i){"use strict";var n,d={noop:function(){},uid:(n=0,function(){return n++}),isNullOrUndef:function(t){return null==t},isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},isObject:function(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)},valueOrDefault:function(t,e){return void 0===t?e:t},valueAtIndexOrDefault:function(t,e,i){return d.valueOrDefault(d.isArray(t)?t[e]:t,i)},callback:function(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)},each:function(t,e,i,n){var o,a,r;if(d.isArray(t))if(a=t.length,n)for(o=a-1;0<=o;o--)e.call(i,t[o],o);else for(o=0;o
';var o=e.childNodes[0],a=e.childNodes[1];function r(){e._reset(),t()}return e._reset=function(){o.scrollLeft=1e6,o.scrollTop=1e6,a.scrollLeft=1e6,a.scrollTop=1e6},x(o,"scroll",r.bind(o,"expand")),x(a,"scroll",r.bind(a,"shrink")),e}((n=function(){if(c.resizer)return t(y("resize",i))},r=!1,function(){a=Array.prototype.slice.call(arguments),o=o||this,r||(r=!0,f.requestAnimFrame.call(window,function(){r=!1,n.apply(o,a)}))}));l=function(){var t;c.resizer&&((t=e.parentNode)&&t!==h.parentNode&&t.insertBefore(h,t.firstChild),h._reset())},u=(s=e)[g]||(s[g]={}),d=u.renderProxy=function(t){t.animationName===v&&l()},f.each(b,function(t){x(s,t,d)}),u.reflow=!!s.offsetParent,s.classList.add(m)}function o(t){var e,i,n=t[g]||{},o=n.resizer;delete n.resizer,t=(e=t)[g]||{},(i=t.renderProxy)&&(f.each(b,function(t){a(e,t,i)}),delete t.renderProxy),e.classList.remove(m),o&&o.parentNode&&o.parentNode.removeChild(o)}e.exports={_enabled:"undefined"!=typeof window&&"undefined"!=typeof document,initialize:function(){var t,e,i="from{opacity:0.99}to{opacity:1}";e="@-webkit-keyframes "+v+"{"+i+"}@keyframes "+v+"{"+i+"}."+m+"{-webkit-animation:"+v+" 0.001s;animation:"+v+" 0.001s;}",i=(t=this)._style||document.createElement("style"),t._style||(e="/* Chart.js */\n"+e,(t._style=i).setAttribute("type","text/css"),document.getElementsByTagName("head")[0].appendChild(i)),i.appendChild(document.createTextNode(e))},acquireContext:function(t,e){"string"==typeof t?t=document.getElementById(t):t.length&&(t=t[0]);var i,n,o,a,r=(t=t&&t.canvas?t.canvas:t)&&t.getContext&&t.getContext("2d");return r&&r.canvas===t?(n=e,a=(i=t).style,e=i.getAttribute("height"),t=i.getAttribute("width"),i[g]={initial:{height:e,width:t,style:{display:a.display,height:a.height,width:a.width}}},a.display=a.display||"block",null!==t&&""!==t||void 0!==(o=s(i,"width"))&&(i.width=o),null!==e&&""!==e||(""===i.style.height?i.height=i.width/(n.options.aspectRatio||2):(n=s(i,"height"),void 0!==o&&(i.height=n))),r):null},releaseContext:function(t){var i,n=t.canvas;n[g]&&(i=n[g].initial,["height","width"].forEach(function(t){var e=i[t];f.isNullOrUndef(e)?n.removeAttribute(t):n.setAttribute(t,e)}),f.each(i.style||{},function(t,e){n.style[e]=t}),n.width=n.width,delete n[g])},addEventListener:function(o,t,a){var e,i=o.canvas;"resize"!==t?x(i,t,((e=a[g]||(a[g]={})).proxies||(e.proxies={}))[o.id+"_"+t]=function(t){var e,i,n;a((i=o,n=r[(e=t).type]||e.type,t=f.getRelativePosition(e,i),y(n,i,t.x,t.y,e)))}):l(i,a,o)},removeEventListener:function(t,e,i){var n=t.canvas;"resize"!==e?(t=((i[g]||{}).proxies||{})[t.id+"_"+e])&&a(n,e,t):o(n)}},f.addEvent=x,f.removeEvent=a},{45:45}],48:[function(t,e,i){"use strict";var n=t(45),o=t(46),t=t(47),o=t._enabled?t:o;e.exports=n.extend({initialize:function(){},acquireContext:function(){},releaseContext:function(){},addEventListener:function(){},removeEventListener:function(){}},o)},{45:45,46:46,47:47}],49:[function(t,e,i){"use strict";var s=t(25),f=t(40),l=t(45);s._set("global",{plugins:{filler:{propagate:!0}}}),e.exports=function(){var h={dataset:function(t){var e=t.fill,i=t.chart,t=i.getDatasetMeta(e),n=t&&i.isDatasetVisible(e)&&t.dataset._children||[],o=n.length||0;return o?function(t,e){return e');for(var i=0;i'),t.data.datasets[i].label&&e.push(t.data.datasets[i].label),e.push("");return e.push(""),e.join("")}}),e.exports=function(n){var o=n.layoutService,t=P.noop;function D(t,e){return t.usePointStyle?e*Math.SQRT2:t.boxWidth}function a(t,e){var i=new n.Legend({ctx:t.ctx,options:e,chart:t});o.configure(t,i,e),o.addBox(t,i),t.legend=i}return n.Legend=r.extend({initialize:function(t){P.extend(this,t),this.legendHitBoxes=[],this.doughnutMode=!1},beforeUpdate:t,update:function(t,e,i){var n=this;return n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n.margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate(),n.minSize},afterUpdate:t,beforeSetDimensions:t,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:t,beforeBuildLabels:t,buildLabels:function(){var e=this,i=e.options.labels||{},t=P.callback(i.generateLabels,[e.chart],e)||[];i.filter&&(t=t.filter(function(t){return i.filter(t,e.chart.data)})),e.options.reverse&&t.reverse(),e.legendItems=t},afterBuildLabels:t,beforeFit:t,fit:function(){var i,n,o,a,r,s,l,u=this,t=u.options,d=t.labels,e=t.display,c=u.ctx,h=I.global,f=P.valueOrDefault,g=f(d.fontSize,h.defaultFontSize),t=f(d.fontStyle,h.defaultFontStyle),h=f(d.fontFamily,h.defaultFontFamily),t=P.fontString(g,t,h),p=u.legendHitBoxes=[],m=u.minSize,h=u.isHorizontal();h?(m.width=u.maxWidth,m.height=e?10:0):(m.width=e?10:0,m.height=u.maxHeight),e&&(c.font=t,h?(i=u.lineWidths=[0],n=u.legendItems.length?g+d.padding:0,c.textAlign="left",c.textBaseline="top",P.each(u.legendItems,function(t,e){t=D(d,g)+g/2+c.measureText(t.text).width;i[i.length-1]+t+d.padding>=u.width&&(n+=g+d.padding,i[i.length]=u.left),p[e]={left:0,top:0,width:t,height:g},i[i.length-1]+=t+d.padding}),m.height+=n):(h=d.padding,o=u.columnWidths=[],a=d.padding,s=r=0,l=g+h,P.each(u.legendItems,function(t,e){t=D(d,g)+g/2+c.measureText(t.text).width;s+l>m.height&&(a+=r+d.padding,o.push(r),s=r=0),r=Math.max(r,t),s+=l,p[e]={left:0,top:0,width:t,height:g}}),a+=r,o.push(r),m.width+=a)),u.width=m.width,u.height=m.height},afterFit:t,isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},draw:function(){var h,f,t,g,e,i,p,m,v,b,x,y=this,k=y.options,w=k.labels,M=I.global,S=M.elements.line,C=y.width,_=y.lineWidths;k.display&&(h=y.ctx,t=(f=P.valueOrDefault)(w.fontColor,M.defaultFontColor),g=f(w.fontSize,M.defaultFontSize),e=f(w.fontStyle,M.defaultFontStyle),i=f(w.fontFamily,M.defaultFontFamily),i=P.fontString(g,e,i),h.textAlign="left",h.textBaseline="middle",h.lineWidth=.5,h.strokeStyle=t,h.fillStyle=t,h.font=i,p=D(w,g),m=y.legendHitBoxes,v=y.isHorizontal(),b=v?{x:y.left+(C-_[0])/2,y:y.top+w.padding,line:0}:{x:y.left+w.padding,y:y.top+w.padding,line:0},x=g+w.padding,P.each(y.legendItems,function(t,e){var i,n,o,a,r,s,l=h.measureText(t.text).width,u=p+g/2+l,d=b.x,c=b.y;v?C<=d+u&&(c=b.y+=x,b.line++,d=b.x=y.left+(C-_[b.line])/2):c+x>y.bottom&&(d=b.x=d+y.columnWidths[b.line]+w.padding,c=b.y=y.top+w.padding,b.line++),i=d,n=c,o=t,isNaN(p)||p<=0||(h.save(),h.fillStyle=f(o.fillStyle,M.defaultColor),h.lineCap=f(o.lineCap,S.borderCapStyle),h.lineDashOffset=f(o.lineDashOffset,S.borderDashOffset),h.lineJoin=f(o.lineJoin,S.borderJoinStyle),h.lineWidth=f(o.lineWidth,S.borderWidth),h.strokeStyle=f(o.strokeStyle,M.defaultColor),a=0===f(o.lineWidth,S.borderWidth),h.setLineDash&&h.setLineDash(f(o.lineDash,S.borderDash)),k.labels&&k.labels.usePointStyle?(s=(r=g*Math.SQRT2/2)/Math.SQRT2,P.canvas.drawPoint(h,o.pointStyle,r,i+s,n+s)):(a||h.strokeRect(i,n,p,g),h.fillRect(i,n,p,g)),h.restore()),m[e].left=d,m[e].top=c,e=t,t=l,d=p+(l=g/2)+(d=d),l=c+l,h.fillText(e.text,d,l),e.hidden&&(h.beginPath(),h.lineWidth=2,h.moveTo(d,l),h.lineTo(d+t,l),h.stroke()),v?b.x+=u+w.padding:b.y+=x}))},handleEvent:function(t){var e=this,i=e.options,n="mouseup"===t.type?"click":t.type,o=!1;if("mousemove"===n){if(!i.onHover)return}else{if("click"!==n)return;if(!i.onClick)return}var a=t.x,r=t.y;if(a>=e.left&&a<=e.right&&r>=e.top&&r<=e.bottom)for(var s=e.legendHitBoxes,l=0;l=u.left&&a<=u.left+u.width&&r>=u.top&&r<=u.top+u.height){if("click"===n){i.onClick.call(e,t.native,e.legendItems[l]),o=!0;break}if("mousemove"===n){i.onHover.call(e,t.native,e.legendItems[l]),o=!0;break}}}return o}}),{id:"legend",beforeInit:function(t){var e=t.options.legend;e&&a(t,e)},beforeUpdate:function(t){var e=t.options.legend,i=t.legend;e?(P.mergeIf(e,I.global.legend),i?(o.configure(t,i,e),i.options=e):a(t,e)):i&&(o.removeBox(t,i),delete t.legend)},afterEvent:function(t,e){t=t.legend;t&&t.handleEvent(e)}}}},{25:25,26:26,45:45}],51:[function(t,e,i){"use strict";var x=t(25),r=t(26),y=t(45);x._set("global",{title:{display:!1,fontStyle:"bold",fullWidth:!0,lineHeight:1.2,padding:10,position:"top",text:"",weight:2e3}}),e.exports=function(n){var o=n.layoutService,t=y.noop;function a(t,e){var i=new n.Title({ctx:t.ctx,options:e,chart:t});o.configure(t,i,e),o.addBox(t,i),t.titleBlock=i}return n.Title=r.extend({initialize:function(t){y.extend(this,t),this.legendHitBoxes=[]},beforeUpdate:t,update:function(t,e,i){var n=this;return n.beforeUpdate(),n.maxWidth=t,n.maxHeight=e,n.margins=i,n.beforeSetDimensions(),n.setDimensions(),n.afterSetDimensions(),n.beforeBuildLabels(),n.buildLabels(),n.afterBuildLabels(),n.beforeFit(),n.fit(),n.afterFit(),n.afterUpdate(),n.minSize},afterUpdate:t,beforeSetDimensions:t,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:t,beforeBuildLabels:t,buildLabels:t,afterBuildLabels:t,beforeFit:t,fit:function(){var t=this,e=y.valueOrDefault,i=t.options,n=i.display,o=e(i.fontSize,x.global.defaultFontSize),a=t.minSize,e=y.isArray(i.text)?i.text.length:1,o=y.options.toLineHeight(i.lineHeight,o),i=n?e*o+2*i.padding:0;t.isHorizontal()?(a.width=t.maxWidth,a.height=i):(a.width=i,a.height=t.maxHeight),t.width=a.width,t.height=a.height},afterFit:t,isHorizontal:function(){var t=this.options.position;return"top"===t||"bottom"===t},draw:function(){var t=this,e=t.ctx,i=y.valueOrDefault,n=t.options,o=x.global;if(n.display){var a,r,s,l=i(n.fontSize,o.defaultFontSize),u=i(n.fontStyle,o.defaultFontStyle),d=i(n.fontFamily,o.defaultFontFamily),c=y.fontString(l,u,d),h=y.options.toLineHeight(n.lineHeight,l),f=h/2+n.padding,g=0,p=t.top,u=t.left,d=t.bottom,l=t.right;e.fillStyle=i(n.fontColor,o.defaultFontColor),e.font=c,t.isHorizontal()?(r=u+(l-u)/2,s=p+f,a=l-u):(r="left"===n.position?u+f:l-f,s=p+(d-p)/2,a=d-p,g=Math.PI*("left"===n.position?-.5:.5)),e.save(),e.translate(r,s),e.rotate(g),e.textAlign="center",e.textBaseline="middle";var m=n.text;if(y.isArray(m))for(var v=0,b=0;br.max)&&(r.max=t))})}),r.min=isFinite(r.min)&&!isNaN(r.min)?r.min:0,r.max=isFinite(r.max)&&!isNaN(r.max)?r.max:1,this.handleTickRangeOptions()},getTickLimit:function(){var t,e=this.options.ticks;return this.isHorizontal()?Math.min(e.maxTicksLimit||11,Math.ceil(this.width/50)):(t=c.valueOrDefault(e.fontSize,n.global.defaultFontSize),Math.min(e.maxTicksLimit||11,Math.ceil(this.height/(2*t))))},handleDirectionalChanges:function(){this.isHorizontal()||this.ticks.reverse()},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForValue:function(t){var e,i=this,n=i.start,o=+i.getRightValue(t),t=i.end-n;return e=i.isHorizontal()?i.left+i.width/t*(o-n):i.bottom-i.height/t*(o-n),Math.round(e)},getValueForPixel:function(t){var e=this,i=e.isHorizontal(),n=i?e.width:e.height,n=(i?t-e.left:e.bottom-t)/n;return e.start+(e.end-e.start)*n},getPixelForTick:function(t){return this.getPixelForValue(this.ticksAsNumbers[t])}});t.scaleService.registerScaleType("linear",i,e)}},{25:25,34:34,45:45}],54:[function(t,e,i){"use strict";var o=t(45),n=t(34);e.exports=function(e){var t=o.noop;e.LinearScaleBase=e.Scale.extend({getRightValue:function(t){return"string"==typeof t?+t:e.Scale.prototype.getRightValue.call(this,t)},handleTickRangeOptions:function(){var t=this,e=t.options.ticks;e.beginAtZero&&(i=o.sign(t.min),n=o.sign(t.max),i<0&&n<0?t.max=0:0=t.max&&(i?t.max=t.min+1:t.min=t.max-1),t.min===t.max&&(t.max++,e.beginAtZero||t.min--)},getTickLimit:t,handleDirectionalChanges:t,buildTicks:function(){var t=this,e=t.options.ticks,i=t.getTickLimit(),i={maxTicks:i=Math.max(2,i),min:e.min,max:e.max,stepSize:o.valueOrDefault(e.fixedStepSize,e.stepSize)},i=t.ticks=n.generators.linear(i,t);t.handleDirectionalChanges(),t.max=o.max(i),t.min=o.min(i),e.reverse?(i.reverse(),t.start=t.max,t.end=t.min):(t.start=t.min,t.end=t.max)},convertTicksToLabels:function(){var t=this;t.ticksAsNumbers=t.ticks.slice(),t.zeroLineIndex=t.ticks.indexOf(0),e.Scale.prototype.convertTicksToLabels.call(t)}})}},{34:34,45:45}],55:[function(t,e,i){"use strict";var d=t(45),n=t(34);e.exports=function(t){var e={position:"left",ticks:{callback:n.formatters.logarithmic}},i=t.Scale.extend({determineDataLimits:function(){var a=this,r=a.options,t=r.ticks,s=a.chart,e=s.data.datasets,i=d.valueOrDefault,n=a.isHorizontal();function l(t){return n?t.xAxisID===a.id:t.yAxisID===a.id}a.min=null,a.max=null,a.minNotZero=null;var u,o=r.stacked;void 0===o&&d.each(e,function(t,e){var i;o||(i=s.getDatasetMeta(e),s.isDatasetVisible(e)&&l(i)&&void 0!==i.stack&&(o=!0))}),r.stacked||o?(u={},d.each(e,function(t,e){var n=s.getDatasetMeta(e),o=[n.type,void 0===r.stacked&&void 0===n.stack?e:"",n.stack].join(".");s.isDatasetVisible(e)&&l(n)&&(void 0===u[o]&&(u[o]=[]),d.each(t.data,function(t,e){var i=u[o],t=+a.getRightValue(t);isNaN(t)||n.data[e].hidden||(i[e]=i[e]||0,r.relativePoints?i[e]=100:i[e]+=t)}))}),d.each(u,function(t){var e=d.min(t),t=d.max(t);a.min=null===a.min?e:Math.min(a.min,e),a.max=null===a.max?t:Math.max(a.max,t)})):d.each(e,function(t,e){var i=s.getDatasetMeta(e);s.isDatasetVisible(e)&&l(i)&&d.each(t.data,function(t,e){t=+a.getRightValue(t);isNaN(t)||i.data[e].hidden||((null===a.min||ta.max)&&(a.max=t),0!=t&&(null===a.minNotZero||to.r&&(o.r=d.end,a.r=l),c.starto.b&&(o.b=c.end,a.b=l)}t.setReductions(n,o,a)}function n(t){var e=t.ctx,i=m.valueOrDefault,n=t.options,o=n.angleLines,a=n.pointLabels;e.lineWidth=o.lineWidth,e.strokeStyle=o.color;var r=t.getDistanceFromCenterForValue(n.ticks.reverse?t.min:t.max),s=p(t);e.textBaseline="top";for(var l,u,d,c,h=g(t)-1;0<=h;h--)o.display&&(d=t.getPointPosition(h,r),e.beginPath(),e.moveTo(t.xCenter,t.yCenter),e.lineTo(d.x,d.y),e.stroke(),e.closePath()),a.display&&(l=t.getPointPosition(h,r+5),c=i(a.fontColor,f.defaultFontColor),e.font=s.font,e.fillStyle=c,u=t.getIndexAngle(h),d=m.toDegrees(u),e.textAlign=0===(c=d)||180===c?"center":c<180?"left":"right",u=d,c=t._pointLabelSizes[h],d=l,90===u||270===u?d.y-=c.h/2:(270>1)-1]||null,a=t[n],!o)return{lo:null,hi:a};if(a[e]i))return{lo:o,hi:a};s=n-1}}return{lo:a,hi:null}}(t,e,i),a=o.lo?o.hi?o.lo:t[t.length-2]:t[0],o=o.lo?o.hi||t[t.length-1]:t[1],t=o[e]-a[e],t=t?(i-a[e])/t:0,t=(o[n]-a[n])*t;return a[n]+t}var n=new Map;function a(t,e){var i=e.parser,e=e.parser||e.format;return"function"==typeof i?i(t):"string"==typeof t&&"string"==typeof e?b(t,e):!(t=!(t instanceof b)?function(t){let e;return void 0!==t&&(n.has(t)?e=n.get(t):(e=b(t),n.set(t,e))),e}(t):t).isValid()&&"function"==typeof e?e(t):t}function M(t,e){if(g.isNullOrUndef(t))return null;var i=e.options.time,t=a(e.getRightValue(t),i);return t.isValid()?(i.round&&t.startOf(i.round),t.valueOf()):null}function S(t){for(var e=y.indexOf(t)+1,i=y.length;e=y.indexOf(e);r--)if(o=y[r],x[o].common&&a.as(o)>=t.length)return o;return y[e?y.indexOf(e):0]}(v,p.minUnit,c.min,c.max),c._majorUnit=S(c._unit),c._table=function(t,e,i,n){if("linear"===n||!t.length)return[{time:e,pos:0},{time:i,pos:1}];for(var o,a,r,s=[],l=[e],u=0,d=t.length;ug){[m,g]=[g,m]}if(i>m&&m){i=m}if(o0){let t=r.getRuler(0);r.barHeight=r.calculateBarHeight(t)+4;helpers.each(e.data,function(t,e){r.updateElement(t,e,a)},r)}},updateElement:function(t,e,a){var i=this;var r=i.getMeta();var o=i.getScaleForId(r.xAxisID);var n=i.getScaleForId(r.yAxisID);var s=i.getDataset();var l=s.data[e];var d=t.custom||{};var h=i.index;var c=i.chart.options;var u=c.elements||Chart.defaults.timeline.elements;var f=u.rectangle;var m=u.textPadding;var g=u.minBarWidth;t._xScale=o;t._yScale=n;t._datasetIndex=i.index;t._index=e;var v=u.textFunction(l[u.keyValue],i.chart.data.datasets,h);var p=o.getPixelForValue(l[u.keyStart]);var x=o.getPixelForValue(l[u.keyEnd]);var y=n.getPixelForValue(l,h,h);var b=x-p;var w=i.barHeight;var _=_color(u.colorFunction(v,l,i.chart.data.datasets,h));var k=u.showText;var C=u.font;if(!C){C='bold 12px "Helvetica Neue", Helvetica, Arial, sans-serif'}var M=y-w/2;t._model={x:a?p-b:p,y:M,width:Math.max(b,g),height:w,base:p+b,backgroundColor:_.rgbaString(),borderSkipped:d.borderSkipped?d.borderSkipped:f.borderSkipped,borderColor:d.borderColor?d.borderColor:helpers.getValueAtIndexOrDefault(s.borderColor,e,f.borderColor),borderWidth:d.borderWidth?d.borderWidth:helpers.getValueAtIndexOrDefault(s.borderWidth,e,f.borderWidth),label:i.chart.data.labels[e],datasetLabel:s.label,text:v,textColor:_.luminosity()>.5?"#333333":"#ffffff"};t.draw=function(){var t=this._chart.ctx;var e=this._view;var a=t.globalAlpha;var r=t.globalCompositeOperation;t.fillStyle=e.backgroundColor;t.lineWidth=e.borderWidth;t.globalCompositeOperation="destination-over";t.fillRect(e.x,e.y,e.width,e.height);t.globalAlpha=.5;t.globalCompositeOperation="source-over";t.fillRect(e.x,e.y,e.width,e.height);t.globalAlpha=a;t.globalCompositeOperation=r;if(k){t.beginPath();var i=t.measureText(e.text);if(i.width>0&&i.width+m+2=e.left&&t<=e.right};t.tooltipPosition=function(){var t=this.getCenterPoint();return{x:t.x,y:t.y}};t.getCenterPoint=function(){var t=this._view;var e,a;e=t.x+t.width/2;a=t.y+t.height/2;return{x:e,y:a}};t.inRange=function(t,e){var a=false;if(this._view){var r=i.getBarBounds(this);a=t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom}return a};t.pivot()},getBarCount:function(){var r=this;var i=0;helpers.each(r.chart.data.datasets,function(t,e){var a=r.chart.getDatasetMeta(e);if(a.bar&&r.chart.isDatasetVisible(e)){++i}},r);return i},draw:function(t){var e,a;var r=this.getMeta().data;for(e=0,a=r.length;eg){[m,g]=[g,m]}if(i>m&&m){i=m}if(o0){let t=r.getRuler(0);r.barHeight=r.calculateBarHeight(t)+4;helpers.each(e.data,function(t,e){r.updateElement(t,e,a)},r)}},updateElement:function(t,e,a){var i=this;var r=i.getMeta();var o=i.getScaleForId(r.xAxisID);var n=i.getScaleForId(r.yAxisID);var s=i.getDataset();var l=s.data[e];var d=t.custom||{};var h=i.index;var c=i.chart.options;var u=c.elements||Chart.defaults.timeline.elements;var f=u.rectangle;var m=u.minBarWidth;t._xScale=o;t._yScale=n;t._datasetIndex=i.index;t._index=e;var g=l[u.keyValue];var v=o.getPixelForValue(l[u.keyStart]);var p=o.getPixelForValue(l[u.keyEnd]);var x=n.getPixelForValue(l,h,h);var y=p-v;var b=i.barHeight;var w=x-b/2;t._model={x:a?v-y:v,y:w,width:Math.max(y,m),height:b,base:v+y,backgroundColor:"#000000",borderSkipped:d.borderSkipped?d.borderSkipped:f.borderSkipped,borderColor:d.borderColor?d.borderColor:helpers.getValueAtIndexOrDefault(s.borderColor,e,f.borderColor),borderWidth:d.borderWidth?d.borderWidth:helpers.getValueAtIndexOrDefault(s.borderWidth,e,f.borderWidth),label:i.chart.data.labels[e],datasetLabel:s.label,text:g,textColor:"#ffffff"};t.getPosition=function(t){return this._view.x+(t?this._view.width:0)};t.getMidPosition=function(){return this._view.y+this._view.height/2};t.getValue=function(){return this._view.text};t.inXRange=function(t){var e=i.getBarBounds(this);return t>=e.left&&t<=e.right};t.tooltipPosition=function(){var t=this.getCenterPoint();return{x:t.x,y:t.y}};t.getCenterPoint=function(){var t=this._view;var e,a;e=t.x+t.width/2;a=t.y+t.height/2;return{x:e,y:a}};t.inRange=function(t,e){var a=false;if(this._view){var r=i.getBarBounds(this);a=t>=r.left&&t<=r.right&&e>=r.top&&e<=r.bottom}return a};t.pivot()},getBarCount:function(){var r=this;var i=0;helpers.each(r.chart.data.datasets,function(t,e){var a=r.chart.getDatasetMeta(e);if(a.bar&&r.chart.isDatasetVisible(e)){++i}},r);return i},draw:function(t){let o=this.index`;let e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});let a=window.URL||window.webkitURL||window;let r=a.createObjectURL(e);let i=new Image;i.onload=()=>{arrowImageMap.set(o,i)};i.src=r}var r=this.getMeta().data;if(!r.length||!arrowImageMap.has(o))return;const i=arrowImageMap.get(o);const n=this.chart.chartArea;const s=30;const a=Math.ceil((n.right-n.left)/s);const l=r[0].getMidPosition();if(e){const m=l-i.height/2;this.chart.ctx.fillStyle=e;this.chart.ctx.lineWidth=0;this.chart.ctx.fillRect(n.left,m-3,n.right-n.left,i.height+6)}const d=this.chart.ctx.getTransform();let h=this.getScaleForId(this.getMeta().xAxisID);let c=h.getPixelForValue(moment().startOf("day"));let u=c%s;let f=0;for(let t=0;tv){if(v>=g){a=r[f].getValue()*1}break}}if(a!=null){let t=g+i.width/2;let e=m+i.height/2;this.chart.ctx.setTransform(d);this.chart.ctx.translate(t,e);this.chart.ctx.rotate((a+180)/180*Math.PI);this.chart.ctx.translate(-t,-e);this.chart.ctx.drawImage(i,g,m,i.width,i.height)}}this.chart.ctx.setTransform(d)},calculateBarHeight:function(t){var e=this;var a=e.getScaleForId(e.getMeta().yAxisID);if(a.options.barThickness){return a.options.barThickness}return a.options.stacked?t.categoryHeight:t.barHeight},removeHoverStyle:function(t){},setHoverStyle:function(t){}});Chart.defaults.arrowline={elements:{minBarWidth:1,keyStart:0,keyEnd:1,keyValue:2},layout:{padding:{left:0,right:0,top:0,bottom:0}},legend:{display:false},scales:{xAxes:[{type:"timeline",position:"bottom",distribution:"linear",categoryPercentage:.8,barPercentage:.9,gridLines:{display:true,drawBorder:true,drawTicks:true},ticks:{maxRotation:0},unit:"day"}],yAxes:[{type:"category",position:"left",barThickness:20,categoryPercentage:.8,barPercentage:.9,offset:true,gridLines:{display:true,offsetGridLines:true,drawBorder:true,drawTicks:true}}]}};!function(n){function e(n,r){var t=n[0],o=n[1],u=n[2],e=n[3],t=c(t,o,u,e,r[0],7,-680876936),e=c(e,t,o,u,r[1],12,-389564586),u=c(u,e,t,o,r[2],17,606105819),o=c(o,u,e,t,r[3],22,-1044525330);t=c(t,o,u,e,r[4],7,-176418897),e=c(e,t,o,u,r[5],12,1200080426),u=c(u,e,t,o,r[6],17,-1473231341),o=c(o,u,e,t,r[7],22,-45705983),t=c(t,o,u,e,r[8],7,1770035416),e=c(e,t,o,u,r[9],12,-1958414417),u=c(u,e,t,o,r[10],17,-42063),o=c(o,u,e,t,r[11],22,-1990404162),t=c(t,o,u,e,r[12],7,1804603682),e=c(e,t,o,u,r[13],12,-40341101),u=c(u,e,t,o,r[14],17,-1502002290),o=c(o,u,e,t,r[15],22,1236535329),t=f(t,o,u,e,r[1],5,-165796510),e=f(e,t,o,u,r[6],9,-1069501632),u=f(u,e,t,o,r[11],14,643717713),o=f(o,u,e,t,r[0],20,-373897302),t=f(t,o,u,e,r[5],5,-701558691),e=f(e,t,o,u,r[10],9,38016083),u=f(u,e,t,o,r[15],14,-660478335),o=f(o,u,e,t,r[4],20,-405537848),t=f(t,o,u,e,r[9],5,568446438),e=f(e,t,o,u,r[14],9,-1019803690),u=f(u,e,t,o,r[3],14,-187363961),o=f(o,u,e,t,r[8],20,1163531501),t=f(t,o,u,e,r[13],5,-1444681467),e=f(e,t,o,u,r[2],9,-51403784),u=f(u,e,t,o,r[7],14,1735328473),o=f(o,u,e,t,r[12],20,-1926607734),t=i(t,o,u,e,r[5],4,-378558),e=i(e,t,o,u,r[8],11,-2022574463),u=i(u,e,t,o,r[11],16,1839030562),o=i(o,u,e,t,r[14],23,-35309556),t=i(t,o,u,e,r[1],4,-1530992060),e=i(e,t,o,u,r[4],11,1272893353),u=i(u,e,t,o,r[7],16,-155497632),o=i(o,u,e,t,r[10],23,-1094730640),t=i(t,o,u,e,r[13],4,681279174),e=i(e,t,o,u,r[0],11,-358537222),u=i(u,e,t,o,r[3],16,-722521979),o=i(o,u,e,t,r[6],23,76029189),t=i(t,o,u,e,r[9],4,-640364487),e=i(e,t,o,u,r[12],11,-421815835),u=i(u,e,t,o,r[15],16,530742520),o=i(o,u,e,t,r[2],23,-995338651),t=a(t,o,u,e,r[0],6,-198630844),e=a(e,t,o,u,r[7],10,1126891415),u=a(u,e,t,o,r[14],15,-1416354905),o=a(o,u,e,t,r[5],21,-57434055),t=a(t,o,u,e,r[12],6,1700485571),e=a(e,t,o,u,r[3],10,-1894986606),u=a(u,e,t,o,r[10],15,-1051523),o=a(o,u,e,t,r[1],21,-2054922799),t=a(t,o,u,e,r[8],6,1873313359),e=a(e,t,o,u,r[15],10,-30611744),u=a(u,e,t,o,r[6],15,-1560198380),o=a(o,u,e,t,r[13],21,1309151649),t=a(t,o,u,e,r[4],6,-145523070),e=a(e,t,o,u,r[11],10,-1120210379),u=a(u,e,t,o,r[2],15,718787259),o=a(o,u,e,t,r[9],21,-343485551),n[0]=g(t,n[0]),n[1]=g(o,n[1]),n[2]=g(u,n[2]),n[3]=g(e,n[3])}function c(n,r,t,o,u,e,c){return h(r&t|~r&o,n,r,u,e,c)}function f(n,r,t,o,u,e,c){return h(r&o|t&~o,n,r,u,e,c)}function i(n,r,t,o,u,e,c){return h(r^t^o,n,r,u,e,c)}function a(n,r,t,o,u,e,c){return h(t^(r|~o),n,r,u,e,c)}var h=function(n,r,t,o,u,e){return r=g(g(r,n),g(o,e)),g(r<>>32-u,t)},d=(n.md5hx=function(n){for(var r=n.length,t=[1732584193,-271733879,-1732584194,271733878],o=64;o<=n.length;o+=64)e(t,d(n.substring(o-64,o)));n=n.substring(o-64);var u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(o=0;o>2]|=n.charCodeAt(o)<<(o%4<<3);if(u[o>>2]|=128<<(o%4<<3),55>2]=n.charCodeAt(t)+(n.charCodeAt(t+1)<<8)+(n.charCodeAt(t+2)<<16)+(n.charCodeAt(t+3)<<24);return r}),g=function(n,r){return n+r&4294967295}}(window);var _global="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:this;function bom(e,t){return void 0===t?t={autoBom:!1}:"object"!=typeof t&&(console.warn("Deprecated: Expected third argument to be a object"),t={autoBom:!t}),t.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob([String.fromCharCode(65279),e],{type:e.type}):e}function download(e,t,o){var n=new XMLHttpRequest;n.open("GET",e),n.responseType="blob",n.onload=function(){saveAs(n.response,t,o)},n.onerror=function(){console.error("could not download file")},n.send()}function corsEnabled(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&t.status<=299}function click(t){try{t.dispatchEvent(new MouseEvent("click"))}catch(e){var o=document.createEvent("MouseEvents");o.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),t.dispatchEvent(o)}}var isMacOSWebView=_global.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),saveAs=_global.saveAs||("object"!=typeof window||window!==_global?function(){}:"download"in HTMLAnchorElement.prototype&&!isMacOSWebView?function(e,t,o){var n=_global.URL||_global.webkitURL,a=document.createElement("a");t=t||e.name||"download",a.download=t,a.rel="noopener","string"==typeof e?(a.href=e,a.origin!==location.origin?corsEnabled(a.href)?download(e,t,o):click(a,a.target="_blank"):click(a)):(a.href=n.createObjectURL(e),setTimeout(function(){n.revokeObjectURL(a.href)},4e4),setTimeout(function(){click(a)},0))}:"msSaveOrOpenBlob"in navigator?function(e,t,o){var n;t=t||e.name||"download","string"==typeof e?corsEnabled(e)?download(e,t,o):((n=document.createElement("a")).href=e,n.target="_blank",setTimeout(function(){click(n)})):navigator.msSaveOrOpenBlob(bom(e,o),t)}:function(e,t,o,n){if((n=n||open("","_blank"))&&(n.document.title=n.document.body.innerText="downloading..."),"string"==typeof e)return download(e,t,o);var a,l,i,t="application/octet-stream"===e.type,o=/constructor/i.test(_global.HTMLElement)||_global.safari,r=/CriOS\/[\d]+/.test(navigator.userAgent);(r||t&&o||isMacOSWebView)&&"undefined"!=typeof FileReader?((a=new FileReader).onloadend=function(){var e=a.result,e=r?e:e.replace(/^data:[^;]*;/,"data:attachment/file;");n?n.location.href=e:location=e,n=null},a.readAsDataURL(e)):(l=_global.URL||_global.webkitURL,i=l.createObjectURL(e),n?n.location=i:location.href=i,n=null,setTimeout(function(){l.revokeObjectURL(i)},4e4))});_global.saveAs=saveAs.saveAs=saveAs,"undefined"!=typeof module&&(module.exports=saveAs);const lang_en={ui:{label:{type_to_search:"Type to search for an entity to add",error_retreiving:"Could not retrieve available entities !",loading:"Loading available entities..."},popup:{remove_all:"Remove all dynamically added graphs ?",enable_panel:"Enable entity history info panel ?",disable_panel:"Disable entity history info panel ?"},menu:{export_csv:"Export as CSV",export_stats:"Export statistics as CSV",remove_all:"Remove all added graphs",enable_panel:"Enable history info panel",disable_panel:"Disable history info panel"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 Day",n_days:"%1 Days",week:"1 Week",n_weeks:"%1 Weeks",month:"1 Month",n_months:"%1 Months",year:"1 Year"},interval:{_10m:"10 min",hourly:"Hourly",daily:"Daily",monthly:"Monthly",rawline:"As line"}}};const lang_fr={ui:{label:{type_to_search:"Tapez ici pour rechercher une entité à ajouter",error_retreiving:"Impossible de récupérer les entités !",loading:"Chargement des entités disponibles..."},popup:{remove_all:"Supprimer tous les graphiques ajoutés dynamiquement ?",enable_panel:"Activer le panneau d'historique des entités ?",disable_panel:"Déactiver le panneau d'historique des entités ?"},menu:{export_csv:"Exporter le CSV",export_stats:"Exporter le CSV des statistiques",remove_all:"Supprimer tous les graphiques",enable_panel:"Activer le panneau d'historique",disable_panel:"Déactiver le panneau d'historique"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 Jour",n_days:"%1 Jours",week:"1 Sem",n_weeks:"%1 Sem",month:"1 Mois",n_months:"%1 Mois",year:"1 An"},interval:{_10m:"10 min",hourly:"Heure",daily:"Journée",monthly:"Mensuel",rawline:"Linéaire"}}};const lang_de={ui:{label:{type_to_search:"Entität suchen oder auswählen",error_retreiving:"Entitäten konnten nicht geladen werden !",loading:"Lade verfügbare Entitäten..."},popup:{remove_all:"Alle dynamisch hinzugefügten Diagramme entfernen ?",enable_panel:"Verlaufsinfo für Entitäten aktivieren ?",disable_panel:"Verlaufsinfo für Entitäten deaktivieren ?"},menu:{export_csv:"Als CSV exportieren",export_stats:"Statistik als CSV exportieren",remove_all:"Alle Diagramme entfernen",enable_panel:"Verlaufsinfo aktivieren",disable_panel:"Verlaufsinfo deaktivieren"},ranges:{l_hour:"< 1 Std",hour:"1 Stunde",n_hours:"%1 Stdn.",day:"1 Tag",n_days:"%1 Tage",week:"1 Woche",n_weeks:"%1 Wo.",month:"1 Monat",n_months:"%1 Monate",year:"1 Jahr"},interval:{_10m:"10 Min",hourly:"Stündlich",daily:"Täglich",monthly:"Monatlich",rawline:"Als Linie"}}};const lang_es={ui:{label:{type_to_search:"Seleccionar entidad a añadir",error_retreiving:"No se encuentran entidades disponibles!",loading:"Cargando entidades ..."},popup:{remove_all:"Borrar gráficos añadidos dinámicamente ?",enable_panel:"Habilitar panel info historia entidades ?",disable_panel:"Deshabilitar panel info historia entidades ?"},menu:{export_csv:"Exportar como CSV",export_stats:"Exportar estadísticas como CSV",remove_all:"Borrar gráficos añadidos",enable_panel:"Activar panel info historia",disable_panel:"Desactivar panel info historia"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 Día",n_days:"%1 Días",week:"1 Sem.",n_weeks:"%1 Sem.",month:"1 Mes",n_months:"%1 Meses",year:"1 Año"},interval:{_10m:"10 min",hourly:"Horario",daily:"Diario",monthly:"Mensual",rawline:"Línea"}}};const lang_nl={ui:{label:{type_to_search:"Typ om te zoeken naar een entiteit om toe te voegen",error_retreiving:"Kan beschikbare entiteiten niet ophalen !",loading:"Beschikbare entiteiten laden..."},popup:{remove_all:"Alle dynamisch toegevoegde grafieken verwijderen ?",enable_panel:"Schakel het informatiepaneel over de geschiedenis van de entiteit in ?",disable_panel:"Schakel het informatiepaneel over de geschiedenis van de entiteit uit ?"},menu:{export_csv:"Exporteren als CSV",export_stats:"Exporteer statistieken als CSV",remove_all:"Verwijder alle toegevoegde grafieken",enable_panel:"Deelvenster Geschiedenisinfo inschakelen",disable_panel:"Schakel geschiedenisinfopaneel uit"},ranges:{l_hour:"< 1 u",hour:"1 u",n_hours:"%1 u",day:"1 Dag",n_days:"%1 Dagen",week:"1 Week",n_weeks:"%1 Weken",month:"1 Maand",n_months:"%1 Maand",year:"1 Jaar"},interval:{_10m:"10 minuten",hourly:"Per uur",daily:"Dagelijks",monthly:"Maandelijks",rawline:"Lijngrafiek"}}};const lang_pl={ui:{label:{type_to_search:"Wpisz, aby wyszukać i dodać encję",error_retreiving:"Nie można pobrać dostępnych elementów !",loading:"Ładowanie dostępnych elementów..."},popup:{remove_all:"Usuń wszystkie wykresy ?",enable_panel:"Włącz panel informacji o historii ?",disable_panel:"Wyłącz panel informacji o historii ?"},menu:{export_csv:"Eksportuj w CSV",export_stats:"Eksportuj statystyki w CSV",remove_all:"Usuń wszystkie dodane grafiki",enable_panel:"Włącz panel historia",disable_panel:"Wyłącz panel historia"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 Dzień",n_days:"%1 Dni",week:"1 Tydzień",n_weeks:"%1 Tyg",month:"1 Miesiąc",n_months:"%1 Mies",year:"1 Rok"},interval:{_10m:"10 minut",hourly:"Godzina",daily:"Dzień",monthly:"Miesiąc",rawline:"As line"}}};const lang_sv={ui:{label:{type_to_search:"Skriv för att söka efter en enhet att lägga till",error_retreiving:"Kunde inte hämta tillgängliga enheter!",loading:"Laddar tillgängliga enheter..."},popup:{remove_all:"Ta bort alla dynamiskt tillagda grafer?",enable_panel:"Aktivera panelen för enhetens historikinformation?",disable_panel:"Inaktivera panelen för enhetens historikinformation?"},menu:{export_csv:"Exportera som CSV",export_stats:"Exportera statistik som CSV",remove_all:"Ta bort alla tillagda grafer",enable_panel:"Aktivera historikinfo-panelen",disable_panel:"Inaktivera historikinfo-panelen"},ranges:{l_hour:"< 1 tim",hour:"1 tim",n_hours:"%1 timmar",day:"1 dag",n_days:"%1 dagar",week:"1 vecka",n_weeks:"%1 veckor",month:"1 månad",n_months:"%1 månader",year:"1 år"},interval:{_10m:"10 min",hourly:"Varje timme",daily:"Varje dag",monthly:"Varje månad",rawline:"As line"}}};const lang_da={ui:{label:{type_to_search:"Indtast for at søge efter en entitet, der skal tilføjes",error_retreiving:"Fejl ved indlæsning af entiteter !",loading:"Indlæser tilgængelige entiteter..."},popup:{remove_all:"Fjern alle dynamisk tilføjede grafer ?",enable_panel:"Brug historik graf som standard ?",disable_panel:"Fravælg historik graf som standard ?"},menu:{export_csv:"Eksporter som CSV",export_stats:"Eksporter statistik som CSV",remove_all:"Fjern alle tilføjede grafer ",enable_panel:"Brug historik graf som standard",disable_panel:"Deaktivér historik graf som standard"},ranges:{l_hour:"< 1 T",hour:"1 T",n_hours:"%1 T",day:"1 dag",n_days:"%1 dage",week:"1 uge",n_weeks:"%1 uger",month:"1 måned",n_months:"%1 måneder",year:"1 år"},interval:{_10m:"10 min",hourly:"Hver time",daily:"Daglig",monthly:"Månedlig",rawline:"As line"}}};const lang_sk={ui:{label:{type_to_search:"Napíšte, ak chcete vyhľadať entitu, ktorú chcete pridať",error_retreiving:"Nepodarilo sa načítať dostupné entity !",loading:"Načitavanie dostupných entít..."},popup:{remove_all:"Odstrániť všetky dynamicky pridané grafy ?",enable_panel:"Povoliť informačný panel histórie ?",disable_panel:"Zakázať informačný panel histórie ?"},menu:{export_csv:"Export ako CSV",export_stats:"Export štatistiky ako CSV",remove_all:"Odstrániť všetky pridané grafy",enable_panel:"Povoliť informačný panel histórie",disable_panel:"Zakázať informačný panel histórie"},ranges:{l_hour:"< 1 H",hour:"1 H",n_hours:"%1 H",day:"1 deň",n_days:"%1 dní",week:"1 týždeň",n_weeks:"%1 týždňov",month:"1 mesiac",n_months:"%1 mesiacov",year:"1 rok"},interval:{_10m:"10 min",hourly:"Hodinovo",daily:"Denne",monthly:"Mesačné",rawline:"Ako čiara"}}};const lang_ru={ui:{label:{type_to_search:"Начните поиск объекта для добавления",error_retreiving:"Невозможно загрузить доступные объекты!",loading:"Загрузка доступных объектов..."},popup:{remove_all:"Очистить все добавленные графики?",enable_panel:"Активировать историю в панели информации",disable_panel:"Деактивировать историю в панели информации"},menu:{export_csv:"Экспортировать как CSV",export_stats:"Экспортировать статистику как CSV",remove_all:"Очистить все добавленные графики",enable_panel:"Активировать историю в панели информации",disable_panel:"Деактивировать историю в панели информации"},ranges:{l_hour:"< 1 Ч",hour:"1 Ч",n_hours:"%1 Ч",day:"1 День",n_days:"%1 Дн",week:"1 Неделя",n_weeks:"%1 Нед",month:"1 Месяц",n_months:"%1 Мес",year:"1 Год"},interval:{_10m:"10 мин",hourly:"По часам",daily:"По дням",monthly:"По месяцам",rawline:"Линия"}}};var languages={en:lang_en,fr:lang_fr,de:lang_de,es:lang_es,nl:lang_nl,pl:lang_pl,sv:lang_sv,da:lang_da,sk:lang_sk,ru:lang_ru};var language="en";function setLanguage(e){language="en";let a=e.replace("-","_").split("_");if(a&&a.length>0&&languages[a[0]])language=a[0]}function i18n(e,a){let n=e.split(".").reduce((e,a)=>e[a],languages[language]);if(n===undefined)n=e.split(".").reduce((e,a)=>e[a],languages["en"]);if(n&&a)n=n.replace("%1",a);return n}const Version="1.0.50";var isMobile=navigator.appVersion.indexOf("Mobi")>-1||navigator.userAgent.indexOf("HomeAssistant")>-1;const ranges=[1,2,6,12,24,48,72,96,120,144,168,336,504,720,2184,4368,8760];var panstate={};panstate.mx=0;panstate.lx=0;panstate.my=0;panstate.ly=0;panstate.tc=0;panstate.g=null;panstate.overlay=null;panstate.st0=null;panstate.st1=null;let infoPanelEnabled=!!JSON.parse(window.localStorage.getItem("history-explorer-info-panel"));class HistoryCardState{constructor(){this.colorMap=new Map;this.timeCache=new Map;this.stateTexts=new Map;this.stateMap=new Map;this.csvExporter=new HistoryCSVExporter;this.statsExporter=new StatisticsCSVExporter;this.stateColors=stateColors;this.stateColorsDark=stateColorsDark;this.ui={};this.ui.dateSelector=[];this.ui.rangeSelector=[];this.ui.zoomButton=[];this.ui.inputField=[];this.ui.darkMode=false;this.ui.spinOverlay=null;this.ui.optionStyle="";this.ui.hideHeader=false;this.ui.hideInterval=false;this.ui.hideSelector=false;this.ui.stickyTools=0;this.ui.wideInterval=false;this.i18n={};this.i18n.valid=false;this.i18n.styleDateSelector="";this.i18n.styleTimeTicks="";this.i18n.styleDateTicks="";this.i18n.styleDateTimeTooltip="";this.pconfig={};this.pconfig.graphLabelColor="#333";this.pconfig.graphGridColor="#00000000";this.pconfig.lineGraphHeight=250;this.pconfig.barGraphHeight=150;this.pconfig.timelineBarHeight=24;this.pconfig.timelineBarSpacing=40;this.pconfig.labelAreaWidth=65;this.pconfig.labelsVisible=true;this.pconfig.showTooltipColors=[true,true];this.pconfig.tooltipSize="auto";this.pconfig.tooltipShowDuration=false;this.pconfig.tooltipShowLabel=true;this.pconfig.tooltipStateTextMode="raw";this.pconfig.closeButtonColor=undefined;this.pconfig.customStateColors=undefined;this.pconfig.colorSeed=137;this.pconfig.stateTextMode="raw";this.pconfig.graphConfig=[];this.pconfig.entityOptions=undefined;this.pconfig.lockAllGraphs=false;this.pconfig.combineSameUnits=false;this.pconfig.recordedEntitiesOnly=false;this.pconfig.filterEntities=undefined;this.pconfig.decimation="fast";this.pconfig.roundingPrecision=2;this.pconfig.defaultLineMode=undefined;this.pconfig.nextDefaultColor=0;this.pconfig.showUnavailable=true;this.pconfig.showCurrentValues=false;this.pconfig.axisAddMarginMin=true;this.pconfig.axisAddMarginMax=true;this.pconfig.defaultTimeRange="24";this.pconfig.defaultTimeOffset=undefined;this.pconfig.timeTickDensity="high";this.pconfig.timeTickOverride=undefined;this.pconfig.timeTickShortDate=false;this.pconfig.refreshEnabled=false;this.pconfig.refreshInterval=undefined;this.pconfig.exportSeparator=undefined;this.pconfig.exportTimeFormat=undefined;this.pconfig.exportStatsPeriod=undefined;this.pconfig.entities=[];this.pconfig.infoPanelConfig=null;this.loader={};this.loader.startTime=0;this.loader.endTime=0;this.loader.startIndex=-1;this.loader.endIndex=-1;this.loader.loadingStats=false;this.state={};this.state.drag=false;this.state.selecting=false;this.state.updateCanvas=null;this.state.loading=false;this.state.zoomMode=false;this.state.altGraph=null;this.state.autoScroll=false;this.activeRange={};this.activeRange.timeRangeHours=24;this.activeRange.timeRangeMinutes=0;this.activeRange.tickStepSize=1;this.activeRange.tickStepUnit="hour";this.activeRange.dataClusterSize=0;this.statistics={};this.statistics.enabled=false;this.statistics.retention=undefined;this.statistics.mode="";this.statistics.period="hour";this.id="";this.graphs=[];this.g_id=0;this.firstDynamicId=0;this.startTime;this.endTime;this.limitSlot=0;this.cacheSize=365+1;this.cache=[];this._hass=null;this._this=null;this.version=[];this.contentValid=false;this.entitiesPopulated=false;this.iid=0;this.tid=0;this.lastWidth=0;this.defocusCall=this.entitySelectorDefocus.bind(this);this.databaseCallback=null}getNextDefaultColor(){let t=this.pconfig.nextDefaultColor++;this.pconfig.nextDefaultColor=this.pconfig.nextDefaultColor%defaultColors.length;return defaultColors[t]}getStateColor(t,e,i,s){let a;if(s===undefined||s===null||s==="")s="unknown";if(i){const n=i+"."+s;a=this.pconfig.customStateColors?.[n];if(!a)a=this.pconfig.customStateColors?.[i]}if(!a&&e){const n=e+"."+s;a=this.pconfig.customStateColors?.[n];if(!a)a=this.pconfig.customStateColors?.[e]}if(!a&&t){const n=t+"."+s;a=this.pconfig.customStateColors?.[n];if(!a)a=this.pconfig.customStateColors?.[t]}if(!a){a=this.pconfig.customStateColors?.[s]}if(!a&&e){const n=e+"."+s;a=this.ui.darkMode&&this.stateColorsDark[n]?this.stateColorsDark[n]:this.stateColors[n]}if(!a&&t){const n=t+"."+s;a=this.ui.darkMode&&this.stateColorsDark[n]?this.stateColorsDark[n]:this.stateColors[n]}if(!a){a=this.ui.darkMode&&this.stateColorsDark[s]?this.stateColorsDark[s]:this.stateColors[s]}if(!a){if(!this.colorMap.has(s)){const o=md5hx(s);const r=(o[0]&2147483647)*this.pconfig.colorSeed%359;const l=Math.ceil(45+30*((o[1]&2147483647)%255/255))-(this.ui.darkMode?13:0);const h=Math.ceil(55+10*((o[1]&2147483647)%255/255))-(this.ui.darkMode?5:0);a="hsl("+r+","+l+"%,"+h+"%)";this.colorMap.set(s,a)}else a=this.colorMap.get(s)}return a}getLocalizedState(t,e,i,s){const a=s+t;let n=this.stateTexts.get(a);if(!n){n=i&&this._hass.localize(`component.${e}.entity_component.${i}.state.${t}`)||this._hass.localize(`component.${e}.entity_component._.state.${t}`)||i&&this._hass.localize(`component.${e}.state.${i}.${t}`)||this._hass.localize(`component.${e}.state._.${t}`)||t;this.stateTexts.set(a,n)}return n}today(e=false){if(!this.state.loading){if(e)this.setTimeRangeFromString(String(this.pconfig.defaultTimeRange));let t=moment();if(this.pconfig.defaultTimeOffset){const i=this.pconfig.defaultTimeOffset.slice(0,-1);switch(this.pconfig.defaultTimeOffset.slice(-1)[0]){case"m":t=t.add(i,"minute");break;case"h":t=t.add(i,"hour");break;case"d":t=t.add(i,"day");break;case"w":t=t.add(i,"week");break;case"o":t=t.add(i,"month");break;case"H":t=moment(t.format("YYYY-MM-DDTHH:00:00")).add(i,"hour");break;case"D":t=moment(t.format("YYYY-MM-DDT00:00:00")).add(i,"day");break;case"O":t=moment(t.format("YYYY-MM-01T00:00:00")).add(i,"month");break}}this.endTime=t.format("YYYY-MM-DDTHH:mm:ss");this.startTime=moment(this.endTime).subtract(this.activeRange.timeRangeHours,"hour").subtract(this.activeRange.timeRangeMinutes,"minute").format("YYYY-MM-DDTHH:mm:ss");this.updateHistory()}this.state.autoScroll=true}todayNoReset(){this.today(false)}todayReset(){this.today(true)}subDay(){if(!this.state.loading){if(this.activeRange.timeRangeHours<24)this.setTimeRange(24,false);let t=moment(this.startTime).subtract(1,this.activeRange.timeRangeHours<720?"day":"month");let e=moment(t).add(this.activeRange.timeRangeHours,"hour");this.startTime=t.format("YYYY-MM-DD")+"T00:00:00";this.endTime=e.format("YYYY-MM-DD")+"T00:00:00";this.updateHistory()}}addDay(){if(!this.state.loading){if(this.activeRange.timeRangeHours<24)this.setTimeRange(24,false);let t=moment(this.startTime).add(1,this.activeRange.timeRangeHours<720?"day":"month");let e=moment(t).add(this.activeRange.timeRangeHours,"hour");this.startTime=t.format("YYYY-MM-DD")+"T00:00:00";this.endTime=e.format("YYYY-MM-DD")+"T00:00:00";this.updateHistory()}}toggleZoom(){this.state.zoomMode=!this.state.zoomMode;for(let t of this.ui.zoomButton)if(t)t.style.backgroundColor=this.state.zoomMode?this.ui.darkMode?"#ffffff3a":"#0000003a":"#0000";if(panstate.overlay){panstate.overlay.remove();panstate.overlay=null}}decZoom(){this.decZoomStep()}incZoom(){this.incZoomStep()}timeRangeSelected(t){this.setTimeRange(t.target.value,true)}exportFile(){this.menuSetVisibility(0,false);this.menuSetVisibility(1,false);this.csvExporter.exportFile(this)}exportStatistics(){this.menuSetVisibility(0,false);this.menuSetVisibility(1,false);this.statsExporter.exportFile(this)}toggleInfoPanel(){this.menuSetVisibility(0,false);this.menuSetVisibility(1,false);if(confirm(infoPanelEnabled?i18n("ui.popup.disable_panel"):i18n("ui.popup.enable_panel"))){infoPanelEnabled=!infoPanelEnabled;this.writeInfoPanelConfig(true);location.reload()}}decZoomStep(e=null,i=.5){if(!this.activeRange.timeRangeHours){this.activeRange.timeRangeMinutes*=2;if(this.activeRange.timeRangeMinutes>=60){this.activeRange.timeRangeMinutes=0;this.activeRange.timeRangeHours=0}}if(!this.activeRange.timeRangeMinutes){let t=ranges.findIndex(t=>t>=this.activeRange.timeRangeHours);if(t>=0){if(ranges[t]>this.activeRange.timeRangeHours)t--;if(tt>=this.activeRange.timeRangeHours);if(i>0)this.setTimeRange(ranges[i-1],true,t,e);else this.setTimeRangeMinutes((this.activeRange.timeRangeHours*60+this.activeRange.timeRangeMinutes)/2,true,t,e)}selectBarInterval(t){const i=t.target.id.substr(t.target.id.indexOf("-")+1);for(let e=0;e @@ -6,7 +6,7 @@ `}parseIntervalConfig(t){const e={"10m":0,hourly:1,daily:2,monthly:3};return e[t]}scaleLockClicked(t){const i=t.currentTarget.id.substr(t.currentTarget.id.indexOf("-")+1);for(let e=0;e - `}updateScaleLockState(t,e){const i=t.chart.options.scales.yAxes[0].ticks.forceMin&&t.chart.options.scales.yAxes[0].ticks.forceMax;let s=this._this.querySelector(`#ca-${t.id}`);if(s){s.children[0].style.display=i&&!e?"none":"inherit";s.style.opacity=e||t.yaxisLock?1:.3}}computeTickDensity(t){const e={low:4,medium:3,high:2,higher:1,highest:0};let i=e[this.pconfig.timeTickDensity];if(i===undefined)i=2;return Math.max(t<650?4:t<1100?3:t<1300?2:t<1900?1:0,i)}setStepSize(t=false){const e=this._this.querySelector("#maincard").clientWidth;const i=this.computeTickDensity(e);if(this.activeRange.timeRangeHours){const s=this.activeRange.timeRangeHours;const a=[];a.push({1:"2m",2:"5m",3:"5m",4:"5m",5:"5m",6:"10m",7:"10m",8:"10m",9:"10m",10:"15m",11:"15m",12:"15m",24:"30m",48:"1h",72:"2h",96:"2h",120:"3h",144:"3h",168:"6h",336:"12h",504:"12h",720:"1d",2184:"1o",4368:"1o",8760:"1o"});a.push({1:"2m",2:"5m",3:"10m",4:"10m",5:"10m",6:"15m",7:"15m",8:"20m",9:"20m",10:"30m",11:"30m",12:"30m",24:"1h",48:"2h",72:"3h",96:"3h",120:"6h",144:"6h",168:"12h",336:"1d",504:"1d",720:"1d",2184:"1o",4368:"1o",8760:"1o"});a.push({1:"5m",2:"10m",3:"15m",4:"30m",5:"30m",6:"30m",7:"30m",8:"30m",9:"30m",10:"1h",11:"1h",12:"1h",24:"2h",48:"4h",72:"6h",96:"6h",120:"12h",144:"12h",168:"12h",336:"1d",504:"2d",720:"2d",2184:"1o",4368:"1o",8760:"1o"});a.push({1:"10m",2:"20m",3:"30m",4:"1h",5:"1h",6:"1h",7:"1h",8:"1h",9:"1h",10:"2h",11:"2h",12:"2h",24:"4h",48:"8h",72:"12h",96:"1d",120:"1d",144:"1d",168:"2d",336:"3d",504:"4d",720:"7d",2184:"1o",4368:"1o",8760:"1o"});a.push({1:"20m",2:"30m",3:"1h",4:"2h",5:"2h",6:"2h",7:"2h",8:"2h",9:"2h",10:"4h",11:"4h",12:"4h",24:"6h",48:"12h",72:"1d",96:"2d",120:"2d",144:"2d",168:"4d",336:"7d",504:"7d",720:"14d",2184:"1o",4368:"1o",8760:"1o"});this.activeRange.tickStepSize=a[i][s].slice(0,-1);switch(a[i][s].slice(-1)[0]){case"m":this.activeRange.tickStepUnit="minute";break;case"h":this.activeRange.tickStepUnit="hour";break;case"d":this.activeRange.tickStepUnit="day";break;case"o":this.activeRange.tickStepUnit="month";break}}else if(this.activeRange.timeRangeMinutes){switch(i){case 0:this.activeRange.tickStepSize=1;break;case 1:this.activeRange.tickStepSize=1;break;case 2:this.activeRange.tickStepSize=this.activeRange.timeRangeMinutes<=20?1:5;break;case 3:this.activeRange.tickStepSize=this.activeRange.timeRangeMinutes<=10?1:this.activeRange.timeRangeMinutes<30?5:10;break;case 4:this.activeRange.tickStepSize=this.activeRange.timeRangeMinutes<=5?1:this.activeRange.timeRangeMinutes<25?5:10;break}this.activeRange.tickStepUnit="minute"}else{this.activeRange.tickStepSize=24;this.activeRange.tickStepUnit="hour"}if(t){for(let t of this.graphs){t.chart.options.scales.xAxes[0].time.unit=this.activeRange.tickStepUnit;t.chart.options.scales.xAxes[0].time.stepSize=this.activeRange.tickStepSize;t.chart.update()}}}validateRange(e,t=false){if(t&&e<12&&e>0)return e;let i=ranges.findIndex(t=>t>=e);if(i=48?a[e]*n:0;this.activeRange.timeRangeHours=e;this.activeRange.timeRangeMinutes=0;this.setStepSize(!t);for(let t of this.ui.rangeSelector)if(t)t.value=e;if(t){if(i){let t=moment(i).add(this.activeRange.timeRangeHours*(1-s),"hour");let e=moment(t).subtract(this.activeRange.timeRangeHours,"hour");this.startTime=e.format("YYYY-MM-DDTHH:mm:ss");this.endTime=t.format("YYYY-MM-DDTHH:mm:ss")}else if(this.activeRange.timeRangeHours>24){let t=moment(this.endTime);let e=moment(t).subtract(this.activeRange.timeRangeHours,"hour");this.startTime=e.format("YYYY-MM-DDTHH:mm:ss");this.endTime=t.format("YYYY-MM-DDTHH:mm:ss")}else{let t=(moment(this.endTime)+moment(this.startTime))/2;let e=moment(t).add(this.activeRange.timeRangeHours/2,"hour");let i=moment(e).subtract(this.activeRange.timeRangeHours,"hour");this.startTime=i.format("YYYY-MM-DDTHH:mm:ss");this.endTime=e.format("YYYY-MM-DDTHH:mm:ss")}for(let t of this.graphs){t.chart.options.scales.xAxes[0].time.unit=this.activeRange.tickStepUnit;t.chart.options.scales.xAxes[0].time.stepSize=this.activeRange.tickStepSize;t.chart.options.scales.xAxes[0].time.min=this.startTime;t.chart.options.scales.xAxes[0].time.max=this.endTime;t.chart.update()}this.updateHistory()}}setTimeRangeMinutes(t,e,i,s=.5){if(this.state.loading)return;s=Math.min(Math.max(s,0),1);t=Math.max(t,1);this.activeRange.dataClusterSize=0;this.activeRange.timeRangeHours=0;this.activeRange.timeRangeMinutes=t;this.setStepSize(!e);for(let t of this.ui.rangeSelector)if(t)t.value="0";if(e){if(!i)i=(moment(this.startTime)+moment(this.endTime))/2;let t=moment(i).add(this.activeRange.timeRangeMinutes*(1-s),"minute");let e=moment(t).subtract(this.activeRange.timeRangeMinutes,"minute");this.startTime=e.format("YYYY-MM-DDTHH:mm:ss");this.endTime=t.format("YYYY-MM-DDTHH:mm:ss");for(let t of this.graphs){t.chart.options.scales.xAxes[0].time.unit=this.activeRange.tickStepUnit;t.chart.options.scales.xAxes[0].time.stepSize=this.activeRange.tickStepSize;t.chart.options.scales.xAxes[0].time.min=this.startTime;t.chart.options.scales.xAxes[0].time.max=this.endTime;t.chart.update()}this.updateHistory()}}setTimeRangeFromString(t,e=false,i=null){const s=t.slice(0,-1);let a=0;switch(t.slice(-1)[0]){case"m":a=s*1;break;case"h":a=s*60;break;case"d":a=s<=7?s*24*60:s<=14?14*24*60:s<=21?21*24*60:30*24*60;break;case"w":a=s<=3?s*7*24*60:30*24*60;break;case"o":a=s<=1?30*24*60:s<=3?91*24*60:s<=6?182*24*60:365*24*60;break;case"y":a=365*24*60;break;default:a=t*60;break}const n=Math.floor(a/60);if(n>0)this.setTimeRange(this.validateRange(n,true),e,i);else this.setTimeRangeMinutes(a,e,i)}findFirstIndex(t,e,i){let s=e.start-1;while(s++e.start){if(i(t[s]))return s}return-1}getFormattedLabelName(t,e,i){let s=t;const a=10**this.pconfig.roundingPrecision;const n=Math.round(this._hass.states[e].state*a)/a;if(!isNaN(n)){s+=" ("+n+(i?" "+i:"")+")"}return s}initCache(){let e=moment().format("YYYY-MM-DD")+"T00:00:00";e=moment(e).subtract(this.cacheSize,"day").format("YYYY-MM-DD")+"T00:00:00";for(let t=0;t=20*365)return;let i=this.cache[0].start;for(let t=0;t=this.cache[t].start_m&&ethis.cache[t].start_m&&e<=this.cache[t].end_m)return t}if(e>this.cache[this.cacheSize].end_m)return this.cacheSize;return-1}findCacheEntityIndex(e,i){if(!this.cache[e].valid)return-1;for(let t=0;t=0&&t>=0){let a=[];for(let s=n;s<=t;s++){let i=0;for(let e of this.graphs){for(let t of e.entities){if(a[i]==undefined)a[i]=[];const o=this.findCacheEntityIndex(s,t.entity);if(o>=0)a[i]=a[i].concat(this.cache[s].data[o]);i++}}}if(n>0&&this.cache[n-1].valid){let i=0;for(let e of this.graphs){for(let t of e.entities){for(let e=n-1;e>=0&&this.cache[e].valid;e--){const o=this.findCacheEntityIndex(e,t.entity);if(o>=0){let t=this.cache[e].data[o].length;if(t>0){a[i].unshift({last_changed:this.cache[n].start,state:this.cache[e].data[o][t-1].state});break}}}i++}}}this.buildChartData(a)}else this.buildChartData(null)}searchFirstAffectedSlot(e,i,s){for(let t=e;t<=i;t++){if(this.cache[t].end_m>=s)return t}return undefined}loaderCallback(i){if(this.databaseCallback)this.databaseCallback(i.length>0);let t=false;let s=0;if(this.statistics.enabled&&!this.loader.loadingStats){s=this.cacheSize;for(let e of i){let t=this.searchFirstAffectedSlot(this.loader.startIndex,this.loader.endIndex,moment(e[0].last_changed));if(t&&tthis.loader.startIndex&&this.statistics.retention){const e=this.cacheSize-this.statistics.retention;if(s>e){console.warn(`first partial slot ${s}, first history slot is ${e}`);s=e}}if(s>this.loader.startIndex&&s=s){this.cache[this.loader.startIndex].data=i;this.cache[this.loader.startIndex].valid=true}}else{for(let t=this.loader.startIndex;t<=this.loader.endIndex;t++){this.cache[t].data=[];this.cache[t].valid=t>=s}for(let n of i){let a=0;for(let s=this.loader.startIndex;s<=this.loader.endIndex;s++){let e=moment(this.cache[s].end);let t=this.findFirstIndex(n,{start:a,end:n.length-1},function(t){return moment(t.last_changed)>=e});if(t<0)t=n.length;let i=n.slice(a,t);this.cache[s].data.push(i);a=t}}}for(let e=this.loader.startIndex;e<=this.loader.endIndex;e++){this.cache[e].entities=[];for(let t of i){this.cache[e].entities.push(t[0].entity_id)}}this.generateGraphDataFromCache();this.state.loading=false;if(t)this.updateHistory()}loaderFailed(t){console.log("Database request failure");console.log(t);if(this.databaseCallback)this.databaseCallback(false);this.buildChartData(null);this.state.loading=false}loaderCallbackStats(i){const s=this.statistics.mode;let a=[];for(let t in i){const n=i[t];let e=[];e.push({last_changed:n[0].start,state:n[0][s]??n[0].state,entity_id:t});for(let t=1;tthis.pconfig.showUnavailable||!["unavailable","unknown"].includes(t);let u=0;for(let c of this.graphs){let e=false;for(let t=0;tu){var m=d[u].length;const y=this.buildProcessFunction(c.entities[t].process);if(c.type=="line"){const h=c.entities[t].scale??1;const b=c.entities[t].decimation??this.pconfig.decimation??"fast";if(m>2&&b&&this.activeRange.dataClusterSize>0){let s=this.momentCache(d[u][0].last_changed);let a=null,n=null;let o=null,r=null;for(let i=0;ia){a=e;n=t}if(o===null||e=this.activeRange.dataClusterSize){if(b=="accurate"){if(rf&&g.length>0&&moment(g[g.length-1].x)0&&moment(g[g.length-1].x)0){const h=c.entities[t].scale??1;const v=c.entities[t].netBars??false;const S=c.entities[t].color&&c.entities[t].color.constructor==Object?c.entities[t].color:null;let i;if(c.interval==0)i=moment.duration(10,"minute");else if(c.interval==1)i=moment.duration(1,"hour");else if(c.interval==2)i=moment.duration(1,"day");else if(c.interval==3)i=moment.duration(1,"month");let s=0;let a=this.process(d[u][0].state,y)*1;let n=a;const _=c.interval<=1?"YYYY-MM-DDTHH[:00:00]":c.interval<=2?"YYYY-MM-DDT[00:00:00]":"YYYY-MM-[01]T[00:00:00]";let o=moment(moment(p).format(_));while(s=this.activeRange.dataClusterSize||t==m-1){if(o>0){e=r;i=l;s=moment(e);a=moment(i);t--}}else{if(!o){r=e;h=this.processRaw(d[u][t].state,y)}l=i;o++;continue}if(a>=p){if(a>f)i=this.endTime;if(s>f)break;if(s1?"multiple":String(h));g.push(t)}o=0}}}c.chart.data.datasets[t].data=g;if(r.length>0){c.chart.data.datasets[t].backgroundColor=r;c.chart.data.datasets[t].borderColor=r}e=true}if(e){c.chart.options.scales.xAxes[0].time.unit=this.activeRange.tickStepUnit;c.chart.options.scales.xAxes[0].time.stepSize=this.activeRange.tickStepSize;c.chart.options.scales.xAxes[0].time.min=this.startTime;c.chart.options.scales.xAxes[0].time.max=this.endTime;c.chart.update()}}}generateTooltipContents(i,s,t,e=1){if(this.pconfig.tooltipShowDuration){let t="";let e=moment(s[1]).diff(moment(s[0]));if(e>=24*60*60*1e3){const a=Math.floor(e/(24*60*60*1e3));e-=a*24*60*60*1e3;t=a>1?`${i18n("ui.ranges.n_days",a)}, `:`${i18n("ui.ranges.day")}, `}t+=moment.utc(e).format("HH:mm:ss");i=`${i} (for ${t})`}if(t=="compact"||t=="slim"||t=="auto"&&e<2)return[i,moment(s[0]).format(this.i18n.styleDateTimeTooltip)+" -- "+moment(s[1]).format(this.i18n.styleDateTimeTooltip)];else return[i,moment(s[0]).format(this.i18n.styleDateTimeTooltip),moment(s[1]).format(this.i18n.styleDateTimeTooltip)]}newGraph(t,o,r,i){const e=t.getContext("2d");var s;let a;if(o=="line"||o=="bar"){s={datasets:[]};for(let t of r){s.datasets.push({borderColor:t.bColor,backgroundColor:t.fillColor,borderWidth:t.width,borderDash:t.dashMode==="points"?[1,5]:t.dashMode==="shortlines"?[5,5]:t.dashMode==="longlines"?[10,8]:t.dashMode==="pointline"?[15,3,3,3]:undefined,pointRadius:i?.showSamples?4:0,hitRadius:5,label:this.pconfig.showCurrentValues?this.getFormattedLabelName(t.name,t.entity_id,t.unit):t.name,name:t.name,steppedLine:t.mode==="stepped",cubicInterpolationMode:t.mode!=="stepped"&&t.mode!=="lines"?"monotone":"default",lineTension:t.mode==="lines"?0:undefined,domain:t.domain,entity_id:t.entity_id,unit:t.unit,hidden:t.hidden,data:{}});a=a??t.unit}}else if(o=="timeline"||o=="arrowline"){s={labels:[],datasets:[]};for(let t of r){s.labels.push(this.pconfig.labelsVisible?t.name:"");s.datasets.push({domain:t.domain,device_class:t.device_class,entity_id:t.entity_id,unit:t.unit,arrowColor:t.bColor,arrowBackground:t.fillColor,data:[]})}}const l=this.pconfig.tooltipSize;var n=new Chart(e,{type:o,data:s,options:{scales:{xAxes:[{type:o=="line"||o=="bar"?"time":o=="arrowline"?"arrowline":"timeline",time:{unit:this.activeRange.tickStepUnit,stepSize:this.activeRange.tickStepSize,displayFormats:{minute:this.i18n.styleTimeTicks,hour:this.i18n.styleTimeTicks,day:this.i18n.styleDateTicks,month:"MMM"},tooltipFormat:this.i18n.styleDateTimeTooltip},ticks:{fontColor:i?.showTimeLabels===false?"rgba(0,0,0,0)":this.pconfig.graphLabelColor,major:{enabled:true,unit:"day",fontStyle:"bold",unitStepSize:1,displayFormats:{day:this.i18n.styleDateTicks}},maxRotation:0},gridLines:{color:this.pconfig.graphGridColor}}],yAxes:[{afterFit:t=>{t.width=this.pconfig.labelAreaWidth},afterDataLimits:t=>{const e=1e-4;if(i?.ymin==null&&this.pconfig.axisAddMarginMin&&o=="line")t.min-=e;if(i?.ymax==null&&this.pconfig.axisAddMarginMax&&o=="line")t.max+=e},ticks:{fontColor:this.pconfig.graphLabelColor,min:i?.ymin??undefined,max:i?.ymax??undefined,forceMin:i?.ymin??undefined,forceMax:i?.ymax??undefined,stepSize:i?.ystepSize??undefined},gridLines:{color:o=="line"||o=="bar"||r.length>1?this.pconfig.graphGridColor:"rgba(0,0,0,0)"},scaleLabel:{display:a!==undefined&&a!==""&&this.pconfig.labelsVisible,labelString:a,fontColor:this.pconfig.graphLabelColor},barThickness:this.pconfig.timelineBarHeight-4}]},topClipMargin:i?.ymax==null?4:1,bottomClipMargin:i?.ymin==null?4:1,animation:{duration:0},tooltips:{callbacks:{label:(e,i)=>{if(o=="line"||o=="bar"){let t="";if(this.pconfig.tooltipShowLabel)t=i.datasets[e.datasetIndex].name||"";if(t)t+=": ";const s=10**this.pconfig.roundingPrecision;t+=Math.round(e.yLabel*s)/s;t+=" "+(i.datasets[e.datasetIndex].unit||"");return t}else if(o=="timeline"){const a=i.datasets[e.datasetIndex];const n=a.data[e.index];let t=n[2];if(this.pconfig.tooltipStateTextMode=="auto")t=this.getLocalizedState(t,a.domain,a.device_class,a.entity_id);return this.generateTooltipContents(t,n,l,r.length)}else if(o=="arrowline"){const n=i.datasets[e.datasetIndex].data[e.index];const s=10**this.pconfig.roundingPrecision;let t=Math.round(n[2]*s)/s;t+=" "+(i.datasets[e.datasetIndex].unit||"");return this.generateTooltipContents(t,n,"slim")}},title:function(e,i){let s="";if(e.length>0){if(o=="line"||o=="bar"){s=e[0].xLabel}else{let t=i.labels[e[0].datasetIndex];s=l!=="slim"?t:""}}return s}},yAlign:o=="line"||o=="bar"?undefined:"nocenter",caretPadding:8,displayColors:o=="line"?this.pconfig.showTooltipColors[0]:o=="timeline"?this.pconfig.showTooltipColors[1]:false},hover:{mode:"nearest",intersect:o!="line"},legend:{display:(o=="line"||o=="bar")&&this.pconfig.hideLegend!=true,labels:{fontColor:this.pconfig.graphLabelColor,usePointStyle:o=="line"||o=="bar"&&r.length>1,boxWidth:0}},elements:{textFunction:(t,e,i)=>{switch(this.pconfig.stateTextMode){case"auto":return this.getLocalizedState(t,e[i].domain,e[i].device_class,e[i].entity_id);case"hide":return"";default:return t}},colorFunction:(t,e,i,s)=>{return this.getStateColor(i[s].domain,i[s].device_class,i[s].entity_id,e[2])},showText:true,font:'normal 13px "Helvetica Neue", Helvetica, Arial, sans-serif',textPadding:4,arrowColor:getComputedStyle(document.body).getPropertyValue("--primary-text-color")},responsive:true,maintainAspectRatio:false}});return n}updateHistory(){if(this.tid){clearTimeout(this.tid);this.tid=0}for(let t of this.ui.dateSelector)if(t)t.innerHTML=moment(this.startTime).format(this.i18n.styleDateSelector);if(!this.cache.length)this.initCache();if(moment(this.startTime)=0?this.findFirstIndex(this.cache,{start:t,end:e},function(t){return!t.valid}):-1;let n=e>=0?this.findLastIndex(this.cache,{start:t,end:e},function(t){return!t.valid}):-1;if(a>=0){if(this.state.loading){if(a>=this.loader.startIndex&&n<=this.loader.endIndex)return;console.log(`Slots ${a} to ${n} need loading`);console.log(`Double loading blocked, slots ${this.loader.startIndex} to ${this.loader.endIndex} are currently loading`);return}this.loader.startTime=this.cache[a].start;this.loader.endTime=this.cache[n].end;this.loader.startIndex=a;this.loader.endIndex=n;let i=0;let t=this.loader.startTime.replace("+","%2b");let e=this.loader.endTime.replace("+","%2b");let s=[];for(let e of this.graphs){for(let t of e.entities){s.push(t.entity);i++}}if(i>0){this.state.loading=true;if(this.statistics.force)this.limitSlot=this.cacheSize+1;if(!this.statistics.enabled||a>this.limitSlot){const o={type:"history/history_during_period",start_time:moment(t).format("YYYY-MM-DDTHH:mm:ssZ"),end_time:moment(e).format("YYYY-MM-DDTHH:mm:ssZ"),minimal_response:true,no_attributes:true,entity_ids:s};this._hass.callWS(o).then(this.loaderCallbackWS.bind(this),this.loaderFailed.bind(this))}else{const o={type:this.version[0]>2022||this.version[1]>=11?"recorder/statistics_during_period":"history/statistics_during_period",start_time:moment(t).format("YYYY-MM-DDTHH:mm:ssZ"),end_time:moment(e).format("YYYY-MM-DDTHH:mm:ssZ"),period:this.statistics.period,statistic_ids:s};this._hass.callWS(o).then(this.loaderCallbackStats.bind(this),this.loaderFailed.bind(this))}}}else this.generateGraphDataFromCache()}updateHistoryAutoRefresh(){const t=moment();const e=moment(this.endTime);if(this.state.autoScroll&&epanstate.g.chart.chartArea.left&&t0){panstate.lx=e.clientX;const t=panstate.g.chart.chartArea.right-panstate.g.chart.chartArea.left;const i=Math.floor((e.clientX-panstate.mx)*((3600*this.activeRange.timeRangeHours+60*this.activeRange.timeRangeMinutes)/t));if(i<0){let t=moment(panstate.tc).add(-i,"second");let e=moment(t).add(this.activeRange.timeRangeHours,"hour").add(this.activeRange.timeRangeMinutes,"minute");this.startTime=t.format("YYYY-MM-DDTHH:mm:ss");this.endTime=e.format("YYYY-MM-DDTHH:mm:ss")}else if(i>0){let t=moment(panstate.tc).subtract(i,"second");let e=moment(t).add(this.activeRange.timeRangeHours,"hour").add(this.activeRange.timeRangeMinutes,"minute");this.startTime=t.format("YYYY-MM-DDTHH:mm:ss");this.endTime=e.format("YYYY-MM-DDTHH:mm:ss")}if(!this.state.loading)this.updateHistory();else this.updateAxes()}if(e.shiftKey&&Math.abs(e.clientY-panstate.ly)>0){panstate.ly=e.clientY;const s=panstate.g.chart.chartArea.bottom-panstate.g.chart.chartArea.top;const a=(e.clientY-panstate.my)*(panstate.y1-panstate.y0)/s;panstate.g.chart.options.scales.yAxes[0].ticks.min=panstate.y0+a;panstate.g.chart.options.scales.yAxes[0].ticks.max=panstate.y1+a;panstate.g.chart.options.scales.yAxes[0].ticks.removeEdgeTicks=true;panstate.g.chart.update()}if(!e.shiftKey){panstate.ly=panstate.my=e.clientY;panstate.y0=panstate.g.chart.options.scales.yAxes[0].ticks.min;panstate.y1=panstate.g.chart.options.scales.yAxes[0].ticks.max}else{if(panstate.g.yaxisLock!==2)this.updateScaleLockState(panstate.g,true);panstate.g.yaxisLock=2}}else if(this.state.selecting&&panstate.overlay){let t=panstate.overlay.getContext("2d");t.clearRect(0,0,panstate.overlay.width,panstate.overlay.height);const n=panstate.overlay.getBoundingClientRect();const o=panstate.mx-n.left;const r=Math.max(Math.min(e.clientX-n.left,panstate.g.chart.chartArea.right),panstate.g.chart.chartArea.left);t.fillStyle=this.ui.darkMode?"#ffffff20":"#00000020";t.fillRect(o,panstate.g.chart.chartArea.top,r-o,panstate.g.chart.chartArea.bottom-panstate.g.chart.chartArea.top);panstate.st1=this.pixelPositionToTimecode(r)}else if(!this.state.altGraph&&e.altKey){for(let t of this.graphs){if(t.canvas===e.target){this.state.altGraph=t;t.chart.options.hover.mode="dataset";break}}}else if(this.state.altGraph&&!e.altKey){this.state.altGraph.chart.options.hover.mode="nearest";this.state.altGraph=null}}pointerUp(t){if(this.state.drag){this.state.drag=false;this.state.updateCanvas=null;panstate.g.chart.options.tooltips.enabled=true;if(panstate.g.chart.options.scales.yAxes[0].ticks.forceMin===undefined&&!panstate.g.yaxisLock){panstate.g.chart.options.scales.yAxes[0].ticks.min=undefined;panstate.g.chart.options.bottomClipMargin=4}else panstate.g.chart.options.bottomClipMargin=1;if(panstate.g.chart.options.scales.yAxes[0].ticks.forceMax===undefined&&!panstate.g.yaxisLock){panstate.g.chart.options.scales.yAxes[0].ticks.max=undefined;panstate.g.chart.options.topClipMargin=4}else panstate.g.chart.options.topClipMargin=1;this.updateHistory()}if(this.state.selecting){this.state.selecting=false;panstate.g.chart.options.tooltips.enabled=true;panstate.overlay.remove();panstate.overlay=null;if(panstate.st1=60?Math.ceil(i/60):0;if(t<12){if(t<1)this.setTimeRangeMinutes(Math.ceil(i),true,e);else this.setTimeRange(t,true,e)}else{t=Math.ceil(t/24);if(t<1)this.setTimeRange(12,true,e);else if(t<2)this.setTimeRange(24,true,e);else if(t<3)this.setTimeRange(48,true,e);else if(t<4)this.setTimeRange(72,true,e);else if(t<5)this.setTimeRange(96,true,e);else if(t<6)this.setTimeRange(120,true,e);else if(t<7)this.setTimeRange(144,true,e);else if(t<13)this.setTimeRange(168,true,e);else if(t<20)this.setTimeRange(336,true,e);else if(t<28)this.setTimeRange(504,true,e);else if(t<45)this.setTimeRange(720,true,e);else if(t<105)this.setTimeRange(2184,true,e);else this.setTimeRange(4368,true,e)}this.toggleZoom()}panstate.g=null;this.state.autoScroll=moment()<=moment(this.endTime)}pointerCancel(t){if(this.state.drag){this.state.drag=false;this.state.updateCanvas=null;panstate.g.chart.options.tooltips.enabled=true;panstate.g.chart.options.scales.yAxes[0].ticks.min=undefined;panstate.g.chart.options.scales.yAxes[0].ticks.max=undefined;panstate.g.chart.options.topClipMargin=4;panstate.g.chart.options.bottomClipMargin=4}if(this.state.selecting){this.state.selecting=false;panstate.g.chart.options.tooltips.enabled=true;panstate.overlay.remove();panstate.overlay=null}panstate.g=null;this.state.autoScroll=moment()<=moment(this.endTime)}wheelScrolled(t){if(t.ctrlKey){t.preventDefault();if(!this.graphs.length||this.state.loading)return;const e=this.graphs[0].canvas.getBoundingClientRect();const i=this.graphs[0].chart.chartArea;const s=t.clientX-e.left-i.left;const a=s/(i.right-i.left);const n=this.factorToTimecode(a);if(t.deltaY<0)this.incZoomStep(n,a);else if(t.deltaY>0)this.decZoomStep(n,a)}if(t.shiftKey){let a=Math.abs(t.deltaX)>Math.abs(t.deltaY)?t.deltaX:t.deltaY;for(let s of this.graphs){const e=s.canvas.getBoundingClientRect();if(t.clientY>=e.top&&t.clientY<=e.bottom){let t=a<0?.9:1/.9;let e=s.chart.options.scales.yAxes[0].ticks;if(e.min===undefined)e.min=s.chart.scales["y-axis-0"].min;if(e.max===undefined)e.max=s.chart.scales["y-axis-0"].max;let i=e.max-e.min;i=i-i*t;e.max-=i*.5;e.min+=i*.5;if(!s.yaxisLock){s.yaxisLock=2;this.updateScaleLockState(s,true)}s.chart.options.scales.yAxes[0].ticks.removeEdgeTicks=true;s.chart.update();break}}}}matchWildcardPattern(t){t=t.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&");t=t.replace(/\\\*/g,".*");return new RegExp("^"+t+"$","i")}addEntitySelected(t){if(this.state.loading)return;let e=t.target?t.target.id=="b8_0"?0:1:-1;if(e<0)return;const i=this.ui.inputField[e]?.value;for(let t of this.ui.inputField)if(t)t.value="";if(i.indexOf("*")>=0){const s=this._this.querySelector(isMobile?`#es_${e}`:`#b6_${this.cid}`);if(!s)return;const a=this.matchWildcardPattern(i);for(let t of Array.from(s.children)){const i=t.innerText;if(a.test(i)){if(this._hass.states[i]==undefined)continue;this.addDynamicGraph(i);this.pconfig.entities.push(i)}}}else{if(this._hass.states[i]==undefined)return;this.addDynamicGraph(i);this.pconfig.entities.push(i)}this.updateHistoryWithClearCache();this.writeLocalState()}removeAllEntities(){this.menuSetVisibility(0,false);this.menuSetVisibility(1,false);if(!confirm(i18n("ui.popup.remove_all")))return;let e=0;for(e=0;e=this.firstDynamicId)break;for(let t=e;t=0)this.pconfig.entities.splice(s,1)}this.graphs.splice(e,1);break}}this.updateHistoryWithClearCache();this.writeLocalState()}addFixedGraph(s){if(s.graph.type=="line"||s.graph.type=="bar"){let i=[];for(let e of s.graph.entities){const a=this.getNextDefaultColor();const n=e.color??a.color;let t=e.fill??(e.color?"rgba(0,0,0,0)":a.fill);if(s.graph.type=="bar")t=n;i.push({...e,color:n,fill:t})}this.addGraphToCanvas(s.id,s.graph.type,i,s.graph.options)}else this.addGraphToCanvas(s.id,s.graph.type,s.graph.entities,s.graph.options);if(s.graph.type=="bar")this._this.querySelector(`#bd-${s.id}`)?.addEventListener("change",this.selectBarInterval.bind(this));if(s.graph.type=="line"||s.graph.type=="bar")this._this.querySelector(`#ca-${s.id}`)?.addEventListener("click",this.scaleLockClicked.bind(this))}addDynamicGraph(t){if(this._hass.states[t]==undefined)return;var e=this.getEntityOptions(t);const i=this.getUnitOfMeasure(t);const s=this.getStateClass(t);const a=e?.type?e.type:s==="total_increasing"?"bar":i==undefined&&s!=="measurement"?"timeline":"line";let n=[{entity:t,color:"#000000",fill:"#00000000",process:e?.process}];if(a=="line"||a=="arrowline"||a=="bar"){if(e?.color){n[0].color=e?.color;n[0].fill=e?.fill??"rgba(0,0,0,0)"}else{const p=this.getNextDefaultColor();n[0].color=p.color;n[0].fill=e?.fill??p.fill}n[0].dashMode=e?.dashMode;n[0].width=e?.width;n[0].lineMode=e?.lineMode;n[0].scale=e?.scale;n[0].hidden=e?.hidden;n[0].netBars=e?.netBars;if(a=="bar"){n[0].fill=n[0].color;n[0].lineMode=e?.lineMode??"lines"}}const o=this.graphs.length-1;let r=o>=0&&a!="bar"&&this.graphs[o].type===a&&(a=="timeline"||this.pconfig.combineSameUnits&&this.getUnitOfMeasure(t)==this.getUnitOfMeasure(this.graphs[o].entities[0].entity));if(r){n=this.graphs[this.graphs.length-1].entities.concat(n);this.graphs[this.graphs.length-1].canvas.parentNode.remove();this.graphs.length--}const l=this.calcGraphHeight(a,n.length,e?.height);let h="";h+=`
`;h+=``;h+=``;if(a=="bar"&&!this.ui.hideInterval)h+=this.createIntervalSelectorHtml(this.g_id,l,this.parseIntervalConfig(e?.interval),this.ui.optionStyle);if(a=="line"||a=="bar")h+=this.createScaleLockIconHtml(this.g_id,l);h+=`
`;let c=document.createElement("div");c.innerHTML=h;let d=this._this.querySelector("#graphlist");d.appendChild(c);if(a=="bar"&&!this.ui.hideInterval)this._this.querySelector(`#bd-${this.g_id}`).addEventListener("change",this.selectBarInterval.bind(this));if(a=="line"||a=="bar")this._this.querySelector(`#ca-${this.g_id}`)?.addEventListener("click",this.scaleLockClicked.bind(this));this._this.querySelector(`#bc-${this.g_id}`).addEventListener("click",this.removeGraph.bind(this));this.addGraphToCanvas(this.g_id++,a,n,e)}addGraphToCanvas(t,e,i,s){const a=this._this.querySelector(`#graph${t}`);let n=[];for(let t of i){n.push({name:t.name===undefined?this._hass.states[t.entity]?.attributes?.friendly_name:t.name,bColor:parseColor(t.color),fillColor:parseColor(t.fill),dashMode:t.dashMode,mode:t.lineMode||this.pconfig.defaultLineMode,width:t.width||2,unit:this.getUnitOfMeasure(t.entity,t.unit),domain:this.getDomainForEntity(t.entity),device_class:this.getDeviceClass(t.entity),hidden:t.hidden,entity_id:t.entity})}const o=this.newGraph(a,e,n,s);const r=this.calcGraphHeight(e,i.length,s?.height);const l=this.parseIntervalConfig(s?.interval)??1;const h={id:t,type:e,canvas:a,graphHeight:r,chart:o,entities:i,interval:l};this.graphs.push(h);a.addEventListener("pointerdown",this.pointerDown.bind(this));a.addEventListener("pointermove",this.pointerMove.bind(this));a.addEventListener("pointerup",this.pointerUp.bind(this));a.addEventListener("pointercancel",this.pointerCancel.bind(this));if(e=="line"||e=="bar")this.updateScaleLockState(h,false)}addUIHtml(t,e,i,s,a,n,o){let r="";if((t||e)&&this.ui.stickyTools&1<`}if(t||e)r+=`
`;const l=``;if(t)r+=` + `}updateScaleLockState(t,e){const i=t.chart.options.scales.yAxes[0].ticks.forceMin&&t.chart.options.scales.yAxes[0].ticks.forceMax;let s=this._this.querySelector(`#ca-${t.id}`);if(s){s.children[0].style.display=i&&!e?"none":"inherit";s.style.opacity=e||t.yaxisLock?1:.3}}computeTickDensity(t){const e={low:4,medium:3,high:2,higher:1,highest:0};let i=e[this.pconfig.timeTickDensity];if(i===undefined)i=2;if(this.pconfig.timeTickOverride===undefined)return Math.max(t<650?4:t<1100?3:t<1300?2:t<1900?1:0,i);else return e[this.pconfig.timeTickOverride]??2}setStepSize(t=false){const e=this._this.querySelector("#maincard").clientWidth;const i=this.computeTickDensity(e);if(this.activeRange.timeRangeHours){const s=this.activeRange.timeRangeHours;const a=[];a.push({1:"2m",2:"5m",3:"5m",4:"5m",5:"5m",6:"10m",7:"10m",8:"10m",9:"10m",10:"15m",11:"15m",12:"15m",24:"30m",48:"1h",72:"2h",96:"2h",120:"3h",144:"3h",168:"6h",336:"12h",504:"12h",720:"1d",2184:"1o",4368:"1o",8760:"1o"});a.push({1:"2m",2:"5m",3:"10m",4:"10m",5:"10m",6:"15m",7:"15m",8:"20m",9:"20m",10:"30m",11:"30m",12:"30m",24:"1h",48:"2h",72:"3h",96:"3h",120:"6h",144:"6h",168:"12h",336:"1d",504:"1d",720:"1d",2184:"1o",4368:"1o",8760:"1o"});a.push({1:"5m",2:"10m",3:"15m",4:"30m",5:"30m",6:"30m",7:"30m",8:"30m",9:"30m",10:"1h",11:"1h",12:"1h",24:"2h",48:"4h",72:"6h",96:"6h",120:"12h",144:"12h",168:"12h",336:"1d",504:"2d",720:"2d",2184:"1o",4368:"1o",8760:"1o"});a.push({1:"10m",2:"20m",3:"30m",4:"1h",5:"1h",6:"1h",7:"1h",8:"1h",9:"1h",10:"2h",11:"2h",12:"2h",24:"4h",48:"8h",72:"12h",96:"1d",120:"1d",144:"1d",168:"2d",336:"3d",504:"4d",720:"7d",2184:"1o",4368:"1o",8760:"1o"});a.push({1:"20m",2:"30m",3:"1h",4:"2h",5:"2h",6:"2h",7:"2h",8:"2h",9:"2h",10:"4h",11:"4h",12:"4h",24:"6h",48:"12h",72:"1d",96:"2d",120:"2d",144:"2d",168:"4d",336:"7d",504:"7d",720:"14d",2184:"1o",4368:"1o",8760:"1o"});this.activeRange.tickStepSize=a[i][s].slice(0,-1);switch(a[i][s].slice(-1)[0]){case"m":this.activeRange.tickStepUnit="minute";break;case"h":this.activeRange.tickStepUnit="hour";break;case"d":this.activeRange.tickStepUnit="day";break;case"o":this.activeRange.tickStepUnit="month";break}}else if(this.activeRange.timeRangeMinutes){switch(i){case 0:this.activeRange.tickStepSize=1;break;case 1:this.activeRange.tickStepSize=1;break;case 2:this.activeRange.tickStepSize=this.activeRange.timeRangeMinutes<=20?1:5;break;case 3:this.activeRange.tickStepSize=this.activeRange.timeRangeMinutes<=10?1:this.activeRange.timeRangeMinutes<30?5:10;break;case 4:this.activeRange.tickStepSize=this.activeRange.timeRangeMinutes<=5?1:this.activeRange.timeRangeMinutes<25?5:10;break}this.activeRange.tickStepUnit="minute"}else{this.activeRange.tickStepSize=24;this.activeRange.tickStepUnit="hour"}if(t){for(let t of this.graphs){t.chart.options.scales.xAxes[0].time.unit=this.activeRange.tickStepUnit;t.chart.options.scales.xAxes[0].time.stepSize=this.activeRange.tickStepSize;t.chart.update()}}}validateRange(e,t=false){if(t&&e<12&&e>0)return e;let i=ranges.findIndex(t=>t>=e);if(i=48?a[e]*n:0;this.activeRange.timeRangeHours=e;this.activeRange.timeRangeMinutes=0;this.setStepSize(!t);for(let t of this.ui.rangeSelector)if(t)t.value=e;if(t){if(i){let t=moment(i).add(this.activeRange.timeRangeHours*(1-s),"hour");let e=moment(t).subtract(this.activeRange.timeRangeHours,"hour");this.startTime=e.format("YYYY-MM-DDTHH:mm:ss");this.endTime=t.format("YYYY-MM-DDTHH:mm:ss")}else if(this.activeRange.timeRangeHours>24){let t=moment(this.endTime);let e=moment(t).subtract(this.activeRange.timeRangeHours,"hour");this.startTime=e.format("YYYY-MM-DDTHH:mm:ss");this.endTime=t.format("YYYY-MM-DDTHH:mm:ss")}else{let t=(moment(this.endTime)+moment(this.startTime))/2;let e=moment(t).add(this.activeRange.timeRangeHours/2,"hour");let i=moment(e).subtract(this.activeRange.timeRangeHours,"hour");this.startTime=i.format("YYYY-MM-DDTHH:mm:ss");this.endTime=e.format("YYYY-MM-DDTHH:mm:ss")}for(let t of this.graphs){t.chart.options.scales.xAxes[0].time.unit=this.activeRange.tickStepUnit;t.chart.options.scales.xAxes[0].time.stepSize=this.activeRange.tickStepSize;t.chart.options.scales.xAxes[0].time.min=this.startTime;t.chart.options.scales.xAxes[0].time.max=this.endTime;t.chart.update()}this.updateHistory()}}setTimeRangeMinutes(t,e,i,s=.5){if(this.state.loading)return;s=Math.min(Math.max(s,0),1);t=Math.max(t,1);this.activeRange.dataClusterSize=0;this.activeRange.timeRangeHours=0;this.activeRange.timeRangeMinutes=t;this.setStepSize(!e);for(let t of this.ui.rangeSelector)if(t)t.value="0";if(e){if(!i)i=(moment(this.startTime)+moment(this.endTime))/2;let t=moment(i).add(this.activeRange.timeRangeMinutes*(1-s),"minute");let e=moment(t).subtract(this.activeRange.timeRangeMinutes,"minute");this.startTime=e.format("YYYY-MM-DDTHH:mm:ss");this.endTime=t.format("YYYY-MM-DDTHH:mm:ss");for(let t of this.graphs){t.chart.options.scales.xAxes[0].time.unit=this.activeRange.tickStepUnit;t.chart.options.scales.xAxes[0].time.stepSize=this.activeRange.tickStepSize;t.chart.options.scales.xAxes[0].time.min=this.startTime;t.chart.options.scales.xAxes[0].time.max=this.endTime;t.chart.update()}this.updateHistory()}}setTimeRangeFromString(t,e=false,i=null){const s=t.slice(0,-1);let a=0;switch(t.slice(-1)[0]){case"m":a=s*1;break;case"h":a=s*60;break;case"d":a=s<=7?s*24*60:s<=14?14*24*60:s<=21?21*24*60:30*24*60;break;case"w":a=s<=3?s*7*24*60:30*24*60;break;case"o":a=s<=1?30*24*60:s<=3?91*24*60:s<=6?182*24*60:365*24*60;break;case"y":a=365*24*60;break;default:a=t*60;break}const n=Math.floor(a/60);if(n>0)this.setTimeRange(this.validateRange(n,true),e,i);else this.setTimeRangeMinutes(a,e,i)}findFirstIndex(t,e,i){let s=e.start-1;while(s++e.start){if(i(t[s]))return s}return-1}getFormattedLabelName(t,e,i){let s=t;const a=10**this.pconfig.roundingPrecision;const n=Math.round(this._hass.states[e].state*a)/a;if(!isNaN(n)){s+=" ("+n+(i?" "+i:"")+")"}return s}initCache(){let e=moment().format("YYYY-MM-DD")+"T00:00:00";e=moment(e).subtract(this.cacheSize,"day").format("YYYY-MM-DD")+"T00:00:00";for(let t=0;t=20*365)return;let i=this.cache[0].start;for(let t=0;t=this.cache[t].start_m&&ethis.cache[t].start_m&&e<=this.cache[t].end_m)return t}if(e>this.cache[this.cacheSize].end_m)return this.cacheSize;return-1}findCacheEntityIndex(e,i){if(!this.cache[e].valid)return-1;for(let t=0;t=0&&t>=0){let a=[];for(let s=n;s<=t;s++){let i=0;for(let e of this.graphs){for(let t of e.entities){if(a[i]==undefined)a[i]=[];const o=this.findCacheEntityIndex(s,t.entity);if(o>=0)a[i]=a[i].concat(this.cache[s].data[o]);i++}}}if(n>0&&this.cache[n-1].valid){let i=0;for(let e of this.graphs){for(let t of e.entities){for(let e=n-1;e>=0&&this.cache[e].valid;e--){const o=this.findCacheEntityIndex(e,t.entity);if(o>=0){let t=this.cache[e].data[o].length;if(t>0){a[i].unshift({last_changed:this.cache[n].start,state:this.cache[e].data[o][t-1].state});break}}}i++}}}this.buildChartData(a)}else this.buildChartData(null)}searchFirstAffectedSlot(e,i,s){for(let t=e;t<=i;t++){if(this.cache[t].end_m>=s)return t}return undefined}loaderCallback(i){if(this.databaseCallback)this.databaseCallback(i.length>0);let t=false;let s=0;if(this.statistics.enabled&&!this.loader.loadingStats){s=this.cacheSize;for(let e of i){let t=this.searchFirstAffectedSlot(this.loader.startIndex,this.loader.endIndex,moment(e[0].last_changed));if(t&&tthis.loader.startIndex&&this.statistics.retention){const e=this.cacheSize-this.statistics.retention;if(s>e){console.warn(`first partial slot ${s}, first history slot is ${e}`);s=e}}if(s>this.loader.startIndex&&s=s){this.cache[this.loader.startIndex].data=i;this.cache[this.loader.startIndex].valid=true}}else{for(let t=this.loader.startIndex;t<=this.loader.endIndex;t++){this.cache[t].data=[];this.cache[t].valid=t>=s}for(let n of i){let a=0;for(let s=this.loader.startIndex;s<=this.loader.endIndex;s++){let e=moment(this.cache[s].end);let t=this.findFirstIndex(n,{start:a,end:n.length-1},function(t){return moment(t.last_changed)>=e});if(t<0)t=n.length;let i=n.slice(a,t);this.cache[s].data.push(i);a=t}}}for(let e=this.loader.startIndex;e<=this.loader.endIndex;e++){this.cache[e].entities=[];for(let t of i){this.cache[e].entities.push(t[0].entity_id)}}this.generateGraphDataFromCache();this.state.loading=false;if(t)this.updateHistory()}loaderFailed(t){console.log("Database request failure");console.log(t);if(this.databaseCallback)this.databaseCallback(false);this.buildChartData(null);this.state.loading=false}loaderCallbackStats(i){const s=this.statistics.mode;let a=[];for(let t in i){const n=i[t];let e=[];e.push({last_changed:n[0].start,state:n[0][s]??n[0].state,entity_id:t});for(let t=1;tthis.pconfig.showUnavailable||!["unavailable","unknown"].includes(t);let u=0;for(let c of this.graphs){let e=false;for(let t=0;tu){var m=d[u].length;const y=this.buildProcessFunction(c.entities[t].process);if(c.type=="line"){const h=c.entities[t].scale??1;const b=c.entities[t].decimation??this.pconfig.decimation??"fast";if(m>2&&b&&this.activeRange.dataClusterSize>0){let s=this.momentCache(d[u][0].last_changed);let a=null,n=null;let o=null,r=null;for(let i=0;ia){a=e;n=t}if(o===null||e=this.activeRange.dataClusterSize){if(b=="accurate"){if(rf&&g.length>0&&moment(g[g.length-1].x)0&&moment(g[g.length-1].x)0){const h=c.entities[t].scale??1;const v=c.entities[t].netBars??false;const S=c.entities[t].color&&c.entities[t].color.constructor==Object?c.entities[t].color:null;let i;if(c.interval==0)i=moment.duration(10,"minute");else if(c.interval==1)i=moment.duration(1,"hour");else if(c.interval==2)i=moment.duration(1,"day");else if(c.interval==3)i=moment.duration(1,"month");let s=0;let a=this.process(d[u][0].state,y)*1;let n=a;const _=c.interval<=1?"YYYY-MM-DDTHH[:00:00]":c.interval<=2?"YYYY-MM-DDT[00:00:00]":"YYYY-MM-[01]T[00:00:00]";let o=moment(moment(p).format(_));while(s=this.activeRange.dataClusterSize||t==m-1){if(o>0){e=r;i=l;s=moment(e);a=moment(i);t--}}else{if(!o){r=e;h=this.processRaw(d[u][t].state,y)}l=i;o++;continue}if(a>=p){if(a>f)i=this.endTime;if(s>f)break;if(s1?"multiple":String(h));g.push(t)}o=0}}}c.chart.data.datasets[t].data=g;if(r.length>0){c.chart.data.datasets[t].backgroundColor=r;c.chart.data.datasets[t].borderColor=r}e=true}if(e){c.chart.options.scales.xAxes[0].time.unit=this.activeRange.tickStepUnit;c.chart.options.scales.xAxes[0].time.stepSize=this.activeRange.tickStepSize;c.chart.options.scales.xAxes[0].time.min=this.startTime;c.chart.options.scales.xAxes[0].time.max=this.endTime;c.chart.update()}}}generateTooltipContents(i,s,t,e=1){if(this.pconfig.tooltipShowDuration){let t="";let e=moment(s[1]).diff(moment(s[0]));if(e>=24*60*60*1e3){const a=Math.floor(e/(24*60*60*1e3));e-=a*24*60*60*1e3;t=a>1?`${i18n("ui.ranges.n_days",a)}, `:`${i18n("ui.ranges.day")}, `}t+=moment.utc(e).format("HH:mm:ss");i=`${i} (for ${t})`}if(t=="compact"||t=="slim"||t=="auto"&&e<2)return[i,moment(s[0]).format(this.i18n.styleDateTimeTooltip)+" -- "+moment(s[1]).format(this.i18n.styleDateTimeTooltip)];else return[i,moment(s[0]).format(this.i18n.styleDateTimeTooltip),moment(s[1]).format(this.i18n.styleDateTimeTooltip)]}newGraph(t,o,r,i){const e=t.getContext("2d");var s;let a;if(o=="line"||o=="bar"){s={datasets:[]};for(let t of r){s.datasets.push({borderColor:t.bColor,backgroundColor:t.fillColor,borderWidth:t.width,borderDash:t.dashMode==="points"?[1,5]:t.dashMode==="shortlines"?[5,5]:t.dashMode==="longlines"?[10,8]:t.dashMode==="pointline"?[15,3,3,3]:undefined,pointRadius:i?.showSamples?4:0,hitRadius:5,label:this.pconfig.showCurrentValues?this.getFormattedLabelName(t.name,t.entity_id,t.unit):t.name,name:t.name,steppedLine:t.mode==="stepped",cubicInterpolationMode:t.mode!=="stepped"&&t.mode!=="lines"?"monotone":"default",lineTension:t.mode==="lines"?0:undefined,domain:t.domain,entity_id:t.entity_id,unit:t.unit,hidden:t.hidden,data:{}});a=a??t.unit}}else if(o=="timeline"||o=="arrowline"){s={labels:[],datasets:[]};for(let t of r){s.labels.push(this.pconfig.labelsVisible?t.name:"");s.datasets.push({domain:t.domain,device_class:t.device_class,entity_id:t.entity_id,unit:t.unit,arrowColor:t.bColor,arrowBackground:t.fillColor,data:[]})}}const l=this.pconfig.tooltipSize;var n=new Chart(e,{type:o,data:s,options:{scales:{xAxes:[{type:o=="line"||o=="bar"?"time":o=="arrowline"?"arrowline":"timeline",time:{unit:this.activeRange.tickStepUnit,stepSize:this.activeRange.tickStepSize,displayFormats:{minute:this.i18n.styleTimeTicks,hour:this.i18n.styleTimeTicks,day:this.i18n.styleDateTicks,month:"MMM"},tooltipFormat:this.i18n.styleDateTimeTooltip},ticks:{fontColor:i?.showTimeLabels===false?"rgba(0,0,0,0)":this.pconfig.graphLabelColor,major:{enabled:true,unit:"day",fontStyle:"bold",unitStepSize:1,displayFormats:{day:this.i18n.styleDateTicks}},maxRotation:0},gridLines:{color:this.pconfig.graphGridColor}}],yAxes:[{afterFit:t=>{t.width=this.pconfig.labelAreaWidth},afterDataLimits:t=>{const e=1e-4;if(i?.ymin==null&&this.pconfig.axisAddMarginMin&&o=="line")t.min-=e;if(i?.ymax==null&&this.pconfig.axisAddMarginMax&&o=="line")t.max+=e},ticks:{fontColor:this.pconfig.graphLabelColor,min:i?.ymin??undefined,max:i?.ymax??undefined,forceMin:i?.ymin??undefined,forceMax:i?.ymax??undefined,stepSize:i?.ystepSize??undefined},gridLines:{color:o=="line"||o=="bar"||r.length>1?this.pconfig.graphGridColor:"rgba(0,0,0,0)"},scaleLabel:{display:a!==undefined&&a!==""&&this.pconfig.labelsVisible,labelString:a,fontColor:this.pconfig.graphLabelColor},barThickness:this.pconfig.timelineBarHeight-4}]},topClipMargin:i?.ymax==null?4:1,bottomClipMargin:i?.ymin==null?4:1,animation:{duration:0},tooltips:{callbacks:{label:(e,i)=>{if(o=="line"||o=="bar"){let t="";if(this.pconfig.tooltipShowLabel)t=i.datasets[e.datasetIndex].name||"";if(t)t+=": ";const s=10**this.pconfig.roundingPrecision;t+=Math.round(e.yLabel*s)/s;t+=" "+(i.datasets[e.datasetIndex].unit||"");return t}else if(o=="timeline"){const a=i.datasets[e.datasetIndex];const n=a.data[e.index];let t=n[2];if(this.pconfig.tooltipStateTextMode=="auto")t=this.getLocalizedState(t,a.domain,a.device_class,a.entity_id);return this.generateTooltipContents(t,n,l,r.length)}else if(o=="arrowline"){const n=i.datasets[e.datasetIndex].data[e.index];const s=10**this.pconfig.roundingPrecision;let t=Math.round(n[2]*s)/s;t+=" "+(i.datasets[e.datasetIndex].unit||"");return this.generateTooltipContents(t,n,"slim")}},title:function(e,i){let s="";if(e.length>0){if(o=="line"||o=="bar"){s=e[0].xLabel}else{let t=i.labels[e[0].datasetIndex];s=l!=="slim"?t:""}}return s}},yAlign:o=="line"||o=="bar"?undefined:"nocenter",caretPadding:8,displayColors:o=="line"?this.pconfig.showTooltipColors[0]:o=="timeline"?this.pconfig.showTooltipColors[1]:false},hover:{mode:"nearest",intersect:o!="line"},legend:{display:(o=="line"||o=="bar")&&this.pconfig.hideLegend!=true,labels:{fontColor:this.pconfig.graphLabelColor,usePointStyle:o=="line"||o=="bar"&&r.length>1,boxWidth:0}},elements:{textFunction:(t,e,i)=>{switch(this.pconfig.stateTextMode){case"auto":return this.getLocalizedState(t,e[i].domain,e[i].device_class,e[i].entity_id);case"hide":return"";default:return t}},colorFunction:(t,e,i,s)=>{return this.getStateColor(i[s].domain,i[s].device_class,i[s].entity_id,e[2])},showText:true,font:'normal 13px "Helvetica Neue", Helvetica, Arial, sans-serif',textPadding:4,arrowColor:getComputedStyle(document.body).getPropertyValue("--primary-text-color")},responsive:true,maintainAspectRatio:false}});return n}updateHistory(){if(this.tid){clearTimeout(this.tid);this.tid=0}for(let t of this.ui.dateSelector)if(t)t.innerHTML=moment(this.startTime).format(this.i18n.styleDateSelector);if(!this.cache.length)this.initCache();if(moment(this.startTime)=0?this.findFirstIndex(this.cache,{start:t,end:e},function(t){return!t.valid}):-1;let n=e>=0?this.findLastIndex(this.cache,{start:t,end:e},function(t){return!t.valid}):-1;if(a>=0){if(this.state.loading){if(a>=this.loader.startIndex&&n<=this.loader.endIndex)return;console.log(`Slots ${a} to ${n} need loading`);console.log(`Double loading blocked, slots ${this.loader.startIndex} to ${this.loader.endIndex} are currently loading`);return}this.loader.startTime=this.cache[a].start;this.loader.endTime=this.cache[n].end;this.loader.startIndex=a;this.loader.endIndex=n;let i=0;let t=this.loader.startTime.replace("+","%2b");let e=this.loader.endTime.replace("+","%2b");let s=[];for(let e of this.graphs){for(let t of e.entities){s.push(t.entity);i++}}if(i>0){this.state.loading=true;if(this.statistics.force)this.limitSlot=this.cacheSize+1;if(!this.statistics.enabled||a>this.limitSlot){const o={type:"history/history_during_period",start_time:moment(t).format("YYYY-MM-DDTHH:mm:ssZ"),end_time:moment(e).format("YYYY-MM-DDTHH:mm:ssZ"),minimal_response:true,no_attributes:true,entity_ids:s};this._hass.callWS(o).then(this.loaderCallbackWS.bind(this),this.loaderFailed.bind(this))}else{const o={type:this.version[0]>2022||this.version[1]>=11?"recorder/statistics_during_period":"history/statistics_during_period",start_time:moment(t).format("YYYY-MM-DDTHH:mm:ssZ"),end_time:moment(e).format("YYYY-MM-DDTHH:mm:ssZ"),period:this.statistics.period,statistic_ids:s};this._hass.callWS(o).then(this.loaderCallbackStats.bind(this),this.loaderFailed.bind(this))}}}else this.generateGraphDataFromCache()}updateHistoryAutoRefresh(){const t=moment();const e=moment(this.endTime);if(this.state.autoScroll&&epanstate.g.chart.chartArea.left&&t0){panstate.lx=e.clientX;const t=panstate.g.chart.chartArea.right-panstate.g.chart.chartArea.left;const i=Math.floor((e.clientX-panstate.mx)*((3600*this.activeRange.timeRangeHours+60*this.activeRange.timeRangeMinutes)/t));if(i<0){let t=moment(panstate.tc).add(-i,"second");let e=moment(t).add(this.activeRange.timeRangeHours,"hour").add(this.activeRange.timeRangeMinutes,"minute");this.startTime=t.format("YYYY-MM-DDTHH:mm:ss");this.endTime=e.format("YYYY-MM-DDTHH:mm:ss")}else if(i>0){let t=moment(panstate.tc).subtract(i,"second");let e=moment(t).add(this.activeRange.timeRangeHours,"hour").add(this.activeRange.timeRangeMinutes,"minute");this.startTime=t.format("YYYY-MM-DDTHH:mm:ss");this.endTime=e.format("YYYY-MM-DDTHH:mm:ss")}if(!this.state.loading)this.updateHistory();else this.updateAxes()}if(e.shiftKey&&Math.abs(e.clientY-panstate.ly)>0){panstate.ly=e.clientY;const s=panstate.g.chart.chartArea.bottom-panstate.g.chart.chartArea.top;const a=(e.clientY-panstate.my)*(panstate.y1-panstate.y0)/s;panstate.g.chart.options.scales.yAxes[0].ticks.min=panstate.y0+a;panstate.g.chart.options.scales.yAxes[0].ticks.max=panstate.y1+a;panstate.g.chart.options.scales.yAxes[0].ticks.removeEdgeTicks=true;panstate.g.chart.update()}if(!e.shiftKey){panstate.ly=panstate.my=e.clientY;panstate.y0=panstate.g.chart.options.scales.yAxes[0].ticks.min;panstate.y1=panstate.g.chart.options.scales.yAxes[0].ticks.max}else{if(panstate.g.yaxisLock!==2)this.updateScaleLockState(panstate.g,true);panstate.g.yaxisLock=2}}else if(this.state.selecting&&panstate.overlay){let t=panstate.overlay.getContext("2d");t.clearRect(0,0,panstate.overlay.width,panstate.overlay.height);const n=panstate.overlay.getBoundingClientRect();const o=panstate.mx-n.left;const r=Math.max(Math.min(e.clientX-n.left,panstate.g.chart.chartArea.right),panstate.g.chart.chartArea.left);t.fillStyle=this.ui.darkMode?"#ffffff20":"#00000020";t.fillRect(o,panstate.g.chart.chartArea.top,r-o,panstate.g.chart.chartArea.bottom-panstate.g.chart.chartArea.top);panstate.st1=this.pixelPositionToTimecode(r)}else if(!this.state.altGraph&&e.altKey){for(let t of this.graphs){if(t.canvas===e.target){this.state.altGraph=t;t.chart.options.hover.mode="dataset";break}}}else if(this.state.altGraph&&!e.altKey){this.state.altGraph.chart.options.hover.mode="nearest";this.state.altGraph=null}}pointerUp(t){if(this.state.drag){this.state.drag=false;this.state.updateCanvas=null;panstate.g.chart.options.tooltips.enabled=true;if(panstate.g.chart.options.scales.yAxes[0].ticks.forceMin===undefined&&!panstate.g.yaxisLock){panstate.g.chart.options.scales.yAxes[0].ticks.min=undefined;panstate.g.chart.options.bottomClipMargin=4}else panstate.g.chart.options.bottomClipMargin=1;if(panstate.g.chart.options.scales.yAxes[0].ticks.forceMax===undefined&&!panstate.g.yaxisLock){panstate.g.chart.options.scales.yAxes[0].ticks.max=undefined;panstate.g.chart.options.topClipMargin=4}else panstate.g.chart.options.topClipMargin=1;this.updateHistory()}if(this.state.selecting){this.state.selecting=false;panstate.g.chart.options.tooltips.enabled=true;panstate.overlay.remove();panstate.overlay=null;if(panstate.st1=60?Math.ceil(i/60):0;if(t<12){if(t<1)this.setTimeRangeMinutes(Math.ceil(i),true,e);else this.setTimeRange(t,true,e)}else{t=Math.ceil(t/24);if(t<1)this.setTimeRange(12,true,e);else if(t<2)this.setTimeRange(24,true,e);else if(t<3)this.setTimeRange(48,true,e);else if(t<4)this.setTimeRange(72,true,e);else if(t<5)this.setTimeRange(96,true,e);else if(t<6)this.setTimeRange(120,true,e);else if(t<7)this.setTimeRange(144,true,e);else if(t<13)this.setTimeRange(168,true,e);else if(t<20)this.setTimeRange(336,true,e);else if(t<28)this.setTimeRange(504,true,e);else if(t<45)this.setTimeRange(720,true,e);else if(t<105)this.setTimeRange(2184,true,e);else this.setTimeRange(4368,true,e)}this.toggleZoom()}panstate.g=null;this.state.autoScroll=moment()<=moment(this.endTime)}pointerCancel(t){if(this.state.drag){this.state.drag=false;this.state.updateCanvas=null;panstate.g.chart.options.tooltips.enabled=true;panstate.g.chart.options.scales.yAxes[0].ticks.min=undefined;panstate.g.chart.options.scales.yAxes[0].ticks.max=undefined;panstate.g.chart.options.topClipMargin=4;panstate.g.chart.options.bottomClipMargin=4}if(this.state.selecting){this.state.selecting=false;panstate.g.chart.options.tooltips.enabled=true;panstate.overlay.remove();panstate.overlay=null}panstate.g=null;this.state.autoScroll=moment()<=moment(this.endTime)}wheelScrolled(t){if(t.ctrlKey){t.preventDefault();if(!this.graphs.length||this.state.loading)return;const e=this.graphs[0].canvas.getBoundingClientRect();const i=this.graphs[0].chart.chartArea;const s=t.clientX-e.left-i.left;const a=s/(i.right-i.left);const n=this.factorToTimecode(a);if(t.deltaY<0)this.incZoomStep(n,a);else if(t.deltaY>0)this.decZoomStep(n,a)}if(t.shiftKey){let a=Math.abs(t.deltaX)>Math.abs(t.deltaY)?t.deltaX:t.deltaY;for(let s of this.graphs){const e=s.canvas.getBoundingClientRect();if(t.clientY>=e.top&&t.clientY<=e.bottom){let t=a<0?.9:1/.9;let e=s.chart.options.scales.yAxes[0].ticks;if(e.min===undefined)e.min=s.chart.scales["y-axis-0"].min;if(e.max===undefined)e.max=s.chart.scales["y-axis-0"].max;let i=e.max-e.min;i=i-i*t;e.max-=i*.5;e.min+=i*.5;if(!s.yaxisLock){s.yaxisLock=2;this.updateScaleLockState(s,true)}s.chart.options.scales.yAxes[0].ticks.removeEdgeTicks=true;s.chart.update();break}}}}matchWildcardPattern(t){t=t.replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\-]","g"),"\\$&");t=t.replace(/\\\*/g,".*");return new RegExp("^"+t+"$","i")}addEntitySelected(t){if(this.state.loading)return;let e=t.target?t.target.id=="b8_0"?0:1:-1;if(e<0)return;const i=this.ui.inputField[e]?.value;for(let t of this.ui.inputField)if(t)t.value="";if(i.indexOf("*")>=0){const s=this._this.querySelector(isMobile?`#es_${e}`:`#b6_${this.cid}`);if(!s)return;const a=this.matchWildcardPattern(i);for(let t of Array.from(s.children)){const i=t.innerText;if(a.test(i)){if(this._hass.states[i]==undefined)continue;this.addDynamicGraph(i);this.pconfig.entities.push(i)}}}else{if(this._hass.states[i]==undefined)return;this.addDynamicGraph(i);this.pconfig.entities.push(i)}this.updateHistoryWithClearCache();this.writeLocalState()}removeAllEntities(){this.menuSetVisibility(0,false);this.menuSetVisibility(1,false);if(!confirm(i18n("ui.popup.remove_all")))return;let e=0;for(e=0;e=this.firstDynamicId)break;for(let t=e;t=0)this.pconfig.entities.splice(s,1)}this.graphs.splice(e,1);break}}this.updateHistoryWithClearCache();this.writeLocalState()}addFixedGraph(s){if(s.graph.type=="line"||s.graph.type=="bar"){let i=[];for(let e of s.graph.entities){const a=this.getNextDefaultColor();const n=e.color??a.color;let t=e.fill??(e.color?"rgba(0,0,0,0)":a.fill);if(s.graph.type=="bar")t=n;i.push({...e,color:n,fill:t})}this.addGraphToCanvas(s.id,s.graph.type,i,s.graph.options)}else this.addGraphToCanvas(s.id,s.graph.type,s.graph.entities,s.graph.options);if(s.graph.type=="bar")this._this.querySelector(`#bd-${s.id}`)?.addEventListener("change",this.selectBarInterval.bind(this));if(s.graph.type=="line"||s.graph.type=="bar")this._this.querySelector(`#ca-${s.id}`)?.addEventListener("click",this.scaleLockClicked.bind(this))}addDynamicGraph(t){if(this._hass.states[t]==undefined)return;var e=this.getEntityOptions(t);const i=this.getUnitOfMeasure(t);const s=this.getStateClass(t);const a=e?.type?e.type:s==="total_increasing"?"bar":i==undefined&&s!=="measurement"?"timeline":"line";let n=[{entity:t,color:"#000000",fill:"#00000000",process:e?.process}];if(a=="line"||a=="arrowline"||a=="bar"){if(e?.color){n[0].color=e?.color;n[0].fill=e?.fill??"rgba(0,0,0,0)"}else{const p=this.getNextDefaultColor();n[0].color=p.color;n[0].fill=e?.fill??p.fill}n[0].dashMode=e?.dashMode;n[0].width=e?.width;n[0].lineMode=e?.lineMode;n[0].scale=e?.scale;n[0].hidden=e?.hidden;n[0].netBars=e?.netBars;if(a=="bar"){n[0].fill=n[0].color;n[0].lineMode=e?.lineMode??"lines"}}const o=this.graphs.length-1;let r=o>=0&&a!="bar"&&this.graphs[o].type===a&&(a=="timeline"||this.pconfig.combineSameUnits&&this.getUnitOfMeasure(t)==this.getUnitOfMeasure(this.graphs[o].entities[0].entity));if(r){n=this.graphs[this.graphs.length-1].entities.concat(n);this.graphs[this.graphs.length-1].canvas.parentNode.remove();this.graphs.length--}const l=this.calcGraphHeight(a,n.length,e?.height);let h="";h+=`
`;h+=``;h+=``;if(a=="bar"&&!this.ui.hideInterval)h+=this.createIntervalSelectorHtml(this.g_id,l,this.parseIntervalConfig(e?.interval),this.ui.optionStyle);if(a=="line"||a=="bar")h+=this.createScaleLockIconHtml(this.g_id,l);h+=`
`;let c=document.createElement("div");c.innerHTML=h;let d=this._this.querySelector("#graphlist");d.appendChild(c);if(a=="bar"&&!this.ui.hideInterval)this._this.querySelector(`#bd-${this.g_id}`).addEventListener("change",this.selectBarInterval.bind(this));if(a=="line"||a=="bar")this._this.querySelector(`#ca-${this.g_id}`)?.addEventListener("click",this.scaleLockClicked.bind(this));this._this.querySelector(`#bc-${this.g_id}`).addEventListener("click",this.removeGraph.bind(this));this.addGraphToCanvas(this.g_id++,a,n,e)}addGraphToCanvas(t,e,i,s){const a=this._this.querySelector(`#graph${t}`);let n=[];for(let t of i){n.push({name:t.name===undefined?this._hass.states[t.entity]?.attributes?.friendly_name:t.name,bColor:parseColor(t.color),fillColor:parseColor(t.fill),dashMode:t.dashMode,mode:t.lineMode||this.pconfig.defaultLineMode,width:t.width||2,unit:this.getUnitOfMeasure(t.entity,t.unit),domain:this.getDomainForEntity(t.entity),device_class:this.getDeviceClass(t.entity),hidden:t.hidden,entity_id:t.entity})}const o=this.newGraph(a,e,n,s);const r=this.calcGraphHeight(e,i.length,s?.height);const l=this.parseIntervalConfig(s?.interval)??1;const h={id:t,type:e,canvas:a,graphHeight:r,chart:o,entities:i,interval:l};this.graphs.push(h);a.addEventListener("pointerdown",this.pointerDown.bind(this));a.addEventListener("pointermove",this.pointerMove.bind(this));a.addEventListener("pointerup",this.pointerUp.bind(this));a.addEventListener("pointercancel",this.pointerCancel.bind(this));if(e=="line"||e=="bar")this.updateScaleLockState(h,false)}addUIHtml(t,e,i,s,a,n,o){let r="";if((t||e)&&this.ui.stickyTools&1<`}if(t||e)r+=`
`;const l=``;if(t)r+=`
@@ -67,7 +67,7 @@ -
`;if(t||e)r+=`
`;r+=``;if((t||e)&&this.ui.stickyTools&1<`;return r}insertUIHtmlText(t){let e=this._this.querySelector(`#ef_${t}`);if(e)e.innerHTML=i18n("ui.menu.export_csv");let i=this._this.querySelector(`#eh_${t}`);if(i)i.innerHTML=i18n("ui.menu.export_stats");let s=this._this.querySelector(`#eg_${t}`);if(s)s.innerHTML=i18n("ui.menu.remove_all");let a=this._this.querySelector(`#ei_${t}`);if(a)a.innerHTML=infoPanelEnabled?i18n("ui.menu.disable_panel"):i18n("ui.menu.enable_panel");let n=this._this.querySelector(`#by_${t}`);if(n){n.children[0].innerHTML=i18n("ui.ranges.l_hour");n.children[1].innerHTML=i18n("ui.ranges.hour");n.children[2].innerHTML=i18n("ui.ranges.n_hours",2);n.children[3].innerHTML=i18n("ui.ranges.n_hours",3);n.children[4].innerHTML=i18n("ui.ranges.n_hours",4);n.children[5].innerHTML=i18n("ui.ranges.n_hours",5);n.children[6].innerHTML=i18n("ui.ranges.n_hours",6);n.children[7].innerHTML=i18n("ui.ranges.n_hours",7);n.children[8].innerHTML=i18n("ui.ranges.n_hours",8);n.children[9].innerHTML=i18n("ui.ranges.n_hours",9);n.children[10].innerHTML=i18n("ui.ranges.n_hours",10);n.children[11].innerHTML=i18n("ui.ranges.n_hours",11);n.children[12].innerHTML=i18n("ui.ranges.n_hours",12);n.children[13].innerHTML=i18n("ui.ranges.day");n.children[14].innerHTML=i18n("ui.ranges.n_days",2);n.children[15].innerHTML=i18n("ui.ranges.n_days",3);n.children[16].innerHTML=i18n("ui.ranges.n_days",4);n.children[17].innerHTML=i18n("ui.ranges.n_days",5);n.children[18].innerHTML=i18n("ui.ranges.n_days",6);n.children[19].innerHTML=i18n("ui.ranges.week");n.children[20].innerHTML=i18n("ui.ranges.n_weeks",2);n.children[21].innerHTML=i18n("ui.ranges.n_weeks",3);n.children[22].innerHTML=i18n("ui.ranges.month");n.children[23].innerHTML=i18n("ui.ranges.n_months",3);n.children[24].innerHTML=i18n("ui.ranges.n_months",6);n.children[25].innerHTML=i18n("ui.ranges.year")}}resize(){const t=this._this.querySelector("#maincard").clientWidth;if(Math.abs(this.lastWidth-t)>2){const e=this.computeTickDensity(t)!=this.computeTickDensity(this.lastWidth);this.lastWidth=t;for(let t of this.graphs)t.chart.resize(undefined,t.graphHeight);if(e)this.setStepSize(true)}this.resizeSelector()}adjustSelectorPosition(t,e){const i=this._this.querySelector(`#rf_${e}`);const s=this._this.querySelector(`#sl_${e}`);s.style.display="inline-block";const a=i.style.display!=="none";if(!t&&a){i.style.display="none";const n=this._this.querySelector(`#dl_${e}`);n.after(s)}else if(t&&!a){i.style.display="block";i.appendChild(s)}}resizeSelector(){const i=120;const s=220;const a=500;const n=this._this.querySelector("#maincard").clientWidth;for(let e=0;e<2;++e){const o=this._this.querySelector(`#b7_${e}`);if(o){let t=n-i-(this._this.querySelector(`#dl_${e}`)?.clientWidth??0)-(this._this.querySelector(`#dr_${e}`)?.clientWidth??0);const r=t{this.resize()});e.observe(this._this.querySelector("#maincard"));this.writeInfoPanelConfig();if(this.pconfig.refreshInterval)setInterval(this.refresh.bind(this),this.pconfig.refreshInterval*1e3)}}refresh(){this.cache[this.cacheSize].valid=false;this.updateHistory()}updateContent(){if(!this.contentValid){let t=this._this.querySelector("#maincard").clientWidth;if(t>0){clearInterval(this.iid);this.createContent();this.iid=null}}}menuSetVisibility(e,t){const i=this._this.querySelector(`#eo_${e}`);if(!i)return;this._this.querySelector(`#bo_${e}`).style.transform=t?"scale(1,-1)":"scale(1,1)";if(t){i.style.display="block";const s=this._this.querySelector("#maincard").clientWidth-4;let t=this._this.querySelector(`#bo_${e}`).offsetLeft-30;if(t+i.clientWidth>=s){t=s-i.clientWidth}i.style.left=t+"px"}else i.style.display="none"}menuClicked(t){if(!t.currentTarget)return;const e=t.currentTarget.id.substr(3)*1;this.menuSetVisibility(e,this._this.querySelector(`#eo_${e}`)?.style.display=="none")}setDropdownVisibility(t,e){let i=this._this.querySelector(`#b7_${t}`);let s=this._this.querySelector(`#es_${t}`);if(!i||!s)return;if(e){s.style["min-width"]=i.clientWidth+"px";s.style.display="block";for(let t of s.getElementsByTagName("a"))t.style.display="block"}else s.style.display="none"}entitySelectorFocus(t){if(!t.target)return;const e=t.target.id.substr(3)*1;this.setDropdownVisibility(e^1,false);this.setDropdownVisibility(e,true);this.focusClick=true;if(!this.focusListener){this.focusListener=true;window.addEventListener("click",this.defocusCall)}}entitySelectorDefocus(t){if(!this.focusClick){window.removeEventListener("click",this.defocusCall);this.focusListener=undefined;this.setDropdownVisibility(0,false);this.setDropdownVisibility(1,false)}else this.focusClick=undefined}entitySelectorEntered(t){if(!t.target)return;const e=t.target.id.substr(3)*1;let i=this._this.querySelector(`#es_${e}`);let s=this._this.querySelector(`#b7_${e}`);let a=s.value.toLowerCase();let n=i.getElementsByTagName("a");for(let e of n){let t=e.textContent;if(t.toLowerCase().indexOf(a)>=0)e.style.display="block";else e.style.display="none"}}entitySelectorEntryClicked(t){window.removeEventListener("click",this.defocusCall);this.focusListener=undefined;const e=t.target.href.slice(-1);let i=this._this.querySelector(`#b7_${e}`);let s=this._this.querySelector(`#es_${e}`);i.value=t.target.id;s.style.display="none"}buildFilterRegexList(){let e=[];if(this.pconfig.filterEntities){if(Array.isArray(this.pconfig.filterEntities)){for(let t of this.pconfig.filterEntities)if(t)e.push(this.matchWildcardPattern(t))}else e.push(this.matchWildcardPattern(this.pconfig.filterEntities))}return e}matchRegexList(e,i){if(!e.length)return true;for(let t of e)if(t.test(i))return true;return false}entityCollectorCallback(e){for(let s=0;s<(isMobile?2:1);++s){const a=this._this.querySelector(isMobile?`#es_${s}`:`#b6_${this.cid}`);if(!a)continue;while(a.firstChild)a.removeChild(a.firstChild);const n=this.buildFilterRegexList();let i=[];for(let t in e){if(this.matchRegexList(n,t))i.push(t)}i.sort();for(let e of i){let t;if(isMobile){t=document.createElement("a");t.href=`#s_${s}`;t.id=e;t.style="display:block;padding:2px 5px;text-decoration:none;color:inherit";t.addEventListener("click",this.entitySelectorEntryClicked.bind(this),true)}else t=document.createElement("option");t.innerHTML=e;a.appendChild(t)}}for(let t of this.ui.inputField)if(t)t.placeholder=i18n("ui.label.type_to_search")}entityCollectorFailed(t){console.log(t);this.entityCollectAll();for(let t of this.ui.inputField)if(t)t.placeholder=i18n("ui.label.error_retreiving")}entityCollectAll(){for(let s=0;s<(isMobile?2:1);++s){const a=this._this.querySelector(isMobile?`#es_${s}`:`#b6_${this.cid}`);if(!a)continue;while(a.firstChild)a.removeChild(a.firstChild);const e=this.buildFilterRegexList();let i=[];for(let t in this._hass.states){if(!this.matchRegexList(e,t))continue;const n=this.getDomainForEntity(t);if(!["automation","script","zone","camera","persistent_notification","timer"].includes(n)){i.push(t)}}i.sort();for(let e of i){let t;if(isMobile){t=document.createElement("a");t.href=`#s_${s}`;t.id=e;t.style="display:block;padding:2px 5px;text-decoration:none;color:inherit";t.addEventListener("click",this.entitySelectorEntryClicked.bind(this),true)}else t=document.createElement("option");t.innerHTML=e;a.appendChild(t)}}for(let t of this.ui.inputField)if(t)t.placeholder=i18n("ui.label.type_to_search")}requestEntityCollection(){if(this.entitiesPopulated)return;this.entitiesPopulated=true;if(this.ui.hideSelector)return;this.ui.inputField[0]=this._this.querySelector(`#b7_0`);this.ui.inputField[1]=this._this.querySelector(`#b7_1`);if(this.pconfig.recordedEntitiesOnly){for(let t of this.ui.inputField)if(t)t.placeholder=i18n("ui.label.loading");const t=moment().subtract(1,"hour").format("YYYY-MM-DDTHH:mm:ss");const i=this.buildFilterRegexList();let e=[];for(let t in this._hass.states){if(!this.matchRegexList(i,t))continue;const s=this.getDomainForEntity(t);if(!["automation","script","zone","camera","persistent_notification","timer"].includes(s))e.push(t)}const s={type:"history/history_during_period",start_time:t,minimal_response:true,no_attributes:true,entity_ids:e};this._hass.callWS(s).then(this.entityCollectorCallback.bind(this),this.entityCollectorFailed.bind(this))}else this.entityCollectAll()}initLocalization(){if(this.i18n.valid)return;let t=this._hass.language?this._hass.language:"en-GB";setLanguage(t);this.ui.wideInterval=["da","nl","sv","sk","ru"].includes(t);const e=getLocalizedDateString(t,{dateStyle:"medium"});this.i18n.styleDateTicks=e[0]=="D"?"D MMM":"MMM D";this.i18n.styleDateSelector=isMobile?this.i18n.styleDateTicks:e;if(this._hass.locale?.time_format==="24")t="en-GB";if(this._hass.locale?.time_format==="12")t="en-US";this.i18n.styleTimeTicks=getLocalizedDateString(t,{timeStyle:"short"});this.i18n.styleDateTimeTooltip=this.i18n.styleDateTicks+", "+getLocalizedDateString(t,{timeStyle:"medium"});this.i18n.valid=true}writeLocalState(){const t={version:1,entities:this.pconfig.entities};window.localStorage.removeItem("history-explorer-card");window.localStorage.removeItem("history-explorer_card_"+this.id);window.localStorage.setItem("history-explorer_card_"+this.id,JSON.stringify(t))}readLocalState(){let t=JSON.parse(window.localStorage.getItem("history-explorer_card_"+this.id));if(t&&t.version===1){this.pconfig.entities=t.entities}else{t=JSON.parse(window.localStorage.getItem("history-explorer-card"));if(t)this.pconfig.entities=t;else this.pconfig.entities=[]}}writeInfoPanelConfig(t=false){if(!infoPanelEnabled){window.localStorage.removeItem("history-explorer-info-panel")}else if(infoPanelEnabled&&(this.pconfig.infoPanelConfig||t)){let t={};t.enabled=true;t.config=this.pconfig.infoPanelConfig;window.localStorage.removeItem("history-explorer-info-panel");window.localStorage.setItem("history-explorer-info-panel",JSON.stringify(t))}}handleChangedEntities(){if(!this.pconfig.showCurrentValues&&!this.pconfig.refreshEnabled)return false;let t=false;for(let s of this.graphs){let i=0;for(let e of s.entities){const a=this._hass.states[e.entity].last_changed;if(this.stateMap.has(e.entity)&&a!=this.stateMap.get(e.entity)){if(this.pconfig.showCurrentValues){let t=s.chart.data.datasets[i];t.label=this.getFormattedLabelName(t.name,e.entity,t.unit)}t=true}this.stateMap.set(e.entity,a);i++}}return t}buildEntityExclusionList(e){let i=[];if(e)for(let t of e){const s=this.matchWildcardPattern(t.entity);if(s)i.push(s)}return i}buildGraphListFromConfig(s){const a=function(e,i){for(let t of i)if(t.test(e))return true;return false};for(let t=0;t=0){const n=this.buildEntityExclusionList(e.exclude);const o=this.matchWildcardPattern(e.entity);for(let t in this._hass.states){if(o&&o.test(t)&&!a(t,n)){i.entities.push({...e,entity:t})}}}else i.entities.push(e)}this.pconfig.graphConfig.push({graph:i,id:this.g_id++})}}}function isSingleSymbol(t){return t.length==1&&t[0].toLowerCase()==t[0].toUpperCase()}function getLocalizedDateString(t,e){let i=new Intl.DateTimeFormat(t,e).formatToParts(new Date);return i.map(t=>{switch(t.type){case"year":return"YYYY";case"month":return"MMM";case"day":return"D";case"hour":return i.findIndex(t=>t.type=="dayPeriod")>=0?"h":"HH";case"minute":return"mm";case"second":return"ss";case"dayPeriod":return"a";default:return[".",",","/","-"].includes(t.value)||!isSingleSymbol(t.value)?" ":t.value}}).join("")}var gcid=0;class HistoryExplorerCard extends HTMLElement{instance=null;configSet=false;set hass(t){if(this.configSet){this.configSet=false;this.InitWithConfig(t)}if(!this.instance)return;this.instance._this=this;this.instance._hass=t;this.instance.version=t.config.version.split(".").map(Number);if(!this.instance.i18n.valid)this.instance.initLocalization();if(!this.instance.entitiesPopulated)this.instance.requestEntityCollection();if(!this.instance.contentValid&&!this.instance.iid)this.instance.iid=setInterval(this.instance.updateContent.bind(this.instance),100);if(this.instance.contentValid&&this.instance.handleChangedEntities()){if(this.instance.pconfig.showCurrentValues)this.instance.updateHistory();if(this.instance.pconfig.refreshEnabled){this.instance.cache[this.instance.cacheSize].valid=false;if(this.instance.tid)clearTimeout(this.instance.tid);this.instance.tid=setTimeout(this.instance.updateHistoryAutoRefresh.bind(this.instance),2e3)}}}set panel(t){this.setConfig(t.config)}setConfig(t){this.config=t;this.configSet=true}InitWithConfig(t){const e=this.config;if(!this.instance)this.instance=new HistoryCardState;this.instance._hass=t;this.instance.g_id=0;this.instance.pconfig.graphConfig=[];if(e.graphs)this.instance.buildGraphListFromConfig(e.graphs);this.instance.firstDynamicId=this.instance.g_id;this.instance.pconfig.customStateColors={};if(e.stateColors){for(let t in e.stateColors){this.instance.pconfig.customStateColors[t]=parseColor(e.stateColors[t])}}this.instance.pconfig.entityOptions=e.entityOptions;this.instance.pconfig.labelAreaWidth=e.labelAreaWidth??65;this.instance.pconfig.labelsVisible=e.labelsVisible??true;this.instance.pconfig.hideLegend=e.legendVisible==false?true:undefined;this.instance.pconfig.showTooltipColors[0]=e.tooltip?.showColorsLine??e.showTooltipColorsLine??true;this.instance.pconfig.showTooltipColors[1]=e.tooltip?.showColorsTimeline??e.showTooltipColorsTimeline??true;this.instance.pconfig.tooltipSize=e.tooltip?.size??e.tooltipSize??"auto";this.instance.pconfig.tooltipShowDuration=e.tooltip?.showDuration??e.tooltipShowDuration??false;this.instance.pconfig.tooltipShowLabel=e.tooltip?.showLabel??true;this.instance.pconfig.tooltipStateTextMode=e.tooltip?.stateTextMode??e.stateTextMode??"raw";this.instance.pconfig.colorSeed=e.stateColorSeed??137;this.instance.pconfig.stateTextMode=e.stateTextMode??"raw";this.instance.pconfig.decimation=e.decimation;this.instance.pconfig.roundingPrecision=e.rounding||2;this.instance.pconfig.defaultLineMode=e.lineMode;this.instance.pconfig.showUnavailable=e.showUnavailable??false;this.instance.pconfig.showCurrentValues=e.showCurrentValues??false;this.instance.pconfig.axisAddMarginMin=e.axisAddMarginMin!==undefined?e.axisAddMarginMin:false;this.instance.pconfig.axisAddMarginMax=e.axisAddMarginMax!==undefined?e.axisAddMarginMax:false;this.instance.pconfig.recordedEntitiesOnly=e.recordedEntitiesOnly??false;this.instance.pconfig.filterEntities=e.filterEntities;this.instance.pconfig.combineSameUnits=e.combineSameUnits===true;this.instance.pconfig.defaultTimeRange=e.defaultTimeRange??"24";this.instance.pconfig.defaultTimeOffset=e.defaultTimeOffset??undefined;this.instance.pconfig.timeTickDensity=e.timeTickDensity??"high";this.instance.pconfig.lineGraphHeight=(e.lineGraphHeight??250)*1;this.instance.pconfig.barGraphHeight=(e.barGraphHeight??150)*1;this.instance.pconfig.timelineBarHeight=(e.timelineBarHeight??24)*1;this.instance.pconfig.timelineBarSpacing=(e.timelineBarSpacing??40)*1;this.instance.pconfig.refreshEnabled=e.refresh?.automatic??false;this.instance.pconfig.refreshInterval=e.refresh?.interval??undefined;this.instance.pconfig.exportSeparator=e.csv?.separator;this.instance.pconfig.exportTimeFormat=e.csv?.timeFormat;this.instance.pconfig.exportAttributes=e.csv?.exportAttributes;this.instance.pconfig.exportStatsPeriod=e.csv?.statisticsPeriod??"hour";this.instance.statistics.enabled=e.statistics?.enabled??true;this.instance.statistics.mode=e.statistics?.mode??"mean";this.instance.statistics.retention=e.statistics?.retention??undefined;this.instance.statistics.period=e.statistics?.period??"hour";this.instance.statistics.force=e.statistics?.force??undefined;this.instance.pconfig.closeButtonColor=parseColor(e.uiColors?.closeButton??"#0000001f");this.instance.pconfig.infoPanelConfig=e.infoPanel;this.instance.id=e.cardName??"default";this.instance.cid=gcid++;this.instance.contentValid=false;this.instance.entitiesPopulated=false;const i=e.header||"History explorer";const s=parseColor(e.uiColors?.buttons??getComputedStyle(document.body).getPropertyValue("--primary-color")+"1f");const a={hide:0,top:1,bottom:2,both:3};const n=a[e.uiLayout?.toolbar]??1;const o=a[e.uiLayout?.selector]??2;this.instance.ui.stickyTools=a[e.uiLayout?.sticky]??0;this.instance.ui.hideSelector=o===0;const r=e.uiLayout?.invertZoom===true;const l=`style="color:var(--primary-text-color);background-color:var(--card-background-color)"`;const h=e.uiColors?.selector?`style="color:var(--primary-text-color);background-color:${e.uiColors.selector};border:1px solid black;"`:"";this.instance.ui.optionStyle=l;this.instance.ui.hideHeader=i==="hide";this.instance.ui.hideInterval=e.uiLayout?.interval==="hide";let c=` +
`;if(t||e)r+=``;r+=``;if((t||e)&&this.ui.stickyTools&1<`;return r}insertUIHtmlText(t){let e=this._this.querySelector(`#ef_${t}`);if(e)e.innerHTML=i18n("ui.menu.export_csv");let i=this._this.querySelector(`#eh_${t}`);if(i)i.innerHTML=i18n("ui.menu.export_stats");let s=this._this.querySelector(`#eg_${t}`);if(s)s.innerHTML=i18n("ui.menu.remove_all");let a=this._this.querySelector(`#ei_${t}`);if(a)a.innerHTML=infoPanelEnabled?i18n("ui.menu.disable_panel"):i18n("ui.menu.enable_panel");let n=this._this.querySelector(`#by_${t}`);if(n){n.children[0].innerHTML=i18n("ui.ranges.l_hour");n.children[1].innerHTML=i18n("ui.ranges.hour");n.children[2].innerHTML=i18n("ui.ranges.n_hours",2);n.children[3].innerHTML=i18n("ui.ranges.n_hours",3);n.children[4].innerHTML=i18n("ui.ranges.n_hours",4);n.children[5].innerHTML=i18n("ui.ranges.n_hours",5);n.children[6].innerHTML=i18n("ui.ranges.n_hours",6);n.children[7].innerHTML=i18n("ui.ranges.n_hours",7);n.children[8].innerHTML=i18n("ui.ranges.n_hours",8);n.children[9].innerHTML=i18n("ui.ranges.n_hours",9);n.children[10].innerHTML=i18n("ui.ranges.n_hours",10);n.children[11].innerHTML=i18n("ui.ranges.n_hours",11);n.children[12].innerHTML=i18n("ui.ranges.n_hours",12);n.children[13].innerHTML=i18n("ui.ranges.day");n.children[14].innerHTML=i18n("ui.ranges.n_days",2);n.children[15].innerHTML=i18n("ui.ranges.n_days",3);n.children[16].innerHTML=i18n("ui.ranges.n_days",4);n.children[17].innerHTML=i18n("ui.ranges.n_days",5);n.children[18].innerHTML=i18n("ui.ranges.n_days",6);n.children[19].innerHTML=i18n("ui.ranges.week");n.children[20].innerHTML=i18n("ui.ranges.n_weeks",2);n.children[21].innerHTML=i18n("ui.ranges.n_weeks",3);n.children[22].innerHTML=i18n("ui.ranges.month");n.children[23].innerHTML=i18n("ui.ranges.n_months",3);n.children[24].innerHTML=i18n("ui.ranges.n_months",6);n.children[25].innerHTML=i18n("ui.ranges.year")}}resize(){const t=this._this.querySelector("#maincard").clientWidth;if(Math.abs(this.lastWidth-t)>2){const e=this.computeTickDensity(t)!=this.computeTickDensity(this.lastWidth);this.lastWidth=t;for(let t of this.graphs)t.chart.resize(undefined,t.graphHeight);if(e)this.setStepSize(true)}this.resizeSelector()}adjustSelectorPosition(t,e){const i=this._this.querySelector(`#rf_${e}`);const s=this._this.querySelector(`#sl_${e}`);s.style.display="inline-block";const a=i.style.display!=="none";if(!t&&a){i.style.display="none";const n=this._this.querySelector(`#dl_${e}`);n.after(s)}else if(t&&!a){i.style.display="block";i.appendChild(s)}}resizeSelector(){const i=120;const s=220;const a=500;const n=this._this.querySelector("#maincard").clientWidth;for(let e=0;e<2;++e){const o=this._this.querySelector(`#b7_${e}`);if(o){let t=n-i-(this._this.querySelector(`#dl_${e}`)?.clientWidth??0)-(this._this.querySelector(`#dr_${e}`)?.clientWidth??0);const r=t{this.resize()});e.observe(this._this.querySelector("#maincard"));this.writeInfoPanelConfig();if(this.pconfig.refreshInterval)setInterval(this.refresh.bind(this),this.pconfig.refreshInterval*1e3)}}refresh(){this.cache[this.cacheSize].valid=false;this.updateHistory()}updateContent(){if(!this.contentValid){let t=this._this.querySelector("#maincard").clientWidth;if(t>0){clearInterval(this.iid);this.createContent();this.iid=null}}}menuSetVisibility(e,t){const i=this._this.querySelector(`#eo_${e}`);if(!i)return;this._this.querySelector(`#bo_${e}`).style.transform=t?"scale(1,-1)":"scale(1,1)";if(t){i.style.display="block";const s=this._this.querySelector("#maincard").clientWidth-4;let t=this._this.querySelector(`#bo_${e}`).offsetLeft-30;if(t+i.clientWidth>=s){t=s-i.clientWidth}i.style.left=t+"px"}else i.style.display="none"}menuClicked(t){if(!t.currentTarget)return;const e=t.currentTarget.id.substr(3)*1;this.menuSetVisibility(e,this._this.querySelector(`#eo_${e}`)?.style.display=="none")}setDropdownVisibility(t,e){let i=this._this.querySelector(`#b7_${t}`);let s=this._this.querySelector(`#es_${t}`);if(!i||!s)return;if(e){s.style["min-width"]=i.clientWidth+"px";s.style.display="block";for(let t of s.getElementsByTagName("a"))t.style.display="block"}else s.style.display="none"}entitySelectorFocus(t){if(!t.target)return;const e=t.target.id.substr(3)*1;this.setDropdownVisibility(e^1,false);this.setDropdownVisibility(e,true);this.focusClick=true;if(!this.focusListener){this.focusListener=true;window.addEventListener("click",this.defocusCall)}}entitySelectorDefocus(t){if(!this.focusClick){window.removeEventListener("click",this.defocusCall);this.focusListener=undefined;this.setDropdownVisibility(0,false);this.setDropdownVisibility(1,false)}else this.focusClick=undefined}entitySelectorEntered(t){if(!t.target)return;const e=t.target.id.substr(3)*1;let i=this._this.querySelector(`#es_${e}`);let s=this._this.querySelector(`#b7_${e}`);let a=s.value.toLowerCase();let n=i.getElementsByTagName("a");for(let e of n){let t=e.textContent;if(t.toLowerCase().indexOf(a)>=0)e.style.display="block";else e.style.display="none"}}entitySelectorEntryClicked(t){window.removeEventListener("click",this.defocusCall);this.focusListener=undefined;const e=t.target.href.slice(-1);let i=this._this.querySelector(`#b7_${e}`);let s=this._this.querySelector(`#es_${e}`);i.value=t.target.id;s.style.display="none"}buildFilterRegexList(){let e=[];if(this.pconfig.filterEntities){if(Array.isArray(this.pconfig.filterEntities)){for(let t of this.pconfig.filterEntities)if(t)e.push(this.matchWildcardPattern(t))}else e.push(this.matchWildcardPattern(this.pconfig.filterEntities))}return e}matchRegexList(e,i){if(!e.length)return true;for(let t of e)if(t.test(i))return true;return false}entityCollectorCallback(e){for(let s=0;s<(isMobile?2:1);++s){const a=this._this.querySelector(isMobile?`#es_${s}`:`#b6_${this.cid}`);if(!a)continue;while(a.firstChild)a.removeChild(a.firstChild);const n=this.buildFilterRegexList();let i=[];for(let t in e){if(this.matchRegexList(n,t))i.push(t)}i.sort();for(let e of i){let t;if(isMobile){t=document.createElement("a");t.href=`#s_${s}`;t.id=e;t.style="display:block;padding:2px 5px;text-decoration:none;color:inherit";t.addEventListener("click",this.entitySelectorEntryClicked.bind(this),true)}else t=document.createElement("option");t.innerHTML=e;a.appendChild(t)}}for(let t of this.ui.inputField)if(t)t.placeholder=i18n("ui.label.type_to_search")}entityCollectorFailed(t){console.log(t);this.entityCollectAll();for(let t of this.ui.inputField)if(t)t.placeholder=i18n("ui.label.error_retreiving")}entityCollectAll(){for(let s=0;s<(isMobile?2:1);++s){const a=this._this.querySelector(isMobile?`#es_${s}`:`#b6_${this.cid}`);if(!a)continue;while(a.firstChild)a.removeChild(a.firstChild);const e=this.buildFilterRegexList();let i=[];for(let t in this._hass.states){if(!this.matchRegexList(e,t))continue;const n=this.getDomainForEntity(t);if(!["automation","script","zone","camera","persistent_notification","timer"].includes(n)){i.push(t)}}i.sort();for(let e of i){let t;if(isMobile){t=document.createElement("a");t.href=`#s_${s}`;t.id=e;t.style="display:block;padding:2px 5px;text-decoration:none;color:inherit";t.addEventListener("click",this.entitySelectorEntryClicked.bind(this),true)}else t=document.createElement("option");t.innerHTML=e;a.appendChild(t)}}for(let t of this.ui.inputField)if(t)t.placeholder=i18n("ui.label.type_to_search")}requestEntityCollection(){if(this.entitiesPopulated)return;this.entitiesPopulated=true;if(this.ui.hideSelector)return;this.ui.inputField[0]=this._this.querySelector(`#b7_0`);this.ui.inputField[1]=this._this.querySelector(`#b7_1`);if(this.pconfig.recordedEntitiesOnly){for(let t of this.ui.inputField)if(t)t.placeholder=i18n("ui.label.loading");const t=moment().subtract(1,"hour").format("YYYY-MM-DDTHH:mm:ss");const i=this.buildFilterRegexList();let e=[];for(let t in this._hass.states){if(!this.matchRegexList(i,t))continue;const s=this.getDomainForEntity(t);if(!["automation","script","zone","camera","persistent_notification","timer"].includes(s))e.push(t)}const s={type:"history/history_during_period",start_time:t,minimal_response:true,no_attributes:true,entity_ids:e};this._hass.callWS(s).then(this.entityCollectorCallback.bind(this),this.entityCollectorFailed.bind(this))}else this.entityCollectAll()}initLocalization(){if(this.i18n.valid)return;let t=this._hass.language?this._hass.language:"en-GB";setLanguage(t);this.ui.wideInterval=["da","nl","sv","sk","ru"].includes(t);const e=getLocalizedDateString(t,{dateStyle:"medium"});this.i18n.styleDateTicks=this.pconfig.timeTickShortDate?"D":e[0]=="D"?"D MMM":"MMM D";this.i18n.styleDateSelector=isMobile?this.i18n.styleDateTicks:e;if(this._hass.locale?.time_format==="24")t="en-GB";if(this._hass.locale?.time_format==="12")t="en-US";this.i18n.styleTimeTicks=getLocalizedDateString(t,{timeStyle:"short"});this.i18n.styleDateTimeTooltip=this.i18n.styleDateTicks+", "+getLocalizedDateString(t,{timeStyle:"medium"});this.i18n.valid=true}writeLocalState(){const t={version:1,entities:this.pconfig.entities};window.localStorage.removeItem("history-explorer-card");window.localStorage.removeItem("history-explorer_card_"+this.id);window.localStorage.setItem("history-explorer_card_"+this.id,JSON.stringify(t))}readLocalState(){let t=JSON.parse(window.localStorage.getItem("history-explorer_card_"+this.id));if(t&&t.version===1){this.pconfig.entities=t.entities}else{t=JSON.parse(window.localStorage.getItem("history-explorer-card"));if(t)this.pconfig.entities=t;else this.pconfig.entities=[]}}writeInfoPanelConfig(t=false){if(!infoPanelEnabled){window.localStorage.removeItem("history-explorer-info-panel")}else if(infoPanelEnabled&&(this.pconfig.infoPanelConfig||t)){let t={};t.enabled=true;t.config=this.pconfig.infoPanelConfig;window.localStorage.removeItem("history-explorer-info-panel");window.localStorage.setItem("history-explorer-info-panel",JSON.stringify(t))}}handleChangedEntities(){if(!this.pconfig.showCurrentValues&&!this.pconfig.refreshEnabled)return false;let t=false;for(let s of this.graphs){let i=0;for(let e of s.entities){const a=this._hass.states[e.entity].last_changed;if(this.stateMap.has(e.entity)&&a!=this.stateMap.get(e.entity)){if(this.pconfig.showCurrentValues){let t=s.chart.data.datasets[i];t.label=this.getFormattedLabelName(t.name,e.entity,t.unit)}t=true}this.stateMap.set(e.entity,a);i++}}return t}buildEntityExclusionList(e){let i=[];if(e)for(let t of e){const s=this.matchWildcardPattern(t.entity);if(s)i.push(s)}return i}buildGraphListFromConfig(s){const a=function(e,i){for(let t of i)if(t.test(e))return true;return false};for(let t=0;t=0){const n=this.buildEntityExclusionList(e.exclude);const o=this.matchWildcardPattern(e.entity);for(let t in this._hass.states){if(o&&o.test(t)&&!a(t,n)){i.entities.push({...e,entity:t})}}}else i.entities.push(e)}this.pconfig.graphConfig.push({graph:i,id:this.g_id++})}}}function isSingleSymbol(t){return t.length==1&&t[0].toLowerCase()==t[0].toUpperCase()}function getLocalizedDateString(t,e){let i=new Intl.DateTimeFormat(t,e).formatToParts(new Date);return i.map(t=>{switch(t.type){case"year":return"YYYY";case"month":return"MMM";case"day":return"D";case"hour":return i.findIndex(t=>t.type=="dayPeriod")>=0?"h":"HH";case"minute":return"mm";case"second":return"ss";case"dayPeriod":return"a";default:return[".",",","/","-"].includes(t.value)||!isSingleSymbol(t.value)?" ":t.value}}).join("")}var gcid=0;class HistoryExplorerCard extends HTMLElement{instance=null;configSet=false;set hass(t){if(this.configSet){this.configSet=false;this.InitWithConfig(t)}if(!this.instance)return;this.instance._this=this;this.instance._hass=t;this.instance.version=t.config.version.split(".").map(Number);if(!this.instance.i18n.valid)this.instance.initLocalization();if(!this.instance.entitiesPopulated)this.instance.requestEntityCollection();if(!this.instance.contentValid&&!this.instance.iid)this.instance.iid=setInterval(this.instance.updateContent.bind(this.instance),100);if(this.instance.contentValid&&this.instance.handleChangedEntities()){if(this.instance.pconfig.showCurrentValues)this.instance.updateHistory();if(this.instance.pconfig.refreshEnabled){this.instance.cache[this.instance.cacheSize].valid=false;if(this.instance.tid)clearTimeout(this.instance.tid);this.instance.tid=setTimeout(this.instance.updateHistoryAutoRefresh.bind(this.instance),2e3)}}}set panel(t){this.setConfig(t.config)}setConfig(t){this.config=t;this.configSet=true}InitWithConfig(t){const e=this.config;if(!this.instance)this.instance=new HistoryCardState;this.instance._hass=t;this.instance.g_id=0;this.instance.pconfig.graphConfig=[];if(e.graphs)this.instance.buildGraphListFromConfig(e.graphs);this.instance.firstDynamicId=this.instance.g_id;this.instance.pconfig.customStateColors={};if(e.stateColors){for(let t in e.stateColors){this.instance.pconfig.customStateColors[t]=parseColor(e.stateColors[t])}}this.instance.pconfig.entityOptions=e.entityOptions;this.instance.pconfig.labelAreaWidth=e.labelAreaWidth??65;this.instance.pconfig.labelsVisible=e.labelsVisible??true;this.instance.pconfig.hideLegend=e.legendVisible==false?true:undefined;this.instance.pconfig.showTooltipColors[0]=e.tooltip?.showColorsLine??e.showTooltipColorsLine??true;this.instance.pconfig.showTooltipColors[1]=e.tooltip?.showColorsTimeline??e.showTooltipColorsTimeline??true;this.instance.pconfig.tooltipSize=e.tooltip?.size??e.tooltipSize??"auto";this.instance.pconfig.tooltipShowDuration=e.tooltip?.showDuration??e.tooltipShowDuration??false;this.instance.pconfig.tooltipShowLabel=e.tooltip?.showLabel??true;this.instance.pconfig.tooltipStateTextMode=e.tooltip?.stateTextMode??e.stateTextMode??"raw";this.instance.pconfig.colorSeed=e.stateColorSeed??137;this.instance.pconfig.stateTextMode=e.stateTextMode??"raw";this.instance.pconfig.decimation=e.decimation;this.instance.pconfig.roundingPrecision=e.rounding||2;this.instance.pconfig.defaultLineMode=e.lineMode;this.instance.pconfig.showUnavailable=e.showUnavailable??false;this.instance.pconfig.showCurrentValues=e.showCurrentValues??false;this.instance.pconfig.axisAddMarginMin=e.axisAddMarginMin!==undefined?e.axisAddMarginMin:false;this.instance.pconfig.axisAddMarginMax=e.axisAddMarginMax!==undefined?e.axisAddMarginMax:false;this.instance.pconfig.recordedEntitiesOnly=e.recordedEntitiesOnly??false;this.instance.pconfig.filterEntities=e.filterEntities;this.instance.pconfig.combineSameUnits=e.combineSameUnits===true;this.instance.pconfig.defaultTimeRange=e.defaultTimeRange??"24";this.instance.pconfig.defaultTimeOffset=e.defaultTimeOffset??undefined;this.instance.pconfig.timeTickDensity=e.timeTicks?.density??e.timeTickDensity??"high";this.instance.pconfig.timeTickOverride=e.timeTicks?.densityOverride??undefined;this.instance.pconfig.timeTickShortDate=e.timeTicks?.dateFormat==="short";this.instance.pconfig.lineGraphHeight=(e.lineGraphHeight??250)*1;this.instance.pconfig.barGraphHeight=(e.barGraphHeight??150)*1;this.instance.pconfig.timelineBarHeight=(e.timelineBarHeight??24)*1;this.instance.pconfig.timelineBarSpacing=(e.timelineBarSpacing??40)*1;this.instance.pconfig.refreshEnabled=e.refresh?.automatic??false;this.instance.pconfig.refreshInterval=e.refresh?.interval??undefined;this.instance.pconfig.exportSeparator=e.csv?.separator;this.instance.pconfig.exportTimeFormat=e.csv?.timeFormat;this.instance.pconfig.exportAttributes=e.csv?.exportAttributes;this.instance.pconfig.exportStatsPeriod=e.csv?.statisticsPeriod??"hour";this.instance.statistics.enabled=e.statistics?.enabled??true;this.instance.statistics.mode=e.statistics?.mode??"mean";this.instance.statistics.retention=e.statistics?.retention??undefined;this.instance.statistics.period=e.statistics?.period??"hour";this.instance.statistics.force=e.statistics?.force??undefined;this.instance.pconfig.closeButtonColor=parseColor(e.uiColors?.closeButton??"#0000001f");this.instance.pconfig.infoPanelConfig=e.infoPanel;this.instance.id=e.cardName??"default";this.instance.cid=gcid++;this.instance.contentValid=false;this.instance.entitiesPopulated=false;const i=e.header||"History explorer";const s=parseColor(e.uiColors?.buttons??getComputedStyle(document.body).getPropertyValue("--primary-color")+"1f");const a={hide:0,top:1,bottom:2,both:3};const n=a[e.uiLayout?.toolbar]??1;const o=a[e.uiLayout?.selector]??2;this.instance.ui.stickyTools=a[e.uiLayout?.sticky]??0;this.instance.ui.hideSelector=o===0;const r=e.uiLayout?.invertZoom===true;const l=`style="color:var(--primary-text-color);background-color:var(--card-background-color)"`;const h=e.uiColors?.selector?`style="color:var(--primary-text-color);background-color:${e.uiColors.selector};border:1px solid black;"`:"";this.instance.ui.optionStyle=l;this.instance.ui.hideHeader=i==="hide";this.instance.ui.hideInterval=e.uiLayout?.interval==="hide";let c=` ${this.instance.addUIHtml(n&1,o&1,s,l,h,r,0)}
@@ -77,7 +77,7 @@ ${(n|o)&2&&!(this.instance.ui.stickyTools&2)?"
":""} - `;this.innerHTML=c;this.instance.ui.spinOverlay=document.createElement("div");this.instance.ui.spinOverlay.style="position:fixed;display:block;width:100%;height:100%;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,0.5);z-index:2;backdrop-filter:blur(5px)";this.instance.ui.spinOverlay.innerHTML=``}getCardSize(){return 3}static getStubConfig(){return{cardName:"historycard-"+Math.floor(Math.random()*99999999+1)}}}console.info(`%c HISTORY-EXPLORER-CARD %c Version ${Version}`,"color:white;background:blue;font-weight:bold","color:black;background:white;font-weight:bold");customElements.define("history-explorer-card",HistoryExplorerCard);window.customCards=window.customCards||[];window.customCards.push({type:"history-explorer-card",name:"History Explorer Card",preview:false,description:"An interactive history viewer card"});var defaultColors=[{color:"#3e95cd",fill:"rgba(151,187,205,0.15)"},{color:"#95cd3e",fill:"rgba(187,205,151,0.15)"},{color:"#cd3e3e",fill:"rgba(205,151,151,0.15)"},{color:"#3ecd95",fill:"rgba(151,205,187,0.15)"},{color:"#cd953e",fill:"rgba(205,187,151,0.15)"},{color:"#953ecd",fill:"rgba(187,151,205,0.15)"},{color:"#175ec8",fill:"rgba(151,187,205,0.15)"},{color:"#ff7f00",fill:"rgba(225,179,133,0.15)"},{color:"#cd3e95",fill:"rgba(205,151,187,0.15)"}];const defaultGood="#66a61e";const defaultBad="#b5342d";const defaultMultiple="#e5ad23";const activeRed="#cd3e3e";const activeGreen="#3ecd3e";const multipleRed="rgb(213, 142, 142)";const multipleGreen="rgb(142, 213, 142)";const defaultInactiveLight="#dddddd";const defaultInactiveDark="#383838";const stateColors={unknown:"#888888",unavailable:"#aaaaaa",idle:"#aaaaaa",on:activeRed,off:defaultInactiveLight,"binary_sensor.multiple":multipleRed,"battery_charging.on":activeGreen,"battery_charging.multiple":multipleGreen,"plug.on":activeGreen,"plug.multiple":multipleGreen,"running.on":activeGreen,"running.multiple":multipleGreen,"update.on":activeGreen,"update.multiple":multipleGreen,"connectivity.on":defaultGood,"connectivity.off":defaultBad,"connectivity.multiple":defaultMultiple,"power.on":defaultGood,"power.off":defaultBad,"power.multiple":defaultMultiple,"presence.on":defaultGood,"presence.off":defaultBad,"presence.multiple":defaultMultiple,"gas.on":defaultBad,"gas.off":defaultGood,"gas.multiple":defaultMultiple,"smoke.on":defaultBad,"smoke.off":defaultGood,"smoke.multiple":defaultMultiple,"problem.on":defaultBad,"problem.off":defaultGood,"problem.multiple":defaultMultiple,"safety.on":defaultBad,"safety.off":defaultGood,"safety.multiple":defaultMultiple,"person.home":"#66a61e","person.not_home":"#b5342d","person.arriving":"#d5bd43","person.leaving":"#d5bd43","person.multiple":"#e5ad23","weather.cloudy":"#91acce","weather.fog":"#adadad","weather.rainy":"#5285df","weather.partlycloudy":"#11a3e9","weather.sunny":"#e9db11","weather.multiple":"#aaaaaa","automation.on":activeGreen,"automation.multiple":multipleGreen,"input_select.Arret":defaultInactiveLight,"input_select.Eco":"#44739e","input_select.Confort - 2":"#53b8ba","input_select.Confort - 1":"#984ea3","input_select.Confort":"#e99745","sensor.WCDMA":"#44739e","sensor.LTE":"#984ea3"};const stateColorsDark={off:defaultInactiveDark,"input_select.Arret":defaultInactiveDark};function parseColor(e){if(e&&e.constructor==Object)return e;while(e&&e.startsWith("--"))e=getComputedStyle(document.body).getPropertyValue(e);return e}function parseColorRange(t,l){let a,o,n,r;for(let e in t){const i=e*1;if(l>=i&&(n==undefined||i>n)){a=t[e];n=i}if(l0){this.overlay=s.ui.spinOverlay;document.body.appendChild(this.overlay);let t={type:"history/history_during_period",start_time:moment(e).format("YYYY-MM-DDTHH:mm:ssZ"),end_time:moment(r).format("YYYY-MM-DDTHH:mm:ssZ"),minimal_response:!this.saveAttributes,no_attributes:!this.saveAttributes,entity_ids:a};s._hass.callWS(t).then(this.exportCallback.bind(this),this.exportFailed.bind(this))}}}class StatisticsCSVExporter{constructor(){this.overlay=null;this.separator=undefined;this.timeFormat=undefined}exportCallback(e){let s=[];s.push(`Time stamp${this.separator}State${this.separator}Mean${this.separator}Min${this.separator}Max\r\n`);for(let t in e){const i=e[t];if(!i.length)continue;s.push(t+"\r\n");for(let t of i){const r=moment(t.start).format(this.timeFormat);s.push(r+this.separator+(t.state??"")+this.separator+(t["mean"]??"")+this.separator+(t["min"]??"")+this.separator+(t["max"]??"")+"\r\n")}}const t=new Blob(s,{type:"text/plain;charset=utf-8"});document.body.removeChild(this.overlay);saveAs(t,"entities-"+moment().format("YYYY-MM-DD_HH:mm:ss")+".csv")}exportFailed(t){document.body.removeChild(this.overlay);console.log(t)}exportFile(s){this.separator=s.pconfig.exportSeparator??",";this.timeFormat=s.pconfig.exportTimeFormat??"YYYY-MM-DD HH:mm:ss";let i=0;let e=s.startTime.replace("+","%2b");let r=s.endTime.replace("+","%2b");let a=[];for(let e of s.graphs){for(let t of e.entities){a.push(t.entity);i++}}if(i>0){this.overlay=s.ui.spinOverlay;document.body.appendChild(this.overlay);let t={type:s.version[0]>2022||s.version[1]>=11?"recorder/statistics_during_period":"history/statistics_during_period",start_time:moment(e).format("YYYY-MM-DDTHH:mm:ssZ"),end_time:moment(r).format("YYYY-MM-DDTHH:mm:ssZ"),period:s.pconfig.exportStatsPeriod??"hour",statistic_ids:a};s._hass.callWS(t).then(this.exportCallback.bind(this),this.exportFailed.bind(this))}}}var _STATE_ATTRIBUTES=["entity_id","assumed_state","attribution","custom_ui_more_info","custom_ui_state_card","device_class","editable","emulated_hue_name","emulated_hue","entity_picture","friendly_name","haaska_hidden","haaska_name","icon","initial_state","last_reset","restored","state_class","supported_features","unit_of_measurement"];const litHtml=t=>{return(o,...e)=>{return{_$litType$:t,strings:o,values:e}}};const html=litHtml(1);let hec_panel={};hec_panel.config=null;hec_panel.show=undefined;hec_panel.entity=null;hec_panel.iid=null;hec_panel.lc=null;function hecHookInfoPanel(){let o=customElements.get("ha-more-info-history");if(!o)return;clearInterval(hec_panel.iid);hec_panel.iid=null;o.prototype._databaseCallback=function(o){if(hec_panel.show===undefined){hec_panel.show=o;if(!o){let o=this.shadowRoot.querySelector("#maincard");if(o)o.style.display="none"}}};o.prototype._setEntityOptions=function(e){const o=this.__entityId;const t=e.getEntityOptions(o);const i=e.getUnitOfMeasure(o);const n=e.getStateClass(o);const l=t?.type?t.type:n==="total_increasing"?"bar":i==undefined&&n!=="measurement"?"timeline":"line";e.pconfig.nextDefaultColor=0;e.pconfig.labelAreaWidth=l=="timeline"||l=="arrowline"?0:55;let a=[{entity:o,process:t?.process}];if(l=="line"||l=="arrowline"||l=="bar"){if(t?.color){a[0].color=t?.color;a[0].fill=t?.fill??"rgba(0,0,0,0)"}else{const s=e.getNextDefaultColor();a[0].color=s.color;a[0].fill=t?.fill??s.fill}a[0].width=t?.width??1.001;a[0].lineMode=t?.lineMode;a[0].scale=t?.scale;if(l=="bar"){a[0].fill=a[0].color;a[0].lineMode=t?.lineMode??"lines"}}const r={type:l,entities:a,options:t};e.pconfig.graphConfig=[];e.pconfig.graphConfig.push({graph:r,id:e.g_id});e.graphs=[];for(let o of e.pconfig.graphConfig)e.addFixedGraph(o)};o.prototype._injectHistoryExplorer=function(e){e.initLocalization();e.insertUIHtmlText(0);for(let o=0;o<1;o++){e._this.querySelector(`#b1_${o}`)?.addEventListener("click",e.subDay.bind(e),false);e._this.querySelector(`#b2_${o}`)?.addEventListener("click",e.addDay.bind(e),false);e._this.querySelector(`#b4_${o}`)?.addEventListener("click",e.decZoom.bind(e),false);e._this.querySelector(`#b5_${o}`)?.addEventListener("click",e.incZoom.bind(e),false);e._this.querySelector(`#bx_${o}`)?.addEventListener("click",e.todayNoReset.bind(e),false);e._this.querySelector(`#bx_${o}`)?.addEventListener("dblclick",e.todayReset.bind(e),false);e._this.querySelector(`#by_${o}`)?.addEventListener("change",e.timeRangeSelected.bind(e));e._this.querySelector(`#bz_${o}`)?.addEventListener("click",e.toggleZoom.bind(e),false);e._this.querySelector(`#bo_${o}`)?.addEventListener("click",e.menuClicked.bind(e),false);e.ui.dateSelector[o]=e._this.querySelector(`#bx_${o}`);e.ui.rangeSelector[o]=e._this.querySelector(`#by_${o}`);e.ui.zoomButton[o]=e._this.querySelector(`#bz_${o}`)}if(!isMobile)e._this.querySelector("#maincard").addEventListener("wheel",e.wheelScrolled.bind(e),{passive:false});const t=hec_panel.config??{};e.g_id=0;e.pconfig.customStateColors={};e.stateColors={...stateColors};e.stateColorsDark={...stateColorsDark};e.stateColors["off"]=defaultGood;e.stateColors["binary_sensor.multiple"]="#e5ad23";e.stateColors["battery_charging.off"]=defaultInactiveLight;e.stateColors["plug.off"]=defaultInactiveLight;e.stateColors["running.off"]=defaultInactiveLight;e.stateColors["update.on"]=defaultInactiveLight;e.stateColorsDark["battery_charging.off"]=defaultInactiveDark;e.stateColorsDark["plug.off"]=defaultInactiveDark;e.stateColorsDark["running.off"]=defaultInactiveDark;e.stateColorsDark["update.on"]=defaultInactiveDark;if(t.stateColors){for(let o in t.stateColors){e.pconfig.customStateColors[o]=parseColor(t.stateColors[o])}}e.pconfig.entityOptions=t.entityOptions;e.pconfig.labelsVisible=false;e.pconfig.showTooltipColors[0]=t.tooltip?.showColorsLine??t.showTooltipColorsLine??true;e.pconfig.showTooltipColors[1]=t.tooltip?.showColorsTimeline??t.showTooltipColorsTimeline??true;e.pconfig.tooltipSize=t.tooltip?.size??t.tooltipSize??"auto";e.pconfig.tooltipShowDuration=t.tooltip?.showDuration??t.tooltipShowDuration??true;e.pconfig.tooltipShowLabel=t.tooltip?.showLabel??true;e.pconfig.tooltipStateTextMode=t.tooltip?.stateTextMode??t.stateTextMode??"auto";e.pconfig.colorSeed=t.stateColorSeed??137;e.pconfig.stateTextMode=t.stateTextMode??"auto";e.pconfig.decimation=t.decimation;e.pconfig.roundingPrecision=t.rounding||2;e.pconfig.defaultLineMode=t.lineMode??"lines";e.pconfig.showUnavailable=t.showUnavailable??false;e.pconfig.showCurrentValues=false;e.pconfig.axisAddMarginMin=t.axisAddMarginMin!==undefined?t.axisAddMarginMin:false;e.pconfig.axisAddMarginMax=t.axisAddMarginMax!==undefined?t.axisAddMarginMax:false;e.pconfig.recordedEntitiesOnly=false;e.pconfig.filterEntities=null;e.pconfig.combineSameUnits=false;e.pconfig.defaultTimeRange=t.defaultTimeRange??"24";e.pconfig.defaultTimeOffset=t.defaultTimeOffset??undefined;e.pconfig.timeTickDensity=t.timeTickDensity??"high";e.pconfig.lineGraphHeight=(t.lineGraphHeight??250)*1;e.pconfig.barGraphHeight=(t.barGraphHeight??150)*1;e.pconfig.timelineBarHeight=(t.timelineBarHeight??24)*1;e.pconfig.timelineBarSpacing=40;e.pconfig.hideLegend=true;e.pconfig.refreshEnabled=t.refresh?.automatic!==undefined?t.refresh.automatic:true;e.pconfig.refreshInterval=undefined;e.statistics.enabled=t.statistics?.enabled??true;e.statistics.mode=t.statistics?.mode??"mean";e.statistics.retention=t.statistics?.retention??undefined;e.statistics.period=t.statistics?.period??"hour";e.statistics.force=undefined;e.ui.darkMode=e._hass.selectedTheme&&e._hass.selectedTheme.dark||e._hass.themes&&e._hass.themes.darkMode;if(t.uimode){if(t.uimode==="dark")e.ui.darkMode=true;else if(t.uimode==="light")e.ui.darkMode=false}e.pconfig.graphLabelColor=parseColor(t.uiColors?.labels??(e.ui.darkMode?"#9b9b9b":"#333"));e.pconfig.graphGridColor=parseColor(t.uiColors?.gridlines??(e.ui.darkMode?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.1)"));this._setEntityOptions(e);e.contentValid=true;e.databaseCallback=this._databaseCallback.bind(this);e.setTimeRangeFromString(String(e.pconfig.defaultTimeRange));e.today(false);let o=new ResizeObserver(o=>{for(let o of e.graphs)o.chart.resize(undefined,o.graphHeight);e.setStepSize(true)});o.observe(this)};function a(o){return o.substr(0,o.indexOf("."))}function r(o,e){return o.states[e]?.attributes?.device_class}function g(o,e,t){let i=e?.[t];if(!i){const n=r(o,t);i=n?e?.[n]:undefined;if(!i){const l=a(t);i=l?e?.[l]:undefined}}return i??undefined}function f(o,e){if(hec_panel?.config?.exclude){return hec_panel.config.exclude[e]||hec_panel.config.exclude[a(e)]||hec_panel.config.exclude[r(o,e)]}return false}o.prototype._hec_updated=function(o){if(!this.hec_instance){hec_panel.show=undefined;y();this.hec_instance=new HistoryCardState;this.hec_instance._this=this.shadowRoot;this.hec_instance._hass=this.__hass;this.hec_instance.version=this.__hass.config.version.split(".").map(Number);if(f(this.__hass,this.__entityId)){return this._oldUpdated(o)}this._injectHistoryExplorer(this.hec_instance);hec_panel.lc=this.__hass.states[this.__entityId]?.last_changed}else{if(this._recreate){this._recreate=false;this._setEntityOptions(this.hec_instance);this.hec_instance.updateHistoryWithClearCache()}const e=this.__hass.states[this.__entityId]?.last_changed;if(hec_panel.lc!=e){hec_panel.lc=e;if(this.hec_instance.pconfig.refreshEnabled){this.hec_instance.cache[this.hec_instance.cacheSize].valid=false;if(this.hec_instance.tid)clearTimeout(this.hec_instance.tid);this.hec_instance.tid=setTimeout(this.hec_instance.updateHistoryAutoRefresh.bind(this.hec_instance),2e3)}}}};function b(o){switch(o){case"line":return hec_panel?.config?.lineGraphHeight??250;case"bar":return(hec_panel?.config?.barGraphHeight??150)+24;default:return 90}}o.prototype._hec_render=function(){if(!this.hec_instance)y();const o=this.__entityId;if(f(this.__hass,o)){return this._oldRender()}const e=g(this.__hass,hec_panel?.config?.entityOptions,o);const t=this.__hass.states[o]?.attributes?.unit_of_measurement;const i=this.__hass.states[o]?.attributes?.state_class;const n=e?.type?e.type:i==="total_increasing"?"bar":t==undefined&&i!=="measurement"?"timeline":"line";const l=b(n);const a="var(--primary-text-color)";const r="var(--card-background-color)";const s=parseColor(hec_panel?.config?.uiColors?.buttons??getComputedStyle(document.body).getPropertyValue("--primary-color")+"1f");const c=parseColor(hec_panel?.config?.uiColors?.closeButton??"#0000001f");const d=hec_panel?.config?.uiLayout?.toolbar!="hide";const p=hec_panel?.config?.uiLayout?.invertZoom===true;const h=hec_panel?.config?.uiLayout?.interval!="hide";if(hec_panel.entity!==this.__entityId){hec_panel.entity=this.__entityId;hec_panel.show=undefined;if(this.hec_instance)this._recreate=true}const u=0;if(d){return html` + `;this.innerHTML=c;this.instance.ui.spinOverlay=document.createElement("div");this.instance.ui.spinOverlay.style="position:fixed;display:block;width:100%;height:100%;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,0.5);z-index:2;backdrop-filter:blur(5px)";this.instance.ui.spinOverlay.innerHTML=``}getCardSize(){return 3}static getStubConfig(){return{cardName:"historycard-"+Math.floor(Math.random()*99999999+1)}}}console.info(`%c HISTORY-EXPLORER-CARD %c Version ${Version}`,"color:white;background:blue;font-weight:bold","color:black;background:white;font-weight:bold");customElements.define("history-explorer-card",HistoryExplorerCard);window.customCards=window.customCards||[];window.customCards.push({type:"history-explorer-card",name:"History Explorer Card",preview:false,description:"An interactive history viewer card"});var defaultColors=[{color:"#3e95cd",fill:"rgba(151,187,205,0.15)"},{color:"#95cd3e",fill:"rgba(187,205,151,0.15)"},{color:"#cd3e3e",fill:"rgba(205,151,151,0.15)"},{color:"#3ecd95",fill:"rgba(151,205,187,0.15)"},{color:"#cd953e",fill:"rgba(205,187,151,0.15)"},{color:"#953ecd",fill:"rgba(187,151,205,0.15)"},{color:"#175ec8",fill:"rgba(151,187,205,0.15)"},{color:"#ff7f00",fill:"rgba(225,179,133,0.15)"},{color:"#cd3e95",fill:"rgba(205,151,187,0.15)"}];const defaultGood="#66a61e";const defaultBad="#b5342d";const defaultMultiple="#e5ad23";const activeRed="#cd3e3e";const activeGreen="#3ecd3e";const multipleRed="rgb(213, 142, 142)";const multipleGreen="rgb(142, 213, 142)";const defaultInactiveLight="#dddddd";const defaultInactiveDark="#383838";const stateColors={unknown:"#888888",unavailable:"#aaaaaa",idle:"#aaaaaa",on:activeRed,off:defaultInactiveLight,"binary_sensor.multiple":multipleRed,"battery_charging.on":activeGreen,"battery_charging.multiple":multipleGreen,"plug.on":activeGreen,"plug.multiple":multipleGreen,"running.on":activeGreen,"running.multiple":multipleGreen,"update.on":activeGreen,"update.multiple":multipleGreen,"connectivity.on":defaultGood,"connectivity.off":defaultBad,"connectivity.multiple":defaultMultiple,"power.on":defaultGood,"power.off":defaultBad,"power.multiple":defaultMultiple,"presence.on":defaultGood,"presence.off":defaultBad,"presence.multiple":defaultMultiple,"gas.on":defaultBad,"gas.off":defaultGood,"gas.multiple":defaultMultiple,"smoke.on":defaultBad,"smoke.off":defaultGood,"smoke.multiple":defaultMultiple,"problem.on":defaultBad,"problem.off":defaultGood,"problem.multiple":defaultMultiple,"safety.on":defaultBad,"safety.off":defaultGood,"safety.multiple":defaultMultiple,"person.home":"#66a61e","person.not_home":"#b5342d","person.arriving":"#d5bd43","person.leaving":"#d5bd43","person.multiple":"#e5ad23","weather.cloudy":"#91acce","weather.fog":"#adadad","weather.rainy":"#5285df","weather.partlycloudy":"#11a3e9","weather.sunny":"#e9db11","weather.multiple":"#aaaaaa","automation.on":activeGreen,"automation.multiple":multipleGreen,"input_select.Arret":defaultInactiveLight,"input_select.Eco":"#44739e","input_select.Confort - 2":"#53b8ba","input_select.Confort - 1":"#984ea3","input_select.Confort":"#e99745","sensor.WCDMA":"#44739e","sensor.LTE":"#984ea3"};const stateColorsDark={off:defaultInactiveDark,"input_select.Arret":defaultInactiveDark};function parseColor(e){if(e&&e.constructor==Object)return e;while(e&&e.startsWith("--"))e=getComputedStyle(document.body).getPropertyValue(e);return e}function parseColorRange(t,l){let a,o,n,r;for(let e in t){const i=e*1;if(l>=i&&(n==undefined||i>n)){a=t[e];n=i}if(l0){this.overlay=s.ui.spinOverlay;document.body.appendChild(this.overlay);let t={type:"history/history_during_period",start_time:moment(e).format("YYYY-MM-DDTHH:mm:ssZ"),end_time:moment(r).format("YYYY-MM-DDTHH:mm:ssZ"),minimal_response:!this.saveAttributes,no_attributes:!this.saveAttributes,entity_ids:a};s._hass.callWS(t).then(this.exportCallback.bind(this),this.exportFailed.bind(this))}}}class StatisticsCSVExporter{constructor(){this.overlay=null;this.separator=undefined;this.timeFormat=undefined}exportCallback(e){let s=[];s.push(`Time stamp${this.separator}State${this.separator}Mean${this.separator}Min${this.separator}Max\r\n`);for(let t in e){const i=e[t];if(!i.length)continue;s.push(t+"\r\n");for(let t of i){const r=moment(t.start).format(this.timeFormat);s.push(r+this.separator+(t.state??"")+this.separator+(t["mean"]??"")+this.separator+(t["min"]??"")+this.separator+(t["max"]??"")+"\r\n")}}const t=new Blob(s,{type:"text/plain;charset=utf-8"});document.body.removeChild(this.overlay);saveAs(t,"entities-"+moment().format("YYYY-MM-DD_HH:mm:ss")+".csv")}exportFailed(t){document.body.removeChild(this.overlay);console.log(t)}exportFile(s){this.separator=s.pconfig.exportSeparator??",";this.timeFormat=s.pconfig.exportTimeFormat??"YYYY-MM-DD HH:mm:ss";let i=0;let e=s.startTime.replace("+","%2b");let r=s.endTime.replace("+","%2b");let a=[];for(let e of s.graphs){for(let t of e.entities){a.push(t.entity);i++}}if(i>0){this.overlay=s.ui.spinOverlay;document.body.appendChild(this.overlay);let t={type:s.version[0]>2022||s.version[1]>=11?"recorder/statistics_during_period":"history/statistics_during_period",start_time:moment(e).format("YYYY-MM-DDTHH:mm:ssZ"),end_time:moment(r).format("YYYY-MM-DDTHH:mm:ssZ"),period:s.pconfig.exportStatsPeriod??"hour",statistic_ids:a};s._hass.callWS(t).then(this.exportCallback.bind(this),this.exportFailed.bind(this))}}}var _STATE_ATTRIBUTES=["entity_id","assumed_state","attribution","custom_ui_more_info","custom_ui_state_card","device_class","editable","emulated_hue_name","emulated_hue","entity_picture","friendly_name","haaska_hidden","haaska_name","icon","initial_state","last_reset","restored","state_class","supported_features","unit_of_measurement"];const litHtml=t=>{return(e,...o)=>{return{_$litType$:t,strings:e,values:o}}};const html=litHtml(1);let hec_panel={};hec_panel.config=null;hec_panel.show=undefined;hec_panel.entity=null;hec_panel.iid=null;hec_panel.lc=null;function hecHookInfoPanel(){let e=customElements.get("ha-more-info-history");if(!e)return;clearInterval(hec_panel.iid);hec_panel.iid=null;e.prototype._databaseCallback=function(e){if(hec_panel.show===undefined){hec_panel.show=e;if(!e){let e=this.shadowRoot.querySelector("#maincard");if(e)e.style.display="none"}}};e.prototype._setEntityOptions=function(o){const e=this.__entityId;const t=o.getEntityOptions(e);const i=o.getUnitOfMeasure(e);const n=o.getStateClass(e);const l=t?.type?t.type:n==="total_increasing"?"bar":i==undefined&&n!=="measurement"?"timeline":"line";o.pconfig.nextDefaultColor=0;o.pconfig.labelAreaWidth=l=="timeline"||l=="arrowline"?0:55;let a=[{entity:e,process:t?.process}];if(l=="line"||l=="arrowline"||l=="bar"){if(t?.color){a[0].color=t?.color;a[0].fill=t?.fill??"rgba(0,0,0,0)"}else{const s=o.getNextDefaultColor();a[0].color=s.color;a[0].fill=t?.fill??s.fill}a[0].width=t?.width??1.001;a[0].lineMode=t?.lineMode;a[0].scale=t?.scale;if(l=="bar"){a[0].fill=a[0].color;a[0].lineMode=t?.lineMode??"lines"}}const r={type:l,entities:a,options:t};o.pconfig.graphConfig=[];o.pconfig.graphConfig.push({graph:r,id:o.g_id});o.graphs=[];for(let e of o.pconfig.graphConfig)o.addFixedGraph(e)};e.prototype._injectHistoryExplorer=function(o){o.initLocalization();o.insertUIHtmlText(0);for(let e=0;e<1;e++){o._this.querySelector(`#b1_${e}`)?.addEventListener("click",o.subDay.bind(o),false);o._this.querySelector(`#b2_${e}`)?.addEventListener("click",o.addDay.bind(o),false);o._this.querySelector(`#b4_${e}`)?.addEventListener("click",o.decZoom.bind(o),false);o._this.querySelector(`#b5_${e}`)?.addEventListener("click",o.incZoom.bind(o),false);o._this.querySelector(`#bx_${e}`)?.addEventListener("click",o.todayNoReset.bind(o),false);o._this.querySelector(`#bx_${e}`)?.addEventListener("dblclick",o.todayReset.bind(o),false);o._this.querySelector(`#by_${e}`)?.addEventListener("change",o.timeRangeSelected.bind(o));o._this.querySelector(`#bz_${e}`)?.addEventListener("click",o.toggleZoom.bind(o),false);o._this.querySelector(`#bo_${e}`)?.addEventListener("click",o.menuClicked.bind(o),false);o.ui.dateSelector[e]=o._this.querySelector(`#bx_${e}`);o.ui.rangeSelector[e]=o._this.querySelector(`#by_${e}`);o.ui.zoomButton[e]=o._this.querySelector(`#bz_${e}`)}if(!isMobile)o._this.querySelector("#maincard").addEventListener("wheel",o.wheelScrolled.bind(o),{passive:false});const t=hec_panel.config??{};o.g_id=0;o.pconfig.customStateColors={};o.stateColors={...stateColors};o.stateColorsDark={...stateColorsDark};o.stateColors["off"]=defaultGood;o.stateColors["binary_sensor.multiple"]="#e5ad23";o.stateColors["battery_charging.off"]=defaultInactiveLight;o.stateColors["plug.off"]=defaultInactiveLight;o.stateColors["running.off"]=defaultInactiveLight;o.stateColors["update.on"]=defaultInactiveLight;o.stateColorsDark["battery_charging.off"]=defaultInactiveDark;o.stateColorsDark["plug.off"]=defaultInactiveDark;o.stateColorsDark["running.off"]=defaultInactiveDark;o.stateColorsDark["update.on"]=defaultInactiveDark;if(t.stateColors){for(let e in t.stateColors){o.pconfig.customStateColors[e]=parseColor(t.stateColors[e])}}o.pconfig.entityOptions=t.entityOptions;o.pconfig.labelsVisible=false;o.pconfig.showTooltipColors[0]=t.tooltip?.showColorsLine??t.showTooltipColorsLine??true;o.pconfig.showTooltipColors[1]=t.tooltip?.showColorsTimeline??t.showTooltipColorsTimeline??true;o.pconfig.tooltipSize=t.tooltip?.size??t.tooltipSize??"auto";o.pconfig.tooltipShowDuration=t.tooltip?.showDuration??t.tooltipShowDuration??true;o.pconfig.tooltipShowLabel=t.tooltip?.showLabel??true;o.pconfig.tooltipStateTextMode=t.tooltip?.stateTextMode??t.stateTextMode??"auto";o.pconfig.colorSeed=t.stateColorSeed??137;o.pconfig.stateTextMode=t.stateTextMode??"auto";o.pconfig.decimation=t.decimation;o.pconfig.roundingPrecision=t.rounding||2;o.pconfig.defaultLineMode=t.lineMode??"lines";o.pconfig.showUnavailable=t.showUnavailable??false;o.pconfig.showCurrentValues=false;o.pconfig.axisAddMarginMin=t.axisAddMarginMin!==undefined?t.axisAddMarginMin:false;o.pconfig.axisAddMarginMax=t.axisAddMarginMax!==undefined?t.axisAddMarginMax:false;o.pconfig.recordedEntitiesOnly=false;o.pconfig.filterEntities=null;o.pconfig.combineSameUnits=false;o.pconfig.defaultTimeRange=t.defaultTimeRange??"24";o.pconfig.defaultTimeOffset=t.defaultTimeOffset??undefined;o.pconfig.timeTickDensity=t.timeTicks?.density??t.timeTickDensity??"high";o.pconfig.timeTickOverride=t.timeTicks?.densityOverride??undefined;o.pconfig.timeTickShortDate=t.timeTicks?.dateFormat==="short";o.pconfig.lineGraphHeight=(t.lineGraphHeight??250)*1;o.pconfig.barGraphHeight=(t.barGraphHeight??150)*1;o.pconfig.timelineBarHeight=(t.timelineBarHeight??24)*1;o.pconfig.timelineBarSpacing=40;o.pconfig.hideLegend=true;o.pconfig.refreshEnabled=t.refresh?.automatic!==undefined?t.refresh.automatic:true;o.pconfig.refreshInterval=undefined;o.statistics.enabled=t.statistics?.enabled??true;o.statistics.mode=t.statistics?.mode??"mean";o.statistics.retention=t.statistics?.retention??undefined;o.statistics.period=t.statistics?.period??"hour";o.statistics.force=undefined;o.ui.darkMode=o._hass.selectedTheme&&o._hass.selectedTheme.dark||o._hass.themes&&o._hass.themes.darkMode;if(t.uimode){if(t.uimode==="dark")o.ui.darkMode=true;else if(t.uimode==="light")o.ui.darkMode=false}o.pconfig.graphLabelColor=parseColor(t.uiColors?.labels??(o.ui.darkMode?"#9b9b9b":"#333"));o.pconfig.graphGridColor=parseColor(t.uiColors?.gridlines??(o.ui.darkMode?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.1)"));this._setEntityOptions(o);o.contentValid=true;o.databaseCallback=this._databaseCallback.bind(this);o.setTimeRangeFromString(String(o.pconfig.defaultTimeRange));o.today(false);let e=new ResizeObserver(e=>{for(let e of o.graphs)e.chart.resize(undefined,e.graphHeight);o.setStepSize(true)});e.observe(this)};function a(e){return e.substr(0,e.indexOf("."))}function r(e,o){return e.states[o]?.attributes?.device_class}function g(e,o,t){let i=o?.[t];if(!i){const n=r(e,t);i=n?o?.[n]:undefined;if(!i){const l=a(t);i=l?o?.[l]:undefined}}return i??undefined}function f(e,o){if(hec_panel?.config?.exclude){return hec_panel.config.exclude[o]||hec_panel.config.exclude[a(o)]||hec_panel.config.exclude[r(e,o)]}return false}e.prototype._hec_updated=function(e){if(!this.hec_instance){hec_panel.show=undefined;y();this.hec_instance=new HistoryCardState;this.hec_instance._this=this.shadowRoot;this.hec_instance._hass=this.__hass;this.hec_instance.version=this.__hass.config.version.split(".").map(Number);if(f(this.__hass,this.__entityId)){return this._oldUpdated(e)}this._injectHistoryExplorer(this.hec_instance);hec_panel.lc=this.__hass.states[this.__entityId]?.last_changed}else{if(this._recreate){this._recreate=false;this._setEntityOptions(this.hec_instance);this.hec_instance.updateHistoryWithClearCache()}const o=this.__hass.states[this.__entityId]?.last_changed;if(hec_panel.lc!=o){hec_panel.lc=o;if(this.hec_instance.pconfig.refreshEnabled){this.hec_instance.cache[this.hec_instance.cacheSize].valid=false;if(this.hec_instance.tid)clearTimeout(this.hec_instance.tid);this.hec_instance.tid=setTimeout(this.hec_instance.updateHistoryAutoRefresh.bind(this.hec_instance),2e3)}}}};function b(e){switch(e){case"line":return hec_panel?.config?.lineGraphHeight??250;case"bar":return(hec_panel?.config?.barGraphHeight??150)+24;default:return 90}}e.prototype._hec_render=function(){if(!this.hec_instance)y();const e=this.__entityId;if(f(this.__hass,e)){return this._oldRender()}const o=g(this.__hass,hec_panel?.config?.entityOptions,e);const t=this.__hass.states[e]?.attributes?.unit_of_measurement;const i=this.__hass.states[e]?.attributes?.state_class;const n=o?.type?o.type:i==="total_increasing"?"bar":t==undefined&&i!=="measurement"?"timeline":"line";const l=b(n);const a="var(--primary-text-color)";const r="var(--card-background-color)";const s=parseColor(hec_panel?.config?.uiColors?.buttons??getComputedStyle(document.body).getPropertyValue("--primary-color")+"1f");const c=parseColor(hec_panel?.config?.uiColors?.closeButton??"#0000001f");const d=hec_panel?.config?.uiLayout?.toolbar!="hide";const p=hec_panel?.config?.uiLayout?.invertZoom===true;const h=hec_panel?.config?.uiLayout?.interval!="hide";if(hec_panel.entity!==this.__entityId){hec_panel.entity=this.__entityId;hec_panel.show=undefined;if(this.hec_instance)this._recreate=true}const u=0;if(d){return html`
@@ -153,4 +153,4 @@
- `}};function y(){let o=JSON.parse(window.localStorage.getItem("history-explorer-info-panel"));if(o)hec_panel.config=o.config}if(infoPanelEnabled){o.prototype._oldUpdated=o.prototype.updated;o.prototype._oldRender=o.prototype.render;o.prototype.updated=o.prototype._hec_updated;o.prototype.render=o.prototype._hec_render}}hec_panel.iid=setInterval(hecHookInfoPanel,100);})(); \ No newline at end of file + `}};function y(){let e=JSON.parse(window.localStorage.getItem("history-explorer-info-panel"));if(e)hec_panel.config=e.config}if(infoPanelEnabled){e.prototype._oldUpdated=e.prototype.updated;e.prototype._oldRender=e.prototype.render;e.prototype.updated=e.prototype._hec_updated;e.prototype.render=e.prototype._hec_render}}hec_panel.iid=setInterval(hecHookInfoPanel,100);})(); \ No newline at end of file diff --git a/src/history-explorer-card.js b/src/history-explorer-card.js index 50a36e7..7ee54bb 100644 --- a/src/history-explorer-card.js +++ b/src/history-explorer-card.js @@ -5,7 +5,7 @@ import "./deps/timeline.js"; import "./deps/md5.min.js" import "./deps/FileSaver.js" -const Version = '1.0.50 dev'; +const Version = '1.0.50'; var isMobile = ( navigator.appVersion.indexOf("Mobi") > -1 ) || ( navigator.userAgent.indexOf("HomeAssistant") > -1 ); @@ -116,6 +116,8 @@ class HistoryCardState { this.pconfig.defaultTimeRange = '24'; this.pconfig.defaultTimeOffset = undefined; this.pconfig.timeTickDensity = 'high'; + this.pconfig.timeTickOverride = undefined; + this.pconfig.timeTickShortDate = false; this.pconfig.refreshEnabled = false; this.pconfig.refreshInterval = undefined; this.pconfig.exportSeparator = undefined; @@ -573,7 +575,10 @@ class HistoryCardState { const densities = { 'low' : 4, 'medium' : 3, 'high' : 2, 'higher' : 1, 'highest' : 0 }; let densityLimit = densities[this.pconfig.timeTickDensity]; if( densityLimit === undefined ) densityLimit = 2; - return Math.max(( width < 650 ) ? 4 : ( width < 1100 ) ? 3 : ( width < 1300 ) ? 2 : ( width < 1900 ) ? 1 : 0, densityLimit); + if( this.pconfig.timeTickOverride === undefined ) + return Math.max(( width < 650 ) ? 4 : ( width < 1100 ) ? 3 : ( width < 1300 ) ? 2 : ( width < 1900 ) ? 1 : 0, densityLimit); + else + return densities[this.pconfig.timeTickOverride] ?? 2; } setStepSize(update = false) @@ -3001,7 +3006,7 @@ class HistoryCardState { this.ui.wideInterval = ['da', 'nl', 'sv', 'sk', 'ru'].includes(locale); const ds = getLocalizedDateString(locale, { dateStyle: 'medium' }); - this.i18n.styleDateTicks = ( ds[0] == 'D' ) ? 'D MMM' : 'MMM D'; + this.i18n.styleDateTicks = this.pconfig.timeTickShortDate ? 'D' : ( ds[0] == 'D' ) ? 'D MMM' : 'MMM D'; this.i18n.styleDateSelector = isMobile ? this.i18n.styleDateTicks : ds; if( this._hass.locale?.time_format === '24' ) locale = 'en-GB'; @@ -3265,7 +3270,9 @@ class HistoryExplorerCard extends HTMLElement this.instance.pconfig.combineSameUnits = config.combineSameUnits === true; this.instance.pconfig.defaultTimeRange = config.defaultTimeRange ?? '24'; this.instance.pconfig.defaultTimeOffset = config.defaultTimeOffset ?? undefined; - this.instance.pconfig.timeTickDensity = config.timeTickDensity ?? 'high'; + this.instance.pconfig.timeTickDensity = config.timeTicks?.density ?? config.timeTickDensity ?? 'high'; + this.instance.pconfig.timeTickOverride = config.timeTicks?.densityOverride ?? undefined; + this.instance.pconfig.timeTickShortDate = config.timeTicks?.dateFormat === 'short'; this.instance.pconfig.lineGraphHeight = ( config.lineGraphHeight ?? 250 ) * 1; this.instance.pconfig.barGraphHeight = ( config.barGraphHeight ?? 150 ) * 1; this.instance.pconfig.timelineBarHeight = ( config.timelineBarHeight ?? 24 ) * 1; diff --git a/src/history-info-panel.js b/src/history-info-panel.js index 1e6abb1..91c1cac 100644 --- a/src/history-info-panel.js +++ b/src/history-info-panel.js @@ -177,7 +177,9 @@ function hecHookInfoPanel() instance.pconfig.combineSameUnits = false; instance.pconfig.defaultTimeRange = config.defaultTimeRange ?? '24'; instance.pconfig.defaultTimeOffset = config.defaultTimeOffset ?? undefined; - instance.pconfig.timeTickDensity = config.timeTickDensity ?? 'high'; + instance.pconfig.timeTickDensity = config.timeTicks?.density ?? config.timeTickDensity ?? 'high'; + instance.pconfig.timeTickOverride = config.timeTicks?.densityOverride ?? undefined; + instance.pconfig.timeTickShortDate = config.timeTicks?.dateFormat === 'short'; instance.pconfig.lineGraphHeight = ( config.lineGraphHeight ?? 250 ) * 1; instance.pconfig.barGraphHeight = ( config.barGraphHeight ?? 150 ) * 1; instance.pconfig.timelineBarHeight = ( config.timelineBarHeight ?? 24 ) * 1;