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