module.exports=function(t){var e={};function s(i){if(e[i])return e[i].exports;var a=e[i]={i:i,l:!1,exports:{}};return t[i].call(a.exports,a,a.exports,s),a.l=!0,a.exports}return s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var a in t)s.d(i,a,function(e){return t[e]}.bind(null,a));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.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,s){"use strict";s.r(e);var i=s(1),a=s.n(i),n=s(2),r=s(3),o=s.n(r);var l=s(4),h=s.n(l),d=s(5),c=s.n(d),p=s(6),u=s.n(p),f=s(7),g=s.n(f),y=s(0),b=s.n(y);function x(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function v(t){let e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}}x.create=((t,e)=>{var s=document.createElement(t);for(var i in e){var a=e[i];if("inside"===i)x(a).appendChild(s);else if("around"===i){var n=x(a);n.parentNode.insertBefore(s,n),s.appendChild(n)}else"styles"===i?"object"==typeof a&&Object.keys(a).map(t=>{s.style[t]=a[t]}):i in s?s[i]=a:s.setAttribute(i,a)}return s});const w={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 A(t){return t.titleHeight+t.margins.top+t.paddings.top}function P(t){return t.margins.left+t.paddings.left}function k(t){return t.margins.top+t.margins.bottom+t.paddings.top+t.paddings.bottom+t.titleHeight+t.legendHeight}function C(t){return t.margins.left+t.margins.right+t.paddings.left+t.paddings.right}const D=700,L=400,T=["line","bar"],M=100,N=.5,O=.01,E=4,S=20,$=2,z=5,W=10,H=7,F=5,I=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta","light-grey","dark-grey"],R={bar:I,line:I,pie:I,percentage:I,heatmap:["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"]},j=Math.PI/180,Y=360;class _{constructor({parent:t=null,colors:e=[]}){this.parent=t,this.colors=e,this.titleName="",this.titleValue="",this.listValues=[],this.titleValueFirst=0,this.x=0,this.y=0,this.top=0,this.left=0,this.setup()}setup(){this.makeTooltip()}refresh(){this.fill(),this.calcPosition()}makeTooltip(){this.container=x.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",()=>{this.hideTip()})}fill(){let t;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((t,e)=>{const s=this.colors[e]||"black";let i=0===t.formatted||t.formatted?t.formatted:t.value,a=x.create("li",{styles:{"border-top":`3px solid ${s}`},innerHTML:`${0===i||i?i:""}\n\t\t\t\t\t${t.title?t.title:""}`});this.dataPointList.appendChild(a)})}calcPosition(){let t=this.container.offsetWidth;this.top=this.y-this.container.offsetHeight-F,this.left=this.x-t/2;let e=this.parent.offsetWidth-t,s=this.container.querySelector(".svg-pointer");if(this.left<0)s.style.left=`calc(50% - ${-1*this.left}px)`,this.left=0;else if(this.left>e){let t=`calc(50% + ${this.left-e}px)`;s.style.left=t,this.left=e}else s.style.left="50%"}setValues(t,e,s={},i=[],a=-1){this.titleName=s.name,this.titleValue=s.value,this.listValues=i,this.x=t,this.y=e,this.titleValueFirst=s.valueFirst||0,this.index=a,this.refresh()}hideTip(){this.container.style.top="0px",this.container.style.left="0px",this.container.style.opacity="0"}showTip(){this.container.style.top=this.top+"px",this.container.style.left=this.left+"px",this.container.style.opacity="1"}}function B(t){return parseFloat(t.toFixed(2))}function V(t,e,s,i=!1){s||(s=i?t[0]:t[t.length-1]);let a=new Array(Math.abs(e)).fill(s);return t=i?a.concat(t):t.concat(a)}function U(t,e){return(t+"").length*e}function G(t,e){return{x:Math.sin(t*j)*e,y:Math.cos(t*j)*e}}function q(t,e){let s,i;return t<=e?(s=e-t,i=t):(s=t-e,i=e),[s,i]}function X(t,e,s=e.length-t.length){return s>0?t=V(t,s):e=V(e,s),[t,e]}const J={"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 K(t){return t>255?255:t<0?0:t}function Q(t,e){let s=Z(t),i=!1;"#"==s[0]&&(s=s.slice(1),i=!0);let a=parseInt(s,16),n=K((a>>16)+e),r=K((a>>8&255)+e);return(i?"#":"")+(K((255&a)+e)|r<<8|n<<16).toString(16)}const Z=t=>J[t]||t,tt=6,et=4,st=10,it="#dadada",at="#555b51";function nt(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function rt(t,e){var s=document.createElementNS("http://www.w3.org/2000/svg",t);for(var i in e){var a=e[i];if("inside"===i)nt(a).appendChild(s);else if("around"===i){var n=nt(a);n.parentNode.insertBefore(s,n),s.appendChild(n)}else"styles"===i?"object"==typeof a&&Object.keys(a).map(t=>{s.style[t]=a[t]}):("className"===i&&(i="class"),"innerHTML"===i?s.textContent=a:s.setAttribute(i,a))}return s}function ot(t,e,s,i){return rt("stop",{inside:t,style:`stop-color: ${s}`,offset:e,"stop-opacity":i})}function lt(t,e="",s){let i={className:t,transform:e};return s&&(i.inside=s),rt("g",i)}function ht(t,e="",s="none",i="none"){return rt("path",{className:e,d:t,styles:{stroke:s,fill:i}})}function dt(t,e,s=!1){let i="path-fill-gradient-"+e+"-"+(s?"lighter":"default"),a=function(t,e){return rt("linearGradient",{inside:t,id:e,x1:0,x2:0,y1:0,y2:1})}(t,i),n=[1,.6,.2];return s&&(n=[.4,.2,0]),ot(a,"0%",e,n[0]),ot(a,"50%",e,n[1]),ot(a,"100%",e,n[2]),i}function ct(t,e,s,i,a="none",n={}){let r={className:t,x:e,y:s,width:i,height:i,fill:a};return Object.keys(n).map(t=>{r[t]=n[t]}),rt("rect",r)}function pt(t,e,s,i,a={}){let n=a.fontSize||st;return rt("text",{className:t,x:e,y:s,dy:(void 0!==a.dy?a.dy:n/2)+"px","font-size":n+"px",fill:a.fill||at,"text-anchor":a.textAnchor||"start",innerHTML:i})}function ut(t,e,s,i,a={}){a.stroke||(a.stroke=it),a.lineType||(a.lineType="");let n=rt("line",{className:"line-horizontal "+a.className+("dashed"===a.lineType?"dashed":""),x1:s,x2:i,y1:0,y2:0,styles:{stroke:a.stroke}}),r=rt("text",{x:si?s+et:s-et-st,dy:st+"px","font-size":st+"px","text-anchor":"middle",innerHTML:e+""}),o=rt("g",{transform:`translate(${t}, 0)`});return o.appendChild(n),o.appendChild(r),o}(t,e,a,n,{stroke:i.stroke,className:i.className,lineType:i.lineType})}let ft={bar:t=>{let e;"rect"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);let s=t.cloneNode();return s.style.fill="#000000",s.style.opacity="0.4",e&&s.setAttribute("transform",e),s},dot:t=>{let e;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);let s=t.cloneNode(),i=t.getAttribute("r"),a=t.getAttribute("fill");return s.setAttribute("r",parseInt(i)+4),s.setAttribute("fill",a),s.style.opacity="0.6",e&&s.setAttribute("transform",e),s},heat_square:t=>{let e;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);let s=t.cloneNode(),i=t.getAttribute("r"),a=t.getAttribute("fill");return s.setAttribute("r",parseInt(i)+4),s.setAttribute("fill",a),s.style.opacity="0.6",e&&s.setAttribute("transform",e),s}},gt={bar:(t,e)=>{let s;"rect"!==t.nodeName&&(s=t.getAttribute("transform"),t=t.childNodes[0]);let i=["x","y","width","height"];Object.values(t.attributes).filter(t=>i.includes(t.name)&&t.specified).map(t=>{e.setAttribute(t.name,t.nodeValue)}),s&&e.setAttribute("transform",s)},dot:(t,e)=>{let s;"circle"!==t.nodeName&&(s=t.getAttribute("transform"),t=t.childNodes[0]);let i=["cx","cy"];Object.values(t.attributes).filter(t=>i.includes(t.name)&&t.specified).map(t=>{e.setAttribute(t.name,t.nodeValue)}),s&&e.setAttribute("transform",s)},heat_square:(t,e)=>{let s;"circle"!==t.nodeName&&(s=t.getAttribute("transform"),t=t.childNodes[0]);let i=["cx","cy"];Object.values(t.attributes).filter(t=>i.includes(t.name)&&t.specified).map(t=>{e.setAttribute(t.name,t.nodeValue)}),s&&e.setAttribute("transform",s)}};const yt=350,bt=350,xt=yt,vt=250,wt="easein";function At(t,e,s,i){let a="string"==typeof e?e:e.join(", ");return[t,{transform:s.join(", ")},i,wt,"translate",{transform:a}]}function Pt(t,e,s){return At(t,[0,s],[0,e],xt)}const kt={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 Ct(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function Dt(t,e){let s=[],i=[];e.map(t=>{let e,a,n=t[0],r=n.parentNode;t[0]=n,[e,a]=function(t,e,s,i="linear",a,n={}){let r=t.cloneNode(!0),o=t.cloneNode(!0);for(var l in e){let d;d="transform"===l?document.createElementNS("http://www.w3.org/2000/svg","animateTransform"):document.createElementNS("http://www.w3.org/2000/svg","animate");let c=n[l]||t.getAttribute(l),p=e[l],u={attributeName:l,from:c,to:p,begin:"0s",dur:s/1e3+"s",values:c+";"+p,keySplines:kt[i],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};for(var h in a&&(u.type=a),u)d.setAttribute(h,u[h]);r.appendChild(d),a?o.setAttribute(l,`translate(${p})`):o.setAttribute(l,p)}return[r,o]}(...t),s.push(a),i.push([e,r]),r.replaceChild(e,n)});let a=t.cloneNode(!0);return i.map((t,i)=>{t[1].replaceChild(s[i],t[0]),e[i][0]=s[i]}),a}const Lt=".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}";let Tt;class Mt{constructor(t,e){if(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:1},this.measures=JSON.parse(JSON.stringify(w));let s=this.measures;this.setMeasures(e),this.title.length||(s.titleHeight=0),this.config.showLegend||(s.legendHeight=0),this.argHeight=e.height||s.baseHeight,this.state={},this.options={},this.initTimeout=D,this.config.isNavigable&&(this.overlays=[]),this.configure(e)}prepareData(t){return t}prepareFirstData(t){return t}validateColors(t,e){const s=[];return(t=(t||[]).concat(R[e])).forEach(t=>{const e=Z(t);!function(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}(e)?console.warn('"'+t+'" is not a valid color.'):s.push(e)}),s}setMeasures(){}configure(){let t=this.argHeight;this.baseHeight=t,this.height=t-k(this.measures),Tt=this.boundDrawFn.bind(this),window.addEventListener("resize",Tt),window.addEventListener("orientationchange",this.boundDrawFn.bind(this))}boundDrawFn(){this.draw(!0)}unbindWindowEvents(){window.removeEventListener("resize",Tt),window.removeEventListener("orientationchange",this.boundDrawFn.bind(this))}setup(){this.makeContainer(),this.updateWidth(),this.makeTooltip(),this.draw(!1,!0)}makeContainer(){this.parent.innerHTML="";let t={inside:this.parent,className:"chart-container"};this.independentWidth&&(t.styles={width:this.independentWidth+"px"}),this.container=x.create("div",t)}makeTooltip(){this.tip=new _({parent:this.container,colors:this.colors}),this.bindTooltip()}bindTooltip(){}draw(t=!1,e=!1){this.updateWidth(),this.calc(t),this.makeChartArea(),this.setupComponents(),this.components.forEach(t=>t.setup(this.drawArea)),this.render(this.components,!1),e&&(this.data=this.realData,setTimeout(()=>{this.update(this.data)},this.initTimeout)),this.renderLegend(),this.setupNavigation(e)}calc(){}updateWidth(){var t,e,s;this.baseWidth=(t=this.parent,e=window.getComputedStyle(t),s=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight),t.clientWidth-s),this.width=this.baseWidth-C(this.measures)}makeChartArea(){this.svg&&this.container.removeChild(this.svg);let t=this.measures;var e,s,i,a;this.svg=(e=this.container,s="frappe-chart chart",i=this.baseWidth,a=this.baseHeight,rt("svg",{className:s,inside:e,width:i,height:a})),this.svgDefs=rt("defs",{inside:this.svg}),this.title.length&&(this.titleEL=pt("title",t.margins.left,t.margins.top,this.title,{fontSize:t.titleFontSize,fill:"#666666",dy:t.titleFontSize}));let n=A(t);this.drawArea=lt(this.type+"-chart chart-draw-area",`translate(${P(t)}, ${n})`),this.config.showLegend&&(n+=this.height+t.paddings.bottom,this.legendArea=lt("chart-legend",`translate(${P(t)}, ${n})`)),this.title.length&&this.svg.appendChild(this.titleEL),this.svg.appendChild(this.drawArea),this.config.showLegend&&this.svg.appendChild(this.legendArea),this.updateTipOffset(P(t),A(t))}updateTipOffset(t,e){this.tip.offset={x:t,y:e}}setupComponents(){this.components=new Map}update(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.calc(),this.render()}render(t=this.components,e=!0){this.config.isNavigable&&this.overlays.map(t=>t.parentNode.removeChild(t));let s=[];t.forEach(t=>{s=s.concat(t.update(e))}),s.length>0?(!function(t,e,s){if(0===s.length)return;let i=Dt(e,s);e.parentNode==t&&(t.removeChild(e),t.appendChild(i)),setTimeout(()=>{i.parentNode==t&&(t.removeChild(i),t.appendChild(e))},vt)}(this.container,this.svg,s),setTimeout(()=>{t.forEach(t=>t.make()),this.updateNav()},L)):(t.forEach(t=>t.make()),this.updateNav())}updateNav(){this.config.isNavigable&&(this.makeOverlay(),this.bindUnits())}renderLegend(){}setupNavigation(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",t=>{(function(t){var e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)})(this.container)&&(t=t||window.event,this.keyActions[t.keyCode]&&this.keyActions[t.keyCode]())}))}makeOverlay(){}updateOverlay(){}bindOverlay(){}bindUnits(){}onLeftArrow(){}onRightArrow(){}onUpArrow(){}onDownArrow(){}onEnterKey(){}addDataPoint(){}removeDataPoint(){}getDataPoint(){}setCurrentDataPoint(){}updateDataset(){}export(){let t=function(t){let 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");let s=x.create("style",{innerHTML:Lt});e.insertBefore(s,e.firstChild);let i=x.create("div");return i.appendChild(e),i.innerHTML}(this.svg);!function(t,e){var s=document.createElement("a");s.style="display: none";var i=new Blob(e,{type:"image/svg+xml; charset=utf-8"}),a=window.URL.createObjectURL(i);s.href=a,s.download=t,document.body.appendChild(s),s.click(),setTimeout(function(){document.body.removeChild(s),window.URL.revokeObjectURL(a)},300)}(this.title||"Chart",[t])}}class Nt extends Mt{constructor(t,e){super(t,e)}configure(t){super.configure(t),this.config.maxSlices=t.maxSlices||20,this.config.maxLegendPoints=t.maxLegendPoints||20}calc(){let t=this.state,e=this.config.maxSlices;t.sliceTotals=[];let s=this.data.labels.map((t,e)=>{let s=0;return this.data.datasets.map(t=>{s+=t.values[e]}),[s,t]}).filter(t=>t[0]>=0),i=s;if(s.length>e){s.sort((t,e)=>e[0]-t[0]),i=s.slice(0,e-1);let t=s.slice(e-1),a=0;t.map(t=>{a+=t[0]}),i.push([a,"Rest"]),this.colors[e-1]="grey"}t.labels=[],i.map(e=>{t.sliceTotals.push(e[0]),t.labels.push(e[1])}),t.grandTotal=t.sliceTotals.reduce((t,e)=>t+e,0),this.center={x:this.width/2,y:this.height/2}}renderLegend(){let t=this.state;this.legendArea.textContent="",this.legendTotals=t.sliceTotals.slice(0,this.config.maxLegendPoints);let e=0,s=0;this.legendTotals.map((i,a)=>{let n=Math.floor((this.width-C(this.measures))/110);e>n&&(e=0,s+=20);let r=function(t,e,s,i="none",a){let n={className:"legend-dot",cx:0,cy:0,r:s,fill:i},r=rt("text",{className:"legend-dataset-text",x:0,y:0,dx:st+"px",dy:st/3+"px","font-size":1.2*st+"px","text-anchor":"start",fill:at,innerHTML:a}),o=rt("g",{transform:`translate(${t}, ${e})`});return o.appendChild(rt("circle",n)),o.appendChild(r),o}(110*e+5,s,5,this.colors[a],`${t.labels[a]}: ${i}`);this.legendArea.appendChild(r),e++})}}const Ot=12,Et=7,St=1e3,$t=86400,zt=["January","February","March","April","May","June","July","August","September","October","November","December"],Wt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Ht(t){let e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function Ft(t){let e=t.getDate(),s=t.getMonth()+1;return[t.getFullYear(),(s>9?"":"0")+s,(e>9?"":"0")+e].join("-")}function It(t){return new Date(t.getTime())}function Rt(t,e){let s=Bt(t);return Math.ceil(function(t,e){let s=$t*St;return(Ht(e)-Ht(t))/s}(s,e)/Et)}function jt(t,e){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function Yt(t,e=!1){let s=zt[t];return e?s.slice(0,3):s}function _t(t,e){return new Date(e,t+1,0)}function Bt(t){let e=It(t);const s=e.getDay();return 0!==s&&Vt(e,-1*s),e}function Vt(t,e){t.setDate(t.getDate()+e)}class Ut{constructor({layerClass:t="",layerTransform:e="",constants:s,getData:i,makeElements:a,animateElements:n}){this.layerTransform=e,this.constants=s,this.makeElements=a,this.getData=i,this.animateElements=n,this.store=[],this.labels=[],this.layerClass=t,this.layerClass="function"==typeof this.layerClass?this.layerClass():this.layerClass,this.refresh()}refresh(t){this.data=t||this.getData()}setup(t){this.layer=lt(this.layerClass,this.layerTransform,t)}make(){this.render(this.data),this.oldData=this.data}render(t){this.store=this.makeElements(t),this.layer.textContent="",this.store.forEach(t=>{this.layer.appendChild(t)}),this.labels.forEach(t=>{this.layer.appendChild(t)})}update(t=!0){this.refresh();let e=[];return t&&(e=this.animateElements(this.data)||[]),e}}let Gt={pieSlices:{layerClass:"pie-slices",makeElements:t=>t.sliceStrings.map((e,s)=>{let i=ht(e,"pie-path","none",t.colors[s]);return i.style.transition="transform .3s;",i}),animateElements(t){return this.store.map((e,s)=>(function(t,e){return[t,{d:e},yt,wt]})(e,t.sliceStrings[s]))}},percentageBars:{layerClass:"percentage-bars",makeElements(t){return t.xPositions.map((e,s)=>{return function(t,e,s,i,a=$,n="none"){return rt("rect",{className:"percentage-bar",x:t,y:e,width:s,height:i,fill:n,styles:{stroke:Q(n,-25),"stroke-dasharray":`0, ${i+s}, ${s}, ${i}`,"stroke-width":a}})}(e,0,t.widths[s],this.constants.barHeight,this.constants.barDepth,t.colors[s])})},animateElements(t){if(t)return[]}},yAxis:{layerClass:"y axis",makeElements(t){return t.positions.map((e,s)=>(function(t,e,s,i={}){i.pos||(i.pos="left"),i.offset||(i.offset=0),i.mode||(i.mode="span"),i.stroke||(i.stroke=it),i.className||(i.className="");let a=-1*tt,n="span"===i.mode?s+tt:0;return"tick"===i.mode&&"right"===i.pos&&(a=s+tt,n=s),ut(t,e,a+=i.offset,n+=i.offset,{stroke:i.stroke,className:i.className,lineType:i.lineType})})(e,t.labels[s],this.constants.width,{mode:this.constants.mode,pos:this.constants.pos}))},animateElements(t){let e=t.positions,s=t.labels,i=this.oldData.positions,a=this.oldData.labels;return[i,e]=X(i,e),[a,s]=X(a,s),this.render({positions:i,labels:s}),this.store.map((t,s)=>Pt(t,e[s],i[s]))}},xAxis:{layerClass:"x axis",makeElements(t){return t.positions.map((e,s)=>mt(e,t.calcLabels[s],this.constants.height,{mode:this.constants.mode,pos:this.constants.pos}))},animateElements(t){let e=t.positions,s=t.calcLabels,i=this.oldData.positions,a=this.oldData.calcLabels;return[i,e]=X(i,e),[a,s]=X(a,s),this.render({positions:i,calcLabels:s}),this.store.map((t,s)=>(function(t,e,s){return At(t,[s,0],[e,0],xt)})(t,e[s],i[s]))}},yMarkers:{layerClass:"y-markers",makeElements(t){return t.map(t=>(function(t,e,s,i={}){i.labelPos||(i.labelPos="right");let a=rt("text",{className:"chart-label",x:"left"===i.labelPos?et:s-U(e,5)-et,y:0,dy:st/-2+"px","font-size":st+"px","text-anchor":"start",innerHTML:e+""}),n=ut(t,"",0,s,{stroke:i.stroke||it,className:i.className||"",lineType:i.lineType});return n.appendChild(a),n})(t.position,t.label,this.constants.width,{labelPos:t.options.labelPos,mode:"span",lineType:"dashed"}))},animateElements(t){[this.oldData,t]=X(this.oldData,t);let e=t.map(t=>t.position),s=t.map(t=>t.label),i=t.map(t=>t.options),a=this.oldData.map(t=>t.position);return this.render(a.map((t,e)=>({position:a[e],label:s[e],options:i[e]}))),this.store.map((t,s)=>Pt(t,e[s],a[s]))}},yRegions:{layerClass:"y-regions",makeElements(t){return t.map(t=>(function(t,e,s,i,a={}){let n=t-e,r=rt("rect",{className:"bar mini",styles:{fill:"rgba(228, 234, 239, 0.49)",stroke:it,"stroke-dasharray":`${s}, ${n}`},x:0,y:0,width:s,height:n});a.labelPos||(a.labelPos="right");let o=rt("text",{className:"chart-label",x:"left"===a.labelPos?et:s-U(i+"",4.5)-et,y:0,dy:st/-2+"px","font-size":st+"px","text-anchor":"start",innerHTML:i+""}),l=rt("g",{transform:`translate(0, ${e})`});return l.appendChild(r),l.appendChild(o),l})(t.startPos,t.endPos,this.constants.width,t.label,{labelPos:t.options.labelPos}))},animateElements(t){[this.oldData,t]=X(this.oldData,t);let e=t.map(t=>t.endPos),s=t.map(t=>t.label),i=t.map(t=>t.startPos),a=t.map(t=>t.options),n=this.oldData.map(t=>t.endPos),r=this.oldData.map(t=>t.startPos);this.render(n.map((t,e)=>({startPos:r[e],endPos:n[e],label:s[e],options:a[e]})));let o=[];return this.store.map((t,s)=>{o=o.concat(function(t,e,s,i){let a=e-s,n=t.childNodes[0],r=n.getAttribute("width");return[[n,{height:a,"stroke-dasharray":`${r}, ${a}`},xt,wt],At(t,[0,i],[0,s],xt)]}(t,i[s],e[s],n[s]))}),o}},heatDomain:{layerClass:function(){return"heat-domain domain-"+this.constants.index},makeElements(t){let{index:e,colWidth:s,rowHeight:i,squareSize:a,xTranslate:n}=this.constants,r=n,o=0;return this.serializedSubDomains=[],t.cols.map((t,n)=>{1===n&&this.labels.push(pt("domain-name",r,-12,Yt(e,!0).toUpperCase(),{fontSize:9})),t.map((t,e)=>{if(t.fill){let s={"data-date":t.yyyyMmDd,"data-value":t.dataValue,"data-day":e},i=ct("day",r,o,a,t.fill,s);this.serializedSubDomains.push(i)}o+=i}),o=0,r+=s}),this.serializedSubDomains},animateElements(t){if(t)return[]}},barGraph:{layerClass:function(){return"dataset-units dataset-bars dataset-"+this.constants.index},makeElements(t){let e=this.constants;return this.unitType="bar",this.units=t.yPositions.map((s,i)=>(function(t,e,s,i,a="",n=0,r=0,o={}){let[l,h]=q(e,o.zeroLine);h-=r,0===l&&(l=o.minHeight,h-=o.minHeight);let d=rt("rect",{className:"bar mini",style:`fill: ${i}`,"data-point-index":n,x:t,y:h,width:s,height:l});if((a+="")||a.length){d.setAttribute("y",0),d.setAttribute("x",0);let e=rt("text",{className:"data-point-value",x:s/2,y:0,dy:st/2*-1+"px","font-size":st+"px","text-anchor":"middle",innerHTML:a}),i=rt("g",{"data-point-index":n,transform:`translate(${t}, ${h})`});return i.appendChild(d),i.appendChild(e),i}return d})(t.xPositions[i],s,t.barWidth,e.color,t.labels[i],i,t.offsets[i],{zeroLine:t.zeroLine,barsWidth:t.barsWidth,minHeight:e.minHeight})),this.units},animateElements(t){let e=t.xPositions,s=t.yPositions,i=t.offsets,a=t.labels,n=this.oldData.xPositions,r=this.oldData.yPositions,o=this.oldData.offsets,l=this.oldData.labels;[n,e]=X(n,e),[r,s]=X(r,s),[o,i]=X(o,i),[l,a]=X(l,a),this.render({xPositions:n,yPositions:r,offsets:o,labels:a,zeroLine:this.oldData.zeroLine,barsWidth:this.oldData.barsWidth,barWidth:this.oldData.barWidth});let h=[];return this.store.map((a,n)=>{h=h.concat(function(t,e,s,i,a=0,n={}){let[r,o]=q(s,n.zeroLine);if(o-=a,"rect"!==t.nodeName){let s=[t.childNodes[0],{width:i,height:r},yt,wt],a=t.getAttribute("transform").split("(")[1].slice(0,-1);return[s,At(t,a,[e,o],xt)]}return[[t,{width:i,height:r,x:e,y:o},yt,wt]]}(a,e[n],s[n],t.barWidth,i[n],{zeroLine:t.zeroLine}))}),h}},lineGraph:{layerClass:function(){return"dataset-units dataset-line dataset-"+this.constants.index},makeElements(t){let e=this.constants;return this.unitType="dot",this.paths={},e.hideLine||(this.paths=function(t,e,s,i={},a={}){let n=e.map((e,s)=>t[s]+","+e).join("L"),r=ht("M"+n,"line-graph-path",s);if(i.heatline){let t=dt(a.svgDefs,s);r.style.stroke=`url(#${t})`}let o={path:r};if(i.regionFill){let e=dt(a.svgDefs,s,!0),i="M"+`${t[0]},${a.zeroLine}L`+n+`L${t.slice(-1)[0]},${a.zeroLine}`;o.region=ht(i,"region-fill","none",`url(#${e})`)}return o}(t.xPositions,t.yPositions,e.color,{heatline:e.heatline,regionFill:e.regionFill},{svgDefs:e.svgDefs,zeroLine:t.zeroLine})),this.units=[],e.hideDots||(this.units=t.yPositions.map((s,i)=>(function(t,e,s,i,a="",n=0){let r=rt("circle",{style:`fill: ${i}`,"data-point-index":n,cx:t,cy:e,r:s});if((a+="")||a.length){r.setAttribute("cy",0),r.setAttribute("cx",0);let i=rt("text",{className:"data-point-value",x:0,y:0,dy:st/2*-1-s+"px","font-size":st+"px","text-anchor":"middle",innerHTML:a}),o=rt("g",{"data-point-index":n,transform:`translate(${t}, ${e})`});return o.appendChild(r),o.appendChild(i),o}return r})(t.xPositions[i],s,t.radius,e.color,e.valuesOverPoints?t.values[i]:"",i))),Object.values(this.paths).concat(this.units)},animateElements(t){let e=t.xPositions,s=t.yPositions,i=t.values,a=this.oldData.xPositions,n=this.oldData.yPositions,r=this.oldData.values;[a,e]=X(a,e),[n,s]=X(n,s),[r,i]=X(r,i),this.render({xPositions:a,yPositions:n,values:i,zeroLine:this.oldData.zeroLine,radius:this.oldData.radius});let o=[];return Object.keys(this.paths).length&&(o=o.concat(function(t,e,s,i){let a=[],n=s.map((t,s)=>e[s]+","+t).join("L");const r=[t.path,{d:"M"+n},bt,wt];if(a.push(r),t.region){let s=`${e[0]},${i}L`,r=`L${e.slice(-1)[0]}, ${i}`;const o=[t.region,{d:"M"+s+n+r},bt,wt];a.push(o)}return a}(this.paths,e,s,t.zeroLine))),this.units.length&&this.units.map((t,i)=>{o=o.concat(function(t,e,s){if("circle"!==t.nodeName){let i=t.getAttribute("transform").split("(")[1].slice(0,-1);return[At(t,i,[e,s],xt)]}return[[t,{cx:e,cy:s},yt,wt]]}(t,e[i],s[i]))}),o}}};function qt(t,e,s){let i=Object.keys(Gt).filter(e=>t.includes(e)),a=Gt[i[0]];return Object.assign(a,{constants:e,getData:s}),new Ut(a)}function Xt(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 s=Math.floor(Math.log10(t));return[e*(t/Math.pow(10,s)),s]}function Jt(t,e=0){let[s,i]=Xt(t),a=e?e/Math.pow(10,i):0,n=function(t,e=0){let s=Math.ceil(t),i=Math.floor(e),a=s-i,n=a,r=1;a>5&&(a%2!=0&&(a=++s-i),n=a/2,r=2),a<=2&&(r=a/(n=4)),0===a&&(n=5,r=1);let o=[];for(var l=0;l<=n;l++)o.push(i+r*l);return o}(s=s.toFixed(6),a);return n=n.map(t=>t*Math.pow(10,i))}function Kt(t){return t[1]-t[0]}function Qt(t,e){return B(e.zeroLine-t*e.scaleMultiplier)}const Zt=W+2,te=Zt;class ee extends Mt{constructor(t,e){super(t,e),this.barOptions=e.barOptions||{},this.lineOptions=e.lineOptions||{},this.type=e.type||"line",this.init=1,this.setup()}setMeasures(){this.data.datasets.length<=1&&(this.config.showLegend=0,this.measures.paddings.bottom=30)}configure(t){super.configure(t),t.axisOptions=t.axisOptions||{},t.tooltipOptions=t.tooltipOptions||{},this.config.xAxisMode=t.axisOptions.xAxisMode||"span",this.config.yAxisMode=t.axisOptions.yAxisMode||"span",this.config.xIsSeries=t.axisOptions.xIsSeries||0,this.config.formatTooltipX=t.tooltipOptions.formatTooltipX,this.config.formatTooltipY=t.tooltipOptions.formatTooltipY,this.config.valuesOverPoints=t.valuesOverPoints}prepareData(t=this.data){return function(t,e){t.labels=t.labels||[];let s=t.labels.length,i=t.datasets,a=new Array(s).fill(0);return i||(i=[{values:a}]),i.map(t=>{if(t.values){let e=t.values;e=(e=e.map(t=>isNaN(t)?0:t)).length>s?e.slice(0,s):V(e,s-e.length,0)}else t.values=a;t.chartType||(T.includes(e),t.chartType=e)}),t.yRegions&&t.yRegions.map(t=>{t.end({name:"",values:s.slice(0,-1),chartType:t.chartType}))};return t.yMarkers&&(i.yMarkers=[{value:0,label:""}]),t.yRegions&&(i.yRegions=[{start:0,end:0,label:""}]),i}(t)}calc(t=!1){this.calcXPositions(),t||this.calcYAxisParameters(this.getAllYValues(),"line"===this.type),this.makeDataByIndex()}calcXPositions(){let 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((e,s)=>B(t.xOffset+s*t.unitWidth))}}calcYAxisParameters(t,e="false"){const s=function(t,e=!1){let s=Math.max(...t),i=Math.min(...t),a=0,n=[];function r(t,e){let s=Jt(t),i=s[1]-s[0],a=0;for(var n=1;a=0&&i>=0)a=Xt(s)[1],n=e?Jt(s,i):Jt(s);else if(s>0&&i<0){let t=Math.abs(i);s>=t?(a=Xt(s)[1],n=r(s,t)):(a=Xt(t)[1],n=r(t,s).map(t=>-1*t))}else if(s<=0&&i<=0){let t=Math.abs(i),r=Math.abs(s);a=Xt(t)[1],n=(n=e?Jt(t,r):Jt(t)).reverse().map(t=>-1*t)}return n}(t,e),i=this.height/((a=s)[a.length-1]-a[0]);var a;const n=Kt(s)*i,r=this.height-function(t){let e,s=Kt(t);e=t.indexOf(0)>=0?t.indexOf(0):t[0]>0?-1*t[0]/s:-1*t[t.length-1]/s+(t.length-1);return e}(s)*n;this.state.yAxis={labels:s,positions:s.map(t=>r-t*i),scaleMultiplier:i,zeroLine:r},this.calcDatasetPoints(),this.calcYExtremes(),this.calcYRegions()}calcDatasetPoints(){let t=this.state,e=e=>e.map(e=>Qt(e,t.yAxis));t.datasets=this.data.datasets.map((t,s)=>{let i=t.values,a=t.cumulativeYs||[];return{name:t.name,index:s,chartType:t.chartType,values:i,yPositions:e(i),cumulativeYs:a,cumulativeYPos:e(a)}})}calcYExtremes(){let 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(e=>{e.yPositions.map((e,s)=>{e(e.position=Qt(e.value,t.yAxis),e.options||(e.options={}),e))),this.data.yRegions&&(this.state.yRegions=this.data.yRegions.map(e=>(e.startPos=Qt(e.start,t.yAxis),e.endPos=Qt(e.end,t.yAxis),e.options||(e.options={}),e)))}getAllYValues(){let t="values";if(this.barOptions.stacked){t="cumulativeYs";let e=new Array(this.state.datasetLength).fill(0);this.data.datasets.map((s,i)=>{let a=this.data.datasets[i].values;s[t]=e=e.map((t,e)=>t+a[e])})}let e=this.data.datasets.map(e=>e[t]);return this.data.yMarkers&&e.push(this.data.yMarkers.map(t=>t.value)),this.data.yRegions&&this.data.yRegions.map(t=>{e.push([t.end,t.start])}),[].concat(...e)}setupComponents(){let t=[["yAxis",{mode:this.config.yAxisMode,width:this.width},function(){return this.state.yAxis}.bind(this)],["xAxis",{mode:this.config.xAxisMode,height:this.height},function(){let t=this.state;return t.xAxis.calcLabels=function(t,e=[],s=!0){let i=t/e.length;i<=0&&(i=1);let a=i/H;return e.map((t,e)=>((t+="").length>a&&(s?e%Math.ceil(t.length/a)!=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)]],e=this.state.datasets.filter(t=>"bar"===t.chartType),s=this.state.datasets.filter(t=>"line"===t.chartType),i=e.map(t=>{let s=t.index;return["barGraph-"+t.index,{index:s,color:this.colors[s],stacked:this.barOptions.stacked,valuesOverPoints:this.config.valuesOverPoints,minHeight:this.height*O},function(){let t=this.state,i=t.datasets[s],a=this.barOptions.stacked,n=this.barOptions.spaceRatio||N,r=t.unitWidth*(1-n),o=r/(a?1:e.length),l=t.xAxis.positions.map(t=>t-r/2);a||(l=l.map(t=>t+o*s));let h=new Array(t.datasetLength).fill("");this.config.valuesOverPoints&&(h=a&&i.index===t.datasets.length-1?i.cumulativeYs:i.values);let d=new Array(t.datasetLength).fill(0);return a&&(d=i.yPositions.map((t,e)=>t-i.cumulativeYPos[e])),{xPositions:l,yPositions:i.yPositions,offsets:d,labels:h,zeroLine:t.yAxis.zeroLine,barsWidth:r,barWidth:o}}.bind(this)]}),a=s.map(t=>{let e=t.index;return["lineGraph-"+t.index,{index:e,color:this.colors[e],svgDefs:this.svgDefs,heatline:this.lineOptions.heatline,regionFill:this.lineOptions.regionFill,hideDots:this.lineOptions.hideDots,hideLine:this.lineOptions.hideLine,valuesOverPoints:this.config.valuesOverPoints},function(){let t=this.state,s=t.datasets[e],i=t.yAxis.positions[0]!r.includes(t[0])||this.state[t[0]]).map(t=>{let e=qt(...t);return(t[0].includes("lineGraph")||t[0].includes("barGraph"))&&this.dataUnitComponents.push(e),[t[0],e]}))}makeDataByIndex(){this.dataByIndex={};let t=this.state,e=this.config.formatTooltipX,s=this.config.formatTooltipY;t.xAxis.labels.map((i,a)=>{let n=this.state.datasets.map((t,e)=>{let i=t.values[a];return{title:t.name,value:i,yPos:t.yPositions[a],color:this.colors[e],formatted:s?s(i):i}});this.dataByIndex[a]={label:i,formattedLabel:e?e(i):i,xPos:t.xAxis.positions[a],values:n,yExtreme:t.yExtremes[a]}})}bindTooltip(){this.container.addEventListener("mousemove",t=>{let e=this.measures,s=v(this.container),i=t.pageX-s.left-P(e),a=t.pageY-s.top;aA(e)?this.mapTooltipXPosition(i):this.tip.hideTip()})}mapTooltipXPosition(t){let e=this.state;if(!e.yExtremes)return;let s=function(t,e,s=!1){let i=e.reduce(function(e,s){return Math.abs(s-t)1&&(this.legendArea.textContent="",t.datasets.map((t,e)=>{let s=function(t,e,s,i="none",a){let n={className:"legend-bar",x:0,y:0,width:s,height:"2px",fill:i},r=rt("text",{className:"legend-dataset-text",x:0,y:0,dy:2*st+"px","font-size":1.2*st+"px","text-anchor":"start",fill:at,innerHTML:a}),o=rt("g",{transform:`translate(${t}, ${e})`});return o.appendChild(rt("rect",n)),o.appendChild(r),o}(M*e,"0",M,this.colors[e],t.name);this.legendArea.appendChild(s)}))}makeOverlay(){this.init?this.init=0:(this.overlayGuides&&this.overlayGuides.forEach(t=>{let e=t.overlay;e.parentNode.removeChild(e)}),this.overlayGuides=this.dataUnitComponents.map(t=>({type:t.unitType,overlay:void 0,units:t.units})),void 0===this.state.currentIndex&&(this.state.currentIndex=this.state.datasetLength-1),this.overlayGuides.map(t=>{let e=t.units[this.state.currentIndex];t.overlay=ft[t.type](e),this.drawArea.appendChild(t.overlay)}))}updateOverlayGuides(){this.overlayGuides&&this.overlayGuides.forEach(t=>{let e=t.overlay;e.parentNode.removeChild(e)})}bindOverlay(){this.parent.addEventListener("data-select",()=>{this.updateOverlay()})}bindUnits(){this.dataUnitComponents.map(t=>{t.units.map(t=>{t.addEventListener("click",()=>{let e=t.getAttribute("data-point-index");this.setCurrentDataPoint(e)})})}),this.tip.container.addEventListener("click",()=>{let t=this.tip.container.getAttribute("data-point-index");this.setCurrentDataPoint(t)})}updateOverlay(){this.overlayGuides.map(t=>{let e=t.units[this.state.currentIndex];gt[t.type](e,t.overlay)})}onLeftArrow(){this.setCurrentDataPoint(this.state.currentIndex-1)}onRightArrow(){this.setCurrentDataPoint(this.state.currentIndex+1)}getDataPoint(t=this.state.currentIndex){let e=this.state;return{index:t,label:e.xAxis.labels[t],values:e.datasets.map(e=>e.values[t])}}setCurrentDataPoint(t){let 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,s){var i=document.createEvent("HTMLEvents");for(var a in i.initEvent(e,!0,!0),s)i[a]=s[a];t.dispatchEvent(i)}(this.parent,"data-select",this.getDataPoint()))}addDataPoint(t,e,s=this.state.datasetLength){super.addDataPoint(t,e,s),this.data.labels.splice(s,0,t),this.data.datasets.map((t,i)=>{t.values.splice(s,0,e[i])}),this.update(this.data)}removeDataPoint(t=this.state.datasetLength-1){this.data.labels.length<=1||(super.removeDataPoint(t),this.data.labels.splice(t,1),this.data.datasets.map(e=>{e.values.splice(t,1)}),this.update(this.data))}updateDataset(t,e=0){this.data.datasets[e].values=t,this.update(this.data)}updateDatasets(t){this.data.datasets.map((e,s)=>{t[s]&&(e.values=t[s])}),this.update(this.data)}}const se={bar:ee,line:ee,percentage:class extends Nt{constructor(t,e){super(t,e),this.type="percentage",this.setup()}setMeasures(t){let e=this.measures;this.barOptions=t.barOptions||{};let s=this.barOptions;s.height=s.height||S,s.depth=s.depth||$,e.paddings.right=30,e.legendHeight=80,e.baseHeight=8*(s.height+.5*s.depth)}setupComponents(){let 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(t=>{let e=qt(...t);return[t[0],e]}))}calc(){super.calc();let t=this.state;t.xPositions=[],t.widths=[];let e=0;t.sliceTotals.map(s=>{let i=this.width*s/t.grandTotal;t.widths.push(i),t.xPositions.push(e),e+=i})}makeDataByIndex(){}bindTooltip(){let t=this.state;this.container.addEventListener("mousemove",e=>{let s=this.components.get("percentageBars").store,i=e.target;if(s.includes(i)){let e=s.indexOf(i),a=v(this.container),n=v(i),r=n.left-a.left+parseInt(i.getAttribute("width"))/2,o=n.top-a.top,l=(this.formattedLabels&&this.formattedLabels.length>0?this.formattedLabels[e]:this.state.labels[e])+": ",h=t.sliceTotals[e]/t.grandTotal;this.tip.setValues(r,o,{name:l,value:(100*h).toFixed(1)+"%"}),this.tip.showTip()}})}},heatmap:class extends Mt{constructor(t,e){super(t,e),this.type="heatmap",this.countLabel=e.countLabel||"";let s=["Sunday","Monday"],i=s.includes(e.startSubDomain)?e.startSubDomain:"Sunday";this.startSubDomainIndex=s.indexOf(i),this.setup()}setMeasures(t){let e=this.measures;this.discreteDomains=0===t.discreteDomains?0:1,e.paddings.top=3*te,e.paddings.bottom=0,e.legendHeight=2*te,e.baseHeight=te*Et+k(e);let s=this.data,i=this.discreteDomains?Ot:0;this.independentWidth=(Rt(s.start,s.end)+i)*Zt+C(e)}updateWidth(){let t=this.discreteDomains?Ot:0,e=this.state.noOfWeeks?this.state.noOfWeeks:52;this.baseWidth=(e+t)*Zt+C(this.measures)}prepareData(t=this.data){if(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){let e={};Object.keys(t.dataPoints).forEach(s=>{let i=new Date(s*St);e[Ft(i)]=t.dataPoints[s]}),t.dataPoints=e}return t}calc(){let t=this.state;t.start=It(this.data.start),t.end=It(this.data.end),t.firstWeekStart=It(t.start),t.noOfWeeks=Rt(t.start,t.end),t.distribution=function(t,e){let s=Math.max(...t),i=1/(e-1),a=[];for(var n=0;n["heatDomain",{index:s.index,colWidth:Zt,rowHeight:te,squareSize:W,xTranslate:t.domainConfigs.filter((t,e)=>et.cols.length-e).reduce((t,e)=>t+e,0)*Zt},function(){return t.domainConfigs[i]}.bind(this)]);this.components=new Map(s.map((t,e)=>{let s=qt(...t);return[t[0]+"-"+e,s]}));let i=0;Wt.forEach((t,e)=>{if([1,3,5].includes(e)){let e=pt("subdomain-name",-Zt/2,i,t,{fontSize:W,dy:8,textAnchor:"end"});this.drawArea.appendChild(e)}i+=te})}update(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.draw(),this.bindTooltip()}bindTooltip(){this.container.addEventListener("mousemove",t=>{this.components.forEach(e=>{let s=e.store,i=t.target;if(s.includes(i)){let e=i.getAttribute("data-value"),s=i.getAttribute("data-date").split("-"),a=Yt(parseInt(s[1])-1,!0),n=this.container.getBoundingClientRect(),r=i.getBoundingClientRect(),o=parseInt(t.target.getAttribute("width")),l=r.left-n.left+o/2,h=r.top-n.top,d=e+" "+this.countLabel,c=" on "+a+" "+s[0]+", "+s[2];this.tip.setValues(l,h,{name:c,value:d,valueFirst:1},[]),this.tip.showTip()}})})}renderLegend(){this.legendArea.textContent="";let t=0,e=te,s=pt("subdomain-name",t,e,"Less",{fontSize:W+1,dy:9});t=2*Zt+Zt/2,this.legendArea.appendChild(s),this.colors.slice(0,z).map((s,i)=>{const a=ct("heatmap-legend-unit",t+(Zt+3)*i,e,W,s);this.legendArea.appendChild(a)});let i=pt("subdomain-name",t+z*(Zt+3)+Zt/4,e,"More",{fontSize:W+1,dy:9});this.legendArea.appendChild(i)}getDomains(){let t=this.state;const[e,s]=[t.start.getMonth(),t.start.getFullYear()],[i,a]=[t.end.getMonth(),t.end.getFullYear()],n=i-e+1+12*(a-s);let r=[],o=It(t.start);for(var l=0;l=i.start&&a<=i.end;s||a.getMonth()!==e||!r?t.yyyyMmDd=Ft(a):t=this.getSubDomainConfig(a),n.push(t)}return n}getSubDomainConfig(t){let e=Ft(t),s=this.data.dataPoints[e];var i,a;return{yyyyMmDd:e,dataValue:s||0,fill:this.colors[(i=s,a=this.state.distribution,a.filter(t=>tthis.width?this.center.x:this.center.y;const{radius:e,clockWise:s}=this,i=t.slicesProperties||[];t.sliceStrings=[],t.slicesProperties=[];let a=180-this.config.startAngle;t.sliceTotals.map((n,r)=>{const o=a,l=n/t.grandTotal*Y,h=s?-l:l,d=a+=h,c=G(o,e),p=G(d,e),u=this.init&&i[r];let m,f;this.init?(m=u?u.startPosition:c,f=u?u.endPosition:c):(m=c,f=p);const g=function(t,e,s,i,a=1){let[n,r]=[s.x+t.x,s.y+t.y],[o,l]=[s.x+e.x,s.y+e.y];return`M${s.x} ${s.y}\n\t\tL${n} ${r}\n\t\tA ${i} ${i} 0 0 ${a?1:0}\n\t\t${o} ${l} z`}(m,f,this.center,this.radius,this.clockWise);t.sliceStrings.push(g),t.slicesProperties.push({startPosition:c,endPosition:p,value:n,total:t.grandTotal,startAngle:o,endAngle:d,angle:h})}),this.init=0}setupComponents(){let t=this.state,e=[["pieSlices",{},function(){return{sliceStrings:t.sliceStrings,colors:this.colors}}.bind(this)]];this.components=new Map(e.map(t=>{let e=qt(...t);return[t[0],e]}))}calTranslateByAngle(t){const{radius:e,hoverRadio:s}=this,i=G(t.startAngle+t.angle/2,e);return`translate3d(${i.x*s}px,${i.y*s}px,0)`}hoverSlice(t,e,s,i){if(!t)return;const a=this.colors[e];if(s){Ct(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.fill=Q(a,50);let s=v(this.svg),n=i.pageX-s.left+10,r=i.pageY-s.top-10,o=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[e]:this.state.labels[e])+": ",l=(100*this.state.sliceTotals[e]/this.state.grandTotal).toFixed(1);this.tip.setValues(n,r,{name:o,value:l+"%"}),this.tip.showTip()}else Ct(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.fill=a}bindTooltip(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}mouseMove(t){const e=t.target;let s=this.components.get("pieSlices").store,i=this.curActiveSliceIndex,a=this.curActiveSlice;if(s.includes(e)){let n=s.indexOf(e);this.hoverSlice(a,i,!1),this.curActiveSlice=e,this.curActiveSliceIndex=n,this.hoverSlice(e,n,!0,t)}else this.mouseLeave()}mouseLeave(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}};class ie{constructor(t,e){return function(t="line",e,s){return"axis-mixed"===t?(s.type="line",new ee(e,s)):se[t]?new se[t](e,s):void console.error("Undefined chart type: "+t)}(e.type,t,e)}}var ae=function(t){var e,s;function i(){return t.apply(this,arguments)||this}s=t,(e=i).prototype=Object.create(s.prototype),e.prototype.constructor=e,e.__proto__=s;var a=i.prototype;return a.init=function(){t.prototype.init.call(this);var e=new Date;e.setTime(e.getTime()+1e3*app.data.statistics.timezoneOffset),e.setUTCHours(0,0,0,0),e.setTime(e.getTime()-1e3*app.data.statistics.timezoneOffset),e/=1e3,this.entities=["users","discussions","posts"],this.periods={today:{start:e,end:e+86400,step:3600},last_7_days:{start:e-604800,end:e,step:86400},last_28_days:{start:e-2419200,end:e,step:86400},last_12_months:{start:e-31449600,end:e,step:604800}},this.selectedEntity="users",this.selectedPeriod="last_7_days"},a.className=function(){return"StatisticsWidget"},a.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(c.a,{buttonClassName:"Button Button--text",caretIcon:"fas fa-caret-down"},Object.keys(this.periods).map(function(e){return m(u.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(s){var i=t.getTotalCount(s),a=t.getPeriodCount(s,e),n=t.getPeriodCount(s,t.getLastPeriod(e)),r=n>0&&(a-n)/n*100;return m("a",{className:"StatisticsWidget-entity"+(t.selectedEntity===s?" active":""),onclick:t.changeEntity.bind(t,s)},m("h3",{className:"StatisticsWidget-heading"},app.translator.trans("flarum-statistics.admin.statistics."+s+"_heading")),m("div",{className:"StatisticsWidget-total",title:i},b()(i)),m("div",{className:"StatisticsWidget-period",title:a},b()(a)," ",r?m("span",{className:"StatisticsWidget-change StatisticsWidget-change--"+(r>0?"up":"down")},g()("fas fa-arrow-"+(r>0?"up":"down")),Math.abs(r.toFixed(1)),"%"):""))}),m("div",{className:"StatisticsWidget-chart",config:this.drawChart.bind(this)}))},a.drawChart=function(t,e,s){if(!s.chart||s.entity!==this.selectedEntity||s.period!==this.selectedPeriod){for(var i=app.data.statistics.timezoneOffset,a=this.periods[this.selectedPeriod],n=a.end-a.start,r=[],o=[],l=[],h=a.start;h86400&&(d+=" - "+moment.unix(h+i+a.step-1).utc().format("D MMM"))),r.push(d),o.push(this.getPeriodCount(this.selectedEntity,{start:h,end:h+a.step})),l.push(this.getPeriodCount(this.selectedEntity,{start:h-n,end:h-n+a.step}))}var c={labels:r,datasets:[{values:l},{values:o}]};s.chart?s.chart.update(c):s.chart=new ie(t,{data:c,type:"line",height:280,axisOptions:{xAxisMode:"tick",yAxisMode:"span",xIsSeries:!0},lineOptions:{hideDots:1},colors:["black",app.forum.attribute("themePrimaryColor")]}),s.entity=this.selectedEntity,s.period=this.selectedPeriod}},a.changeEntity=function(t){this.selectedEntity=t},a.changePeriod=function(t){this.selectedPeriod=t},a.getTotalCount=function(t){return app.data.statistics[t].total},a.getPeriodCount=function(t,e){var s=app.data.statistics[t].timed,i=0;for(var a in s)a>=e.start&&a