import{r as d,h as e,F as i,a as s}from"./p-9add63ef.js";import{a as o}from"./p-401e165e.js";const n=":host{display:block}.download__details{opacity:0.75}";const l=n;const t=class{constructor(e){d(this,e);this.allLink=undefined;this.heading=undefined;this.busy=undefined;this.loading=undefined;this.requestNonce=undefined;this.error=undefined;this.purchases=[]}renderEmpty(){return e("div",null,e("sc-divider",{style:{"--spacing":"0"}}),e("slot",{name:"empty"},e("sc-empty",{icon:"download"},wp.i18n.__("You don't have any downloads.","surecart"))))}renderLoading(){return e("sc-card",{"no-padding":true,style:{"--overflow":"hidden"}},e("sc-stacked-list",null,e("sc-stacked-list-row",{style:{"--columns":"2"},"mobile-size":0},e("div",{style:{padding:"0.5em"}},e("sc-skeleton",{style:{width:"30%",marginBottom:"0.75em"}}),e("sc-skeleton",{style:{width:"20%"}})))))}renderList(){return this.purchases.map((d=>{var s,n,l,t,c,a,r,u,v,f;const h=d===null||d===void 0?void 0:d.variant;const b=(h===null||h===void 0?void 0:h.downloads_enabled)&&((n=(s=h===null||h===void 0?void 0:h.downloads)===null||s===void 0?void 0:s.data)===null||n===void 0?void 0:n.length)>0;const m=b?h.downloads.data.filter((d=>!d.archived)):((c=(t=(l=d===null||d===void 0?void 0:d.product)===null||l===void 0?void 0:l.downloads)===null||t===void 0?void 0:t.data)===null||c===void 0?void 0:c.filter((d=>!d.archived)))||[];const p=b?(a=h.downloads.pagination)===null||a===void 0?void 0:a.count:(v=(u=(r=d===null||d===void 0?void 0:d.product)===null||r===void 0?void 0:r.downloads)===null||u===void 0?void 0:u.pagination)===null||v===void 0?void 0:v.count;const y=(m||[]).map((d=>{var e;return(d===null||d===void 0?void 0:d.media)?(e=d===null||d===void 0?void 0:d.media)===null||e===void 0?void 0:e.byte_size:0}));const w=y.reduce(((d,e)=>d+e),0);return e("sc-stacked-list-row",{href:!(d===null||d===void 0?void 0:d.revoked)?o(window.location.href,{action:"show",model:"download",id:d.id,nonce:this.requestNonce}):null,key:d.id,"mobile-size":0},e("sc-spacing",{style:{"--spacing":"var(--sc-spacing-xx--small)"}},e("div",null,e("strong",null,(f=d===null||d===void 0?void 0:d.product)===null||f===void 0?void 0:f.name)),e("div",{class:"download__details"},wp.i18n.sprintf(wp.i18n._n("%s file","%s files",p,"surecart"),p),!!w&&e(i,null," ","• ",e("sc-format-bytes",{value:w})))),e("sc-icon",{name:"chevron-right",slot:"suffix"}))}))}renderContent(){var d;if(this.loading){return this.renderLoading()}if(((d=this.purchases)===null||d===void 0?void 0:d.length)===0){return this.renderEmpty()}return e("sc-card",{"no-padding":true,style:{"--overflow":"hidden"}},e("sc-stacked-list",null,this.renderList()))}render(){return e("sc-dashboard-module",{key:"5c8ddf82445d104a101536771a33802c60f95d78",class:"downloads-list",error:this.error},e("span",{key:"b9c4e10da64d1630078fdefbf93d91f40aeab9cc",slot:"heading"},e("slot",{key:"db1216dcb9ffc12fc833edde740ae02e5cd5e671",name:"heading"},this.heading||wp.i18n.__("Items","surecart"))),e("slot",{key:"b9b09cc64fcf9fced6a703759ccbc686f330edf2",name:"before"}),!!this.allLink&&e("sc-button",{key:"ba3a4fbc34a7bd82ccf80478b4e5e406e6574867",type:"link",href:this.allLink,slot:"end"},wp.i18n.__("View all","surecart"),e("sc-icon",{key:"5ae134a422e79797008b9d2a9a7de89f70c6dbc2",name:"chevron-right",slot:"suffix"})),this.renderContent(),e("slot",{key:"b3b28959ace88d9fedb5d34f3c073fa110d752d3",name:"after"}),this.busy&&e("sc-block-ui",{key:"e6f0974d2163ac90331b89ce8d492880ae02c896"}))}get el(){return s(this)}};t.style=l;export{t as sc_purchase_downloads_list};
//# sourceMappingURL=p-71c95136.entry.js.map