"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[6115],{92072:(e,r,t)=>{t.r(r),t.d(r,{default:()=>h});var a=t(27723),n=t(86087),o=t(29491),s=t(96476),i=t(47143),c=t(98846),d=t(77374),l=t(83306),m=t(94111),p=t(59505),u=t(56109),y=t(39793);const{performanceIndicators:f}=(0,u.Qk)("dataEndpoints",{performanceIndicators:[]});class g extends n.Component{renderMenu(){const{hiddenBlocks:e,isFirst:r,isLast:t,onMove:o,onRemove:s,onTitleBlur:i,onTitleChange:d,onToggleHiddenBlock:m,titleInput:p,controls:u}=this.props;return(0,y.jsx)(c.EllipsisMenu,{label:(0,a.__)("Choose which analytics to display and the section name","woocommerce"),placement:"bottom-end",renderContent:({onToggle:g})=>(0,y.jsxs)(n.Fragment,{children:[(0,y.jsx)(c.MenuTitle,{children:(0,a.__)("Display stats:","woocommerce")}),f.map(((r,t)=>{const a=!e.includes(r.stat);return(0,y.jsx)(c.MenuItem,{checked:a,isCheckbox:!0,isClickable:!0,onInvoke:()=>{m(r.stat)(),(0,l.recordEvent)("dash_indicators_toggle",{status:a?"off":"on",key:r.stat})},children:r.label},t)})),(0,y.jsx)(u,{onToggle:g,onMove:o,onRemove:s,isFirst:r,isLast:t,onTitleBlur:i,onTitleChange:d,titleInput:p})]})})}renderList(){const{query:e,primaryRequesting:r,secondaryRequesting:t,primaryError:n,secondaryError:o,primaryData:i,secondaryData:m,userIndicators:u,defaultDateRange:f}=this.props;if(r||t)return(0,y.jsx)(c.SummaryListPlaceholder,{numberOfItems:u.length});if(n||o)return null;const g=(0,s.getPersistedQuery)(e),{compare:h}=(0,d.getDateParamsFromQuery)(e,f),k="previous_period"===h?(0,a.__)("Previous period:","woocommerce"):(0,a.__)("Previous year:","woocommerce"),{formatAmount:_,getCurrencyConfig:w}=this.context,b=w();return(0,y.jsx)(c.SummaryList,{children:()=>u.map(((e,r)=>{const{primaryValue:t,secondaryValue:a,delta:n,reportUrl:o,reportUrlType:s}=(0,p.w)({indicator:e,primaryData:i,secondaryData:m,currency:b,formatAmount:_,persistedQuery:g});return(0,y.jsx)(c.SummaryNumber,{href:o,hrefType:s,label:e.label,value:t,prevLabel:k,prevValue:a,delta:n,onLinkClickCallback:()=>{(0,l.recordEvent)("dash_indicators_click",{key:e.stat})}},r)}))})}render(){const{userIndicators:e,title:r}=this.props;return(0,y.jsxs)(n.Fragment,{children:[(0,y.jsx)(c.SectionHeader,{title:r||(0,a.__)("Store Performance","woocommerce"),menu:this.renderMenu()}),e.length>0&&(0,y.jsx)("div",{className:"woocommerce-dashboard__store-performance",children:this.renderList()})]})}}g.contextType=m.CurrencyContext;const h=(0,o.compose)((0,i.withSelect)(((e,r)=>{const{hiddenBlocks:t,query:a,filters:n}=r,o=f.filter((e=>!t.includes(e.stat))),s={hiddenBlocks:t,userIndicators:o,indicators:f};if(0===o.length)return s;const i=(0,p.m)(e,o,a,n);return{...s,...i}})))(g)},59505:(e,r,t)=>{t.d(r,{m:()=>l,w:()=>d});var a=t(66087),n=t(77374),o=t(40314),s=t(96476),i=t(43577),c=t(15703);const d=({indicator:e,primaryData:r,secondaryData:t,currency:n,formatAmount:o,persistedQuery:d})=>{const l=(0,a.find)(r.data,(r=>r.stat===e.stat)),m=(0,a.find)(t.data,(r=>r.stat===e.stat));if(!l||!m)return{};const p=l._links&&l._links.report[0]&&l._links.report[0].href||"",u=function(e,r,t){return e?"/jetpack"===e?(0,c.getAdminLink)("admin.php?page=jetpack#/dashboard"):(0,s.getNewPath)(r,e,{chart:t.chart}):""}(p,d,l),y="/jetpack"===p?"wp-admin":"wc-admin",f="currency"===l.format,g=(0,i.calculateDelta)(l.value,m.value);return{primaryValue:f?o(l.value):(0,i.formatValue)(n,l.format,l.value),secondaryValue:f?o(m.value):(0,i.formatValue)(n,m.format,m.value),delta:g,reportUrl:u,reportUrlType:y}},l=(e,r,t,a)=>{const{getReportItems:s,getReportItemsError:i,isResolving:c}=e(o.reportsStore),{woocommerce_default_date_range:d}=e(o.settingsStore).getSetting("wc_admin","wcAdminSettings"),l=(0,n.getCurrentDates)(t,d),m=l.primary.before,p=l.secondary.before,u=r.map((e=>e.stat)).join(","),y=(0,o.getFilterQuery)({filters:a,query:t}),f={...y,after:(0,n.appendTimestamp)(l.primary.after,"start"),before:(0,n.appendTimestamp)(m,m.isSame((0,n.getStoreTimeZoneMoment)(),"day")?"now":"end"),stats:u},g={...y,after:(0,n.appendTimestamp)(l.secondary.after,"start"),before:(0,n.appendTimestamp)(p,p.isSame((0,n.getStoreTimeZoneMoment)(),"day")?"now":"end"),stats:u};return{primaryData:s("performance-indicators",f),primaryError:i("performance-indicators",f)||null,primaryRequesting:c("getReportItems",["performance-indicators",f]),secondaryData:s("performance-indicators",g),secondaryError:i("performance-indicators",g)||null,secondaryRequesting:c("getReportItems",["performance-indicators",g]),defaultDateRange:d}}}}]);