const d=document.getElementById("emailPanel");if(d){let n=function(t){return String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")},l=function(t){i.innerHTML=t&&t.length?t.map(e=>`<tr><td>${n(e.email)}</td><td>${n(e.quota_mb)} MB</td><td class="text-end">
                <button class="btn btn-sm btn-outline-danger" data-del="${n(e.email)}"><i class="fas fa-trash"></i></button></td></tr>`).join(""):'<tr><td colspan="3" class="text-muted text-center py-3">—</td></tr>'},c=function(t){t&&(u.innerHTML=`<div class="alert alert-${t.status==="success"?"success":"danger"}">${n(t.message||"")}</div>`)};var g=n,p=l,b=c;const r=d.dataset.handleUrl,m=d.dataset.csrf,i=document.getElementById("mailboxRows"),u=document.getElementById("mailboxAlert");async function o(t,e={}){const a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-CSRF-TOKEN":m},credentials:"same-origin",body:JSON.stringify({op:t,...e})});return a.ok?a.json():{status:"error",message:`HTTP ${a.status}`,data:{}}}async function f(){var e;const t=await o("list");l(((e=t==null?void 0:t.data)==null?void 0:e.mailboxes)||[])}document.getElementById("mailboxAddForm").addEventListener("submit",async t=>{var s;t.preventDefault();const e=t.target,a=await o("create",{email:e.email.value,password:e.password.value,quota_mb:e.quota_mb.value});c(a),(s=a==null?void 0:a.data)!=null&&s.mailboxes&&l(a.data.mailboxes),e.reset()}),i.addEventListener("click",async t=>{var s;const e=t.target.closest("[data-del]");if(!e)return;const a=await o("delete",{email:e.dataset.del});c(a),(s=a==null?void 0:a.data)!=null&&s.mailboxes&&l(a.data.mailboxes)}),f()}
