import{l as w,t as s,c as f}from"./index-BCrAQR8N.chunk.mjs";import{l as p}from"./logger-DRUu-xbg.chunk.mjs";const{limit:a,downloads:c}=w("files_downloadlimit","download_limit",{limit:-1,downloads:0});p.debug("Download limit",{limit:a,downloads:c});let n=a-c,d=0;const m=(e,o)=>{o===0?e.innerText=s("files_downloadlimit","You have reached the maximum amount of downloads allowed"):e.innerText=f("files_downloadlimit","1 remaining download allowed","{count} remaining downloads allowed",o,{count:o})};window.addEventListener("DOMContentLoaded",()=>{if(a<1)return;const e=document.getElementById("header-primary-action");if(!e)return;const o=document.createElement("span");o.setAttribute("style","color: var(--color-background-plain-text, var(--color-primary-text)); padding: 0 10px;"),m(o,n),e.prepend(o);const l=document.querySelector("#files-public-content");if(!l)return;l.oncontextmenu=t=>(t.preventDefault(),t.stopPropagation(),!1);const i=Array.from(document.querySelectorAll('a[href*="/download/"]'));new Set(i).forEach(t=>{t.addEventListener("click",r=>{if(d>0&&!confirm(s("files_downloadlimit","This share has a limited number of downloads. Are you sure you want to trigger a new download?"))){r.preventDefault(),r.stopPropagation();return}n--,d++,m(o,n),n===0&&[...i].forEach(u=>u.remove())})})});
//# sourceMappingURL=files_downloadlimit-public.mjs.map
