You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

3 line
56 KiB

  1. var frappe=function(t){"use strict";function e(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function i(t){var e=t.getBoundingClientRect();return{top:e.top+(document.documentElement.scrollTop||document.body.scrollTop),left:e.left+(document.documentElement.scrollLeft||document.body.scrollLeft)}}function n(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)}function a(t){var e=window.getComputedStyle(t),i=parseFloat(e.paddingLeft)+parseFloat(e.paddingRight);return t.clientWidth-i}function r(t,e,i){var n=document.createEvent("HTMLEvents");n.initEvent(e,!0,!0);for(var a in i)n[a]=i[a];return t.dispatchEvent(n)}function s(t){return parseFloat(t.toFixed(2))}function o(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];i||(i=n?t[0]:t[t.length-1]);var a=new Array(Math.abs(e)).fill(i);return t=n?a.concat(t):t.concat(a)}function l(t,e){return(t+"").length*e}function c(t,e){return{x:Math.sin(t*_t)*e,y:Math.cos(t*_t)*e}}function u(t,e){var i=void 0,n=void 0;return t<=e?(i=e-t,n=t):(i=t-e,n=e),[i,n]}function h(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length-t.length;return i>0?t=o(t,i):e=o(e,i),[t,e]}function d(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function p(t,e){var i=document.createElementNS("http://www.w3.org/2000/svg",t);for(var n in e){var a=e[n];if("inside"===n)d(a).appendChild(i);else if("around"===n){var r=d(a);r.parentNode.insertBefore(i,r),i.appendChild(r)}else"styles"===n?"object"===(void 0===a?"undefined":bt(a))&&Object.keys(a).map(function(t){i.style[t]=a[t]}):("className"===n&&(n="class"),"innerHTML"===n?i.textContent=a:i.setAttribute(n,a))}return i}function f(t,e){return p("linearGradient",{inside:t,id:e,x1:0,x2:0,y1:0,y2:1})}function v(t,e,i,n){return p("stop",{inside:t,style:"stop-color: "+i,offset:e,"stop-opacity":n})}function g(t,e,i,n){return p("svg",{className:e,inside:t,width:i,height:n})}function y(t){return p("defs",{inside:t})}function m(t,e){return p("g",{className:e,inside:t,transform:arguments.length>2&&void 0!==arguments[2]?arguments[2]:""})}function b(t){return p("path",{className:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",d:t,styles:{stroke:arguments.length>2&&void 0!==arguments[2]?arguments[2]:"none",fill:arguments.length>3&&void 0!==arguments[3]?arguments[3]:"none"}})}function x(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:1,r=i.x+t.x,s=i.y+t.y,o=i.x+e.x,l=i.y+e.y;return"M"+i.x+" "+i.y+"\n\t\tL"+r+" "+s+"\n\t\tA "+n+" "+n+" 0 0 "+(a?1:0)+"\n\t\t"+o+" "+l+" z"}function k(t,e){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n="path-fill-gradient-"+e+"-"+(i?"lighter":"default"),a=f(t,n),r=[1,.6,.2];return i&&(r=[.4,.2,0]),v(a,"0%",e,r[0]),v(a,"50%",e,r[1]),v(a,"100%",e,r[2]),n}function w(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"none",r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s={className:t,x:e,y:i,width:n,height:n,fill:a};return Object.keys(r).map(function(t){s[t]=r[t]}),p("rect",s)}function A(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Rt;return p("text",{className:t,x:e,y:i,dy:a/2+"px","font-size":a+"px",innerHTML:n})}function P(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};a.stroke||(a.stroke=It);var r=p("line",{className:"line-vertical "+a.className,x1:0,x2:0,y1:i,y2:n,styles:{stroke:a.stroke}}),s=p("text",{x:0,y:i>n?i+Ht:i-Ht-Rt,dy:Rt+"px","font-size":Rt+"px","text-anchor":"middle",innerHTML:e+""}),o=p("g",{transform:"translate("+t+", 0)"});return o.appendChild(r),o.appendChild(s),o}function D(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};a.stroke||(a.stroke=It),a.lineType||(a.lineType="");var r=p("line",{className:"line-horizontal "+a.className+("dashed"===a.lineType?"dashed":""),x1:i,x2:n,y1:0,y2:0,styles:{stroke:a.stroke}}),s=p("text",{x:i<n?i-Ht:i+Ht,y:0,dy:Rt/2-2+"px","font-size":Rt+"px","text-anchor":i<n?"end":"start",innerHTML:e+""}),o=p("g",{transform:"translate(0, "+t+")","stroke-opacity":1});return 0!==s&&"0"!==s||(o.style.stroke="rgba(27, 31, 35, 0.6)"),o.appendChild(r),o.appendChild(s),o}function T(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.pos||(n.pos="left"),n.offset||(n.offset=0),n.mode||(n.mode="span"),n.stroke||(n.stroke=It),n.className||(n.className="");var a=-1*Ft,r="span"===n.mode?i+Ft:0;return"tick"===n.mode&&"right"===n.pos&&(a=i+Ft,r=i),a+=n.offset,r+=n.offset,D(t,e,a,r,{stroke:n.stroke,className:n.className,lineType:n.lineType})}function M(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};n.pos||(n.pos="bottom"),n.offset||(n.offset=0),n.mode||(n.mode="span"),n.stroke||(n.stroke=It),n.className||(n.className="");var a=i+Ft,r="span"===n.mode?-1*Ft:i;return"tick"===n.mode&&"top"===n.pos&&(a=-1*Ft,r=0),P(t,e,a,r,{stroke:n.stroke,className:n.className,lineType:n.lineType})}function L(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=p("text",{className:"chart-label",x:i-l(e,5)-Ht,y:0,dy:Rt/-2+"px","font-size":Rt+"px","text-anchor":"start",innerHTML:e+""}),r=D(t,"",0,i,{stroke:n.stroke||It,className:n.className||"",lineType:n.lineType});return r.appendChild(a),r}function C(t,e,i,n){var a=t-e,r=p("rect",{className:"bar mini",styles:{fill:"rgba(228, 234, 239, 0.49)",stroke:It,"stroke-dasharray":i+", "+a},x:0,y:0,width:i,height:a}),s=p("text",{className:"chart-label",x:i-l(n+"",4.5)-Ht,y:0,dy:Rt/-2+"px","font-size":Rt+"px","text-anchor":"start",innerHTML:n+""}),o=p("g",{transform:"translate(0, "+e+")"});return o.appendChild(r),o.appendChild(s),o}function O(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0,o=arguments.length>7&&void 0!==arguments[7]?arguments[7]:{},l=u(e,o.zeroLine),c=Dt(l,2),h=c[0],d=c[1],f=p("rect",{className:"bar mini",style:"fill: "+n,"data-point-index":r,x:t,y:d-=s,width:i,height:h||o.minHeight});if((a+="")||a.length){f.setAttribute("y",0),f.setAttribute("x",0);var v=p("text",{className:"data-point-value",x:i/2,y:0,dy:Rt/2*-1+"px","font-size":Rt+"px","text-anchor":"middle",innerHTML:a}),g=p("g",{"data-point-index":r,transform:"translate("+t+", "+d+")"});return g.appendChild(f),g.appendChild(v),g}return f}function N(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,s=p("circle",{style:"fill: "+n,"data-point-index":r,cx:t,cy:e,r:i});if((a+="")||a.length){s.setAttribute("cy",0),s.setAttribute("cx",0);var o=p("text",{className:"data-point-value",x:0,y:0,dy:Rt/2*-1-i+"px","font-size":Rt+"px","text-anchor":"middle",innerHTML:a}),l=p("g",{"data-point-index":r,transform:"translate("+t+", "+e+")"});return l.appendChild(s),l.appendChild(o),l}return s}function E(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},r=e.map(function(e,i){return t[i]+","+e}).join("L"),s=b("M"+r,"line-graph-path",i);if(n.heatline){var o=k(a.svgDefs,i);s.style.stroke="url(#"+o+")"}var l={path:s};if(n.regionFill){var c=k(a.svgDefs,i,!0),u="M"+t[0]+","+a.zeroLine+"L"+r+"L"+t.slice(-1)[0]+","+a.zeroLine;l.region=b(u,"region-fill","none","url(#"+c+")")}return l}function S(t){return t>255?255:t<0?0:t}function _(t,e){var i=Bt(t),n=!1;"#"==i[0]&&(i=i.slice(1),n=!0);var a=parseInt(i,16),r=S((a>>16)+e),s=S((a>>8&255)+e),o=S((255&a)+e);return(n?"#":"")+(o|s<<8|r<<16).toString(16)}function z(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}function j(t,e,i,n){var a="string"==typeof e?e:e.join(", ");return[t,{transform:i.join(", ")},n,Kt,"translate",{transform:a}]}function W(t,e,i){return j(t,[i,0],[e,0],Xt)}function F(t,e,i){return j(t,[0,i],[0,e],Xt)}function H(t,e,i,n){var a=e-i,r=t.childNodes[0];return[[r,{height:a,"stroke-dasharray":r.getAttribute("width")+", "+a},Xt,Kt],j(t,[0,n],[0,i],Xt)]}function R(t,e,i,n){var a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,r=u(i,(arguments.length>5&&void 0!==arguments[5]?arguments[5]:{}).zeroLine),s=Dt(r,2),o=s[0],l=s[1];return l-=a,"rect"!==t.nodeName?[[t.childNodes[0],{width:n,height:o},Ut,Kt],j(t,t.getAttribute("transform").split("(")[1].slice(0,-1),[e,l],Xt)]:[[t,{width:n,height:o,x:e,y:l},Ut,Kt]]}function I(t,e,i){return"circle"!==t.nodeName?[j(t,t.getAttribute("transform").split("(")[1].slice(0,-1),[e,i],Xt)]:[[t,{cx:e,cy:i},Ut,Kt]]}function Y(t,e,i,n){var a=[],r=i.map(function(t,i){return e[i]+","+t}).join("L"),s=[t.path,{d:"M"+r},qt,Kt];if(a.push(s),t.region){var o=e[0]+","+n+"L",l="L"+e.slice(-1)[0]+", "+n,c=[t.region,{d:"M"+o+r+l},qt,Kt];a.push(c)}return a}function V(t,e){return[t,{d:e},Ut,Kt]}function G(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"linear",a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0,r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=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=r[l]||t.getAttribute(l),h=e[l],d={attributeName:l,from:u,to:h,begin:"0s",dur:i/1e3+"s",values:u+";"+h,keySplines:$t[n],keyTimes:"0;1",calcMode:"spline",fill:"freeze"};a&&(d.type=a);for(var p in d)c.setAttribute(p,d[p]);s.appendChild(c),a?o.setAttribute(l,"translate("+h+")"):o.setAttribute(l,h)}return[s,o]}function B(t,e){t.style.transform=e,t.style.webkitTransform=e,t.style.msTransform=e,t.style.mozTransform=e,t.style.oTransform=e}function U(t,e){var i=[],n=[];e.map(function(t){var e=t[0],a=e.parentNode,r=void 0,s=void 0;t[0]=e;var o=G.apply(void 0,Tt(t)),l=Dt(o,2);r=l[0],s=l[1],i.push(s),n.push([r,a]),a.replaceChild(r,e)});var a=t.cloneNode(!0);return n.map(function(t,n){t[1].replaceChild(i[n],t[0]),e[n][0]=i[n]}),a}function q(t,e,i){if(0!==i.length){var n=U(e,i);e.parentNode==t&&(t.removeChild(e),t.appendChild(n)),setTimeout(function(){n.parentNode==t&&(t.removeChild(n),t.appendChild(e))},Jt)}}function X(t,e,i){var n=Object.keys(ie).filter(function(e){return t.includes(e)}),a=ie[n[0]];return Object.assign(a,{constants:e,getData:i}),new ee(a)}function J(t){var e=new Date(t);return e.setMinutes(e.getMinutes()-e.getTimezoneOffset()),e}function K(t){var e=t.getDate(),i=t.getMonth()+1;return[t.getFullYear(),(i>9?"":"0")+i,(e>9?"":"0")+e].join("-")}function $(t){return new Date(t.getTime())}function Q(t,e){var i=nt(t);return Math.ceil(Z(i,e)/ae)}function Z(t,e){var i=se*re;return(J(e)-J(t))/i}function tt(t,e){return t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}function et(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=oe[t];return e?i.slice(0,3):i}function it(t,e){return new Date(e,t+1,0)}function nt(t){var e=$(t),i=e.getDay();return 0!==i&&at(e,-1*i),e}function at(t,e){t.setDate(t.getDate()+e)}function rt(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 st(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=Math.ceil(t),n=Math.floor(e),a=i-n,r=a,s=1;a>5&&(a%2!=0&&(a=++i-n),r=a/2,s=2),a<=2&&(s=a/(r=4)),0===a&&(r=5,s=1);for(var o=[],l=0;l<=r;l++)o.push(n+s*l);return o}function ot(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=rt(t),n=Dt(i,2),a=n[0],r=n[1],s=e?e/Math.pow(10,r):0,o=st(a=a.toFixed(6),s);return o=o.map(function(t){return t*Math.pow(10,r)})}function lt(t){function e(t,e){for(var i=ot(t),n=i[1]-i[0],a=0,r=1;a<e;r++)a+=n,i.unshift(-1*a);return i}var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=Math.max.apply(Math,Tt(t)),a=Math.min.apply(Math,Tt(t)),r=[];if(n>=0&&a>=0)rt(n)[1],r=i?ot(n,a):ot(n);else if(n>0&&a<0){var s=Math.abs(a);n>=s?(rt(n)[1],r=e(n,s)):(rt(s)[1],r=e(s,n).map(function(t){return-1*t}))}else if(n<=0&&a<=0){var o=Math.abs(a),l=Math.abs(n);rt(o)[1],r=(r=i?ot(o,l):ot(o)).reverse().map(function(t){return-1*t})}return r}function ct(t){var e=ut(t);return t.indexOf(0)>=0?t.indexOf(0):t[0]>0?-1*t[0]/e:-1*t[t.length-1]/e+(t.length-1)}function ut(t){return t[1]-t[0]}function ht(t){return t[t.length-1]-t[0]}function dt(t,e){return s(e.zeroLine-t*e.scaleMultiplier)}function pt(t,e){for(var i=Math.max.apply(Math,Tt(t)),n=1/(e-1),a=[],r=0;r<e;r++){var s=i*(n*r);a.push(s)}return a}function ft(t,e){return e.filter(function(e){return e<t}).length}function vt(t,e){t.labels=t.labels||[];var i=t.labels.length,n=t.datasets,a=new Array(i).fill(0);return n||(n=[{values:a}]),n.map(function(t){if(t.values){var n=t.values;n=(n=n.map(function(t){return isNaN(t)?0:t})).length>i?n.slice(0,i):o(n,i-n.length,0)}else t.values=a;t.chartType||(Et.includes(e),t.chartType=e)}),t.yRegions&&t.yRegions.map(function(t){if(t.end<t.start){var e=[t.end,t.start];t.start=e[0],t.end=e[1]}}),t}function gt(t){var e=t.labels.length,i=new Array(e).fill(0),n={labels:t.labels.slice(0,-1),datasets:t.datasets.map(function(t){return{name:"",values:i.slice(0,-1),chartType:t.chartType}})};return t.yMarkers&&(n.yMarkers=[{value:0,label:""}]),t.yRegions&&(n.yRegions=[{start:0,end:0,label:""}]),n}function yt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=t/e.length/St;return e.map(function(t,e){return(t+="").length>n&&(i?e%Math.ceil(t.length/n)!=0&&(t=""):t=n-3>0?t.slice(0,n-3)+" ...":t.slice(0,n)+".."),t})}function mt(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"line",e=arguments[1],i=arguments[2];return"line"===t?(i.type="line",new ce(e,i)):"bar"===t?(i.type="bar",new ce(e,i)):"axis-mixed"===t?(i.type="line",new ce(e,i)):ue[t]?new ue[t](e,i):void console.error("Undefined chart type: "+t)}!function(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===i&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=t:a.appendChild(document.createTextNode(t))}}('.chart-container{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.chart-container .graph-focus-margin{margin:0 5%}.chart-container>.title{margin-top:25px;margin-left:25px;text-align:left;font-weight:400;font-size:12px;color:#6c7680}.chart-container .graphics{margin-top:10px;padding-top:10px;padding-bottom:10px;position:relative}.chart-container .graph-stats-group{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-pack:distribute;justify-content:space-around;-webkit-box-flex:1;-ms-flex:1;flex:1}.chart-container .graph-stats-container{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;padding:10px}.chart-container .graph-stats-container:after,.chart-container .graph-stats-container:before{content:"";display:block}.chart-container .graph-stats-container .stats{padding-bottom:15px}.chart-container .graph-stats-container .stats-title{color:#8d99a6}.chart-container .graph-stats-container .stats-value{font-size:20px;font-weight:300}.chart-container .graph-stats-container .stats-description{font-size:12px;color:#8d99a6}.chart-container .graph-stats-container .graph-data .stats-value{color:#98d85b}.chart-container .axis,.chart-container .chart-label{fill:#555b51}.chart-container .axis line,.chart-container .chart-label line{stroke:#dadada}.chart-container .percentage-graph .progress{margin-bottom:0}.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 .progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f5f5f5;border-radius:4px;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,.1);box-shadow:inset 0 1px 2px rgba(0,0,0,.1)}.chart-container .progress-bar{float:left;width:0;height:100%;font-size:12px;line-height:20px;color:#fff;text-align:center;background-color:#36414c;-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,.15);-webkit-transition:width .6s ease;transition:width .6s ease}.chart-container .graph-svg-tip{position:absolute;z-index:1;padding:10px;font-size:12px;color:#959da5;text-align:center;background:rgba(0,0,0,.8);border-radius:3px}.chart-container .graph-svg-tip ol,.chart-container .graph-svg-tip ul{padding-left:0;display:-webkit-box;display:-ms-flexbox;display:flex}.chart-container .graph-svg-tip ul.data-point-list li{min-width:90px;-webkit-box-flex:1;-ms-flex:1;flex:1;font-weight:600}.chart-container .graph-svg-tip strong{color:#dfe2e5;font-weight:600}.chart-container .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)}.chart-container .graph-svg-tip.comparison{padding:0;text-align:left;pointer-events:none}.chart-container .graph-svg-tip.comparison .title{display:block;padding:10px;margin:0;font-weight:600;line-height:1;pointer-events:none}.chart-container .graph-svg-tip.comparison ul{margin:0;white-space:nowrap;list-style:none}.chart-container .graph-svg-tip.comparison li{display:inline-block;padding:5px 10px}.chart-container .indicator,.chart-container .indicator-right{background:none;font-size:12px;vertical-align:middle;font-weight:700;color:#6c7680}.chart-container .indicator i{content:"";display:inline-block;height:8px;width:8px;border-radius:8px}.chart-container .indicator:before,.chart-container .indicator i{margin:0 4px 0 0}.chart-container .indicator-right:after{margin:0 0 0 4px}',{});var bt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xt=(function(){function t(t){this.value=t}function e(e){function i(t,e){return new Promise(function(i,a){var o={key:t,arg:e,resolve:i,reject:a,next:null};s?s=s.next=o:(r=s=o,n(t,e))})}function n(i,r){try{var s=e[i](r),o=s.value;o instanceof t?Promise.resolve(o.value).then(function(t){n("next",t)},function(t){n("throw",t)}):a(s.done?"return":"normal",s.value)}catch(t){a("throw",t)}}function a(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):s=null}var r,s;this._invoke=i,"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}(),function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}),kt=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),wt=function t(e,i,n){null===e&&(e=Function.prototype);var a=Object.getOwnPropertyDescriptor(e,i);if(void 0===a){var r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in a)return a.value;var s=a.get;if(void 0!==s)return s.call(n)},At=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},Pt=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},Dt=function(){function t(t,e){var i=[],n=!0,a=!1,r=void 0;try{for(var s,o=t[Symbol.iterator]();!(n=(s=o.next()).done)&&(i.push(s.value),!e||i.length!==e);n=!0);}catch(t){a=!0,r=t}finally{try{!n&&o.return&&o.return()}finally{if(a)throw r}}return i}return function(e,i){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),Tt=function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e<t.length;e++)i[e]=t[e];return i}return Array.from(t)};e.create=function(t,i){var n=document.createElement(t);for(var a in i){var r=i[a];if("inside"===a)e(r).appendChild(n);else if("around"===a){var s=e(r);s.parentNode.insertBefore(n,s),n.appendChild(s)}else"styles"===a?"object"===(void 0===r?"undefined":bt(r))&&Object.keys(r).map(function(t){n.style[t]=r[t]}):a in n?n[a]=r:n.setAttribute(a,r)}return n};var Mt=function(){function t(e){var i=e.parent,n=void 0===i?null:i,a=e.colors,r=void 0===a?[]:a;xt(this,t),this.parent=n,this.colors=r,this.titleName="",this.titleValue="",this.listValues=[],this.titleValueFirst=0,this.x=0,this.y=0,this.top=0,this.left=0,this.setup()}return kt(t,[{key:"setup",value:function(){this.makeTooltip()}},{key:"refresh",value:function(){this.fill(),this.calcPosition()}},{key:"makeTooltip",value:function(){var t=this;this.container=e.create("div",{inside:this.parent,className:"graph-svg-tip comparison",innerHTML:'<span class="title"></span>\n\t\t\t\t<ul class="data-point-list"></ul>\n\t\t\t\t<div class="svg-pointer"></div>'}),this.hideTip(),this.title=this.container.querySelector(".title"),this.dataPointList=this.container.querySelector(".data-point-list"),this.parent.addEventListener("mouseleave",function(){t.hideTip()})}},{key:"fill",value:function(){var t=this,i=void 0;this.index&&this.container.setAttribute("data-point-index",this.index),i=this.titleValueFirst?"<strong>"+this.titleValue+"</strong>"+this.titleName:this.titleName+"<strong>"+this.titleValue+"</strong>",this.title.innerHTML=i,this.dataPointList.innerHTML="",this.listValues.map(function(i,n){var a=t.colors[n]||"black",r=e.create("li",{styles:{"border-top":"3px solid "+a},innerHTML:'<strong style="display: block;">'+(0===i.value||i.value?i.value:"")+"</strong>\n\t\t\t\t\t"+(i.title?i.title:"")});t.dataPointList.appendChild(r)})}},{key:"calcPosition",value:function(){var t=this.container.offsetWidth;this.top=this.y-this.container.offsetHeight,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%"}},{key:"setValues",value:function(t,e){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-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=a,this.refresh()}},{key:"hideTip",value:function(){this.container.style.top="0px",this.container.style.left="0px",this.container.style.opacity="0"}},{key:"showTip",value:function(){this.container.style.top=this.top+"px",this.container.style.left=this.left+"px",this.container.style.opacity="1"}}]),t}(),Lt=["line","scatter","bar","percentage","heatmap","pie"],Ct={bar:["line","scatter","percentage","pie"],line:["scatter","bar","percentage","pie"],pie:["line","scatter","percentage","bar"],percentage:["bar","line","scatter","pie"],heatmap:[]},Ot={bar:"datasets",line:"datasets",pie:"labels",percentage:"labels",heatmap:zt},Nt=700,Et=["line","bar"],St=7,_t=Math.PI/180,zt=5,jt=["light-blue","blue","violet","red","orange","yellow","green","light-green","purple","magenta","light-grey","dark-grey"],Wt={bar:jt,line:jt,pie:jt,percentage:jt,heatmap:["#ebedf0","#c6e48b","#7bc96f","#239a3b","#196127"]},Ft=6,Ht=4,Rt=10,It="#dadada",Yt={bar:function(t){var e=void 0;"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=void 0;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode(),n=t.getAttribute("r"),a=t.getAttribute("fill");return i.setAttribute("r",parseInt(n)+4),i.setAttribute("fill",a),i.style.opacity="0.6",e&&i.setAttribute("transform",e),i},heat_square:function(t){var e=void 0;"circle"!==t.nodeName&&(e=t.getAttribute("transform"),t=t.childNodes[0]);var i=t.cloneNode(),n=t.getAttribute("r"),a=t.getAttribute("fill");return i.setAttribute("r",parseInt(n)+4),i.setAttribute("fill",a),i.style.opacity="0.6",e&&i.setAttribute("transform",e),i}},Vt={bar:function(t,e){var i=void 0;"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=void 0;"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=void 0;"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)}},Gt={"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"},Bt=function(t){return Gt[t]||t},Ut=350,qt=350,Xt=Ut,Jt=250,Kt="easein",$t={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"},Qt=function(){function t(e,i){if(xt(this,t),this.parent="string"==typeof e?document.querySelector(e):e,!(this.parent instanceof HTMLElement))throw new Error("No `parent` element to render on was provided.");this.rawChartArgs=i,this.title=i.title||"",this.argHeight=i.height||240,this.type=i.type||"",this.realData=this.prepareData(i.data),this.data=this.prepareFirstData(this.realData),this.colors=this.validateColors(i.colors,this.type),this.config={showTooltip:1,showLegend:i.showLegend||1,isNavigable:i.isNavigable||0,animate:1},this.state={},this.options={},this.initTimeout=Nt,this.config.isNavigable&&(this.overlays=[]),this.configure(i)}return kt(t,[{key:"configure",value:function(){var t=this;this.setMargins(),window.addEventListener("resize",function(){return t.draw(!0)}),window.addEventListener("orientationchange",function(){return t.draw(!0)})}},{key:"validateColors",value:function(t,e){var i=[];return(t=(t||[]).concat(Wt[e])).forEach(function(t){var e=Bt(t);z(e)?i.push(e):console.warn('"'+t+'" is not a valid color.')}),i}},{key:"setMargins",value:function(){var t=this.argHeight;this.baseHeight=t,this.height=t-70,this.topMargin=10,this.leftMargin=20,this.rightMargin=20}},{key:"setup",value:function(){this.makeContainer(),this.makeTooltip(),this.draw(!1,!0)}},{key:"setupComponents",value:function(){this.components=new Map}},{key:"makeContainer",value:function(){this.parent.innerHTML="",this.container=e.create("div",{inside:this.parent,className:"chart-container"})}},{key:"makeTooltip",value:function(){this.tip=new Mt({parent:this.container,colors:this.colors}),this.bindTooltip()}},{key:"bindTooltip",value:function(){}},{key:"draw",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.calc(e),this.updateWidth(),this.makeChartArea(),this.setupComponents(),this.components.forEach(function(e){return e.setup(t.drawArea)}),this.render(this.components,!1),i&&(this.data=this.realData,setTimeout(function(){t.update(t.data)},this.initTimeout)),e||this.renderLegend(),this.setupNavigation(i)}},{key:"updateWidth",value:function(){this.baseWidth=a(this.parent),this.width=this.baseWidth-(this.leftMargin+this.rightMargin)}},{key:"update",value:function(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.calc(),this.render()}},{key:"prepareData",value:function(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data}},{key:"prepareFirstData",value:function(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data}},{key:"calc",value:function(){}},{key:"render",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.components,i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.config.isNavigable&&this.overlays.map(function(t){return t.parentNode.removeChild(t)});var n=[];e.forEach(function(t){n=n.concat(t.update(i))}),n.length>0?(q(this.container,this.svg,n),setTimeout(function(){e.forEach(function(t){return t.make()}),t.updateNav()},400)):(e.forEach(function(t){return t.make()}),this.updateNav())}},{key:"updateNav",value:function(){this.config.isNavigable&&(this.makeOverlay(),this.bindUnits())}},{key:"makeChartArea",value:function(){this.svg&&this.container.removeChild(this.svg);var t=0,e=0;this.title.length&&(t=30),this.showLegend&&(e=30),this.svg=g(this.container,"frappe-chart chart",this.baseWidth,this.baseHeight+t+e),this.svgDefs=y(this.svg),this.title.length&&(this.titleEL=A("title",this.leftMargin-Ft,this.topMargin,this.title,11),this.svg.appendChild(this.titleEL));var i=this.topMargin+t;this.drawArea=m(this.svg,this.type+"-chart","translate("+this.leftMargin+", "+i+")"),i=this.baseHeight+t,this.legendArea=m(this.svg,"chart-legend","translate("+this.leftMargin+", "+i+")")}},{key:"renderLegend",value:function(){}},{key:"setupNavigation",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.config.isNavigable&&e&&(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(e){n(t.container)&&(e=e||window.event,t.keyActions[e.keyCode]&&t.keyActions[e.keyCode]())}))}},{key:"makeOverlay",value:function(){}},{key:"updateOverlay",value:function(){}},{key:"bindOverlay",value:function(){}},{key:"bindUnits",value:function(){}},{key:"onLeftArrow",value:function(){}},{key:"onRightArrow",value:function(){}},{key:"onUpArrow",value:function(){}},{key:"onDownArrow",value:function(){}},{key:"onEnterKey",value:function(){}},{key:"addDataPoint",value:function(){}},{key:"removeDataPoint",value:function(){}},{key:"getDataPoint",value:function(){}},{key:"setCurrentDataPoint",value:function(){}},{key:"updateDataset",value:function(){}},{key:"getDifferentChart",value:function(t){var e=this.type,i=this.rawChartArgs;if(t!==e){Lt.includes(t)||console.error("'"+t+"' is not a valid chart type."),Ct[e].includes(t)||console.error("'"+e+"' chart cannot be converted to a '"+t+"' chart.");var n=Ot[e]===Ot[t];return i.type=t,i.colors=n?i.colors:void 0,new he(this.parent,i)}}},{key:"unbindWindowEvents",value:function(){var t=this;window.removeEventListener("resize",function(){return t.draw(!0)}),window.removeEventListener("orientationchange",function(){return t.draw(!0)})}}]),t}(),Zt=function(t){function e(t,i){return xt(this,e),Pt(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i))}return At(e,t),kt(e,[{key:"configure",value:function(t){wt(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"configure",this).call(this,t),this.config.maxSlices=t.maxSlices||20,this.config.maxLegendPoints=t.maxLegendPoints||20}},{key:"calc",value: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}),a=n;if(n.length>i){n.sort(function(t,e){return e[0]-t[0]}),a=n.slice(0,i-1);var r=0;n.slice(i-1).map(function(t){r+=t[0]}),a.push([r,"Rest"]),this.colors[i-1]="grey"}e.labels=[],a.map(function(t){e.sliceTotals.push(t[0]),e.labels.push(t[1])})}},{key:"renderLegend",value:function(){}}]),e}(Qt),te=function(t){function n(t,e){xt(this,n);var i=Pt(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,t,e));return i.type="percentage",i.setup(),i}return At(n,t),kt(n,[{key:"makeChartArea",value:function(){this.container.className+=" graph-focus-margin",this.container.style.marginTop="45px",this.svg=e.create("div",{className:"div",inside:this.container}),this.chart=e.create("div",{className:"progress-chart",inside:this.svg}),this.percentageBar=e.create("div",{className:"progress",inside:this.chart})}},{key:"render",value:function(){var t=this,i=this.state;this.grandTotal=i.sliceTotals.reduce(function(t,e){return t+e},0),i.slices=[],i.sliceTotals.map(function(n,a){var r=e.create("div",{className:"progress-bar","data-index":a,inside:t.percentageBar,styles:{background:t.colors[a],width:100*n/t.grandTotal+"%"}});i.slices.push(r)})}},{key:"bindTooltip",value:function(){var t=this,e=this.state;this.container.addEventListener("mousemove",function(n){var a=n.target;if(a.classList.contains("progress-bar")){var r=a.getAttribute("data-index"),s=i(t.container),o=i(a),l=o.left-s.left+a.offsetWidth/2,c=o.top-s.top-6,u=(t.formattedLabels&&t.formattedLabels.length>0?t.formattedLabels[r]:t.state.labels[r])+": ",h=(100*e.sliceTotals[r]/t.grandTotal).toFixed(1);t.tip.setValues(l,c,{name:u,value:h+"%"}),t.tip.showTip()}})}}]),n}(Zt),ee=function(){function t(e){var i=e.layerClass,n=void 0===i?"":i,a=e.layerTransform,r=void 0===a?"":a,s=e.constants,o=e.getData,l=e.makeElements,c=e.animateElements;xt(this,t),this.layerTransform=r,this.constants=s,this.makeElements=l,this.getData=o,this.animateElements=c,this.store=[],this.layerClass=n,this.layerClass="function"==typeof this.layerClass?this.layerClass():this.layerClass,this.refresh()}return kt(t,[{key:"refresh",value:function(t){this.data=t||this.getData()}},{key:"setup",value:function(t){this.layer=m(t,this.layerClass,this.layerTransform)}},{key:"make",value:function(){this.render(this.data),this.oldData=this.data}},{key:"render",value:function(t){var e=this;this.store=this.makeElements(t),this.layer.textContent="",this.store.forEach(function(t){e.layer.appendChild(t)})}},{key:"update",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.refresh();var e=[];return t&&(e=this.animateElements(this.data)),e}}]),t}(),ie={pieSlices:{layerClass:"pie-slices",makeElements:function(t){return t.sliceStrings.map(function(e,i){var n=b(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 V(e,t.sliceStrings[i])})}},percentageBars:{layerClass:"percentage-bars",makeElements:function(t){},animateElements:function(t){}},yAxis:{layerClass:"y axis",makeElements:function(t){var e=this;return t.positions.map(function(i,n){return T(i,t.labels[n],e.constants.width,{mode:e.constants.mode,pos:e.constants.pos})})},animateElements:function(t){var e=t.positions,i=t.labels,n=this.oldData.positions,a=this.oldData.labels,r=h(n,e),s=Dt(r,2);n=s[0],e=s[1];var o=h(a,i),l=Dt(o,2);return a=l[0],i=l[1],this.render({positions:n,labels:i}),this.store.map(function(t,i){return F(t,e[i],n[i])})}},xAxis:{layerClass:"x axis",makeElements:function(t){var e=this;return t.positions.map(function(i,n){return M(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,a=this.oldData.calcLabels,r=h(n,e),s=Dt(r,2);n=s[0],e=s[1];var o=h(a,i),l=Dt(o,2);return a=l[0],i=l[1],this.render({positions:n,calcLabels:i}),this.store.map(function(t,i){return W(t,e[i],n[i])})}},yMarkers:{layerClass:"y-markers",makeElements:function(t){var e=this;return t.map(function(t){return L(t.position,t.label,e.constants.width,{pos:"right",mode:"span",lineType:"dashed"})})},animateElements:function(t){var e=h(this.oldData,t),i=Dt(e,2);this.oldData=i[0];var n=(t=i[1]).map(function(t){return t.position}),a=t.map(function(t){return t.label}),r=this.oldData.map(function(t){return t.position});return this.render(r.map(function(t,e){return{position:r[e],label:a[e]}})),this.store.map(function(t,e){return F(t,n[e],r[e])})}},yRegions:{layerClass:"y-regions",makeElements:function(t){var e=this;return t.map(function(t){return C(t.startPos,t.endPos,e.constants.width,t.label)})},animateElements:function(t){var e=h(this.oldData,t),i=Dt(e,2);this.oldData=i[0];var n=(t=i[1]).map(function(t){return t.endPos}),a=t.map(function(t){return t.label}),r=t.map(function(t){return t.startPos}),s=this.oldData.map(function(t){return t.endPos}),o=this.oldData.map(function(t){return t.startPos});this.render(s.map(function(t,e){return{startPos:o[e],endPos:s[e],label:a[e]}}));var l=[];return this.store.map(function(t,e){l=l.concat(H(t,r[e],n[e],s[e]))}),l}},heatDomain:{layerClass:function(){return"heat-domain domain-"+this.constants.index},makeElements:function(t){var e=this,i=this.constants,n=i.colWidth,a=i.rowHeight,r=i.squareSize,s=i.xTranslate,o=0;return this.serializedSubDomains=[],t.cols.map(function(t){t.map(function(t,i){if(t.fill){var n={"data-date":t.yyyyMmDd,"data-value":t.dataValue,"data-day":i},l=w("day",s,o,r,t.fill,n);e.serializedSubDomains.push(l)}o+=a}),o=0,s+=n}),this.serializedSubDomains},animateElements:function(t){}},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 O(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,a=t.labels,r=this.oldData.xPositions,s=this.oldData.yPositions,o=this.oldData.offsets,l=this.oldData.labels,c=h(r,e),u=Dt(c,2);r=u[0],e=u[1];var d=h(s,i),p=Dt(d,2);s=p[0],i=p[1];var f=h(o,n),v=Dt(f,2);o=v[0],n=v[1];var g=h(l,a),y=Dt(g,2);l=y[0],a=y[1],this.render({xPositions:r,yPositions:s,offsets:o,labels:a,zeroLine:this.oldData.zeroLine,barsWidth:this.oldData.barsWidth,barWidth:this.oldData.barWidth});var m=[];return this.store.map(function(a,r){m=m.concat(R(a,e[r],i[r],t.barWidth,n[r],{zeroLine:t.zeroLine}))}),m}},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=E(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(function(i,n){return N(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,a=this.oldData.xPositions,r=this.oldData.yPositions,s=this.oldData.values,o=h(a,e),l=Dt(o,2);a=l[0],e=l[1];var c=h(r,i),u=Dt(c,2);r=u[0],i=u[1];var d=h(s,n),p=Dt(d,2);s=p[0],n=p[1],this.render({xPositions:a,yPositions:r,values:n,zeroLine:this.oldData.zeroLine,radius:this.oldData.radius});var f=[];return Object.keys(this.paths).length&&(f=f.concat(Y(this.paths,e,i,t.zeroLine))),this.units.length&&this.units.map(function(t,n){f=f.concat(I(t,e[n],i[n]))}),f}}},ne=function(t){function e(t,i){xt(this,e);var n=Pt(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i));return n.type="pie",n.initTimeout=0,n.setup(),n}return At(e,t),kt(e,[{key:"configure",value:function(t){wt(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"configure",this).call(this,t),this.mouseMove=this.mouseMove.bind(this),this.mouseLeave=this.mouseLeave.bind(this),this.hoverRadio=t.hoverRadio||.1,this.config.startAngle=t.startAngle||0,this.clockWise=t.clockWise||!1}},{key:"prepareFirstData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data;return this.init=1,t}},{key:"calc",value:function(){wt(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"calc",this).call(this);var t=this.state;this.center={x:this.width/2,y:this.height/2},this.radius=this.height>this.width?this.center.x:this.center.y,t.grandTotal=t.sliceTotals.reduce(function(t,e){return t+e},0),this.calcSlices()}},{key:"calcSlices",value:function(){var t=this,e=this.state,i=this.radius,n=this.clockWise,a=e.slicesProperties||[];e.sliceStrings=[],e.slicesProperties=[];var r=180-this.config.startAngle;e.sliceTotals.map(function(s,o){var l=r,u=s/e.grandTotal*360,h=n?-u:u,d=r+=h,p=c(l,i),f=c(d,i),v=t.init&&a[o],g=void 0,y=void 0;t.init?(g=v?v.startPosition:p,y=v?v.endPosition:p):(g=p,y=f);var m=x(g,y,t.center,t.radius,t.clockWise);e.sliceStrings.push(m),e.slicesProperties.push({startPosition:p,endPosition:f,value:s,total:e.grandTotal,startAngle:l,endAngle:d,angle:h})}),this.init=0}},{key:"setupComponents",value: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=X.apply(void 0,Tt(t));return[t[0],e]}))}},{key:"calTranslateByAngle",value:function(t){var e=this.radius,i=this.hoverRadio,n=c(t.startAngle+t.angle/2,e);return"translate3d("+n.x*i+"px,"+n.y*i+"px,0)"}},{key:"hoverSlice",value:function(t,e,n,a){if(t){var r=this.colors[e];if(n){B(t,this.calTranslateByAngle(this.state.slicesProperties[e])),t.style.fill=_(r,50);var s=i(this.svg),o=a.pageX-s.left+10,l=a.pageY-s.top-10,c=(this.formatted_labels&&this.formatted_labels.length>0?this.formatted_labels[e]:this.state.labels[e])+": ",u=(100*this.state.sliceTotals[e]/this.state.grandTotal).toFixed(1);this.tip.setValues(o,l,{name:c,value:u+"%"}),this.tip.showTip()}else B(t,"translate3d(0,0,0)"),this.tip.hideTip(),t.style.fill=r}}},{key:"bindTooltip",value:function(){this.container.addEventListener("mousemove",this.mouseMove),this.container.addEventListener("mouseleave",this.mouseLeave)}},{key:"mouseMove",value:function(t){var e=t.target,i=this.components.get("pieSlices").store,n=this.curActiveSliceIndex,a=this.curActiveSlice;if(i.includes(e)){var r=i.indexOf(e);this.hoverSlice(a,n,!1),this.curActiveSlice=e,this.curActiveSliceIndex=r,this.hoverSlice(e,r,!0,t)}else this.mouseLeave()}},{key:"mouseLeave",value:function(){this.hoverSlice(this.curActiveSlice,this.curActiveSliceIndex,!1)}}]),e}(Zt),ae=7,re=1e3,se=86400,oe=["January","February","March","April","May","June","July","August","September","October","November","December"],le=function(t){function e(t,i){xt(this,e);var n=Pt(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i));n.type="heatmap",n.discreteDomains=0===i.discreteDomains?0:1,n.countLabel=i.countLabel||"";var a=["Sunday","Monday"],r=a.includes(i.startSubDomain)?i.startSubDomain:"Sunday";return n.startSubDomainIndex=a.indexOf(r),n.setup(),n}return At(e,t),kt(e,[{key:"updateWidth",value:function(){this.baseWidth=12*(this.state.noOfWeeks+99),this.discreteDomains&&(this.baseWidth+=144)}},{key:"prepareData",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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){var e={};Object.keys(t.dataPoints).forEach(function(i){var n=new Date(i*re);e[K(n)]=t.dataPoints[i]}),t.dataPoints=e}return t}},{key:"calc",value:function(){var t=this.state;t.start=this.data.start,t.end=this.data.end,t.firstWeekStart=nt(t.start),t.noOfWeeks=Q(t.start,t.end),t.distribution=pt(Object.values(this.data.dataPoints),zt),t.domainConfigs=this.getDomains()}},{key:"setupComponents",value:function(){var t=this,e=this.state,i=e.domainConfigs.map(function(i,n){return["heatDomain",{index:n,colWidth:12,rowHeight:12,squareSize:10,xTranslate:12*e.domainConfigs.filter(function(t,e){return e<n}).map(function(t){return t.cols.length-1}).reduce(function(t,e){return t+e},0)},function(){return e.domainConfigs[n]}.bind(t)]});this.components=new Map(i.map(function(t,e){var i=X.apply(void 0,Tt(t));return[t[0]+"-"+e,i]}))}},{key:"update",value:function(t){t||console.error("No data to update."),this.data=this.prepareData(t),this.draw(),this.bindTooltip()}},{key:"bindTooltip",value:function(){var t=this;Array.prototype.slice.call(document.querySelectorAll(".data-group .day")).map(function(e){e.addEventListener("mouseenter",function(e){var i=e.target.getAttribute("data-value"),n=e.target.getAttribute("data-date").split("-"),a=et(parseInt(n[1])-1,!0),r=t.container.getBoundingClientRect(),s=e.target.getBoundingClientRect(),o=parseInt(e.target.getAttribute("width")),l=s.left-r.left+(o+2)/2,c=s.top-r.top-(o+2)/2,u=i+" "+t.countLabel,h=" on "+a+" "+n[0]+", "+n[2];t.tip.setValues(l,c,{name:h,value:u,valueFirst:1},[]),t.tip.showTip()})})}},{key:"getDomains",value:function(){for(var t=this.state,e=[t.start.getMonth(),t.start.getFullYear()],i=e[0],n=e[1],a=[t.end.getMonth(),t.end.getFullYear()],r=a[0]-i+1+12*(a[1]-n),s=[],o=$(t.start),l=0;l<r;l++){var c=t.end;if(!tt(o,t.end)){var u=[o.getMonth(),o.getFullYear()];c=it(u[0],u[1])}s.push(this.getDomainConfig(o,c)),at(c,1),o=c}return s}},{key:"getDomainConfig",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",i=[t.getMonth(),t.getFullYear()],n=i[0],a=i[1],r=nt(t),s={index:n,cols:[]},o=Q(r,e=$(e)||it(n,a)),l=[],c=0;c<o;c++){var u=this.getCol(r,n);l.push(u),at(r=new Date(u[ae-1].yyyyMmDd),1)}return r.getDay()===this.startSubDomainIndex&&(at(r,1),l.push(this.getCol(r,n,!0))),s.cols=l,s}},{key:"getCol",value:function(t,e){for(var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=$(t),a=[],r=0;r<ae;r++,at(n,1)){var s={};i||n.getMonth()!==e?s.yyyyMmDd=K(n):s=this.getSubDomainConfig(n),a.push(s)}return a}},{key:"getSubDomainConfig",value:function(t){var e=K(t),i=this.data.dataPoints[e];return{yyyyMmDd:e,dataValue:i||0,fill:this.colors[ft(i,this.state.distribution)]}}}]),e}(Qt),ce=function(t){function e(t,i){xt(this,e);var n=Pt(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,i));return n.barOptions=i.barOptions||{},n.lineOptions=i.lineOptions||{},n.type=i.type||"line",n.init=1,n.setup(),n}return At(e,t),kt(e,[{key:"configure",value:function(t){wt(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"configure",this).call(this,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}},{key:"setMargins",value:function(){wt(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"setMargins",this).call(this),this.leftMargin=60,this.rightMargin=40}},{key:"prepareData",value:function(){return vt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data,this.type)}},{key:"prepareFirstData",value:function(){return gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.data)}},{key:"calc",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.calcXPositions(),t||this.calcYAxisParameters(this.getAllYValues(),"line"===this.type)}},{key:"calcXPositions",value:function(){var t=this.state,e=this.data.labels;t.datasetLength=e.length,t.unitWidth=this.width/t.datasetLength,t.xOffset=t.unitWidth/2,t.xAxis={labels:e,positions:e.map(function(e,i){return s(t.xOffset+i*t.unitWidth)})}}},{key:"calcYAxisParameters",value:function(t){var e=lt(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"false"),i=this.height/ht(e),n=ut(e)*i,a=this.height-ct(e)*n;this.state.yAxis={labels:e,positions:e.map(function(t){return a-t*i}),scaleMultiplier:i,zeroLine:a},this.calcDatasetPoints(),this.calcYExtremes(),this.calcYRegions()}},{key:"calcDatasetPoints",value:function(){var t=this.state,e=function(e){return e.map(function(e){return dt(e,t.yAxis)})};t.datasets=this.data.datasets.map(function(t,i){var n=t.values,a=t.cumulativeYs||[];return{name:t.name,index:i,chartType:t.chartType,values:n,yPositions:e(n),cumulativeYs:a,cumulativeYPos:e(a)}})}},{key:"calcYExtremes",value:function(){var t=this.state;if(this.barOptions.stacked)return void(t.yExtremes=t.datasets[t.datasets.length-1].cumulativeYPos);t.yExtremes=new Array(t.datasetLength).fill(9999),t.datasets.map(function(e){e.yPositions.map(function(e,i){e<t.yExtremes[i]&&(t.yExtremes[i]=e)})})}},{key:"calcYRegions",value:function(){var t=this.state;this.data.yMarkers&&(this.state.yMarkers=this.data.yMarkers.map(function(e){return e.position=dt(e.value,t.yAxis),e})),this.data.yRegions&&(this.state.yRegions=this.data.yRegions.map(function(e){return e.startPos=dt(e.start,t.yAxis),e.endPos=dt(e.end,t.yAxis),e}))}},{key:"getAllYValues",value:function(){var t,e=this,i="values";if(this.barOptions.stacked){i="cumulativeYs";var n=new Array(this.state.datasetLength).fill(0);this.data.datasets.map(function(t,a){var r=e.data.datasets[a].values;t[i]=n=n.map(function(t,e){return t+r[e]})})}var a=this.data.datasets.map(function(t){return t[i]});return this.data.yMarkers&&a.push(this.data.yMarkers.map(function(t){return t.value})),this.data.yRegions&&this.data.yRegions.map(function(t){a.push([t.end,t.start])}),(t=[]).concat.apply(t,Tt(a))}},{key:"setupComponents",value:function(){var t=this,e=[["yAxis",{mode:this.config.yAxisMode,width:this.width},function(){return this.state.yAxis}.bind(this)],["xAxis",{mode:this.config.xAxisMode,height:this.height},function(){var t=this.state;return t.xAxis.calcLabels=yt(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}),a=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:.01*t.height},function(){var t=this.state,e=t.datasets[n],a=this.barOptions.stacked,r=this.barOptions.spaceRatio||.5,s=t.unitWidth*(1-r),o=s/(a?1:i.length),l=t.xAxis.positions.map(function(t){return t-s/2});a||(l=l.map(function(t){return t+o*n}));var c=new Array(t.datasetLength).fill("");this.config.valuesOverPoints&&(c=a&&e.index===t.datasets.length-1?e.cumulativeYs:e.values);var u=new Array(t.datasetLength).fill(0);return a&&(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:s,barWidth:o}}.bind(t)]}),r=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,hideDots:t.lineOptions.hideDots,hideLine:t.lineOptions.hideLine,valuesOverPoints:t.config.valuesOverPoints},function(){var t=this.state,e=t.datasets[i];return{xPositions:t.xAxis.positions,yPositions:e.yPositions,values:e.values,zeroLine:t.yAxis.zeroLine,radius:this.lineOptions.dotSize||4}}.bind(t)]}),s=[["yMarkers",{width:this.width,pos:"right"},function(){return this.state.yMarkers}.bind(this)]];e=e.concat(a,r,s);var o=["yMarkers","yRegions"];this.dataUnitComponents=[],this.components=new Map(e.filter(function(e){return!o.includes(e[0])||t.state[e[0]]}).map(function(e){var i=X.apply(void 0,Tt(e));return(e[0].includes("lineGraph")||e[0].includes("barGraph"))&&t.dataUnitComponents.push(i),[e[0],i]}))}},{key:"bindTooltip",value:function(){var t=this;this.container.addEventListener("mousemove",function(e){var n=i(t.container),a=e.pageX-n.left-t.leftMargin;e.pageY-n.top-t.topMargin<t.height+2*t.topMargin?t.mapTooltipXPosition(a):t.tip.hideTip()})}},{key:"mapTooltipXPosition",value:function(t){var e=this,i=this.state;if(i.yExtremes){var n=this.config.formatTooltipY,a=this.config.formatTooltipX,r=i.xAxis.labels;a&&a(r[0])&&(r=r.map(function(t){return a(t)})),n=n&&n(i.yAxis.labels[0])?n:0;for(var s=i.datasetLength-1;s>=0;s--){var o=i.xAxis.positions[s];if(t>o-i.unitWidth/2){var l=o+this.leftMargin,c=i.yExtremes[s]+this.topMargin,u=this.data.datasets.map(function(t,i){return{title:t.name,value:n?n(t.values[s]):t.values[s],color:e.colors[i]}});this.tip.setValues(l,c,{name:r[s],value:""},u,s),this.tip.showTip();break}}}}},{key:"renderLegend",value:function(){}},{key:"makeOverlay",value:function(){var t=this;if(this.init)return void(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=Yt[e.type](i),t.drawArea.appendChild(e.overlay)})}},{key:"updateOverlayGuides",value:function(){this.overlayGuides&&this.overlayGuides.forEach(function(t){var e=t.overlay;e.parentNode.removeChild(e)})}},{key:"bindOverlay",value:function(){var t=this;this.parent.addEventListener("data-select",function(){t.updateOverlay()})}},{key:"bindUnits",value: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)})}},{key:"updateOverlay",value:function(){var t=this;this.overlayGuides.map(function(e){var i=e.units[t.state.currentIndex];Vt[e.type](i,e.overlay)})}},{key:"onLeftArrow",value:function(){this.setCurrentDataPoint(this.state.currentIndex-1)}},{key:"onRightArrow",value:function(){this.setCurrentDataPoint(this.state.currentIndex+1)}},{key:"getDataPoint",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state.currentIndex,e=this.state;return{index:t,label:e.xAxis.labels[t],values:e.datasets.map(function(e){return e.values[t]})}}},{key:"setCurrentDataPoint",value: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,r(this.parent,"data-select",this.getDataPoint()))}},{key:"addDataPoint",value:function(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.state.datasetLength;wt(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"addDataPoint",this).call(this,t,i,n),this.data.labels.splice(n,0,t),this.data.datasets.map(function(t,e){t.values.splice(n,0,i[e])}),this.update(this.data)}},{key:"removeDataPoint",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state.datasetLength-1;this.data.labels.length<=1||(wt(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"removeDataPoint",this).call(this,t),this.data.labels.splice(t,1),this.data.datasets.map(function(e){e.values.splice(t,1)}),this.update(this.data))}},{key:"updateDataset",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.data.datasets[e].values=t,this.update(this.data)}},{key:"updateDatasets",value:function(t){this.data.datasets.map(function(e,i){t[i]&&(e.values=t[i])}),this.update(this.data)}}]),e}(Qt),ue={percentage:te,heatmap:le,pie:ne},he=function t(e,i){return xt(this,t),mt(i.type,e,i)};return t.Chart=he,t.PercentageChart=te,t.PieChart=ne,t.Heatmap=le,t.AxisChart=ce,t}({});
  2. //# sourceMappingURL=frappe-charts.min.js.map