module.exports=function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=8)}([function(t,e){t.exports=flarum.core.compat["utils/abbreviateNumber"]},function(t,e){t.exports=flarum.core.compat.app},function(t,e){t.exports=flarum.core.compat.extend},function(t,e){t.exports=flarum.core.compat["components/DashboardPage"]},function(t,e){t.exports=flarum.core.compat["components/DashboardWidget"]},function(t,e){t.exports=flarum.core.compat["components/SelectDropdown"]},function(t,e){t.exports=flarum.core.compat["components/Button"]},function(t,e){t.exports=flarum.core.compat["helpers/icon"]},function(t,e,i){"use strict";i.r(e);var n=i(1),s=i.n(n),a=i(2),r=i(3),o=i.n(r);function l(t,e){return(l=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,l(t,e)}var u=i(4),h=i.n(u),d=i(5),p=i.n(d),f=i(6),v=i.n(f),g=i(7),y=i.n(g),b=i(0),x=i.n(b);function w(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function A(t){var e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}}w.create=function(t,e){var i=document.createElement(t);for(var n in e){var s=e[n];if("inside"===n)w(s).appendChild(i);else if("around"===n){var a=w(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 P={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 k(t){return t.titleHeight+t.margins.top+t.paddings.top}function M(t){return t.margins.left+t.paddings.left}function T(t){return t.margins.top+t.margins.bottom+t.paddings.top+t.paddings.bottom+t.titleHeight+t.legendHeight}function L(t){return t.margins.left+t.margins.right+t.paddings.left+t.paddings.right}var C=["line","bar"],D=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta","light-grey","dark-grey"],N={bar:D,line:D,pie:D,percentage:D,heatmap:["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"],donut:D},S=Math.PI/180,O=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=w.create("div",{inside:this.parent,className:"graph-svg-tip comparison",innerHTML:'\n\t\t\t\t\n\t\t\t\t
'}),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?""+this.titleValue+""+this.titleName:this.titleName+""+this.titleValue+"",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=w.create("li",{styles:{"border-top":"3px solid "+n},innerHTML:''+(0===s||s?s:"")+"\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 E(t){return parseFloat(t.toFixed(2))}function z(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 t=n?s.concat(t):t.concat(s)}function W(t,e){return(t+"").length*e}function H(t,e){return{x:Math.sin(t*S)*e,y:Math.cos(t*S)*e}}function F(t,e){return void 0===e&&(e=!1),!Number.isNaN(t)&&(void 0!==t&&(!!Number.isFinite(t)&&!(e&&t<0)))}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=z(t,i):e=z(e,i),[t,e]}function j(t,e){if(t)return t.length>e?t.slice(0,e-3)+"...":t}function Y(t,e){for(var i=[],n=0;n255?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};function G(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function q(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)G(s).appendChild(i);else if("around"===n){var a=G(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 X(t,e,i,n){return q("stop",{inside:t,style:"stop-color: "+i,offset:e,"stop-opacity":n})}function J(t,e,i){void 0===e&&(e=""),void 0===i&&(i=void 0);var n={className:t,transform:e};return i&&(n.inside=i),q("g",n)}function K(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),q("path",{className:e,d:t,styles:{stroke:i,fill:n,"stroke-width":s}})}function $(t,e,i){void 0===i&&(i=!1);var n="path-fill-gradient-"+e+"-"+(i?"lighter":"default"),s=function(t,e){return q("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]),X(s,"0%",e,a[0]),X(s,"50%",e,a[1]),X(s,"100%",e,a[2]),n}function Q(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]})),q("rect",o)}function Z(t,e,i,n,s){void 0===s&&(s={});var a=s.fontSize||10;return q("text",{className:t,x:e,y:i,dy:(void 0!==s.dy?s.dy:a/2)+"px","font-size":a+"px",fill:s.fill||"#555b51","text-anchor":s.textAnchor||"start",innerHTML:n})}function tt(t,e,i,n,s){void 0===s&&(s={}),s.stroke||(s.stroke="#dadada"),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=q("line",{className:"line-horizontal "+s.className+("dashed"===s.lineType?"dashed":""),x1:i,x2:n,y1:0,y2:0,styles:{stroke:s.stroke}}),r=q("text",{x:in?i+4:i-4-10,dy:"10px","font-size":"10px","text-anchor":"middle",innerHTML:e+""}),o=q("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})}var it={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}},nt={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)}};function st(t,e,i,n){var s="string"==typeof e?e:e.join(", ");return[t,{transform:i.join(", ")},n,"easein","translate",{transform:s}]}function at(t,e,i){return st(t,[0,i],[0,e],350)}function rt(t,e){return[t,{d:e},350,"easein"]}var ot={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 lt(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 u=a[l]||t.getAttribute(l),h=e[l],d={attributeName:l,from:u,to:h,begin:"0s",dur:i/1e3+"s",values:u+";"+h,keySplines:ot[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("+h+")"):o.setAttribute(l,h)}return[r,o]}function ct(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function ut(t,e){var i=[],n=[];e.map((function(t){var e,s,a=t[0],r=a.parentNode;t[0]=a;var o=lt.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 ht=function(){function t(t,e){if(e=function t(e){var i,n,s;if(e instanceof Date)return new Date(e.getTime());if("object"!=typeof e||null===e)return e;for(s in i=Array.isArray(e)?[]:{},e)n=e[s],i[s]=t(n);return i}(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(P));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(N[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-T(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=w.create("div",t)},e.makeTooltip=function(){this.tip=new O({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-L(this.measures)},e.makeChartArea=function(){this.svg&&this.container.removeChild(this.svg);var t,e,i,n,s=this.measures;this.svg=(t=this.container,e="frappe-chart chart",i=this.baseWidth,n=this.baseHeight,q("svg",{className:e,inside:t,width:i,height:n})),this.svgDefs=q("defs",{inside:this.svg}),this.title.length&&(this.titleEL=Z("title",s.margins.left,s.margins.top,this.title,{fontSize:s.titleFontSize,fill:"#666666",dy:s.titleFontSize}));var a=k(s);this.drawArea=J(this.type+"-chart chart-draw-area","translate("+M(s)+", "+a+")"),this.config.showLegend&&(a+=this.height+s.paddings.bottom,this.legendArea=J("chart-legend","translate("+M(s)+", "+a+")")),this.title.length&&this.svg.appendChild(this.titleEL),this.svg.appendChild(this.drawArea),this.config.showLegend&&this.svg.appendChild(this.legendArea),this.updateTipOffset(M(s),k(s))},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=ut(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,n;i=e.container,(n=i.getBoundingClientRect()).top>=0&&n.left>=0&&n.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&n.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=w.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=w.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}(),dt=function(t){function e(e,i){return t.call(this,e,i)||this}c(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-L(t.measures))/r);t.legendTotals.lengtho&&(i=0,n+=20);var l=r*i+5,c=t.config.truncateLegends?j(e.labels[a],r/10):e.labels[a],u=t.config.formatTooltipY?t.config.formatTooltipY(s):s,h=function(t,e,i,n,s,a){void 0===n&&(n="none"),void 0===a&&(a=!1);var r={className:"legend-dot",cx:0,cy:0,r:i,fill:n},o=q("text",{className:"legend-dataset-text",x:0,y:0,dx:"10px",dy:10/3+"px","font-size":"12px","text-anchor":"start",fill:"#555b51",innerHTML:s=a?j(s,15):s}),l=q("g",{transform:"translate("+t+", "+e+")"});return l.appendChild(q("circle",r)),l.appendChild(o),l}(l,n,5,t.colors[a],c+": "+u,!1);t.legendArea.appendChild(h),i++}))},e}(ht),pt=["January","February","March","April","May","June","July","August","September","October","November","December"],ft=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function vt(t){var e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function mt(t){var e=t.getDate(),i=t.getMonth()+1;return[t.getFullYear(),(i>9?"":"0")+i,(e>9?"":"0")+e].join("-")}function gt(t){return new Date(t.getTime())}function yt(t,e){var i=At(t);return Math.ceil(function(t,e){return(vt(e)-vt(t))/864e5}(i,e)/7)}function bt(t,e){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function xt(t,e){void 0===e&&(e=!1);var i=pt[t];return e?i.slice(0,3):i}function wt(t,e){return new Date(e,t+1,0)}function At(t){var e=gt(t),i=e.getDay();return 0!==i&&Pt(e,-1*i),e}function Pt(t,e){t.setDate(t.getDate()+e)}var kt=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=J(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}(),Mt={donutSlices:{layerClass:"donut-slices",makeElements:function(t){return t.sliceStrings.map((function(e,i){var n=K(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 rt(e,t.sliceStrings[i])}))}},pieSlices:{layerClass:"pie-slices",makeElements:function(t){return t.sliceStrings.map((function(e,i){var n=K(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 rt(e,t.sliceStrings[i])}))}},percentageBars:{layerClass:"percentage-bars",makeElements:function(t){var e=this;return t.xPositions.map((function(i,n){return function(t,e,i,n,s,a){return void 0===s&&(s=2),void 0===a&&(a="none"),q("rect",{className:"percentage-bar",x:t,y:e,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])}))},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={}),F(t)||(t=0),n.pos||(n.pos="left"),n.offset||(n.offset=0),n.mode||(n.mode="span"),n.stroke||(n.stroke="#dadada"),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),tt(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 at(t,e[i],n[i])}))}},xAxis:{layerClass:"x axis",makeElements:function(t){var e=this;return t.positions.map((function(i,n){return et(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 st(t,[i,0],[e,0],350)}(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=q("text",{className:"chart-label",x:"left"===n.labelPos?4:i-W(e,5)-4,y:0,dy:"-5px","font-size":"10px","text-anchor":"start",innerHTML:e+""}),a=tt(t,"",0,i,{stroke:n.stroke||"#dadada",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 at(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=q("rect",{className:"bar mini",styles:{fill:"rgba(228, 234, 239, 0.49)",stroke:"#dadada","stroke-dasharray":i+", "+a},x:0,y:0,width:i,height:a});s.labelPos||(s.labelPos="right");var o=q("text",{className:"chart-label",x:"left"===s.labelPos?4:i-W(n+"",4.5)-4,y:0,dy:"-5px","font-size":"10px","text-anchor":"start",innerHTML:n+""}),l=q("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},350,"easein"],st(t,[0,n],[0,i],350)]}(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=l,u=0;return this.serializedSubDomains=[],t.cols.map((function(t,i){1===i&&e.labels.push(Z("domain-name",c,-12,xt(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=Q("day",c,u,r,o,t.fill,n);e.serializedSubDomains.push(s)}u+=a})),u=0,c+=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],u=l[1];u-=r,0===c&&(c=o.minHeight,u-=o.minHeight),F(t)||(t=0),F(u)||(u=0),F(c,!0)||(c=0),F(i,!0)||(i=0);var h=q("rect",{className:"bar mini",style:"fill: "+n,"data-point-index":a,x:t,y:u,width:i,height:c});if((s+="")||s.length){h.setAttribute("y",0),h.setAttribute("x",0);var d=q("text",{className:"data-point-value",x:i/2,y:0,dy:"-5px","font-size":"10px","text-anchor":"middle",innerHTML:s}),p=q("g",{"data-point-index":a,transform:"translate("+t+", "+u+")"});return p.appendChild(h),p.appendChild(d),p}return h}(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 u=R(r,i);r=u[0],i=u[1];var h=R(o,n);o=h[0],n=h[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},350,"easein"],u=t.getAttribute("transform").split("(")[1].slice(0,-1);return[c,st(t,u,[e,l],350)]}return[[t,{width:n,height:o,x:e,y:l},350,"easein"]]}(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=Y(t,e));var r=K("M"+a,"line-graph-path",i);if(n.heatline){var o=$(s.svgDefs,i);r.style.stroke="url(#"+o+")"}var l={path:r};if(n.regionFill){var c=$(s.svgDefs,i,!0),u="M"+t[0]+","+s.zeroLine+"L"+a+"L"+t.slice(-1)[0]+","+s.zeroLine;l.region=K(u,"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=q("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=q("text",{className:"data-point-value",x:0,y:0,dy:-5-i+"px","font-size":"10px","text-anchor":"middle",innerHTML:s}),l=q("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 u=[];return Object.keys(this.paths).length&&(u=u.concat(function(t,e,i,n,s){var a=[],r=i.map((function(t,i){return e[i]+","+t})).join("L");s&&(r=Y(e,i));var o=[t.path,{d:"M"+r},350,"easein"];if(a.push(o),t.region){var l=e[0]+","+n+"L",c="L"+e.slice(-1)[0]+", "+n,u=[t.region,{d:"M"+l+r+c},350,"easein"];a.push(u)}return a}(this.paths,e,i,t.zeroLine,this.constants.spline))),this.units.length&&this.units.map((function(t,n){u=u.concat(function(t,e,i){if("circle"!==t.nodeName){var n=t.getAttribute("transform").split("(")[1].slice(0,-1);return[st(t,n,[e,i],350)]}return[[t,{cx:e,cy:i},350,"easein"]]}(t,e[n],i[n]))})),u}}};function Tt(t,e,i){var n=Object.keys(Mt).filter((function(e){return t.includes(e)})),s=Mt[n[0]];return Object.assign(s,{constants:e,getData:i}),new kt(s)}var Lt=function(t){function e(e,i){var n;return(n=t.call(this,e,i)||this).type="percentage",n.setup(),n}c(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=Tt.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=A(t.container),o=A(s),l=o.left-r.left+parseInt(s.getAttribute("width"))/2,c=o.top-r.top,u=(t.formattedLabels&&t.formattedLabels.length>0?t.formattedLabels[a]:t.state.labels[a])+": ",h=e.sliceTotals[a]/e.grandTotal;t.tip.setValues(l,c,{name:u,value:(100*h).toFixed(1)+"%"}),t.tip.showTip()}}))},e}(dt),Ct=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}c(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,u=r,h=t/i.grandTotal*360,d=h>180?1:0,p=s?-h:h,f=r+=p,v=H(u,n),m=H(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===h?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,u=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+" "+u+" 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:u,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=Tt.apply(void 0,t);return[t[0],e]})))},i.calTranslateByAngle=function(t){var e=this.radius,i=this.hoverRadio,n=H(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){ct(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.fill=V(s,50);var a=A(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 ct(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}(dt);function Dt(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 Nt(t,e){void 0===e&&(e=0);var i=Dt(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=r.map((function(t){return t*Math.pow(10,s)}))}function St(t){return t[1]-t[0]}function Ot(t,e){return E(e.zeroLine-t*e.scaleMultiplier)}var Et=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}c(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+T(e);var i=this.data,n=this.discreteDomains?12:0;this.independentWidth=12*(yt(i.start,i.end)+n)+L(e)},i.updateWidth=function(){var t=this.discreteDomains?12:0,e=this.state.noOfWeeks?this.state.noOfWeeks:52;this.baseWidth=12*(e+t)+L(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[mt(n)]=t.dataPoints[i]})),t.dataPoints=e}return t},i.calc=function(){var t=this.state;t.start=gt(this.data.start),t.end=gt(this.data.end),t.firstWeekStart=gt(t.start),t.noOfWeeks=yt(t.start,t.end),t.distribution=function(t,e){for(var i=Math.max.apply(Math,t),n=1/(e-1),s=[],a=0;a=n.start&&s<=n.end;i||s.getMonth()!==e||!l?o.yyyyMmDd=mt(s):o=this.getSubDomainConfig(s),a.push(o)}return a},i.getSubDomainConfig=function(t){var e,i,n=mt(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 ti?n.slice(0,i):z(n,i-n.length,0),t.values=n}else t.values=s;t.chartType||(C.includes(e),t.chartType=e)})),t.yRegions&&t.yRegions.map((function(t){if(t.end=0&&n>=0)Dt(i)[1],s=e?Nt(i,n):Nt(i);else if(i>0&&n<0){var r=Math.abs(n);if(i>=r)Dt(i)[1],s=a(i,r);else Dt(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);Dt(o)[1],s=(s=e?Nt(o,l):Nt(o)).reverse().map((function(t){return-1*t}))}return s}(t,e),s=this.height/((i=n)[i.length-1]-i[0]),a=St(n)*s,r=this.height-function(t){var e,i=St(t);if(t.indexOf(0)>=0)e=t.indexOf(0);else if(t[0]>0){e=-1*t[0]/i}else{e=-1*t[t.length-1]/i+(t.length-1)}return e}(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 Ot(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?"&":"<"==t?"<":">"})),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){ea&&(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 u=new Array(t.datasetLength).fill(0);return s&&(u=e.yPositions.map((function(t,i){return t-e.cumulativeYPos[i]}))),{xPositions:l,yPositions:e.yPositions,offsets:u,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]k(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)=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);var r={className:"legend-bar",x:0,y:0,width:i,height:"2px",fill:n},o=q("text",{className:"legend-dataset-text",x:0,y:0,dy:"20px","font-size":"12px","text-anchor":"start",fill:"#555b51",innerHTML:s=a?j(s,15):s}),l=q("g",{transform:"translate("+t+", "+e+")"});return l.appendChild(q("rect",r)),l.appendChild(o),l}(100*i,"0",100,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=it[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];nt[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(e,!0,!0),i)n[s]=i[s];t.dispatchEvent(n)}(this.parent,"data-select",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}(ht),Wt={bar:zt,line:zt,percentage:Lt,heatmap:Et,pie:Ct,donut: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}c(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,u=r,h=t/i.grandTotal*360,d=h>180?1:0,p=s?-h:h,f=r+=p,v=H(u,n),m=H(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===h?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:u,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=Tt.apply(void 0,t);return[t[0],e]})))},i.calTranslateByAngle=function(t){var e=this.radius,i=this.hoverRadio,n=H(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){ct(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.stroke=V(s,50);var a=A(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 ct(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}(dt)};var Ht=function(t,e){return function(t,e,i){return void 0===t&&(t="line"),"axis-mixed"===t?(i.type="line",new zt(e,i)):Wt[t]?new Wt[t](e,i):void console.error("Undefined chart type: "+t)}(e.type,t,e)},Ft=function(t){function e(){return t.apply(this,arguments)||this}c(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*app.data.statistics.timezoneOffset),i.setUTCHours(0,0,0,0),i.setTime(i.getTime()-1e3*app.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"},app.translator.trans("flarum-statistics.admin.statistics.total_label")),m("div",{className:"StatisticsWidget-label"},m(p.a,{buttonClassName:"Button Button--text",caretIcon:"fas fa-caret-down"},Object.keys(this.periods).map((function(e){return m(v.a,{active:e===t.selectedPeriod,onclick:t.changePeriod.bind(t,e),icon:e!==t.selectedPeriod||"fas fa-check"},app.translator.trans("flarum-statistics.admin.statistics."+e+"_label"))}))))),this.entities.map((function(i){var n=t.getTotalCount(i),s=t.getPeriodCount(i,e),a=t.getPeriodCount(i,t.getLastPeriod(e)),r=a>0&&(s-a)/a*100;return m("a",{className:"StatisticsWidget-entity"+(t.selectedEntity===i?" active":""),onclick:t.changeEntity.bind(t,i)},m("h3",{className:"StatisticsWidget-heading"},app.translator.trans("flarum-statistics.admin.statistics."+i+"_heading")),m("div",{className:"StatisticsWidget-total",title:n},x()(n)),m("div",{className:"StatisticsWidget-period",title:s},x()(s)," ",r?m("span",{className:"StatisticsWidget-change StatisticsWidget-change--"+(r>0?"up":"down")},y()("fas fa-arrow-"+(r>0?"up":"down")),Math.abs(r.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=app.data.statistics.timezoneOffset,i=this.periods[this.selectedPeriod],n=i.end-i.start,s=[],a=[],r=[],o=i.start;o86400&&(l+=" - "+dayjs.unix(o+e+i.step-1).format("D MMM"))),s.push(l),a.push(this.getPeriodCount(this.selectedEntity,{start:o,end:o+i.step})),r.push(this.getPeriodCount(this.selectedEntity,{start:o-n,end:o-n+i.step}))}var c={labels:s,datasets:[{values:r},{values:a}]};this.chart?this.chart.update(c):this.chart=new Ht(t.dom,{data:c,type:"line",height:280,axisOptions:{xAxisMode:"tick",yAxisMode:"span",xIsSeries:!0},lineOptions:{hideDots:1},colors:["black",app.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 app.data.statistics[t].total},i.getPeriodCount=function(t,e){var i=app.data.statistics[t].timed,n=0;for(var s in i)s>=e.start&&s