"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[9616],{17666:(e,t,r)=>{r.d(t,{Z:()=>w});var o=r(69307),a=r(65736),l=r(94333),c=r(69771),s=r(9818),i=r(92819),n=r(7862),m=r.n(n),u=r(86020),d=r(67221),p=r(81921),_=r(17844),f=r(65994),y=r(10431);function g(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||0===e.length)return null;const o=e.slice(0),a=o.pop();if(a.showFilters(t,r)){const e=(0,y.flattenFilters)(a.filters),r=t[a.param]||a.defaultValue||"all";return(0,i.find)(e,{value:r})}return g(o,t,r)}function h(e){return t=>(0,c.format)(e,t)}class b extends o.Component{shouldComponentUpdate(e){return e.isRequesting!==this.props.isRequesting||e.primaryData.isRequesting!==this.props.primaryData.isRequesting||e.secondaryData.isRequesting!==this.props.secondaryData.isRequesting||!(0,i.isEqual)(e.query,this.props.query)}getItemChartData(){const{primaryData:e,selectedChart:t}=this.props;return e.data.intervals.map((function(e){const r={};return e.subtotals.segments.forEach((function(e){if(e.segment_label){const o=r[e.segment_label]?e.segment_label+" (#"+e.segment_id+")":e.segment_label;r[e.segment_id]={label:o,value:e.subtotals[t.key]||0}}})),{date:(0,c.format)("Y-m-d\\TH:i:s",e.date_start),...r}}))}getTimeChartData(){const{query:e,primaryData:t,secondaryData:r,selectedChart:o,defaultDateRange:a}=this.props,l=(0,p.getIntervalForQuery)(e,a),{primary:s,secondary:i}=(0,p.getCurrentDates)(e,a);return t.data.intervals.map((function(t,a){const n=(0,p.getPreviousDate)(t.date_start,s.after,i.after,e.compare,l),m=r.data.intervals[a];return{date:(0,c.format)("Y-m-d\\TH:i:s",t.date_start),primary:{label:`${s.label} (${s.range})`,labelDate:t.date_start,value:t.subtotals[o.key]||0},secondary:{label:`${i.label} (${i.range})`,labelDate:n.format("YYYY-MM-DD HH:mm:ss"),value:m&&m.subtotals[o.key]||0}}}))}getTimeChartTotals(){const{primaryData:e,secondaryData:t,selectedChart:r}=this.props;return{primary:(0,i.get)(e,["data","totals",r.key],null),secondary:(0,i.get)(t,["data","totals",r.key],null)}}renderChart(e,t,r,l){const{emptySearchResults:c,filterParam:s,interactiveLegend:i,itemsLabel:n,legendPosition:m,path:_,query:f,selectedChart:y,showHeaderControls:g,primaryData:b,defaultDateRange:w}=this.props,v=(0,p.getIntervalForQuery)(f,w),C=(0,p.getAllowedIntervalsForQuery)(f,w),S=(0,p.getDateFormatsForInterval)(v,b.data.intervals.length,{type:"php"}),R=c?(0,a.__)("No data for the current search","woocommerce"):(0,a.__)("No data for the selected date range","woocommerce"),{formatAmount:x,getCurrencyConfig:D}=this.context;return(0,o.createElement)(u.Chart,{allowedIntervals:C,data:r,dateParser:"%Y-%m-%dT%H:%M:%S",emptyMessage:R,filterParam:s,interactiveLegend:i,interval:v,isRequesting:t,itemsLabel:n,legendPosition:m,legendTotals:l,mode:e,path:_,query:f,screenReaderFormat:h(S.screenReaderFormat),showHeaderControls:g,title:y.label,tooltipLabelFormat:h(S.tooltipLabelFormat),tooltipTitle:"time-comparison"===e&&y.label||null,tooltipValueFormat:(0,d.getTooltipValueFormat)(y.type,x),chartType:(0,p.getChartTypeForQuery)(f),valueType:y.type,xFormat:h(S.xFormat),x2Format:h(S.x2Format),currency:D()})}renderItemComparison(){const{isRequesting:e,primaryData:t}=this.props;if(t.isError)return(0,o.createElement)(f.Z,null);const r=e||t.isRequesting,a=this.getItemChartData();return this.renderChart("item-comparison",r,a)}renderTimeComparison(){const{isRequesting:e,primaryData:t,secondaryData:r}=this.props;if(!t||t.isError||r.isError)return(0,o.createElement)(f.Z,null);const a=e||t.isRequesting||r.isRequesting,l=this.getTimeChartData(),c=this.getTimeChartTotals();return this.renderChart("time-comparison",a,l,c)}render(){const{mode:e}=this.props;return"item-comparison"===e?this.renderItemComparison():this.renderTimeComparison()}}b.contextType=_.CurrencyContext,b.propTypes={filters:m().array,isRequesting:m().bool,itemsLabel:m().string,limitProperties:m().array,mode:m().string,path:m().string.isRequired,primaryData:m().object,query:m().object.isRequired,secondaryData:m().object,selectedChart:m().shape({key:m().string.isRequired,label:m().string.isRequired,order:m().oneOf(["asc","desc"]),orderby:m().string,type:m().oneOf(["average","number","currency"]).isRequired}).isRequired},b.defaultProps={isRequesting:!1,primaryData:{data:{intervals:[]},isError:!1,isRequesting:!1},secondaryData:{data:{intervals:[]},isError:!1,isRequesting:!1}};const w=(0,l.compose)((0,s.withSelect)(((e,t)=>{const{charts:r,endpoint:o,filters:a,isRequesting:l,limitProperties:c,query:s,advancedFilters:n}=t,m=c||[o],u=g(a,s),p=(0,i.get)(u,["settings","param"]),_=t.mode||function(e,t){if(e&&t){const r=(0,i.get)(e,["settings","param"]);if(!r||Object.keys(t).includes(r))return(0,i.get)(e,["chartMode"])}return null}(u,s)||"time-comparison",{woocommerce_default_date_range:f}=e(d.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings"),y=e(d.REPORTS_STORE_NAME),h={mode:_,filterParam:p,defaultDateRange:f};if(l)return h;const b=m.some((e=>s[e]&&s[e].length));if(s.search&&!b)return{...h,emptySearchResults:!0};const w=r&&r.map((e=>e.key)),v=(0,d.getReportChartData)({endpoint:o,dataType:"primary",query:s,selector:y,limitBy:m,filters:a,advancedFilters:n,defaultDateRange:f,fields:w});if("item-comparison"===_)return{...h,primaryData:v};const C=(0,d.getReportChartData)({endpoint:o,dataType:"secondary",query:s,selector:y,limitBy:m,filters:a,advancedFilters:n,defaultDateRange:f,fields:w});return{...h,primaryData:v,secondaryData:C}})))(b)},67362:(e,t,r)=>{r.d(t,{O3:()=>s,be:()=>n,u8:()=>i});var o=r(65736),a=r(92694),l=r(36309),c=r(73463);const s=(0,a.applyFilters)("woocommerce_admin_orders_report_charts",[{key:"orders_count",label:(0,o.__)("Orders","woocommerce"),type:"number"},{key:"net_revenue",label:(0,o.__)("Net sales","woocommerce"),order:"desc",orderby:"net_total",type:"currency"},{key:"avg_order_value",label:(0,o.__)("Average order value","woocommerce"),type:"currency"},{key:"avg_items_per_order",label:(0,o.__)("Average items per order","woocommerce"),order:"desc",orderby:"num_items_sold",type:"average"}]),i=(0,a.applyFilters)("woocommerce_admin_orders_report_filters",[{label:(0,o.__)("Show","woocommerce"),staticParams:["chartType","paged","per_page"],param:"filter",showFilters:()=>!0,filters:[{label:(0,o.__)("All orders","woocommerce"),value:"all"},{label:(0,o.__)("Advanced filters","woocommerce"),value:"advanced"}]}]),n=(0,a.applyFilters)("woocommerce_admin_orders_report_advanced_filters",{title:(0,o._x)("Orders match