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:"3f1e9d3ebba9301c99bea71e75416dbcd1bbac2c",class:"downloads-list",error:this.error},s("span",{key:"13b0a3af4727b0d81731a75192b41166957893ad",slot:"heading"},s("slot",{key:"306eca0ea017f191310fd77d629a67003e308c5a",name:"heading"},this.heading||wp.i18n.__("Items","surecart"))),s("slot",{key:"70fae949356f2d9758ce657ee33f23b4d4bcf359",name:"before"}),!!this.allLink&&s("sc-button",{key:"216b118ce949d7124c2bd0e70b7b416eb8ef2b11",type:"link",href:this.allLink,slot:"end"},wp.i18n.__("View all","surecart"),s("sc-icon",{key:"ee5f60198ad15809de363df35e1106aa86f9fc34",name:"chevron-right",slot:"suffix"})),this.renderContent(),s("slot",{key:"d120cc72b69135a7626593183e14dcce19c3cfef",name:"after"}),this.busy&&s("sc-block-ui",{key:"9786845e15d32181c3b0275e9ab60ed6273f15c0"}))}get el(){return i(this)}};l.style=o;export{l as sc_purchase_downloads_list};
//# sourceMappingURL=p-c18d135f.entry.js.map