import{r as d,h as e,F as i,a as s}from"./p-e97fde0a.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,a,c,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)):((a=(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||a===void 0?void 0:a.filter((d=>!d.archived)))||[];const p=b?(c=h.downloads.pagination)===null||c===void 0?void 0:c.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:"77c933bc9eb8d64256675c278dea12b04b1bf1d9",class:"downloads-list",error:this.error},e("span",{key:"1cdd2033d6c0691ec482c607a781235d1a66a7c6",slot:"heading"},e("slot",{key:"9986a4c03d635e4f5cec42bc8db7da887dab4fbe",name:"heading"},this.heading||wp.i18n.__("Items","surecart"))),e("slot",{key:"3bec176268ba64dd246513f3f2ec5104e56bb882",name:"before"}),!!this.allLink&&e("sc-button",{key:"287334ba69c4af3315581a403d38bc8658a9e7c4",type:"link",href:this.allLink,slot:"end"},wp.i18n.__("View all","surecart"),e("sc-icon",{key:"0399fd8a34444bd351c7f52c02f00f73371172a1",name:"chevron-right",slot:"suffix"})),this.renderContent(),e("slot",{key:"d928ee5e00154b383563b1a1bd9e8a5d8f2344f0",name:"after"}),this.busy&&e("sc-block-ui",{key:"43aa1be6f907505359df2fb1c00ffa4c2cefdf9f"}))}get el(){return s(this)}};t.style=l;export{t as sc_purchase_downloads_list};
//# sourceMappingURL=p-855cb997.entry.js.map