function c(){const s=document.querySelector('meta[name="csrf-token"]')?.content||"",i=(e,t="success")=>window.toast?window.toast(e,t):null,r=e=>{if(window.confirmDialog)return window.confirmDialog(e);window.confirm(e.message||"Are you sure?")&&e.onConfirm?.()};document.querySelectorAll("[data-delete]").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.id,o=e.dataset.name||"this agent";t&&r({eyebrow:"Delete agent",title:`Delete "${o}"?`,message:"The agent and its training sources will be removed. Widgets using it will stop replying with AI until you pick a different agent.",confirmText:"Delete agent",cancelText:"Keep",tone:"danger",onConfirm:async()=>{try{const n=await fetch(`/ai-training/api/assistant/${t}`,{method:"DELETE",headers:{"X-CSRF-TOKEN":s,Accept:"application/json"}});if(!n.ok)throw new Error("http "+n.status);e.closest(".ait-row")?.remove(),i("Agent deleted.","success")}catch(n){i("Delete failed — "+(n?.message||"network error"),"error")}}})})});const a=document.getElementById("ait-search");a&&a.addEventListener("input",()=>{const e=a.value.trim().toLowerCase();document.querySelectorAll(".ait-row").forEach(t=>{const o=t.dataset.searchHaystack||"";t.classList.toggle("hidden",e!==""&&!o.includes(e))})})}export{c as default};
