(function(){const n=window.kbSuggestConfig||{},c=document.getElementById(n.inputId||"title"),i=document.getElementById(n.panelId||"ticket-suggestions");if(!n.url||!c||!i)return;const m=n.minChars||8,o=n.translations||{};let r=null,u="";function a(){i.innerHTML="",i.classList.add("d-none")}function p(t){if(!Array.isArray(t)||t.length===0){a();return}const e=t.map(function(s){const g=l(s.title||""),d=l(s.excerpt||""),v=encodeURI(s.url||"#"),y=s.type==="announcement"?o.announcement||"Announcement":o.kb||"Knowledgebase";return'<a href="'+v+'" target="_blank" rel="noopener" class="list-group-item list-group-item-action py-2"><div class="d-flex justify-content-between align-items-start gap-2"><span class="fw-semibold small">'+g+'</span><span class="badge bg-secondary" style="font-size:0.6rem;">'+y+"</span></div>"+(d?'<div class="text-muted small mt-1">'+d+"</div>":"")+"</a>"}).join("");i.innerHTML='<div class="mt-2"><div class="text-muted small mb-1">'+l(o.heading||"These articles may help:")+'</div><div class="list-group">'+e+"</div></div>",i.classList.remove("d-none")}function l(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}async function f(t){try{const e=await fetch(n.url+"?q="+encodeURIComponent(t),{headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest"}});if(!e.ok){a();return}const s=await e.json();p(s.results)}catch{a()}}c.addEventListener("input",function(){const t=c.value.trim();if(t.length<m){a();return}t!==u&&(u=t,clearTimeout(r),r=setTimeout(function(){f(t)},300))})})();
