!function(t){const e={$el:t(".automatewoo-dashboard-widgets"),params:{},init(){e.params=automatewooDashboardLocalizeScript,e.initMasonry()},initMasonry(){e.$el.masonry({itemSelector:".automatewoo-dashboard-widget",columnWidth:".automatewoo-dashboard-widget-sizer",percentPosition:!0,gutter:20,transitionDuration:"0.2s"})},drawGraphFromAnalyticsAPI(t,o,a,r){const i=[];for(const t of a)i.push(o.map((e=>[new Date(e.interval).getTime(),e.subtotals[t]])));return e.drawGraph(t,i,r)},drawGraph(e,o,a){const r=t("string"==typeof e?"#"+e:e),i=[],s=["#3498db","#d0a0e4","#72c9b2"];_.each(o,(function(t,e){const r={label:"",data:t,color:s.shift(),points:{show:!0,radius:3,lineWidth:2,fillColor:"#ffffff",fill:!0},lines:{show:!0,lineWidth:2,fill:!0,fillColor:{colors:[{opacity:.02},{opacity:.16}]}},shadowSize:0,isCurrency:!0===a.is_currency||a.is_currency&&a.is_currency[e]};_.size(o)>1&&(r.lines.fill=!1),i.push(r)}));const n={legend:{show:!1},grid:{color:"#aaa",borderColor:"transparent",borderWidth:0,hoverable:!0},xaxis:{color:"#e5e5e5",position:"bottom",tickColor:"transparent",mode:"time",monthNames:AW.params.locale.month_abbrev,tickLength:1,font:{color:"#aaa"}},yaxis:{color:"#fff",font:{color:"#fff"}}};30===Number(a.interval)&&(n.xaxis.minTickSize=[4,"day"]),t.plot(r,i,n),r.on("plothover",(function(t,e,o){const a=r.parents(".automatewoo-dashboard-chart:first"),i=r.siblings(".automatewoo-dashboard-chart__tooltip:first"),s=a.offset();if(o&&o.series.points.show){let t=o.datapoint[1];o.series.isCurrency&&(t=AW.price(t)),i.html(t).css({top:o.pageY-9-s.top,left:o.pageX+12-s.left}).fadeIn(200)}else i.hide()}))}};AW.Dashboard=e,e.init(),window.customElements.define("automatewoo-dashboard-chart",class extends HTMLElement{connectedCallback(){this.setAttribute("aw-loading","");const t=this.getAttribute("fields").split(","),e=JSON.parse(`[${this.getAttribute("is-currency")||""}]`),o=new URLSearchParams({interval:"day",after:this.getAttribute("after"),before:this.getAttribute("before"),fields:t,per_page:100});wp.apiFetch({path:this.getAttribute("endpoint")+"?"+o.toString()}).then((o=>{this.removeAttribute("aw-loading"),AW.Dashboard.drawGraphFromAnalyticsAPI(this.querySelector("automatewoo-dashboard-chart__flot"),o.intervals,t,{interval:this.getAttribute("interval"),is_currency:e});for(let a=0;a