(window.__wcAdmin_webpackJsonp=window.__wcAdmin_webpackJsonp||[]).push([[50],{530:function(e,t,r){"use strict";r.d(t,"b",(function(){return d})),r.d(t,"a",(function(){return u}));var a=r(9),n=r.n(a),o=r(4),c=r(20),s=r(11),i=r(12),l=r(122),m=r(14);const d=({indicator:e,primaryData:t,secondaryData:r,currency:a,formatAmount:n,persistedQuery:c})=>{const s=Object(o.find)(t.data,t=>t.stat===e.stat),d=Object(o.find)(r.data,t=>t.stat===e.stat);if(!s||!d)return{};const u=s._links&&s._links.report[0]&&s._links.report[0].href||"",p=function(e,t,r){return e?"/jetpack"===e?Object(m.getAdminLink)("admin.php?page=jetpack#/dashboard"):Object(i.getNewPath)(t,e,{chart:r.chart}):""}(u,c,s),b="/jetpack"===u?"wp-admin":"wc-admin",y="currency"===s.format,f=Object(l.calculateDelta)(s.value,d.value);return{primaryValue:y?n(s.value):Object(l.formatValue)(a,s.format,s.value),secondaryValue:y?n(d.value):Object(l.formatValue)(a,d.format,d.value),delta:f,reportUrl:p,reportUrlType:b}},u=(e,t,r,a)=>{const{getReportItems:o,getReportItemsError:i,isResolving:l}=e(s.REPORTS_STORE_NAME),{woocommerce_default_date_range:m}=e(s.SETTINGS_STORE_NAME).getSetting("wc_admin","wcAdminSettings"),d=Object(c.getCurrentDates)(r,m),u=d.primary.before,p=d.secondary.before,b=t.map(e=>e.stat).join(","),y=Object(s.getFilterQuery)({filters:a,query:r}),f={...y,after:Object(c.appendTimestamp)(d.primary.after,"start"),before:Object(c.appendTimestamp)(u,u.isSame(n()(),"day")?"now":"end"),stats:b},j={...y,after:Object(c.appendTimestamp)(d.secondary.after,"start"),before:Object(c.appendTimestamp)(p,p.isSame(n()(),"day")?"now":"end"),stats:b};return{primaryData:o("performance-indicators",f),primaryError:i("performance-indicators",f)||null,primaryRequesting:l("getReportItems",["performance-indicators",f]),secondaryData:o("performance-indicators",j),secondaryError:i("performance-indicators",j)||null,secondaryRequesting:l("getReportItems",["performance-indicators",j]),defaultDateRange:m}}},619:function(e,t,r){},628:function(e,t,r){"use strict";r.r(t);var a=r(0),n=r(2),o=r(13),c=r(12),s=r(7),i=r(21),l=r(20),m=r(16),d=(r(619),r(506)),u=r(530),p=r(22);const{performanceIndicators:b}=Object(p.d)("dataEndpoints",{performanceIndicators:[]});class y extends a.Component{renderMenu(){const{hiddenBlocks:e,isFirst:t,isLast:r,onMove:o,onRemove:c,onTitleBlur:s,onTitleChange:l,onToggleHiddenBlock:d,titleInput:u,controls:p}=this.props;return Object(a.createElement)(i.EllipsisMenu,{label:Object(n.__)("Choose which analytics to display and the section name",'woocommerce'),renderContent:({onToggle:y})=>Object(a.createElement)(a.Fragment,null,Object(a.createElement)(i.MenuTitle,null,Object(n.__)("Display stats:",'woocommerce')),b.map((t,r)=>{const n=!e.includes(t.stat);return Object(a.createElement)(i.MenuItem,{checked:n,isCheckbox:!0,isClickable:!0,key:r,onInvoke:()=>{d(t.stat)(),Object(m.recordEvent)("dash_indicators_toggle",{status:n?"off":"on",key:t.stat})}},t.label)}),Object(a.createElement)(p,{onToggle:y,onMove:o,onRemove:c,isFirst:t,isLast:r,onTitleBlur:s,onTitleChange:l,titleInput:u}))})}renderList(){const{query:e,primaryRequesting:t,secondaryRequesting:r,primaryError:o,secondaryError:s,primaryData:d,secondaryData:p,userIndicators:b,defaultDateRange:y}=this.props;if(t||r)return Object(a.createElement)(i.SummaryListPlaceholder,{numberOfItems:b.length});if(o||s)return null;const f=Object(c.getPersistedQuery)(e),{compare:j}=Object(l.getDateParamsFromQuery)(e,y),O="previous_period"===j?Object(n.__)("Previous period:",'woocommerce'):Object(n.__)("Previous year:",'woocommerce'),{formatAmount:g,getCurrencyConfig:h}=this.context,_=h();return Object(a.createElement)(i.SummaryList,null,()=>b.map((e,t)=>{const{primaryValue:r,secondaryValue:n,delta:o,reportUrl:c,reportUrlType:s}=Object(u.b)({indicator:e,primaryData:d,secondaryData:p,currency:_,formatAmount:g,persistedQuery:f});return Object(a.createElement)(i.SummaryNumber,{key:t,href:c,hrefType:s,label:e.label,value:r,prevLabel:O,prevValue:n,delta:o,onLinkClickCallback:()=>{Object(m.recordEvent)("dash_indicators_click",{key:e.stat})}})}))}render(){const{userIndicators:e,title:t}=this.props;return Object(a.createElement)(a.Fragment,null,Object(a.createElement)(i.SectionHeader,{title:t||Object(n.__)("Store Performance",'woocommerce'),menu:this.renderMenu()}),e.length>0&&Object(a.createElement)("div",{className:"woocommerce-dashboard__store-performance"},this.renderList()))}}y.contextType=d.a,t.default=Object(o.compose)(Object(s.withSelect)((e,t)=>{const{hiddenBlocks:r,query:a,filters:n}=t,o=b.filter(e=>!r.includes(e.stat)),c={hiddenBlocks:r,userIndicators:o,indicators:b};if(0===o.length)return c;const s=Object(u.a)(e,o,a,n);return{...c,...s}}))(y)}}]);