1(function(){'use strict';const modal=document.querySelector('.search-modal');if(!modal||!modal.querySelector('.ls')||!window.ctLiveSearch){return} 2const MIN_CHARS=2;const DEBOUNCE_MS=250;const form=modal.querySelector('.ls-form');const input=modal.querySelector('.ls-input');const boxes=Array.from(modal.querySelectorAll('.ls-filter input'));const allBox=boxes.find((box)=>'all'===box.value);const intro=modal.querySelector('.ls-intro');const results=modal.querySelector('.ls-results');const status=modal.querySelector('.ls-status');const featured=modal.querySelector('.ls-featured');const grid=modal.querySelector('.ls-grid');const empty=modal.querySelector('.ls-empty');const more=modal.querySelector('.ls-more');const state={q:'',page:1,controller:null,timer:null};const ICONS={solutions:'<circle cx="12" cy="12" r="10"/><path d="M2 12h20"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>',news:'<circle cx="12" cy="8" r="6"/><path d="M15.48 12.89 17 22l-5-3-5 3 1.52-9.11"/>',blogs:'<rect x="4" y="4" width="16" height="16" rx="2"/><rect x="9" y="9" width="6" height="6"/><path d="M9 1v3M15 1v3M9 20v3M15 20v3M20 9h3M20 14h3M1 9h3M1 14h3"/>',pdfs:'<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M16 13H8M16 17H8M10 9H8"/>','case-studies':'<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75"/>',arrow:'<path d="M5 12h14M12 5l7 7-7 7"/>',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5M12 15V3"/>',};function icon(name,size){return `<svg width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ICONS[name] || ''}</svg>`} 3function esc(value){return String(value??'').replace(/[&<>"']/g,(c)=>({'&':'&','<':'<','>':'>','"':'"','\'':'''}[c]))} 4function linkAttrs(action){return action.external?' target="_blank" rel="noopener"':''} 5function cardHtml(item){const actions=item.actions.map((action)=>(action.secondary?`<a class="ls-card__action ls-card__action--secondary" href="${esc(action.url)}"${linkAttrs(action)}>${esc(action.label)}</a>`:`<a class="ls-card__action" href="${esc(action.url)}"${linkAttrs(action)}>${esc(action.label)}</a>`)).join('');const primary=item.actions[0];return ` 6 <article class="ls-card ls-card--${esc(item.type)}"> 7 <div class="ls-card__top"> 8 <span class="ls-card__icon">${icon(item.type, 20)}</span> 9 <span class="ls-badge">${esc(item.badge)}</span> 10 </div> 11 <h3 class="ls-card__title"><a href="${esc(item.url)}">${esc(item.title)}</a></h3> 12 ${item.description ? `<p class="ls-card__desc">${esc(item.description)}</p>` : ''} 13 <div class="ls-card__footer"> 14 <div class="ls-card__actions">${actions}</div> 15 <a class="ls-card__go" href="${esc(primary.url)}"${linkAttrs(primary)} tabindex="-1" aria-hidden="true">${icon(primary.icon, 16)}</a> 16 </div> 17 </article>`} 18function featuredHtml(item){const primary=item.actions[0];const media=item.image?`<img src="${esc(item.image)}" alt="" loading="lazy">`:icon(item.type,56);return ` 19 <article class="ls-featured__card ls-card--${esc(item.type)}"> 20 <div class="ls-featured__body"> 21 <span class="ls-featured__label">Featured</span> 22 <h3 class="ls-featured__title"><a href="${esc(item.url)}">${esc(item.title)}</a></h3> 23 ${item.description ? `<p class="ls-featured__desc">${esc(item.description)}</p>` : ''} 24 <a class="ls-btn" href="${esc(primary.url)}"${linkAttrs(primary)}>${esc(item.featured)}</a> 25 </div> 26 <div class="ls-featured__media">${media}</div> 27 </article>`} 28function skeleton(){featured.innerHTML='<div class="ls-skeleton ls-skeleton--featured"></div>';grid.innerHTML='<div class="ls-skeleton"></div>'.repeat(6)} 29function selectedTypes(){return allBox.checked?[]:boxes.filter((box)=>box.checked).map((box)=>box.value)} 30function setCounts(counts){modal.querySelectorAll('.ls-count').forEach((el)=>{const value=counts?counts[el.dataset.type]:undefined;el.textContent=undefined===value?'':value})} 31function showIntro(){if(state.controller){state.controller.abort()} 32state.q='';modal.classList.remove('is-loading');intro.hidden=!1;results.hidden=!0;setCounts(null)} 33function render(data,page){if(1===page){featured.innerHTML=data.featured?featuredHtml(data.featured):'';grid.innerHTML=data.results.map(cardHtml).join('');setCounts(data.counts)}else{grid.insertAdjacentHTML('beforeend',data.results.map(cardHtml).join(''))} 34const none=0===data.total;empty.hidden=!none;empty.innerHTML=none?`<strong>No results for â${esc(state.q)}â</strong><span>Try a different keyword or select another category.</span>`:'';status.textContent=none?'':`${data.total} ${1 === data.total ? 'result' : 'results'} for â${state.q}â`;more.hidden=!data.has_more} 35function search(page=1){const q=input.value.trim();if(q.length<MIN_CHARS){showIntro();return} 36if(state.controller){state.controller.abort()} 37state.controller=new AbortController();state.q=q;state.page=page;const url=new URL(ctLiveSearch.endpoint);url.searchParams.set('q',q);url.searchParams.set('types',selectedTypes().join(','));url.searchParams.set('page',page);intro.hidden=!0;results.hidden=!1;modal.classList.add('is-loading');more.disabled=!0;if(1===page){empty.hidden=!0;more.hidden=!0;skeleton()} 38fetch(url,{signal:state.controller.signal,headers:{Accept:'application/json'}}).then((response)=>{if(!response.ok){throw new Error(`HTTP ${response.status}`)} 39return response.json()}).then((data)=>{modal.classList.remove('is-loading');more.disabled=!1;render(data,page)}
39).catch((error)=>{if('AbortError'===error.name){return} 40modal.classList.remove('is-loading');more.disabled=!1;if(1===page){featured.innerHTML='';grid.innerHTML=''} 41empty.hidden=!1;empty.innerHTML='<strong>Something went wrong</strong><span>Please try again in a moment.</span>'})} 42input.addEventListener('input',()=>{clearTimeout(state.timer);state.timer=setTimeout(()=>search(1),DEBOUNCE_MS)});form.addEventListener('submit',(event)=>{event.preventDefault();clearTimeout(state.timer);search(1)});boxes.forEach((box)=>box.addEventListener('change',()=>{if(box===allBox){boxes.forEach((other)=>{other.checked=other===allBox})}else if(box.checked){allBox.checked=!1} 43if(!boxes.some((other)=>other.checked)){allBox.checked=!0} 44clearTimeout(state.timer);search(1)}));more.addEventListener('click',()=>search(state.page+1));let wasOpen=!1;new MutationObserver(()=>{const open=modal.classList.contains('visible');if(open===wasOpen){return} 45wasOpen=open;document.documentElement.classList.toggle('ls-locked',open);if(open){setTimeout(()=>input.focus(),50)}}).observe(modal,{attributes:!0,attributeFilter:['class']});document.addEventListener('keydown',(event)=>{if('Escape'===event.key&&modal.classList.contains('visible')){modal.classList.remove('visible')}});const close=modal.querySelector('.close-search');if(close){close.addEventListener('keydown',(event)=>{if('Enter'===event.key||' '===event.key){event.preventDefault();modal.classList.remove('visible')}})}}())
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.