'+escapeHtml(h.section)+'
Page '+h.page+''+highlight(h.text,words)+'
let handbook=[];const $=s=>document.querySelector(s);const escapeHtml=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));const stop=new Set('what which where when how does that this with from into their there about could should would have been were does only dose dosing patient patients please show tell using they them the for and are can you your'.split(' '));function tokens(s){return [...new Set((s.toLowerCase().match(/[a-z0-9]+/g)||[]).filter(w=>w.length>2&&!stop.has(w)))];}function highlight(s,words){let safe=escapeHtml(s);for(const w of words.filter(w=>w.length>3).slice(0,8)){const re=new RegExp('\\b('+w+')\\b','gi');safe=safe.replace(re,'$1')}return safe;}function search(q){const words=tokens(q);if(!words.length)return [];return handbook.flatMap(p=>p.paras.map((text,i)=>{const hay=text.toLowerCase(),title=p.section.toLowerCase();let score=0;for(const w of words){if(hay.includes(w))score+=2;if(title.includes(w))score+=1;}return {page:p.page,section:p.section,text,score,i};})).filter(x=>x.score>0).sort((a,b)=>b.score-a.score||a.page-b.page).slice(0,5)}function render(q){const root=$('#results');const hits=search(q);const words=tokens(q);let html='
The handbook may not cover this question. Do not infer an answer.
'+highlight(h.text,words)+'