import{r as s,h as l,F as t,g as o,H as i}from"./p-dfbe004d.js";import{_ as n,s as e,a as d}from"./p-8415f806.js";import"./p-fd56940f.js";import{a as r}from"./p-1c2e2695.js";import"./p-9a7a47e8.js";const a=class{constructor(l){s(this,l),this.purchases=[]}renderEmpty(){return l("div",null,l("sc-divider",{style:{"--spacing":"0"}}),l("slot",{name:"empty"},l("sc-empty",{icon:"download"},n("You don't have any downloads.","surecart"))))}renderLoading(){return l("sc-card",{"no-padding":!0,style:{"--overflow":"hidden"}},l("sc-stacked-list",null,l("sc-stacked-list-row",{style:{"--columns":"2"},"mobile-size":0},l("div",{style:{padding:"0.5em"}},l("sc-skeleton",{style:{width:"30%",marginBottom:"0.75em"}}),l("sc-skeleton",{style:{width:"20%"}})))))}renderList(){return this.purchases.map((s=>{var o,i,n;const a=null===(i=null===(o=null==s?void 0:s.product)||void 0===o?void 0:o.downloads)||void 0===i?void 0:i.data.filter((s=>!s.archived)),c=(a||[]).map((s=>{var l;return(null==s?void 0:s.media)?null===(l=null==s?void 0:s.media)||void 0===l?void 0:l.byte_size:0})).reduce(((s,l)=>s+l),0);return l("sc-stacked-list-row",{href:(null==s?void 0:s.revoked)?null:r(window.location.href,{action:"show",model:"download",id:s.id,nonce:this.requestNonce}),key:s.id,"mobile-size":0},l("sc-spacing",{style:{"--spacing":"var(--sc-spacing-xx--small)"}},l("div",null,l("strong",null,null===(n=null==s?void 0:s.product)||void 0===n?void 0:n.name)),l("div",{class:"download__details"},e(d("%s file","%s files",null==a?void 0:a.length,"surecart"),null==a?void 0:a.length),!!c&&l(t,null," ","• ",l("sc-format-bytes",{value:c})))),l("sc-icon",{name:"chevron-right",slot:"suffix"}))}))}renderContent(){var s;return this.loading?this.renderLoading():0===(null===(s=this.purchases)||void 0===s?void 0:s.length)?this.renderEmpty():l("sc-card",{"no-padding":!0,style:{"--overflow":"hidden"}},l("sc-stacked-list",null,this.renderList()))}render(){return l("sc-dashboard-module",{class:"downloads-list",error:this.error},l("span",{slot:"heading"},l("slot",{name:"heading"},this.heading||n("Items","surecart"))),l("slot",{name:"before"}),!!this.allLink&&l("sc-button",{type:"link",href:this.allLink,slot:"end"},n("View all","surecart"),l("sc-icon",{name:"chevron-right",slot:"suffix"})),this.renderContent(),l("slot",{name:"after"}),this.busy&&l("sc-block-ui",null))}get el(){return o(this)}};a.style=":host{display:block}.download__details{opacity:0.75}";const c=class{constructor(l){s(this,l)}render(){return l(i,null,l("slot",null))}};c.style=":host{display:block}::slotted(*:not(:last-child)){margin-bottom:var(--spacing)}";export{a as sc_purchase_downloads_list,c as sc_spacing}