framework/extensions/statistics/js/dist/admin.js
flarum-bot 0d73e82b0b Bundled output for commit f3d0bdce47
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2022-01-27 21:02:31 +00:00

2 lines
61 KiB
JavaScript
Generated

(()=>{var t={n:e=>{var i=e&&e.__esModule?()=>e.default:()=>e;return t.d(i,{a:i}),i},d:(e,i)=>{for(var n in i)t.o(i,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:i[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e);const i=flarum.core.compat["admin/app"];var n=t.n(i);const s=flarum.core.compat["common/extend"],a=flarum.core.compat["admin/components/DashboardPage"];var r=t.n(a);function o(t,e){return o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},o(t,e)}function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}const c=flarum.core.compat["admin/components/DashboardWidget"];var h=t.n(c);const u=flarum.core.compat["common/components/SelectDropdown"];var d=t.n(u);const p=flarum.core.compat["common/components/Button"];var f=t.n(p);const v=flarum.core.compat["common/helpers/icon"];var g=t.n(v);const y=flarum.core.compat["common/utils/abbreviateNumber"];var b=t.n(y);function x(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function w(t){var e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}}x.create=function(t,e){var i=document.createElement(t);for(var n in e){var s=e[n];if("inside"===n)x(s).appendChild(i);else if("around"===n){var a=x(s);a.parentNode.insertBefore(i,a),i.appendChild(a)}else"styles"===n?"object"==typeof s&&Object.keys(s).map((function(t){i.style[t]=s[t]})):n in i?i[n]=s:i.setAttribute(n,s)}return i};var A={margins:{top:10,bottom:10,left:20,right:20},paddings:{top:20,bottom:40,left:30,right:10},baseHeight:240,titleHeight:20,legendHeight:30,titleFontSize:12};function P(t){return t.titleHeight+t.margins.top+t.paddings.top}function k(t){return t.margins.left+t.paddings.left}function M(t){return t.margins.top+t.margins.bottom+t.paddings.top+t.paddings.bottom+t.titleHeight+t.legendHeight}function T(t){return t.margins.left+t.margins.right+t.paddings.left+t.paddings.right}var L=["line","bar"],C=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta","light-grey","dark-grey"],D={bar:C,line:C,pie:C,percentage:C,heatmap:["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],donut:C},N=Math.PI/180,S=function(){function t(t){var e=t.parent,i=void 0===e?null:e,n=t.colors,s=void 0===n?[]:n;this.parent=i,this.colors=s,this.titleName="",this.titleValue="",this.listValues=[],this.titleValueFirst=0,this.x=0,this.y=0,this.top=0,this.left=0,this.setup()}var e=t.prototype;return e.setup=function(){this.makeTooltip()},e.refresh=function(){this.fill(),this.calcPosition()},e.makeTooltip=function(){var t=this;this.container=x.create("div",{inside:this.parent,className:"graph-svg-tip comparison",innerHTML:'<span class="title"></span>\n\t\t\t\t<ul class="data-point-list"></ul>\n\t\t\t\t<div class="svg-pointer"></div>'}),this.hideTip(),this.title=this.container.querySelector(".title"),this.dataPointList=this.container.querySelector(".data-point-list"),this.parent.addEventListener("mouseleave",(function(){t.hideTip()}))},e.fill=function(){var t,e=this;this.index&&this.container.setAttribute("data-point-index",this.index),t=this.titleValueFirst?"<strong>"+this.titleValue+"</strong>"+this.titleName:this.titleName+"<strong>"+this.titleValue+"</strong>",this.title.innerHTML=t,this.dataPointList.innerHTML="",this.listValues.map((function(t,i){var n=e.colors[i]||"black",s=0===t.formatted||t.formatted?t.formatted:t.value,a=x.create("li",{styles:{"border-top":"3px solid "+n},innerHTML:'<strong style="display: block;">'+(0===s||s?s:"")+"</strong>\n\t\t\t\t\t"+(t.title?t.title:"")});e.dataPointList.appendChild(a)}))},e.calcPosition=function(){var t=this.container.offsetWidth;this.top=this.y-this.container.offsetHeight-5,this.left=this.x-t/2;var e=this.parent.offsetWidth-t,i=this.container.querySelector(".svg-pointer");if(this.left<0)i.style.left="calc(50% - "+-1*this.left+"px)",this.left=0;else if(this.left>e){var n="calc(50% + "+(this.left-e)+"px)";i.style.left=n,this.left=e}else i.style.left="50%"},e.setValues=function(t,e,i,n,s){void 0===i&&(i={}),void 0===n&&(n=[]),void 0===s&&(s=-1),this.titleName=i.name,this.titleValue=i.value,this.listValues=n,this.x=t,this.y=e,this.titleValueFirst=i.valueFirst||0,this.index=s,this.refresh()},e.hideTip=function(){this.container.style.top="0px",this.container.style.left="0px",this.container.style.opacity="0"},e.showTip=function(){this.container.style.top=this.top+"px",this.container.style.left=this.left+"px",this.container.style.opacity="1"},t}();function O(t){return parseFloat(t.toFixed(2))}function E(t,e,i,n){void 0===n&&(n=!1),i||(i=n?t[0]:t[t.length-1]);var s=new Array(Math.abs(e)).fill(i);return n?s.concat(t):t.concat(s)}function z(t,e){return(t+"").length*e}function W(t,e){return{x:Math.sin(t*N)*e,y:Math.cos(t*N)*e}}function H(t,e){return void 0===e&&(e=!1),!(Number.isNaN(t)||void 0===t||!Number.isFinite(t)||e&&t<0)}function F(t){var e,i,n;if(t instanceof Date)return new Date(t.getTime());if("object"!=typeof t||null===t)return t;for(n in e=Array.isArray(t)?[]:{},t)i=t[n],e[n]=F(i);return e}function I(t,e){var i,n;return t<=e?(i=e-t,n=t):(i=t-e,n=e),[i,n]}function R(t,e,i){return void 0===i&&(i=e.length-t.length),i>0?t=E(t,i):e=E(e,i),[t,e]}function Y(t,e){if(t)return t.length>e?t.slice(0,e-3)+"...":t}function j(t,e){for(var i=[],n=0;n<t.length;n++)i.push([t[n],e[n]]);var s=function(t,e,i,n){var s,a,r,o,l=(s=e||t,r=(a=i||t)[0]-s[0],o=a[1]-s[1],{length:Math.sqrt(Math.pow(r,2)+Math.pow(o,2)),angle:Math.atan2(o,r)}),c=l.angle+(n?Math.PI:0),h=.2*l.length;return[t[0]+Math.cos(c)*h,t[1]+Math.sin(c)*h]};return function(t,e){return t.reduce((function(t,e,i,n){return 0===i?e[0]+","+e[1]:t+" "+function(t,e,i){var n=s(i[e-1],i[e-2],t),a=s(t,i[e-1],i[e+1],!0);return"C "+n[0]+","+n[1]+" "+a[0]+","+a[1]+" "+t[0]+","+t[1]}(e,i,n)}),"")}(i)}var _={"light-blue":"#7cd6fd",blue:"#5e64ff",violet:"#743ee2",red:"#ff5858",orange:"#ffa00a",yellow:"#feef72",green:"#28a745","light-green":"#98d85b",purple:"#b554ff",magenta:"#ffa3ef",black:"#36114C",grey:"#bdd3e6","light-grey":"#f0f4f7","dark-grey":"#b8c2cc"};function B(t){return t>255?255:t<0?0:t}function V(t,e){var i=U(t),n=!1;"#"==i[0]&&(i=i.slice(1),n=!0);var s=parseInt(i,16),a=B((s>>16)+e),r=B((s>>8&255)+e);return(n?"#":"")+(B((255&s)+e)|r<<8|a<<16).toString(16)}var U=function(t){return/rgb[a]{0,1}\([\d, ]+\)/gim.test(t)?/\D+(\d*)\D+(\d*)\D+(\d*)/gim.exec(t).map((function(t,e){return 0!==e?Number(t).toString(16):"#"})).reduce((function(t,e){return""+t+e})):_[t]||t},G="#dadada",q="#555b51";function X(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function J(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg",t);for(var n in e){var s=e[n];if("inside"===n)X(s).appendChild(i);else if("around"===n){var a=X(s);a.parentNode.insertBefore(i,a),i.appendChild(a)}else"styles"===n?"object"==typeof s&&Object.keys(s).map((function(t){i.style[t]=s[t]})):("className"===n&&(n="class"),"innerHTML"===n?i.textContent=s:i.setAttribute(n,s))}return i}function K(t,e,i,n){return J("stop",{inside:t,style:"stop-color: "+i,offset:e,"stop-opacity":n})}function $(t,e,i){void 0===e&&(e=""),void 0===i&&(i=void 0);var n={className:t,transform:e};return i&&(n.inside=i),J("g",n)}function Q(t,e,i,n,s){return void 0===e&&(e=""),void 0===i&&(i="none"),void 0===n&&(n="none"),void 0===s&&(s=2),J("path",{className:e,d:t,styles:{stroke:i,fill:n,"stroke-width":s}})}function Z(t,e,i){void 0===i&&(i=!1);var n="path-fill-gradient-"+e+"-"+(i?"lighter":"default"),s=function(t,e){return J("linearGradient",{inside:t,id:e,x1:0,x2:0,y1:0,y2:1})}(t,n),a=[1,.6,.2];return i&&(a=[.4,.2,0]),K(s,"0%",e,a[0]),K(s,"50%",e,a[1]),K(s,"100%",e,a[2]),n}function tt(t,e,i,n,s,a,r){void 0===a&&(a="none"),void 0===r&&(r={});var o={className:t,x:e,y:i,width:n,height:n,rx:s,fill:a};return Object.keys(r).map((function(t){o[t]=r[t]})),J("rect",o)}function et(t,e,i,n,s){void 0===s&&(s={});var a=s.fontSize||10;return J("text",{className:t,x:e,y:i,dy:(void 0!==s.dy?s.dy:a/2)+"px","font-size":a+"px",fill:s.fill||q,"text-anchor":s.textAnchor||"start",innerHTML:n})}function it(t,e,i,n,s){void 0===s&&(s={}),s.stroke||(s.stroke=G),s.lineType||(s.lineType=""),s.shortenNumbers&&(e=function(t){var e;if("number"==typeof t)e=t;else if("string"==typeof t&&(e=Number(t),Number.isNaN(e)))return t;var i=Math.floor(Math.log10(Math.abs(e)));if(i<=2)return e;var n=Math.floor(i/3),s=Math.pow(10,i-3*n)*+(e/Math.pow(10,i)).toFixed(1);return Math.round(100*s)/100+" "+["","K","M","B","T"][n]}(e));var a=J("line",{className:"line-horizontal "+s.className+("dashed"===s.lineType?"dashed":""),x1:i,x2:n,y1:0,y2:0,styles:{stroke:s.stroke}}),r=J("text",{x:i<n?i-4:i+4,y:0,dy:"3px","font-size":"10px","text-anchor":i<n?"end":"start",innerHTML:e+""}),o=J("g",{transform:"translate(0, "+t+")","stroke-opacity":1});return 0!==r&&"0"!==r||(o.style.stroke="rgba(27, 31, 35, 0.6)"),o.appendChild(a),o.appendChild(r),o}var nt={bar:function(t){var e;"rect"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode();return i.style.fill="#000000",i.style.opacity="0.4",e&&i.setAttribute("transform",e),i},dot:function(t){var e;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode(),n=t.getAttribute("r"),s=t.getAttribute("fill");return i.setAttribute("r",parseInt(n)+4),i.setAttribute("fill",s),i.style.opacity="0.6",e&&i.setAttribute("transform",e),i},heat_square:function(t){var e;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode(),n=t.getAttribute("r"),s=t.getAttribute("fill");return i.setAttribute("r",parseInt(n)+4),i.setAttribute("fill",s),i.style.opacity="0.6",e&&i.setAttribute("transform",e),i}},st={bar:function(t,e){var i;"rect"!==t.nodeName&&(i=t.getAttribute("transform"),t=t.childNodes[0]);var n=["x","y","width","height"];Object.values(t.attributes).filter((function(t){return n.includes(t.name)&&t.specified})).map((function(t){e.setAttribute(t.name,t.nodeValue)})),i&&e.setAttribute("transform",i)},dot:function(t,e){var i;"circle"!==t.nodeName&&(i=t.getAttribute("transform"),t=t.childNodes[0]);var n=["cx","cy"];Object.values(t.attributes).filter((function(t){return n.includes(t.name)&&t.specified})).map((function(t){e.setAttribute(t.name,t.nodeValue)})),i&&e.setAttribute("transform",i)},heat_square:function(t,e){var i;"circle"!==t.nodeName&&(i=t.getAttribute("transform"),t=t.childNodes[0]);var n=["cx","cy"];Object.values(t.attributes).filter((function(t){return n.includes(t.name)&&t.specified})).map((function(t){e.setAttribute(t.name,t.nodeValue)})),i&&e.setAttribute("transform",i)}},at=350,rt=at,ot="easein";function lt(t,e,i,n){var s="string"==typeof e?e:e.join(", ");return[t,{transform:i.join(", ")},n,ot,"translate",{transform:s}]}function ct(t,e,i){return lt(t,[0,i],[0,e],rt)}function ht(t,e){return[t,{d:e},at,ot]}var ut={ease:"0.25 0.1 0.25 1",linear:"0 0 1 1",easein:"0.1 0.8 0.2 1",easeout:"0 0 0.58 1",easeinout:"0.42 0 0.58 1"};function dt(t,e,i,n,s,a){void 0===n&&(n="linear"),void 0===s&&(s=void 0),void 0===a&&(a={});var r=t.cloneNode(!0),o=t.cloneNode(!0);for(var l in e){var c=void 0;c="transform"===l?document.createElementNS("http://www.w3.org/2000/svg","animateTransform"):document.createElementNS("http://www.w3.org/2000/svg","animate");var h=a[l]||t.getAttribute(l),u=e[l],d={attributeName:l,from:h,to:u,begin:"0s",dur:i/1e3+"s",values:h+";"+u,keySplines:ut[n],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};for(var p in s&&(d.type=s),d)c.setAttribute(p,d[p]);r.appendChild(c),s?o.setAttribute(l,"translate("+u+")"):o.setAttribute(l,u)}return[r,o]}function pt(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function ft(t,e){var i=[],n=[];e.map((function(t){var e,s,a=t[0],r=a.parentNode;t[0]=a;var o=dt.apply(void 0,t);e=o[0],s=o[1],i.push(s),n.push([e,r]),r&&r.replaceChild(e,a)}));var s=t.cloneNode(!0);return n.map((function(t,n){t[1]&&(t[1].replaceChild(i[n],t[0]),e[n][0]=i[n])})),s}var vt=function(){function t(t,e){if(e=F(e),this.parent="string"==typeof t?document.querySelector(t):t,!(this.parent instanceof HTMLElement))throw new Error("No `parent` element to render on was provided.");this.rawChartArgs=e,this.title=e.title||"",this.type=e.type||"",this.realData=this.prepareData(e.data),this.data=this.prepareFirstData(this.realData),this.colors=this.validateColors(e.colors,this.type),this.config={showTooltip:1,showLegend:1,isNavigable:e.isNavigable||0,animate:void 0!==e.animate?e.animate:1,truncateLegends:e.truncateLegends||1},this.measures=JSON.parse(JSON.stringify(A));var i=this.measures;this.setMeasures(e),this.title.length||(i.titleHeight=0),this.config.showLegend||(i.legendHeight=0),this.argHeight=e.height||i.baseHeight,this.state={},this.options={},this.initTimeout=700,this.config.isNavigable&&(this.overlays=[]),this.configure(e)}var e=t.prototype;return e.prepareData=function(t){return t},e.prepareFirstData=function(t){return t},e.validateColors=function(t,e){var i=[];return(t=(t||[]).concat(D[e])).forEach((function(t){var e=U(t);!function(t){return/(^\s*)(#)((?:[A-Fa-f0-9]{3}){1,2})$/i.test(t)||/(^\s*)(rgb|hsl)(a?)[(]\s*([\d.]+\s*%?)\s*,\s*([\d.]+\s*%?)\s*,\s*([\d.]+\s*%?)\s*(?:,\s*([\d.]+)\s*)?[)]$/i.test(t)}(e)?console.warn('"'+t+'" is not a valid color.'):i.push(e)})),i},e.setMeasures=function(){},e.configure=function(){var t=this,e=this.argHeight;this.baseHeight=e,this.height=e-M(this.measures),this.boundDrawFn=function(){return t.draw(!0)},ResizeObserver&&(this.resizeObserver=new ResizeObserver(this.boundDrawFn),this.resizeObserver.observe(this.parent)),window.addEventListener("resize",this.boundDrawFn),window.addEventListener("orientationchange",this.boundDrawFn)},e.destroy=function(){this.resizeObserver&&this.resizeObserver.disconnect(),window.removeEventListener("resize",this.boundDrawFn),window.removeEventListener("orientationchange",this.boundDrawFn)},e.setup=function(){this.makeContainer(),this.updateWidth(),this.makeTooltip(),this.draw(!1,!0)},e.makeContainer=function(){this.parent.innerHTML="";var t={inside:this.parent,className:"chart-container"};this.independentWidth&&(t.styles={width:this.independentWidth+"px"}),this.container=x.create("div",t)},e.makeTooltip=function(){this.tip=new S({parent:this.container,colors:this.colors}),this.bindTooltip()},e.bindTooltip=function(){},e.draw=function(t,e){var i=this;void 0===t&&(t=!1),void 0===e&&(e=!1),t&&null===this.parent.offsetParent||(this.updateWidth(),this.calc(t),this.makeChartArea(),this.setupComponents(),this.components.forEach((function(t){return t.setup(i.drawArea)})),this.render(this.components,!1),e&&(this.data=this.realData,setTimeout((function(){i.update(i.data)}),this.initTimeout)),this.renderLegend(),this.setupNavigation(e))},e.calc=function(){},e.updateWidth=function(){var t,e,i;this.baseWidth=(t=this.parent,e=window.getComputedStyle(t),i=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight),t.clientWidth-i),this.width=this.baseWidth-T(this.measures)},e.makeChartArea=function(){this.svg&&this.container.removeChild(this.svg);var t=this.measures;this.svg=("frappe-chart chart",J("svg",{className:"frappe-chart chart",inside:this.container,width:this.baseWidth,height:this.baseHeight})),this.svgDefs=J("defs",{inside:this.svg}),this.title.length&&(this.titleEL=et("title",t.margins.left,t.margins.top,this.title,{fontSize:t.titleFontSize,fill:"#666666",dy:t.titleFontSize}));var e=P(t);this.drawArea=$(this.type+"-chart chart-draw-area","translate("+k(t)+", "+e+")"),this.config.showLegend&&(e+=this.height+t.paddings.bottom,this.legendArea=$("chart-legend","translate("+k(t)+", "+e+")")),this.title.length&&this.svg.appendChild(this.titleEL),this.svg.appendChild(this.drawArea),this.config.showLegend&&this.svg.appendChild(this.legendArea),this.updateTipOffset(k(t),P(t))},e.updateTipOffset=function(t,e){this.tip.offset={x:t,y:e}},e.setupComponents=function(){this.components=new Map},e.update=function(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.calc(),this.render(this.components,this.config.animate),this.renderLegend()},e.render=function(t,e){var i=this;void 0===t&&(t=this.components),void 0===e&&(e=!0),this.config.isNavigable&&this.overlays.map((function(t){return t.parentNode.removeChild(t)}));var n=[];t.forEach((function(t){n=n.concat(t.update(e))})),n.length>0?(function(t,e,i){if(0!==i.length){var n=ft(e,i);e.parentNode==t&&(t.removeChild(e),t.appendChild(n)),setTimeout((function(){n.parentNode==t&&(t.removeChild(n),t.appendChild(e))}),250)}}(this.container,this.svg,n),setTimeout((function(){t.forEach((function(t){return t.make()})),i.updateNav()}),400)):(t.forEach((function(t){return t.make()})),this.updateNav())},e.updateNav=function(){this.config.isNavigable&&(this.makeOverlay(),this.bindUnits())},e.renderLegend=function(){},e.setupNavigation=function(t){var e=this;void 0===t&&(t=!1),this.config.isNavigable&&t&&(this.bindOverlay(),this.keyActions={13:this.onEnterKey.bind(this),37:this.onLeftArrow.bind(this),38:this.onUpArrow.bind(this),39:this.onRightArrow.bind(this),40:this.onDownArrow.bind(this)},document.addEventListener("keydown",(function(t){var i;(i=e.container.getBoundingClientRect()).top>=0&&i.left>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&i.right<=(window.innerWidth||document.documentElement.clientWidth)&&(t=t||window.event,e.keyActions[t.keyCode]&&e.keyActions[t.keyCode]())})))},e.makeOverlay=function(){},e.updateOverlay=function(){},e.bindOverlay=function(){},e.bindUnits=function(){},e.onLeftArrow=function(){},e.onRightArrow=function(){},e.onUpArrow=function(){},e.onDownArrow=function(){},e.onEnterKey=function(){},e.addDataPoint=function(){},e.removeDataPoint=function(){},e.getDataPoint=function(){},e.setCurrentDataPoint=function(){},e.updateDataset=function(){},e.export=function(){var t=function(t){var e=t.cloneNode(!0);e.classList.add("chart-container"),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink");var i=x.create("style",{innerHTML:".chart-container{position:relative;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI','Roboto','Oxygen','Ubuntu','Cantarell','Fira Sans','Droid Sans','Helvetica Neue',sans-serif}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .dataset-units circle{stroke:#fff;stroke-width:2}.chart-container .dataset-units path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container .dataset-path{stroke-width:2px}.chart-container .path-group path{fill:none;stroke-opacity:1;stroke-width:2px}.chart-container line.dashed{stroke-dasharray:5,3}.chart-container .axis-line .specific-value{text-anchor:start}.chart-container .axis-line .y-line{text-anchor:end}.chart-container .axis-line .x-line{text-anchor:middle}.chart-container .legend-dataset-text{fill:#6c7680;font-weight:600}.graph-svg-tip{position:absolute;z-index:99999;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.graph-svg-tip ul{padding-left:0;display:flex}.graph-svg-tip ol{padding-left:0;display:flex}.graph-svg-tip ul.data-point-list li{min-width:90px;flex:1;font-weight:600}.graph-svg-tip strong{color:#dfe2e5;font-weight:600}.graph-svg-tip .svg-pointer{position:absolute;height:5px;margin:0 0 0 -5px;content:' ';border:5px solid transparent;border-top-color:rgba(0,0,0,.8)}.graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}"});e.insertBefore(i,e.firstChild);var n=x.create("div");return n.appendChild(e),n.innerHTML}(this.svg);!function(t,e){var i=document.createElement("a");i.style="display: none";var n=new Blob(e,{type:"image/svg+xml; charset=utf-8"}),s=window.URL.createObjectURL(n);i.href=s,i.download=t,document.body.appendChild(i),i.click(),setTimeout((function(){document.body.removeChild(i),window.URL.revokeObjectURL(s)}),300)}(this.title||"Chart",[t])},t}(),mt=function(t){function e(e,i){return t.call(this,e,i)||this}l(e,t);var i=e.prototype;return i.configure=function(e){t.prototype.configure.call(this,e),this.config.formatTooltipY=(e.tooltipOptions||{}).formatTooltipY,this.config.maxSlices=e.maxSlices||20,this.config.maxLegendPoints=e.maxLegendPoints||20},i.calc=function(){var t=this,e=this.state,i=this.config.maxSlices;e.sliceTotals=[];var n=this.data.labels.map((function(e,i){var n=0;return t.data.datasets.map((function(t){n+=t.values[i]})),[n,e]})).filter((function(t){return t[0]>=0})),s=n;if(n.length>i){n.sort((function(t,e){return e[0]-t[0]})),s=n.slice(0,i-1);var a=n.slice(i-1),r=0;a.map((function(t){r+=t[0]})),s.push([r,"Rest"]),this.colors[i-1]="grey"}e.labels=[],s.map((function(t){e.sliceTotals.push(function(t){return Number(Math.round(t+"e4")+"e-4")}(t[0])),e.labels.push(t[1])})),e.grandTotal=e.sliceTotals.reduce((function(t,e){return t+e}),0),this.center={x:this.width/2,y:this.height/2}},i.renderLegend=function(){var t=this,e=this.state;this.legendArea.textContent="",this.legendTotals=e.sliceTotals.slice(0,this.config.maxLegendPoints);var i=0,n=0;this.legendTotals.map((function(s,a){var r=150,o=Math.floor((t.width-T(t.measures))/r);t.legendTotals.length<o&&(r=t.width/t.legendTotals.length),i>o&&(i=0,n+=20);var l=r*i+5,c=t.config.truncateLegends?Y(e.labels[a],r/10):e.labels[a],h=t.config.formatTooltipY?t.config.formatTooltipY(s):s,u=function(t,e,i,n,s,a){void 0===n&&(n="none"),void 0===a&&(a=!1),s=a?Y(s,15):s;var r={className:"legend-dot",cx:0,cy:0,r:5,fill:n},o=J("text",{className:"legend-dataset-text",x:0,y:0,dx:"10px",dy:10/3+"px","font-size":"12px","text-anchor":"start",fill:q,innerHTML:s}),l=J("g",{transform:"translate("+t+", "+e+")"});return l.appendChild(J("circle",r)),l.appendChild(o),l}(l,n,0,t.colors[a],c+": "+h,!1);t.legendArea.appendChild(u),i++}))},e}(vt),gt=["January","February","March","April","May","June","July","August","September","October","November","December"],yt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function bt(t){var e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function xt(t){var e=t.getDate(),i=t.getMonth()+1;return[t.getFullYear(),(i>9?"":"0")+i,(e>9?"":"0")+e].join("-")}function wt(t){return new Date(t.getTime())}function At(t,e){var i=Tt(t);return Math.ceil(function(t,e){return(bt(e)-bt(t))/864e5}(i,e)/7)}function Pt(t,e){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function kt(t,e){void 0===e&&(e=!1);var i=gt[t];return e?i.slice(0,3):i}function Mt(t,e){return new Date(e,t+1,0)}function Tt(t){var e=wt(t),i=e.getDay();return 0!==i&&Lt(e,-1*i),e}function Lt(t,e){t.setDate(t.getDate()+e)}var Ct=function(){function t(t){var e=t.layerClass,i=void 0===e?"":e,n=t.layerTransform,s=void 0===n?"":n,a=t.constants,r=t.getData,o=t.makeElements,l=t.animateElements;this.layerTransform=s,this.constants=a,this.makeElements=o,this.getData=r,this.animateElements=l,this.store=[],this.labels=[],this.layerClass=i,this.layerClass="function"==typeof this.layerClass?this.layerClass():this.layerClass,this.refresh()}var e=t.prototype;return e.refresh=function(t){this.data=t||this.getData()},e.setup=function(t){this.layer=$(this.layerClass,this.layerTransform,t)},e.make=function(){this.render(this.data),this.oldData=this.data},e.render=function(t){var e=this;this.store=this.makeElements(t),this.layer.textContent="",this.store.forEach((function(t){e.layer.appendChild(t)})),this.labels.forEach((function(t){e.layer.appendChild(t)}))},e.update=function(t){void 0===t&&(t=!0),this.refresh();var e=[];return t&&(e=this.animateElements(this.data)||[]),e},t}(),Dt={donutSlices:{layerClass:"donut-slices",makeElements:function(t){return t.sliceStrings.map((function(e,i){var n=Q(e,"donut-path",t.colors[i],"none",t.strokeWidth);return n.style.transition="transform .3s;",n}))},animateElements:function(t){return this.store.map((function(e,i){return ht(e,t.sliceStrings[i])}))}},pieSlices:{layerClass:"pie-slices",makeElements:function(t){return t.sliceStrings.map((function(e,i){var n=Q(e,"pie-path","none",t.colors[i]);return n.style.transition="transform .3s;",n}))},animateElements:function(t){return this.store.map((function(e,i){return ht(e,t.sliceStrings[i])}))}},percentageBars:{layerClass:"percentage-bars",makeElements:function(t){var e=this;return t.xPositions.map((function(i,n){var s=function(t,e,i,n,s,a){return void 0===s&&(s=2),void 0===a&&(a="none"),J("rect",{className:"percentage-bar",x:t,y:0,width:i,height:n,fill:a,styles:{stroke:V(a,-25),"stroke-dasharray":"0, "+(n+i)+", "+i+", "+n,"stroke-width":s}})}(i,0,t.widths[n],e.constants.barHeight,e.constants.barDepth,t.colors[n]);return s}))},animateElements:function(t){if(t)return[]}},yAxis:{layerClass:"y axis",makeElements:function(t){var e=this;return t.positions.map((function(i,n){return function(t,e,i,n){void 0===n&&(n={}),H(t)||(t=0),n.pos||(n.pos="left"),n.offset||(n.offset=0),n.mode||(n.mode="span"),n.stroke||(n.stroke=G),n.className||(n.className="");var s=-6,a="span"===n.mode?i+6:0;return"tick"===n.mode&&"right"===n.pos&&(s=i+6,a=i),it(t,e,s+=n.offset,a+=n.offset,{stroke:n.stroke,className:n.className,lineType:n.lineType,shortenNumbers:n.shortenNumbers})}(i,t.labels[n],e.constants.width,{mode:e.constants.mode,pos:e.constants.pos,shortenNumbers:e.constants.shortenNumbers})}))},animateElements:function(t){var e=t.positions,i=t.labels,n=this.oldData.positions,s=this.oldData.labels,a=R(n,e);n=a[0],e=a[1];var r=R(s,i);return s=r[0],i=r[1],this.render({positions:n,labels:i}),this.store.map((function(t,i){return ct(t,e[i],n[i])}))}},xAxis:{layerClass:"x axis",makeElements:function(t){var e=this;return t.positions.map((function(i,n){return function(t,e,i,n){void 0===n&&(n={}),H(t)||(t=0),n.pos||(n.pos="bottom"),n.offset||(n.offset=0),n.mode||(n.mode="span"),n.stroke||(n.stroke=G),n.className||(n.className="");var s=i+6,a="span"===n.mode?-6:i;return"tick"===n.mode&&"top"===n.pos&&(s=-6,a=0),function(t,e,i,n,s){void 0===s&&(s={}),s.stroke||(s.stroke=G);var a=J("line",{className:"line-vertical "+s.className,x1:0,x2:0,y1:i,y2:n,styles:{stroke:s.stroke}}),r=J("text",{x:0,y:i>n?i+4:i-4-10,dy:"10px","font-size":"10px","text-anchor":"middle",innerHTML:e+""}),o=J("g",{transform:"translate("+t+", 0)"});return o.appendChild(a),o.appendChild(r),o}(t,e,s,a,{stroke:n.stroke,className:n.className,lineType:n.lineType})}(i,t.calcLabels[n],e.constants.height,{mode:e.constants.mode,pos:e.constants.pos})}))},animateElements:function(t){var e=t.positions,i=t.calcLabels,n=this.oldData.positions,s=this.oldData.calcLabels,a=R(n,e);n=a[0],e=a[1];var r=R(s,i);return s=r[0],i=r[1],this.render({positions:n,calcLabels:i}),this.store.map((function(t,i){return function(t,e,i){return lt(t,[i,0],[e,0],rt)}(t,e[i],n[i])}))}},yMarkers:{layerClass:"y-markers",makeElements:function(t){var e=this;return t.map((function(t){return function(t,e,i,n){void 0===n&&(n={}),n.labelPos||(n.labelPos="right");var s=J("text",{className:"chart-label",x:"left"===n.labelPos?4:i-z(e,5)-4,y:0,dy:"-5px","font-size":"10px","text-anchor":"start",innerHTML:e+""}),a=it(t,"",0,i,{stroke:n.stroke||G,className:n.className||"",lineType:n.lineType});return a.appendChild(s),a}(t.position,t.label,e.constants.width,{labelPos:t.options.labelPos,mode:"span",lineType:"dashed"})}))},animateElements:function(t){var e=R(this.oldData,t);this.oldData=e[0];var i=(t=e[1]).map((function(t){return t.position})),n=t.map((function(t){return t.label})),s=t.map((function(t){return t.options})),a=this.oldData.map((function(t){return t.position}));return this.render(a.map((function(t,e){return{position:a[e],label:n[e],options:s[e]}}))),this.store.map((function(t,e){return ct(t,i[e],a[e])}))}},yRegions:{layerClass:"y-regions",makeElements:function(t){var e=this;return t.map((function(t){return function(t,e,i,n,s){void 0===s&&(s={});var a=t-e,r=J("rect",{className:"bar mini",styles:{fill:"rgba(228, 234, 239, 0.49)",stroke:G,"stroke-dasharray":i+", "+a},x:0,y:0,width:i,height:a});s.labelPos||(s.labelPos="right");var o=J("text",{className:"chart-label",x:"left"===s.labelPos?4:i-z(n+"",4.5)-4,y:0,dy:"-5px","font-size":"10px","text-anchor":"start",innerHTML:n+""}),l=J("g",{transform:"translate(0, "+e+")"});return l.appendChild(r),l.appendChild(o),l}(t.startPos,t.endPos,e.constants.width,t.label,{labelPos:t.options.labelPos})}))},animateElements:function(t){var e=R(this.oldData,t);this.oldData=e[0];var i=(t=e[1]).map((function(t){return t.endPos})),n=t.map((function(t){return t.label})),s=t.map((function(t){return t.startPos})),a=t.map((function(t){return t.options})),r=this.oldData.map((function(t){return t.endPos})),o=this.oldData.map((function(t){return t.startPos}));this.render(r.map((function(t,e){return{startPos:o[e],endPos:r[e],label:n[e],options:a[e]}})));var l=[];return this.store.map((function(t,e){l=l.concat(function(t,e,i,n){var s=e-i,a=t.childNodes[0],r=a.getAttribute("width");return[[a,{height:s,"stroke-dasharray":r+", "+s},rt,ot],lt(t,[0,n],[0,i],rt)]}(t,s[e],i[e],r[e]))})),l}},heatDomain:{layerClass:function(){return"heat-domain domain-"+this.constants.index},makeElements:function(t){var e=this,i=this.constants,n=i.index,s=i.colWidth,a=i.rowHeight,r=i.squareSize,o=i.radius,l=i.xTranslate,c=0;return this.serializedSubDomains=[],t.cols.map((function(t,i){1===i&&e.labels.push(et("domain-name",l,-12,kt(n,!0).toUpperCase(),{fontSize:9})),t.map((function(t,i){if(t.fill){var n={"data-date":t.yyyyMmDd,"data-value":t.dataValue,"data-day":i},s=tt("day",l,c,r,o,t.fill,n);e.serializedSubDomains.push(s)}c+=a})),c=0,l+=s})),this.serializedSubDomains},animateElements:function(t){if(t)return[]}},barGraph:{layerClass:function(){return"dataset-units dataset-bars dataset-"+this.constants.index},makeElements:function(t){var e=this.constants;return this.unitType="bar",this.units=t.yPositions.map((function(i,n){return function(t,e,i,n,s,a,r,o){void 0===s&&(s=""),void 0===a&&(a=0),void 0===r&&(r=0),void 0===o&&(o={});var l=I(e,o.zeroLine),c=l[0],h=l[1];h-=r,0===c&&(c=o.minHeight,h-=o.minHeight),H(t)||(t=0),H(h)||(h=0),H(c,!0)||(c=0),H(i,!0)||(i=0);var u=J("rect",{className:"bar mini",style:"fill: "+n,"data-point-index":a,x:t,y:h,width:i,height:c});if((s+="")||s.length){u.setAttribute("y",0),u.setAttribute("x",0);var d=J("text",{className:"data-point-value",x:i/2,y:0,dy:"-5px","font-size":"10px","text-anchor":"middle",innerHTML:s}),p=J("g",{"data-point-index":a,transform:"translate("+t+", "+h+")"});return p.appendChild(u),p.appendChild(d),p}return u}(t.xPositions[n],i,t.barWidth,e.color,t.labels[n],n,t.offsets[n],{zeroLine:t.zeroLine,barsWidth:t.barsWidth,minHeight:e.minHeight})})),this.units},animateElements:function(t){var e=t.xPositions,i=t.yPositions,n=t.offsets,s=t.labels,a=this.oldData.xPositions,r=this.oldData.yPositions,o=this.oldData.offsets,l=this.oldData.labels,c=R(a,e);a=c[0],e=c[1];var h=R(r,i);r=h[0],i=h[1];var u=R(o,n);o=u[0],n=u[1];var d=R(l,s);l=d[0],s=d[1],this.render({xPositions:a,yPositions:r,offsets:o,labels:s,zeroLine:this.oldData.zeroLine,barsWidth:this.oldData.barsWidth,barWidth:this.oldData.barWidth});var p=[];return this.store.map((function(s,a){p=p.concat(function(t,e,i,n,s,a){void 0===s&&(s=0),void 0===a&&(a={});var r=I(i,a.zeroLine),o=r[0],l=r[1];if(l-=s,"rect"!==t.nodeName){var c=[t.childNodes[0],{width:n,height:o},at,ot],h=t.getAttribute("transform").split("(")[1].slice(0,-1);return[c,lt(t,h,[e,l],rt)]}return[[t,{width:n,height:o,x:e,y:l},at,ot]]}(s,e[a],i[a],t.barWidth,n[a],{zeroLine:t.zeroLine}))})),p}},lineGraph:{layerClass:function(){return"dataset-units dataset-line dataset-"+this.constants.index},makeElements:function(t){var e=this.constants;return this.unitType="dot",this.paths={},e.hideLine||(this.paths=function(t,e,i,n,s){void 0===n&&(n={}),void 0===s&&(s={});var a=e.map((function(e,i){return t[i]+","+e})).join("L");n.spline&&(a=j(t,e));var r=Q("M"+a,"line-graph-path",i);if(n.heatline){var o=Z(s.svgDefs,i);r.style.stroke="url(#"+o+")"}var l={path:r};if(n.regionFill){var c=Z(s.svgDefs,i,!0),h="M"+t[0]+","+s.zeroLine+"L"+a+"L"+t.slice(-1)[0]+","+s.zeroLine;l.region=Q(h,"region-fill","none","url(#"+c+")")}return l}(t.xPositions,t.yPositions,e.color,{heatline:e.heatline,regionFill:e.regionFill,spline:e.spline},{svgDefs:e.svgDefs,zeroLine:t.zeroLine})),this.units=[],e.hideDots||(this.units=t.yPositions.map((function(i,n){return function(t,e,i,n,s,a){void 0===s&&(s=""),void 0===a&&(a=0);var r=J("circle",{style:"fill: "+n,"data-point-index":a,cx:t,cy:e,r:i});if((s+="")||s.length){r.setAttribute("cy",0),r.setAttribute("cx",0);var o=J("text",{className:"data-point-value",x:0,y:0,dy:-5-i+"px","font-size":"10px","text-anchor":"middle",innerHTML:s}),l=J("g",{"data-point-index":a,transform:"translate("+t+", "+e+")"});return l.appendChild(r),l.appendChild(o),l}return r}(t.xPositions[n],i,t.radius,e.color,e.valuesOverPoints?t.values[n]:"",n)}))),Object.values(this.paths).concat(this.units)},animateElements:function(t){var e=t.xPositions,i=t.yPositions,n=t.values,s=this.oldData.xPositions,a=this.oldData.yPositions,r=this.oldData.values,o=R(s,e);s=o[0],e=o[1];var l=R(a,i);a=l[0],i=l[1];var c=R(r,n);r=c[0],n=c[1],this.render({xPositions:s,yPositions:a,values:n,zeroLine:this.oldData.zeroLine,radius:this.oldData.radius});var h=[];return Object.keys(this.paths).length&&(h=h.concat(function(t,e,i,n,s){var a=[],r=i.map((function(t,i){return e[i]+","+t})).join("L");s&&(r=j(e,i));var o=[t.path,{d:"M"+r},350,ot];if(a.push(o),t.region){var l=e[0]+","+n+"L",c="L"+e.slice(-1)[0]+", "+n,h=[t.region,{d:"M"+l+r+c},350,ot];a.push(h)}return a}(this.paths,e,i,t.zeroLine,this.constants.spline))),this.units.length&&this.units.map((function(t,n){h=h.concat(function(t,e,i){if("circle"!==t.nodeName){var n=t.getAttribute("transform").split("(")[1].slice(0,-1);return[lt(t,n,[e,i],rt)]}return[[t,{cx:e,cy:i},at,ot]]}(t,e[n],i[n]))})),h}}};function Nt(t,e,i){var n=Object.keys(Dt).filter((function(e){return t.includes(e)})),s=Dt[n[0]];return Object.assign(s,{constants:e,getData:i}),new Ct(s)}var St=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).type="percentage",n.setup(),n}l(e,t);var i=e.prototype;return i.setMeasures=function(t){var e=this.measures;this.barOptions=t.barOptions||{};var i=this.barOptions;i.height=i.height||20,i.depth=i.depth||2,e.paddings.right=30,e.legendHeight=60,e.baseHeight=8*(i.height+.5*i.depth)},i.setupComponents=function(){var t=this.state,e=[["percentageBars",{barHeight:this.barOptions.height,barDepth:this.barOptions.depth},function(){return{xPositions:t.xPositions,widths:t.widths,colors:this.colors}}.bind(this)]];this.components=new Map(e.map((function(t){var e=Nt.apply(void 0,t);return[t[0],e]})))},i.calc=function(){var e=this;t.prototype.calc.call(this);var i=this.state;i.xPositions=[],i.widths=[];var n=0;i.sliceTotals.map((function(t){var s=e.width*t/i.grandTotal;i.widths.push(s),i.xPositions.push(n),n+=s}))},i.makeDataByIndex=function(){},i.bindTooltip=function(){var t=this,e=this.state;this.container.addEventListener("mousemove",(function(i){var n=t.components.get("percentageBars").store,s=i.target;if(n.includes(s)){var a=n.indexOf(s),r=w(t.container),o=w(s),l=o.left-r.left+parseInt(s.getAttribute("width"))/2,c=o.top-r.top,h=(t.formattedLabels&&t.formattedLabels.length>0?t.formattedLabels[a]:t.state.labels[a])+": ",u=e.sliceTotals[a]/e.grandTotal;t.tip.setValues(l,c,{name:h,value:(100*u).toFixed(1)+"%"}),t.tip.showTip()}}))},e}(mt),Ot=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).type="pie",n.initTimeout=0,n.init=1,n.setup(),n}l(e,t);var i=e.prototype;return i.configure=function(e){t.prototype.configure.call(this,e),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=e.hoverRadio||.1,this.config.startAngle=e.startAngle||0,this.clockWise=e.clockWise||!1},i.calc=function(){var e=this;t.prototype.calc.call(this);var i=this.state;this.radius=this.height>this.width?this.center.x:this.center.y;var n=this.radius,s=this.clockWise,a=i.slicesProperties||[];i.sliceStrings=[],i.slicesProperties=[];var r=180-this.config.startAngle;i.sliceTotals.map((function(t,o){var l,c,h=r,u=t/i.grandTotal*360,d=u>180?1:0,p=s?-u:u,f=r+=p,v=W(h,n),m=W(f,n),g=e.init&&a[o];e.init?(l=g?g.startPosition:v,c=g?g.endPosition:v):(l=v,c=m);var y=360===u?function(t,e,i,n,s,a){void 0===s&&(s=1),void 0===a&&(a=0);var r=i.x+t.x,o=i.y+t.y,l=i.x+e.x,c=2*i.y,h=i.y+e.y;return"M"+i.x+" "+i.y+"\n\t\tL"+r+" "+o+"\n\t\tA "+n+" "+n+" 0 "+a+" "+(s?1:0)+"\n\t\t"+l+" "+c+" z\n\t\tL"+r+" "+c+"\n\t\tA "+n+" "+n+" 0 "+a+" "+(s?1:0)+"\n\t\t"+l+" "+h+" z"}(l,c,e.center,e.radius,s,d):function(t,e,i,n,s,a){void 0===s&&(s=1),void 0===a&&(a=0);var r=i.x+t.x,o=i.y+t.y,l=i.x+e.x,c=i.y+e.y;return"M"+i.x+" "+i.y+"\n\t\tL"+r+" "+o+"\n\t\tA "+n+" "+n+" 0 "+a+" "+(s?1:0)+"\n\t\t"+l+" "+c+" z"}(l,c,e.center,e.radius,s,d);i.sliceStrings.push(y),i.slicesProperties.push({startPosition:v,endPosition:m,value:t,total:i.grandTotal,startAngle:h,endAngle:f,angle:p})})),this.init=0},i.setupComponents=function(){var t=this.state,e=[["pieSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors}}.bind(this)]];this.components=new Map(e.map((function(t){var e=Nt.apply(void 0,t);return[t[0],e]})))},i.calTranslateByAngle=function(t){var e=this.radius,i=this.hoverRadio,n=W(t.startAngle+t.angle/2,e);return"translate3d("+n.x*i+"px,"+n.y*i+"px,0)"},i.hoverSlice=function(t,e,i,n){if(t){var s=this.colors[e];if(i){pt(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.fill=V(s,50);var a=w(this.svg),r=n.pageX-a.left+10,o=n.pageY-a.top-10,l=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[e]:this.state.labels[e])+": ",c=(100*this.state.sliceTotals[e]/this.state.grandTotal).toFixed(1);this.tip.setValues(r,o,{name:l,value:c+"%"}),this.tip.showTip()}else pt(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.fill=s}},i.bindTooltip=function(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)},i.mouseMove=function(t){var e=t.target,i=this.components.get("pieSlices").store,n=this.curActiveSliceIndex,s=this.curActiveSlice;if(i.includes(e)){var a=i.indexOf(e);this.hoverSlice(s,n,!1),this.curActiveSlice=e,this.curActiveSliceIndex=a,this.hoverSlice(e,a,!0,t)}else this.mouseLeave()},i.mouseLeave=function(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)},e}(mt);function Et(t){if(0===t)return[0,0];if(isNaN(t))return{mantissa:-6755399441055744,exponent:972};var e=t>0?1:-1;if(!isFinite(t))return{mantissa:4503599627370496*e,exponent:972};t=Math.abs(t);var i=Math.floor(Math.log10(t));return[e*(t/Math.pow(10,i)),i]}function zt(t,e){void 0===e&&(e=0);var i=Et(t),n=i[0],s=i[1],a=e?e/Math.pow(10,s):0,r=function(t,e){void 0===e&&(e=0);var i=Math.ceil(t),n=Math.floor(e),s=i-n,a=s,r=1;s>5&&(s%2!=0&&(s=++i-n),a=s/2,r=2),s<=2&&(r=s/(a=4)),0===s&&(a=5,r=1);for(var o=[],l=0;l<=a;l++)o.push(n+r*l);return o}(n=n.toFixed(6),a);return r.map((function(t){return t*Math.pow(10,s)}))}function Wt(t){return t[1]-t[0]}function Ht(t,e){return O(e.zeroLine-t*e.scaleMultiplier)}var Ft=function(t){function e(e,i){var n;(n=t.call(this,e,i)||this).type="heatmap",n.countLabel=i.countLabel||"";var s=["Sunday","Monday"],a=s.includes(i.startSubDomain)?i.startSubDomain:"Sunday";return n.startSubDomainIndex=s.indexOf(a),n.setup(),n}l(e,t);var i=e.prototype;return i.setMeasures=function(t){var e=this.measures;this.discreteDomains=0===t.discreteDomains?0:1,e.paddings.top=36,e.paddings.bottom=0,e.legendHeight=24,e.baseHeight=84+M(e);var i=this.data,n=this.discreteDomains?12:0;this.independentWidth=12*(At(i.start,i.end)+n)+T(e)},i.updateWidth=function(){var t=this.discreteDomains?12:0,e=this.state.noOfWeeks?this.state.noOfWeeks:52;this.baseWidth=12*(e+t)+T(this.measures)},i.prepareData=function(t){if(void 0===t&&(t=this.data),t.start&&t.end&&t.start>t.end)throw new Error("Start date cannot be greater than end date.");if(t.start||(t.start=new Date,t.start.setFullYear(t.start.getFullYear()-1)),t.end||(t.end=new Date),t.dataPoints=t.dataPoints||{},parseInt(Object.keys(t.dataPoints)[0])>1e5){var e={};Object.keys(t.dataPoints).forEach((function(i){var n=new Date(1e3*i);e[xt(n)]=t.dataPoints[i]})),t.dataPoints=e}return t},i.calc=function(){var t=this.state;t.start=wt(this.data.start),t.end=wt(this.data.end),t.firstWeekStart=wt(t.start),t.noOfWeeks=At(t.start,t.end),t.distribution=function(t,e){for(var i=Math.max.apply(Math,t),n=[],s=0;s<5;s++){var a=i*(.25*s);n.push(a)}return n}(Object.values(this.data.dataPoints)),t.domainConfigs=this.getDomains()},i.setupComponents=function(){var t=this,e=this.state,i=this.discreteDomains?0:1,n=e.domainConfigs.map((function(n,s){return["heatDomain",{index:n.index,colWidth:12,rowHeight:12,squareSize:10,radius:t.rawChartArgs.radius||0,xTranslate:12*e.domainConfigs.filter((function(t,e){return e<s})).map((function(t){return t.cols.length-i})).reduce((function(t,e){return t+e}),0)},function(){return e.domainConfigs[s]}.bind(t)]}));this.components=new Map(n.map((function(t,e){var i=Nt.apply(void 0,t);return[t[0]+"-"+e,i]})));var s=0;yt.forEach((function(e,i){if([1,3,5].includes(i)){var n=et("subdomain-name",-6,s,e,{fontSize:10,dy:8,textAnchor:"end"});t.drawArea.appendChild(n)}s+=12}))},i.update=function(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.draw(),this.bindTooltip()},i.bindTooltip=function(){var t=this;this.container.addEventListener("mousemove",(function(e){t.components.forEach((function(i){var n=i.store,s=e.target;if(n.includes(s)){var a=s.getAttribute("data-value"),r=s.getAttribute("data-date").split("-"),o=kt(parseInt(r[1])-1,!0),l=t.container.getBoundingClientRect(),c=s.getBoundingClientRect(),h=parseInt(e.target.getAttribute("width")),u=c.left-l.left+h/2,d=c.top-l.top,p=a+" "+t.countLabel,f=" on "+o+" "+r[0]+", "+r[2];t.tip.setValues(u,d,{name:f,value:p,valueFirst:1},[]),t.tip.showTip()}}))}))},i.renderLegend=function(){var t=this;this.legendArea.textContent="";var e=0,i=this.rawChartArgs.radius||0,n=et("subdomain-name",e,12,"Less",{fontSize:11,dy:9});e=30,this.legendArea.appendChild(n),this.colors.slice(0,5).map((function(n,s){var a=tt("heatmap-legend-unit",e+15*s,12,10,i,n);t.legendArea.appendChild(a)}));var s=et("subdomain-name",e+75+3,12,"More",{fontSize:11,dy:9});this.legendArea.appendChild(s)},i.getDomains=function(){for(var t=this.state,e=[t.start.getMonth(),t.start.getFullYear()],i=e[0],n=e[1],s=[t.end.getMonth(),t.end.getFullYear()],a=s[0]-i+1+12*(s[1]-n),r=[],o=wt(t.start),l=0;l<a;l++){var c=t.end;if(!Pt(o,t.end)){var h=[o.getMonth(),o.getFullYear()];c=Mt(h[0],h[1])}r.push(this.getDomainConfig(o,c)),Lt(c,1),o=c}return r},i.getDomainConfig=function(t,e){void 0===e&&(e="");var i=[t.getMonth(),t.getFullYear()],n=i[0],s=i[1],a=Tt(t),r={index:n,cols:[]};Lt(e=wt(e)||Mt(n,s),1);for(var o,l=At(a,e),c=[],h=0;h<l;h++)o=this.getCol(a,n),c.push(o),Lt(a=new Date(o[6].yyyyMmDd),1);return void 0!==o[6].dataValue&&(Lt(a,1),c.push(this.getCol(a,n,!0))),r.cols=c,r},i.getCol=function(t,e,i){void 0===i&&(i=!1);for(var n=this.state,s=wt(t),a=[],r=0;r<7;r++,Lt(s,1)){var o={},l=s>=n.start&&s<=n.end;i||s.getMonth()!==e||!l?o.yyyyMmDd=xt(s):o=this.getSubDomainConfig(s),a.push(o)}return a},i.getSubDomainConfig=function(t){var e,i,n=xt(t),s=this.data.dataPoints[n];return{yyyyMmDd:n,dataValue:s||0,fill:this.colors[(e=s,i=this.state.distribution,i.filter((function(t){return t<e})).length)]}},e}(vt),It=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).barOptions=i.barOptions||{},n.lineOptions=i.lineOptions||{},n.type=i.type||"line",n.init=1,n.setup(),n}l(e,t);var i=e.prototype;return i.setMeasures=function(){this.data.datasets.length<=1&&(this.config.showLegend=0,this.measures.paddings.bottom=30)},i.configure=function(e){t.prototype.configure.call(this,e),e.axisOptions=e.axisOptions||{},e.tooltipOptions=e.tooltipOptions||{},this.config.xAxisMode=e.axisOptions.xAxisMode||"span",this.config.yAxisMode=e.axisOptions.yAxisMode||"span",this.config.xIsSeries=e.axisOptions.xIsSeries||0,this.config.shortenYAxisNumbers=e.axisOptions.shortenYAxisNumbers||0,this.config.formatTooltipX=e.tooltipOptions.formatTooltipX,this.config.formatTooltipY=e.tooltipOptions.formatTooltipY,this.config.valuesOverPoints=e.valuesOverPoints},i.prepareData=function(t){return void 0===t&&(t=this.data),function(t,e){t.labels=t.labels||[];var i=t.labels.length,n=t.datasets,s=new Array(i).fill(0);return n||(n=[{values:s}]),n.map((function(t){if(t.values){var n=t.values;n=(n=n.map((function(t){return isNaN(t)?0:t}))).length>i?n.slice(0,i):E(n,i-n.length,0),t.values=n}else t.values=s;t.chartType||(L.includes(e),t.chartType=e)})),t.yRegions&&t.yRegions.map((function(t){if(t.end<t.start){var e=[t.end,t.start];t.start=e[0],t.end=e[1]}})),t}(t,this.type)},i.prepareFirstData=function(t){return void 0===t&&(t=this.data),i=(e=t).labels.length,n=new Array(i).fill(0),s={labels:e.labels.slice(0,-1),datasets:e.datasets.map((function(t){return{name:"",values:n.slice(0,-1),chartType:t.chartType}}))},e.yMarkers&&(s.yMarkers=[{value:0,label:""}]),e.yRegions&&(s.yRegions=[{start:0,end:0,label:""}]),s;var e,i,n,s},i.calc=function(t){void 0===t&&(t=!1),this.calcXPositions(),t||this.calcYAxisParameters(this.getAllYValues(),"line"===this.type),this.makeDataByIndex()},i.calcXPositions=function(){var t=this.state,e=this.data.labels;t.datasetLength=e.length,t.unitWidth=this.width/t.datasetLength,t.xOffset=t.unitWidth/2,t.xAxis={labels:e,positions:e.map((function(e,i){return O(t.xOffset+i*t.unitWidth)}))}},i.calcYAxisParameters=function(t,e){void 0===e&&(e="false");var i,n=function(t,e){void 0===e&&(e=!1);var i=Math.max.apply(Math,t),n=Math.min.apply(Math,t),s=[];function a(t,e){for(var i=zt(t),n=i[1]-i[0],s=0,a=1;s<e;a++)s+=n,i.unshift(-1*s);return i}if(i>=0&&n>=0)Et(i)[1],s=e?zt(i,n):zt(i);else if(i>0&&n<0){var r=Math.abs(n);i>=r?(Et(i)[1],s=a(i,r)):(Et(r)[1],s=a(r,i).reverse().map((function(t){return-1*t})))}else if(i<=0&&n<=0){var o=Math.abs(n),l=Math.abs(i);Et(o)[1],s=(s=e?zt(o,l):zt(o)).reverse().map((function(t){return-1*t}))}return s}(t,e),s=this.height/((i=n)[i.length-1]-i[0]),a=Wt(n)*s,r=this.height-function(t){var e=Wt(t);return t.indexOf(0)>=0?t.indexOf(0):t[0]>0?-1*t[0]/e:-1*t[t.length-1]/e+(t.length-1)}(n)*a;this.state.yAxis={labels:n,positions:n.map((function(t){return r-t*s})),scaleMultiplier:s,zeroLine:r},this.calcDatasetPoints(),this.calcYExtremes(),this.calcYRegions()},i.calcDatasetPoints=function(){var t=this.state,e=function(e){return e.map((function(e){return Ht(e,t.yAxis)}))};t.datasets=this.data.datasets.map((function(t,i){var n=t.values,s=t.cumulativeYs||[];return{name:t.name&&t.name.replace(/<|>|&/g,(function(t){return"&"==t?"&amp;":"<"==t?"&lt;":"&gt;"})),index:i,chartType:t.chartType,values:n,yPositions:e(n),cumulativeYs:s,cumulativeYPos:e(s)}}))},i.calcYExtremes=function(){var t=this.state;this.barOptions.stacked?t.yExtremes=t.datasets[t.datasets.length-1].cumulativeYPos:(t.yExtremes=new Array(t.datasetLength).fill(9999),t.datasets.map((function(e){e.yPositions.map((function(e,i){e<t.yExtremes[i]&&(t.yExtremes[i]=e)}))})))},i.calcYRegions=function(){var t=this.state;this.data.yMarkers&&(this.state.yMarkers=this.data.yMarkers.map((function(e){return e.position=Ht(e.value,t.yAxis),e.options||(e.options={}),e}))),this.data.yRegions&&(this.state.yRegions=this.data.yRegions.map((function(e){return e.startPos=Ht(e.start,t.yAxis),e.endPos=Ht(e.end,t.yAxis),e.options||(e.options={}),e})))},i.getAllYValues=function(){var t,e=this,i="values";if(this.barOptions.stacked){i="cumulativeYs";var n=new Array(this.state.datasetLength).fill(0);this.data.datasets.map((function(t,s){var a=e.data.datasets[s].values;t[i]=n=n.map((function(t,e){return t+a[e]}))}))}var s=this.data.datasets.map((function(t){return t[i]}));return this.data.yMarkers&&s.push(this.data.yMarkers.map((function(t){return t.value}))),this.data.yRegions&&this.data.yRegions.map((function(t){s.push([t.end,t.start])})),(t=[]).concat.apply(t,s)},i.setupComponents=function(){var t=this,e=[["yAxis",{mode:this.config.yAxisMode,width:this.width,shortenNumbers:this.config.shortenYAxisNumbers},function(){return this.state.yAxis}.bind(this)],["xAxis",{mode:this.config.xAxisMode,height:this.height},function(){var t=this.state;return t.xAxis.calcLabels=function(t,e,i){void 0===e&&(e=[]),void 0===i&&(i=!0);var n=t/e.length;n<=0&&(n=1);var s,a=n/7;if(i){var r=Math.max.apply(Math,e.map((function(t){return t.length})));s=Math.ceil(r/a)}return e.map((function(t,e){return(t+="").length>a&&(i?e%s!=0&&(t=""):t=a-3>0?t.slice(0,a-3)+" ...":t.slice(0,a)+".."),t}))}(this.width,t.xAxis.labels,this.config.xIsSeries),t.xAxis}.bind(this)],["yRegions",{width:this.width,pos:"right"},function(){return this.state.yRegions}.bind(this)]],i=this.state.datasets.filter((function(t){return"bar"===t.chartType})),n=this.state.datasets.filter((function(t){return"line"===t.chartType})),s=i.map((function(e){var n=e.index;return["barGraph-"+e.index,{index:n,color:t.colors[n],stacked:t.barOptions.stacked,valuesOverPoints:t.config.valuesOverPoints,minHeight:0*t.height},function(){var t=this.state,e=t.datasets[n],s=this.barOptions.stacked,a=this.barOptions.spaceRatio||.5,r=t.unitWidth*(1-a),o=r/(s?1:i.length),l=t.xAxis.positions.map((function(t){return t-r/2}));s||(l=l.map((function(t){return t+o*n})));var c=new Array(t.datasetLength).fill("");this.config.valuesOverPoints&&(c=s&&e.index===t.datasets.length-1?e.cumulativeYs:e.values);var h=new Array(t.datasetLength).fill(0);return s&&(h=e.yPositions.map((function(t,i){return t-e.cumulativeYPos[i]}))),{xPositions:l,yPositions:e.yPositions,offsets:h,labels:c,zeroLine:t.yAxis.zeroLine,barsWidth:r,barWidth:o}}.bind(t)]})),a=n.map((function(e){var i=e.index;return["lineGraph-"+e.index,{index:i,color:t.colors[i],svgDefs:t.svgDefs,heatline:t.lineOptions.heatline,regionFill:t.lineOptions.regionFill,spline:t.lineOptions.spline,hideDots:t.lineOptions.hideDots,hideLine:t.lineOptions.hideLine,valuesOverPoints:t.config.valuesOverPoints},function(){var t=this.state,e=t.datasets[i],n=t.yAxis.positions[0]<t.yAxis.zeroLine?t.yAxis.positions[0]:t.yAxis.zeroLine;return{xPositions:t.xAxis.positions,yPositions:e.yPositions,values:e.values,zeroLine:n,radius:this.lineOptions.dotSize||4}}.bind(t)]})),r=[["yMarkers",{width:this.width,pos:"right"},function(){return this.state.yMarkers}.bind(this)]];e=e.concat(s,a,r);var o=["yMarkers","yRegions"];this.dataUnitComponents=[],this.components=new Map(e.filter((function(e){return!o.includes(e[0])||t.state[e[0]]})).map((function(e){var i=Nt.apply(void 0,e);return(e[0].includes("lineGraph")||e[0].includes("barGraph"))&&t.dataUnitComponents.push(i),[e[0],i]})))},i.makeDataByIndex=function(){var t=this;this.dataByIndex={};var e=this.state,i=this.config.formatTooltipX,n=this.config.formatTooltipY;e.xAxis.labels.map((function(s,a){var r=t.state.datasets.map((function(e,i){var s=e.values[a];return{title:e.name,value:s,yPos:e.yPositions[a],color:t.colors[i],formatted:n?n(s):s}}));t.dataByIndex[a]={label:s,formattedLabel:i?i(s):s,xPos:e.xAxis.positions[a],values:r,yExtreme:e.yExtremes[a]}}))},i.bindTooltip=function(){var t=this;this.container.addEventListener("mousemove",(function(e){var i=t.measures,n=w(t.container),s=e.pageX-n.left-k(i),a=e.pageY-n.top;a<t.height+P(i)&&a>P(i)?t.mapTooltipXPosition(s):t.tip.hideTip()}))},i.mapTooltipXPosition=function(t){var e=this.state;if(e.yExtremes){var i=function(t,e,i){void 0===i&&(i=!1);var n=e.reduce((function(e,i){return Math.abs(i-t)<Math.abs(e-t)?i:e}),[]);return i?e.indexOf(n):n}(t,e.xAxis.positions,!0);if(i>=0){var n=this.dataByIndex[i];this.tip.setValues(n.xPos+this.tip.offset.x,n.yExtreme+this.tip.offset.y,{name:n.formattedLabel,value:""},n.values,i),this.tip.showTip()}}},i.renderLegend=function(){var t=this,e=this.data;e.datasets.length>1&&(this.legendArea.textContent="",e.datasets.map((function(e,i){var n=function(t,e,i,n,s,a){void 0===n&&(n="none"),void 0===a&&(a=!1),s=a?Y(s,15):s;var r={className:"legend-bar",x:0,y:0,width:100,height:"2px",fill:n},o=J("text",{className:"legend-dataset-text",x:0,y:0,dy:"20px","font-size":"12px","text-anchor":"start",fill:q,innerHTML:s}),l=J("g",{transform:"translate("+t+", 0)"});return l.appendChild(J("rect",r)),l.appendChild(o),l}(100*i,0,0,t.colors[i],e.name,t.config.truncateLegends);t.legendArea.appendChild(n)})))},i.makeOverlay=function(){var t=this;this.init?this.init=0:(this.overlayGuides&&this.overlayGuides.forEach((function(t){var e=t.overlay;e.parentNode.removeChild(e)})),this.overlayGuides=this.dataUnitComponents.map((function(t){return{type:t.unitType,overlay:void 0,units:t.units}})),void 0===this.state.currentIndex&&(this.state.currentIndex=this.state.datasetLength-1),this.overlayGuides.map((function(e){var i=e.units[t.state.currentIndex];e.overlay=nt[e.type](i),t.drawArea.appendChild(e.overlay)})))},i.updateOverlayGuides=function(){this.overlayGuides&&this.overlayGuides.forEach((function(t){var e=t.overlay;e.parentNode.removeChild(e)}))},i.bindOverlay=function(){var t=this;this.parent.addEventListener("data-select",(function(){t.updateOverlay()}))},i.bindUnits=function(){var t=this;this.dataUnitComponents.map((function(e){e.units.map((function(e){e.addEventListener("click",(function(){var i=e.getAttribute("data-point-index");t.setCurrentDataPoint(i)}))}))})),this.tip.container.addEventListener("click",(function(){var e=t.tip.container.getAttribute("data-point-index");t.setCurrentDataPoint(e)}))},i.updateOverlay=function(){var t=this;this.overlayGuides.map((function(e){var i=e.units[t.state.currentIndex];st[e.type](i,e.overlay)}))},i.onLeftArrow=function(){this.setCurrentDataPoint(this.state.currentIndex-1)},i.onRightArrow=function(){this.setCurrentDataPoint(this.state.currentIndex+1)},i.getDataPoint=function(t){void 0===t&&(t=this.state.currentIndex);var e=this.state;return{index:t,label:e.xAxis.labels[t],values:e.datasets.map((function(e){return e.values[t]}))}},i.setCurrentDataPoint=function(t){var e=this.state;(t=parseInt(t))<0&&(t=0),t>=e.xAxis.labels.length&&(t=e.xAxis.labels.length-1),t!==e.currentIndex&&(e.currentIndex=t,function(t,e,i){var n=document.createEvent("HTMLEvents");for(var s in n.initEvent("data-select",!0,!0),i)n[s]=i[s];t.dispatchEvent(n)}(this.parent,0,this.getDataPoint()))},i.addDataPoint=function(e,i,n){void 0===n&&(n=this.state.datasetLength),t.prototype.addDataPoint.call(this,e,i,n),this.data.labels.splice(n,0,e),this.data.datasets.map((function(t,e){t.values.splice(n,0,i[e])})),this.update(this.data)},i.removeDataPoint=function(e){void 0===e&&(e=this.state.datasetLength-1),this.data.labels.length<=1||(t.prototype.removeDataPoint.call(this,e),this.data.labels.splice(e,1),this.data.datasets.map((function(t){t.values.splice(e,1)})),this.update(this.data))},i.updateDataset=function(t,e){void 0===e&&(e=0),this.data.datasets[e].values=t,this.update(this.data)},i.updateDatasets=function(t){this.data.datasets.map((function(e,i){t[i]&&(e.values=t[i])})),this.update(this.data)},e}(vt),Rt=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).type="donut",n.initTimeout=0,n.init=1,n.setup(),n}l(e,t);var i=e.prototype;return i.configure=function(e){t.prototype.configure.call(this,e),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=e.hoverRadio||.1,this.config.startAngle=e.startAngle||0,this.clockWise=e.clockWise||!1,this.strokeWidth=e.strokeWidth||30},i.calc=function(){var e=this;t.prototype.calc.call(this);var i=this.state;this.radius=this.height>this.width?this.center.x-this.strokeWidth/2:this.center.y-this.strokeWidth/2;var n=this.radius,s=this.clockWise,a=i.slicesProperties||[];i.sliceStrings=[],i.slicesProperties=[];var r=180-this.config.startAngle;i.sliceTotals.map((function(t,o){var l,c,h=r,u=t/i.grandTotal*360,d=u>180?1:0,p=s?-u:u,f=r+=p,v=W(h,n),m=W(f,n),g=e.init&&a[o];e.init?(l=g?g.startPosition:v,c=g?g.endPosition:v):(l=v,c=m);var y=360===u?function(t,e,i,n,s,a){void 0===s&&(s=1),void 0===a&&(a=0);var r=i.x+t.x,o=i.y+t.y,l=i.x+e.x,c=2*n+o;return"M"+r+" "+o+"\n\t\tA "+n+" "+n+" 0 "+a+" "+(s?1:0)+"\n\t\t"+l+" "+c+"\n\t\tM"+r+" "+c+"\n\t\tA "+n+" "+n+" 0 "+a+" "+(s?1:0)+"\n\t\t"+l+" "+(i.y+t.y)}(l,c,e.center,e.radius,e.clockWise,d):function(t,e,i,n,s,a){return void 0===s&&(s=1),void 0===a&&(a=0),"M"+(i.x+t.x)+" "+(i.y+t.y)+"\n\t\tA "+n+" "+n+" 0 "+a+" "+(s?1:0)+"\n\t\t"+(i.x+e.x)+" "+(i.y+e.y)}(l,c,e.center,e.radius,e.clockWise,d);i.sliceStrings.push(y),i.slicesProperties.push({startPosition:v,endPosition:m,value:t,total:i.grandTotal,startAngle:h,endAngle:f,angle:p})})),this.init=0},i.setupComponents=function(){var t=this.state,e=[["donutSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors,strokeWidth:this.strokeWidth}}.bind(this)]];this.components=new Map(e.map((function(t){var e=Nt.apply(void 0,t);return[t[0],e]})))},i.calTranslateByAngle=function(t){var e=this.radius,i=this.hoverRadio,n=W(t.startAngle+t.angle/2,e);return"translate3d("+n.x*i+"px,"+n.y*i+"px,0)"},i.hoverSlice=function(t,e,i,n){if(t){var s=this.colors[e];if(i){pt(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.stroke=V(s,50);var a=w(this.svg),r=n.pageX-a.left+10,o=n.pageY-a.top-10,l=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[e]:this.state.labels[e])+": ",c=(100*this.state.sliceTotals[e]/this.state.grandTotal).toFixed(1);this.tip.setValues(r,o,{name:l,value:c+"%"}),this.tip.showTip()}else pt(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.stroke=s}},i.bindTooltip=function(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)},i.mouseMove=function(t){var e=t.target,i=this.components.get("donutSlices").store,n=this.curActiveSliceIndex,s=this.curActiveSlice;if(i.includes(e)){var a=i.indexOf(e);this.hoverSlice(s,n,!1),this.curActiveSlice=e,this.curActiveSliceIndex=a,this.hoverSlice(e,a,!0,t)}else this.mouseLeave()},i.mouseLeave=function(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)},e}(mt),Yt={bar:It,line:It,percentage:St,heatmap:Ft,pie:Ot,donut:Rt},jt=function(t,e){return function(t,e,i){return void 0===t&&(t="line"),"axis-mixed"===t?(i.type="line",new It(e,i)):Yt[t]?new Yt[t](e,i):void console.error("Undefined chart type: "+t)}(e.type,t,e)},_t=function(t){function e(){return t.apply(this,arguments)||this}l(e,t);var i=e.prototype;return i.oninit=function(e){t.prototype.oninit.call(this,e);var i=new Date;i.setTime(i.getTime()+1e3*n().data.statistics.timezoneOffset),i.setUTCHours(0,0,0,0),i.setTime(i.getTime()-1e3*n().data.statistics.timezoneOffset),i/=1e3,this.entities=["users","discussions","posts"],this.periods={today:{start:i,end:i+86400,step:3600},last_7_days:{start:i-604800,end:i,step:86400},last_28_days:{start:i-2419200,end:i,step:86400},last_12_months:{start:i-31449600,end:i,step:604800}},this.selectedEntity="users",this.selectedPeriod="last_7_days"},i.className=function(){return"StatisticsWidget"},i.content=function(){var t=this,e=this.periods[this.selectedPeriod];return m("div",{className:"StatisticsWidget-table"},m("div",{className:"StatisticsWidget-labels"},m("div",{className:"StatisticsWidget-label"},n().translator.trans("flarum-statistics.admin.statistics.total_label")),m("div",{className:"StatisticsWidget-label"},m(d(),{buttonClassName:"Button Button--text",caretIcon:"fas fa-caret-down"},Object.keys(this.periods).map((function(e){return m(f(),{active:e===t.selectedPeriod,onclick:t.changePeriod.bind(t,e),icon:e!==t.selectedPeriod||"fas fa-check"},n().translator.trans("flarum-statistics.admin.statistics."+e+"_label"))}))))),this.entities.map((function(i){var s=t.getTotalCount(i),a=t.getPeriodCount(i,e),r=t.getPeriodCount(i,t.getLastPeriod(e)),o=r>0&&(a-r)/r*100;return m("a",{className:"StatisticsWidget-entity"+(t.selectedEntity===i?" active":""),onclick:t.changeEntity.bind(t,i)},m("h3",{className:"StatisticsWidget-heading"},n().translator.trans("flarum-statistics.admin.statistics."+i+"_heading")),m("div",{className:"StatisticsWidget-total",title:s},b()(s)),m("div",{className:"StatisticsWidget-period",title:a},b()(a)," ",o?m("span",{className:"StatisticsWidget-change StatisticsWidget-change--"+(o>0?"up":"down")},g()("fas fa-arrow-"+(o>0?"up":"down")),Math.abs(o.toFixed(1)),"%"):""))})),m("div",{className:"StatisticsWidget-chart",oncreate:this.drawChart.bind(this),onupdate:this.drawChart.bind(this)}))},i.drawChart=function(t){if(!this.chart||this.entity!==this.selectedEntity||this.period!==this.selectedPeriod){for(var e=n().data.statistics.timezoneOffset,i=this.periods[this.selectedPeriod],s=i.end-i.start,a=[],r=[],o=[],l=i.start;l<i.end;l+=i.step){var c=void 0;i.step<86400?c=dayjs.unix(l+e).format("h A"):(c=dayjs.unix(l+e).format("D MMM"),i.step>86400&&(c+=" - "+dayjs.unix(l+e+i.step-1).format("D MMM"))),a.push(c),r.push(this.getPeriodCount(this.selectedEntity,{start:l,end:l+i.step})),o.push(this.getPeriodCount(this.selectedEntity,{start:l-s,end:l-s+i.step}))}var h={labels:a,datasets:[{values:o},{values:r}]};this.chart?this.chart.update(h):this.chart=new jt(t.dom,{data:h,type:"line",height:280,axisOptions:{xAxisMode:"tick",yAxisMode:"span",xIsSeries:!0},lineOptions:{hideDots:1},colors:["black",n().forum.attribute("themePrimaryColor")]}),this.entity=this.selectedEntity,this.period=this.selectedPeriod}},i.changeEntity=function(t){this.selectedEntity=t},i.changePeriod=function(t){this.selectedPeriod=t},i.getTotalCount=function(t){return n().data.statistics[t].total},i.getPeriodCount=function(t,e){var i=n().data.statistics[t].timed,s=0;for(var a in i)a>=e.start&&a<e.end&&(s+=parseInt(i[a]));return s},i.getLastPeriod=function(t){return{start:t.start-(t.end-t.start),end:t.start}},e}(h());n().initializers.add("flarum-statistics",(function(){(0,s.extend)(r().prototype,"availableWidgets",(function(t){t.add("statistics",m(_t,null),20)}))}))})(),module.exports=e})();
//# sourceMappingURL=admin.js.map