1(function(){'use strict';const cfg=window.anatecsSearch||{};let overlay,panel,input,resultsEl,debounceTimer,lastQuery='';function init(){overlay=document.getElementById('anatecs-search-overlay');fixAnchorScroll();if(!overlay)return;panel=document.getElementById('anatecs-search-panel');input=document.getElementById('anatecs-search-input');resultsEl=document.getElementById('anatecs-search-results');input.setAttribute('placeholder',cfg.placeholder||'Rechercherâ¦');input.setAttribute('aria-label',cfg.placeholder||'Rechercher');document.addEventListener('click',function(e){const btn=e.target.closest('.wp-block-search__button, .search-toggle, [data-anatecs-search], [aria-label="Rechercher"]');if(btn&&!btn.closest('#anatecs-search-overlay')){e.preventDefault();e.stopImmediatePropagation();open()}},!0);document.getElementById('anatecs-search-close').addEventListener('click',close);document.getElementById('anatecs-search-backdrop').addEventListener('click',close);document.addEventListener('keydown',function(e){if(e.key==='Escape'&&!overlay.hidden)close();});input.addEventListener('input',function(){clearTimeout(debounceTimer);const q=input.value.trim();if(q===lastQuery)return;if(q.length<(cfg.minChars||3)){resultsEl.innerHTML='';lastQuery='';return} 2debounceTimer=setTimeout(function(){doSearch(q)},300)})} 3function fixAnchorScroll(){if(window.location.hash!=='#documentation')return;var docEl=document.getElementById('documentation');if(!docEl)return;window.addEventListener('load',function(){var headerEl=document.querySelector('.mainMenu')||document.querySelector('header');var offset=headerEl?Math.round(headerEl.getBoundingClientRect().height):90;var top=Math.round(docEl.getBoundingClientRect().top+window.scrollY)-offset-16;window.scrollTo({top:Math.max(0,top),behavior:'smooth'})})} 4function open(){overlay.hidden=!1;document.body.style.overflow='hidden';requestAnimationFrame(function(){overlay.classList.add('is-open');input.focus()})} 5function close(){overlay.classList.remove('is-open');document.body.style.overflow='';setTimeout(function(){overlay.hidden=!0;input.value='';resultsEl.innerHTML='';lastQuery=''},280)} 6function doSearch(q){lastQuery=q;resultsEl.innerHTML='<div class="as-loading"><span></span><span></span><span></span></div>';var url=new URL(cfg.apiUrl);url.searchParams.set('q',q);fetch(url.toString(),{headers:{'X-WP-Nonce':cfg.nonce}}).then(function(res){if(!res.ok)throw new Error('Network error');return res.json()}).then(function(data){if(input.value.trim()!==q)return;render(data)}).catch(function(){resultsEl.innerHTML='<p class="as-message">Une erreur est survenue, veuillez réessayer.</p>'})} 7var PDF_ICON='<svg class="as-pdf-icon" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg>';function render(data){if(!data.total){resultsEl.innerHTML='<p class="as-message">'+(cfg.noResults||'Aucun résultat trouvé')+'</p>';return} 8var typeOrder=['product','dlm_download','post','page','application'];var labels=cfg.labels||{};var keys=Object.keys(data.results).sort(function(a,b){var ia=typeOrder.indexOf(a),ib=typeOrder.indexOf(b);return(ia<0?99:ia)-(ib<0?99:ib)});var html='';keys.forEach(function(type){var items=data.results[type];if(!items||!items.length)return;var label=labels[type]||type;html+='<div class="as-group">';html+='<h3 class="as-group-title">'+escHtml(label)+'</h3>';html+='<ul class="as-group-list">';items.forEach(function(item){var isDownload=item.type==='dlm_download';var thumb;if(isDownload){thumb='<div class="as-thumb as-thumb--pdf">'+PDF_ICON+'</div>'}else{thumb=item.thumbnail?'<img src="'+escHtml(item.thumbnail)+'" alt="" class="as-thumb" loading="lazy">':'<div class="as-thumb as-thumb--empty"></div>'} 9var badges='';if(!isDownload){if(item.sku)badges+='<span class="as-badge as-badge--sku">Réf. '+escHtml(item.sku)+'</span>';if(item.brand)badges+='<span class="as-badge as-badge--brand">'+escHtml(item.brand.split(',')[0].trim())+'</span>';if(item.categories)badges+='<span class="as-badge as-badge--cat">'+escHtml(item.categories.split(',')[0].trim())+'</span>'}else{badges+='<span class="as-badge as-badge--pdf-type">PDF</span>'} 10var target=isDownload?' target="_blank" rel="noopener"':'';html+='<li>';html+='<a href="'+escHtml(item.url)+'" class="as-item"'+target+'>';html+=thumb;html+='<div class="as-item-body">';
10html+='<span class="as-item-title">'+escHtml(item.title)+'</span>';if(badges)html+='<span class="as-item-badges">'+badges+'</span>';if(item.excerpt)html+='<span class="as-item-excerpt">'+escHtml(item.excerpt)+'</span>';html+='</div>';html+='</a>';html+='</li>'});html+='</ul></div>'});resultsEl.innerHTML=html} 11function escHtml(str){if(!str)return'';return String(str).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"')} 12if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init)}else{init()}}())
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.