"use strict";(globalThis.webpackChunkstoresuite=globalThis.webpackChunkstoresuite||[]).push([[15],{9943(e,t,a){a.r(t),a.d(t,{default:()=>h});var r=a(6087),s=a(7723),n=a(9491),o=a(7143),l=a(6773),i=a(1993),u=a(5),d=a(112),c=a(8468),p=(a(3679),a(8443));function m(e){return t=>(0,p.format)(e,t)}var y=a(1086),g=a(790);class v extends r.Component{render(){const{query:e,path:t,primaryData:a,secondaryData:r}=this.props,{formatAmount:n,getCurrencyConfig:o}=this.context,d=(0,u.getIntervalForQuery)(e,y.I),v=(0,u.getAllowedIntervalsForQuery)(e,y.I),{primary:h,secondary:b}=(0,u.getCurrentDates)(e,y.I),F=function(e,t,a,r,s,n){return e&&e.data&&e.data.intervals?e.data.intervals.map((e,s)=>{const o=t&&t.data&&t.data.intervals&&t.data.intervals[s],l=a.range?`${a.label} (${a.range})`:a.label,i=r&&r.range?`${r.label} (${r.range})`:r?r.label:"",u={date:(0,p.format)("Y-m-d\\TH:i:s",e.date_start),primary:{label:l,labelDate:e.date_start,value:(0,c.get)(e,["subtotals",n],0)}};return o&&(u.secondary={label:i,labelDate:o.date_start,value:(0,c.get)(o,["subtotals",n],0)}),u}):[]}(a,r,h,b,e.compare,"net_revenue"),f=a?.data?.intervals?.length||0,D=(0,u.getDateFormatsForInterval)(d,f,{type:"php"}),R=a?.isRequesting||r?.isRequesting;return(0,g.jsx)("div",{className:"storesuite-dashboard-net-sales-chart",children:(0,g.jsx)(l.Chart,{allowedIntervals:v,data:F,dateParser:"%Y-%m-%dT%H:%M:%S",emptyMessage:(0,s.__)("No data for the selected date range","storesuite"),interval:d,isRequesting:R,legendPosition:"bottom",mode:"time-comparison",path:t,query:e,showHeaderControls:!0,title:(0,s.__)("Net sales","storesuite"),tooltipTitle:(0,s.__)("Net sales","storesuite"),chartType:(0,u.getChartTypeForQuery)(e),valueType:"currency",tooltipValueFormat:(0,i.getTooltipValueFormat)("currency",n),screenReaderFormat:m(D.screenReaderFormat),tooltipLabelFormat:m(D.tooltipLabelFormat),xFormat:m(D.xFormat),x2Format:m(D.x2Format),currency:o()})})}}v.contextType=d.CurrencyContext,v.defaultProps={primaryData:{data:{intervals:[]},isError:!1,isRequesting:!1},secondaryData:{data:{intervals:[]},isError:!1,isRequesting:!1}};const h=(0,n.compose)((0,o.withSelect)((e,t)=>{const{query:a}=t,r=e(i.REPORTS_STORE_NAME);return{primaryData:(0,i.getReportChartData)({endpoint:"revenue",dataType:"primary",query:a,selector:r,limitBy:["revenue"],filters:[],advancedFilters:{},defaultDateRange:y.I,fields:["net_revenue"]}),secondaryData:(0,i.getReportChartData)({endpoint:"revenue",dataType:"secondary",query:a,selector:r,limitBy:["revenue"],filters:[],advancedFilters:{},defaultDateRange:y.I,fields:["net_revenue"]})}}))(v)}}]);