document.addEventListener("DOMContentLoaded",function(){const i=document.getElementById("txtForm"),r=document.getElementById("txtResult"),n=document.getElementById("txtOutput");i&&i.addEventListener("submit",function(t){t.preventDefault(),c()});function c(){const t=document.getElementById("txt_domain").value.trim();if(!t){d("Domain name is required");return}l(),fetch("/api/v1/admin/network-tools/txt",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer "+document.querySelector('meta[name="api-token"]').getAttribute("content")},body:JSON.stringify({domain:t})}).then(e=>e.json()).then(e=>{e.success?a(e.data):d(e.message||"TXT query failed")}).catch(e=>{console.error("Error:",e),d("An error occurred: "+e.message)})}function a(t){if(n.replaceChildren(),t.records&&t.records.length>0)t.records.forEach(e=>{const o=document.createElement("div");o.className="mb-3 p-3 border rounded";const s=document.createElement("strong");s.textContent="TXT Record:",o.appendChild(s),o.appendChild(document.createElement("br")),o.appendChild(document.createTextNode(String(e))),n.appendChild(o)});else{const e=document.createElement("div");e.className="alert alert-info",e.textContent="No TXT records found for this domain.",n.appendChild(e)}r.style.display="block"}function l(){n.innerHTML='<div class="text-center"><i class="fas fa-spinner fa-spin fa-2x"></i><p class="mt-2">Querying TXT records...</p></div>',r.style.display="block"}function d(t){n.innerHTML=`<div class="alert alert-danger">${t}</div>`,r.style.display="block"}});
