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