1var e=document.querySelector(`.focus-reader`),t=document.querySelector(`#article-start`),n=document.querySelector(`[data-focus-open]`);if(e&&t&&n){let r=e.querySelector(`.focus-stage`),i=e.querySelector(`.focus-text`),a=e.querySelector(`.focus-progress`),o=e.querySelector(`.focus-context`),s=e.querySelector(`[data-focus-prev]`),c=e.querySelector(`[data-focus-next]`),l=[],u=[0],d=1,f=!1,p=e.querySelector(`.focus-picker`),m=e.querySelector(`[data-focus-browse]`),h=p.querySelector(`input`),g=p.querySelector(`.focus-sections`),_=g.querySelector(`ol`);function v(){if(f)return;f=!0;let e=new Intl.Segmenter(void 0,{granularity:`sentence`}),n=``;t.querySelectorAll(`h2,h3,p,blockquote,li,pre,figure,img,video,audio,table`).forEach(t=>{if(t.closest(`.sidenote,.book-contents,[data-footnotes]`))return;if(t.tagName.startsWith(`H`)){n=t.textContent?.replace(/#$/,``).trim()||``;return}if(t.classList.contains(`interview-speaker`)||t.parentElement?.closest(`blockquote,li,pre,figure,table`)||[`IMG`,`VIDEO`,`AUDIO`].includes(t.tagName)&&t.parentElement?.closest(`p`))return;let r=document.createElement(`div`);if(r.innerHTML=t.innerHTML,r.querySelectorAll(`.sidenote,.note-marker,.sidenote-number,.passage-anchor-link,input,label,script,style`).forEach(e=>e.remove()),r.querySelectorAll(`[id]`).forEach(e=>e.removeAttribute(`id`)),[`FIGURE`,`IMG`,`VIDEO`,`AUDIO`,`TABLE`].includes(t.tagName)||r.querySelector(`img,video,audio,table`)){let e=document.createElement(`button`);e.type=`button`,e.dataset.focusMedia=``,e.textContent=t.tagName===`TABLE`?`View table in context`:`View media in context`,r.replaceChildren(e)}let i=r.textContent||``;if(!i.trim())return;let a=[0,...[...i.matchAll(/\S+\s*/gu)].map(e=>e.index+e[0].length)];a.at(-1)!==i.length&&a.push(i.length);let o=[...e.segment(i)].map(e=>a.findIndex(t=>t>=e.index+e.segment.length)).filter(e=>e>0);o.at(-1)!==a.length-1&&o.push(a.length-1);let s=t.closest(`.interview-turn`)?.dataset.speaker;l.push({source:t,content:r,context:s||n,boundaries:a,sentenceEnds:o})});let i=[...t.querySelectorAll(`h2,h3`)].filter(e=>!e.closest(`.book-contents`));for(let e of i){let t=l.findIndex(t=>!!(e.compareDocumentPosition(t.source)&Node.DOCUMENT_POSITION_FOLLOWING));if(t<0)continue;let n=document.createElement(`li`),r=document.createElement(`button`);r.type=`button`,r.dataset.focusSection=String(t),r.textContent=e.textContent?.replace(/#$/,``).trim()||``,n.append(r),_.append(n)}g.hidden=!_.children.length,u=[0];for(let e of l)u.push(u.at(-1)+e.boundaries.length-1);d=u.at(-1)||1,new ResizeObserver(()=>B()).observe(r),document.fonts.ready.then(()=>B())}function y(t){p.hidden=!t,m.setAttribute(`aria-expanded`,String(t)),r.inert=t,e.querySelector(`footer`).inert=t,e.querySelector(`header`).inert=t,t?(p.querySelector(`[data-focus-picker-close]`).focus(),O()):m.focus()}m.addEventListener(`click`,()=>y(!0)),p.querySelector(`[data-focus-picker-close]`).addEventListener(`click`,()=>y(!1));let b=p.querySelector(`.focus-reading-groups`),x=p.querySelector(`.focus-search-results`),S=p.querySelector(`.focus-loading`),C=p.querySelector(`.focus-load-error`),w=[],T=!1,E=null;function D(e,t,n,r){let i=document.createElement(`section`);i.dataset.readingGroup=``;let a=document.createElement(`h2`);a.textContent=e;let o=document.createElement(`ul`);for(let e of t){let t=document.createElement(`li`);t.dataset.readingEntry=``,t.dataset.title=e.title,t.dataset.context=e.context,t.dataset.kind=e.kind,t.dataset.order=String(e.order);let i=document.createElement(`a`);if(i.href=e.href,e.href===n&&i.setAttribute(`aria-current`,`page`),i.append(e.title),r){let t=document.createElement(`small`);t.textContent=(e.kind===`book`?`Book · `:``)+e.context,i.append(t)}t.append(i),o.append(t),w.push(t)}return i.append(a,o),i}async function O(){if(!T)return E||(S.hidden=!1,C.hidden=!0,E=(async()=>{let t=e.dataset.focusCollection,n=await fetch(`/focus-reading/${t}.json`);if(!n.ok)throw Error(`Could not load readings`);let r=await n.json(),i=location.pathname.replace(/\/$/,``),a=r.find(e=>e.href===i),o=t!==`posts`&&a&&/[a-z]/i.test(a.context)?r.filter(e=>e.context===a.context).sort((e,t)=>
1e.order-t.order):[];r.sort((e,t)=>e.title.localeCompare(t.title)),w=[];let s=[];o.length>1&&s.push(D(a.context,o,i,!1));let c=r.filter(e=>o.length<=1||!o.includes(e));s.push(D(t===`illich`?`Illich`:t===`lewis`?`C.S. Lewis`:`Writing`,c,i,!0)),b.replaceChildren(...s),T=!0,k()})().catch(()=>{C.hidden=!1,E=null}).finally(()=>{S.hidden=!0}),E)}function k(){let e=h.value.toLowerCase().trim(),t=t=>{let n=t.dataset.title.toLowerCase();return n===e?0:n.includes(e)?1:2},n=w.filter(t=>`${t.dataset.title} ${t.dataset.context}`.toLowerCase().includes(e));n.sort((e,n)=>t(e)-t(n)||(e.dataset.context===n.dataset.context?Number(e.dataset.order)-Number(n.dataset.order):0)),x.replaceChildren(...e?n.map(e=>e.cloneNode(!0)):[]),x.hidden=!e,p.querySelectorAll(`[data-reading-group]`).forEach(t=>{t.hidden=!!e}),g.hidden=!!e||!_.children.length,p.querySelector(`.focus-no-results`).hidden=!T||!e||n.length>0}h.addEventListener(`input`,k),p.addEventListener(`click`,e=>{let t=e.target.closest(`[data-focus-section]`);t&&(N=Number(t.dataset.focusSection),P=0,y(!1),B())}),e.addEventListener(`cancel`,e=>{p.hidden||(e.preventDefault(),y(!1))});let A=`paragraph-reader:`+location.pathname,j=e=>{try{return localStorage.getItem(e)}catch{return null}},M=(e,t)=>{try{localStorage.setItem(e,t)}catch{}},N=0,P=0,F=0,I=[],L=0,R=``;function z(e,t){let n=l[N].content,r=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),i=document.createRange(),a=0,o=!1;for(;r.nextNode();){let n=r.currentNode,s=n.textContent.length;if(!o&&e<=a+s&&(i.setStart(n,Math.max(0,e-a)),o=!0),o&&t<=a+s)return i.setEnd(n,t-a),i.cloneContents();a+=s}return n.cloneNode(!0)}function B(){if(!e.open||!l.length||r.clientHeight<1)return;let t=l[N],n=t.boundaries,f=n.length-1,p=r.clientWidth<430?24:28,m=r.clientWidth<430?28:40,h=()=>i.scrollHeight<=r.clientHeight&&i.scrollWidth<=r.clientWidth,g=(e,t)=>(i.replaceChildren(z(n[e],n[t])),h());i.style.fontSize=m-2+`px`,I=[];for(let e=0;e<f;){let n=t.sentenceEnds.filter(t=>t>e).slice(0,r.clientWidth<430?4:5),a=e;for(let t of n)if(g(e,t))a=t;else break;if(a===e){i.style.fontSize=p+`px`;for(let t of n)if(g(e,t))a=t;else break}if(a===e){let t=e+1,r=n[0]||f;for(;t<=r;){let n=Math.floor((t+r)/2);g(e,n)?(a=n,t=n+1):r=n-1}}a=Math.max(e+1,a),I.push({start:e,end:a}),e=a,i.style.fontSize=m-2+`px`}L=I.findIndex(e=>P<e.end),L<0&&(L=I.length-1),P=I[L].start,F=I[L].end;let _=p,v=m,y=p;for(;_<=v;){let e=Math.floor((_+v)/2);i.style.fontSize=e+`px`,g(P,F)?(y=e,_=e+1):v=e-1}i.style.fontSize=y+`px`,i.replaceChildren(z(n[P],n[F])),o.textContent=t.context,o.hidden=!t.context;let b=Math.max(1,Math.round((u[N]+F)/d*100));a.textContent=`${b}% · passage ${N+1}/${l.length}${I.length>1?` · ${L+1}/${I.length}`:``}`,a.setAttribute(`aria-label`,`${b} percent through, passage ${N+1} of ${l.length}${I.length>1?`, part ${L+1} of ${I.length}`:``}`),s.disabled=N===0&&L===0,c.disabled=N===l.length-1&&L===I.length-1,M(A,JSON.stringify({unit:N,start:P}));let x=t.source.id||t.source.closest(`[id^="l"]`)?.id;x&&history.replaceState(null,``,`#`+x)}function V(e){if(e<0){if(L>0)P=I[L-1].start;else if(N>0)N--,P=2**53-1;else return}else{if(c.disabled)return;L<I.length-1?P=I[L+1].start:(N++,P=0)}B()}function H(){e.close()}n.hidden=!t.querySelector(`p,blockquote,li,pre,figure,img,video,audio,table`),n.addEventListener(`click`,()=>{if(v(),!l.length){n.hidden=!0;return}let t=location.hash&&document.getElementById(location.hash.slice(1)),r=t?l.findIndex(e=>e.source===t||e.source.contains(t)||!!(t.compareDocumentPosition(e.source)&Node.DOCUMENT_POSITION_FOLLOWING)):-1;N=r>=0?r:Math.max(0,l.findIndex(e=>e.source.getBoundingClientRect().bottom>0)),P=0;try{let e=JSON.parse(j(A)||`null`);e&&Number.isInteger(e.unit)&&l[e.unit]&&(!t||e.unit===N)&&(N=e.unit,P=Number.isInteger(e.start)&&e.start>=0&&e.start<l[N].boundaries.length-1?e.start:0)}catch{}R=document.documentElement.style.overflow,document.documentElement.style.overflow=`hidden`,e.showModal(),B()}),e.querySelector(`[data-focus-close]`).addEventListener(`click`,H),e.addEventListener(`close`,()=>{p.hidden||y(!1),document.documentElement.style.overflow=R,l[N].source.scrollIntoView({block:`center`,behavior:`instant`}),n.focus({preventScroll:!0})}),s.addEventListener(`click`,()=>V(-1)),c.addEventListener(`click`,()=>V(1)),e.addEventListener(`click`,t=>{if(!p.hidden)return;let n=t.target;if(n.closest(`[data-focus-media]`)){H();return}if(n.closest(`a,button`)||window.getSelection()?.toString())return;let i=r.getBoundingClientRect();
1t.clientY<i.top||t.clientY>i.bottom||V(t.clientX<e.clientWidth/2?-1:1)}),e.addEventListener(`keydown`,e=>{if(!p.hidden){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),y(!1));return}(e.key===`ArrowRight`||e.key===`ArrowLeft`)&&(e.preventDefault(),V(e.key===`ArrowRight`?1:-1))})}
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.