PageSourceSearch

https://kingjamesbiblereader.com/assets/AdvancedSearchPage-xUh6Gpbv.js

js kingjamesbiblereader.com collected 2026-09-24 14:46:19 UTC 48,915 bytes, 24 lines download raw bytes

1import{c as X,D as We,p as H,ap as Ee,r as y,j as t,m as Z,L as Le,U as Oe,x as Te,n as Me,aa as he,J as Pe,X as Re}from"./index-Cshou3OC.js";import{n as Ie,g as Fe,i as Be,W as Y,h as J,m as _e}from"./bibleApi-DKzoKc5t.js";import{R as qe}from"./rotate-ccw-KxcuQO6X.js";import{C as De}from"./chevron-right-BG73r27I.js";import{P as Ke,e as me}from"./exportVerses-BhedPckb.js";import{g as He}from"./publicOrigin-DLiAwV89.js";import{d as ze}from"./nativeDownload-BWDoQRkH.js";import{F as Ge}from"./file-type-dQRsa89D.js";import{F as Qe}from"./file-text-6bXh8050.js";import{F as xe}from"./flask-conical-DLE44bh7.js";import{S as pe}from"./square-check-big-BDJKxvJ8.js";import{S as ge}from"./square-DhbdM5z9.js";import"./jspdf.es.min-DtorAqlM.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Ue=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],Ve=X("ArrowUpDown",Ue);/**
7 * @license lucide-react v0.475.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const Ze=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],Ye=X("FileDown",Ze);/**
12 * @license lucide-react v0.475.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const Je=[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]],Xe=X("SlidersHorizontal",Je);/**
17 * @license lucide-react v0.475.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const et=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],tt=X("Table",et);function Ce(e){return e.replace(/^¶\s*/,"")}function Ne(e){return e.replace(/\[([^\]]*)\]/g,"$1")}function be(e){return e.match(/[A-Za-z]+/g)||[]}function nt(e){const n=/¶/.test(e),a=(e.match(/¶/g)||[]).length,l=Ce(e),o=l.match(/\[[^\]]*\]/g)||[],d=o.length>0,i=o.reduce((E,U)=>E+be(U).length,0),s=Ne(l).replace(/\s+/g," ").trim(),r=be(s),m=r.length,u=s.length,x=(s.match(/[A-Za-z]/g)||[]).length,p=r.filter(E=>/^[A-Z]/.test(E)).length,j=r.filter(E=>E.length>=2&&E===E.toUpperCase()).length,w=(s.match(/[.!?]+/g)||[]).length||(s?1:0),c=(s.match(/,/g)||[]).length,k=(s.match(/\./g)||[]).length,$=(s.match(/;/g)||[]).length,A=(s.match(/:/g)||[]).length,b=(s.match(/\?/g)||[]).length,N=(s.match(/!/g)||[]).length,L=(s.match(/-/g)||[]).length,F=(s.match(/['’]/g)||[]).length,Q=c+k+$+A+b+N+L+F,M=r.length?r[0].toLowerCase():"",W=r.length?r[r.length-1].toLowerCase():"",D=/^¶/.test(e.trim()),te=r.map(E=>E.toLowerCase()),ne=new Set(te).size;let K=0,z="";for(const E of r)E.length>K&&(K=E.length,z=E);const P=m?+(x/m).toFixed(2):0;return{wordCount:m,charCount:u,letterCount:x,uniqueWordCount:ne,longestWordLen:K,longestWord:z,avgWordLen:P,sentenceCount:w,commaCount:c,periodCount:k,semicolonCount:$,colonCount:A,questionCount:b,exclamationCount:N,hyphenCount:L,apostropheCount:F,totalPunctuationCount:Q,capitalWordCount:p,allCapsWordCount:j,italicWordCount:i,pilcrowCount:a,firstWord:M,lastWord:W,hasPilcrow:n,hasItalics:d,hasComma:c>0,hasPeriod:k>0,hasSemicolon:$>0,hasHyphen:L>0,hasApostrophe:F>0,hasQuestion:b>0,hasExclamation:N>0,hasAllCaps:j>0,hasColon:A>0,startsWithPilcrow:D}}let oe=null,G=null;async function st(e=!1){return oe&&!e?oe:(G&&!e||(G=(async()=>{var l;const n=await We(),a=[];for(const o of H){const d=o.apiName,i=n[d];if(!i)continue;const s=Object.keys(i).map(Number).sort((r,m)=>r-m);for(const r of s){const m=i[r];if(!Array.isArray(m))continue;const u=(p,C,j,w)=>{const c=Fe(p),k=nt(c),$=Be(Ne(Ce(c)).replace(/\s+/g," ").trim());a.push({book:d,abbr:o.abbr,shortName:o.shortName,testament:o.testament,chapter:r,verse:C,kind:j,ref:w,rawText:c,plainText:$,metrics:k})},x=Ee[`${d}:${r}`];
21x&&u(x.replace(/¶\s*/g,""),0,"subscript",`${o.shortName} ${r} superscription`);for(const p of m)!p||typeof p.text!="string"||p.verse==null||(p.heading&&u(String(p.heading).replace(/¶\s*/g,""),p.verse,"heading",`${o.shortName} ${r}:${p.verse} (stanza)`),u(p.text,p.verse,null,`${o.shortName} ${r}:${p.verse}`));const g=(l=n.__colophons)==null?void 0:l[`${d}:${r}`];g&&u(String(g).replace(/¶\s*/g,""),0,"colophon",`${o.shortName} ${r} colophon`)}}return oe=a,G=null,a})()),G)}const T=[{key:"wordCount",label:"Word count",short:"Words"},{key:"charCount",label:"Character count",short:"Characters"},{key:"letterCount",label:"Letter count",short:"Letters"},{key:"uniqueWordCount",label:"Unique words",short:"Unique words"},{key:"longestWordLen",label:"Longest word length",short:"Longest word"},{key:"avgWordLen",label:"Average word length",short:"Avg word length"},{key:"sentenceCount",label:"Sentence count",short:"Sentences"},{key:"commaCount",label:"Commas",short:"Commas"},{key:"periodCount",label:"Full stops (periods)",short:"Full stops"},{key:"semicolonCount",label:"Semicolons",short:"Semicolons"},{key:"colonCount",label:"Colons",short:"Colons"},{key:"questionCount",label:"Question marks",short:"Question marks"},{key:"exclamationCount",label:"Exclamation marks",short:"Exclamations"},{key:"hyphenCount",label:"Hyphens",short:"Hyphens"},{key:"apostropheCount",label:"Apostrophes",short:"Apostrophes"},{key:"totalPunctuationCount",label:"Total punctuation marks",short:"Punctuation"},{key:"capitalWordCount",label:"Capitalised words",short:"Capitalised"},{key:"allCapsWordCount",label:"ALL-CAPS words (e.g. LORD)",short:"ALL-CAPS words"},{key:"italicWordCount",label:"Italic (supplied) words",short:"Italics"}],_=[{key:"hasPilcrow",label:"Begins a new paragraph (¶)"},{key:"hasItalics",label:"Contains italics ([supplied] words)"},{key:"hasComma",label:"Contains a comma"},{key:"hasPeriod",label:"Contains a full stop (period)"},{key:"hasSemicolon",label:"Contains a semicolon"},{key:"hasColon",label:"Contains a colon"},{key:"hasQuestion",label:"Contains a question mark"},{key:"hasExclamation",label:"Contains an exclamation mark"},{key:"hasHyphen",label:"Contains a hyphen"},{key:"hasApostrophe",label:"Contains an apostrophe"},{key:"hasAllCaps",label:"Contains an ALL-CAPS word"}];function fe(){const e={};T.forEach(a=>{e[a.key]={min:"",max:""}});const n={};return _.forEach(a=>{n[a.key]="any"}),{testament:"all",book:"all",sectionStates:{verse:"any",subscript:"any",colophon:"any",heading:"any"},textContains:"",textCaseSensitive:!1,textWholeWord:!1,textInOrder:!1,textAdjacent:!1,textWildcard:!1,ranges:e,bools:n,sortKey:"wordCount",sortDir:"desc"}}function ot(e){if(e.testament!=="all"||e.book!=="all"||e.sectionStates&&Object.values(e.sectionStates).some(n=>n!=="any")||e.textContains.trim()!=="")return!1;for(const n of T)if(e.ranges[n.key].min!==""||e.ranges[n.key].max!=="")return!1;for(const n of _)if(e.bools[n.key]!=="any")return!1;return!0}function ee(e){return Ie(e||"").trim().split(/[\s,]+/).filter(Boolean)}function ie(e,n){if(!n)return!0;const a=e.kind||"verse",l=Object.keys(n).filter(d=>n[d]==="yes");if(l.length)return l.includes(a);const o=Object.keys(n).filter(d=>n[d]==="no");return o.length?!o.includes(a):!0}function de(e,n,a,l,o=!1,d=!1,i=!1){if(!n.length)return!0;const s=x=>{const g=a?x:x.toLowerCase();if(i){let p="";for(const C of g)C==="*"?p+=".*":C==="?"?p+=".":C==="-"?p+="-?":p+=C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return p}return J(g)},r=a?"":"i",m=l?`(?<![${Y}])`:"",u=l?`(?![${Y}])`:"";if(d){const x=n.map(s).join("[,;:.!?()\\u2013\\u2014\\s-]+"),g=`${m}${x}${u}`;return new RegExp(g,r).test(e)}if(o){let x=0;for(const g of n){const p=s(g),C=new RegExp(`${m}${p}${u}`,r+"g");C.lastIndex=x;const j=C.exec(e);if(!j)return!1;x=j.index+j[0].length}return!0}return i?n.every(x=>{const g=s(x);return new RegExp(`${m}${g}${u}`,r).test(e)}):n.every(x=>{const g=s(x);return new RegExp(`${m}${g}${u}`,r).test(e)})}let ae=null;function at(e,n=null){if(!e||!e.length)return null;if(!n){if(ae)return ae;const l={};for(const o of T){let d=1/0,i=-1/0;for(const s of e){const r=s.metrics[o.key];r<d&&(d=r),r>i&&(i=r)}l[o.key]={min:Math.round(d),max:Math.round(i)}}return ae=l,l}const a={};for(const l of T){const o={...n,ranges:{...n.ranges,[l.key]:{min:"",max:""}}};let d=1/0,i=-1/0;for(const s of e){if(!rt(s,o,l.key))continue;const r=s.metrics[l.key];r<d&&(d=r),r>i&&(i=r)}a[l.key]=i===-1/0?null:{min:Math.round(d),max:Math.round(i)}}return a}function rt(e,n,a){const l=ee(n.textContains);if(n.testament!=="all"&&e.testament!==n.testament||n.book!=="all"&&e.book!==n.book||!ie(e,n.sectionStates)||l.length&&!de(e.plainText,l,n.textCaseSensitive,n.textWholeWord,n.textInOrder,n.textAdjacent,n.textWildcard))return!1;for(const o of T){if(o.key===a)continue;const{min:d,max:i}=n.ranges[o.key],s=e.metrics[o.key];if(d!==""&&s<Number(d)||i!==""&&s>Number(i))return!1}for(const o of _){const d=n.bools[o.key];if(d==="any")continue;const i=!!e.metrics[o.key];if(d==="yes"&&!i||d==="no"&&i)return!1}return!0}function q(e,n){const a=ee(n.textContains);let l=0;for(const o of e){if(n.testament!=="all"&&o.testament!==n.testament||n.book!=="all"&&o.book!==n.book||!ie(o,n.sectionStates)||a.length&&!de(o.plainText,a,n.textCaseSensitive,n.textWholeWord,n.textInOrder,n.textAdjacent,n.textWildcard))continue;let d=!0;for(const i of T){const{min:s,max:r}=n.ranges[i.key],m=o.metrics[i.key];if(s!==""&&m<Number(s)){d=!1;break}if(r!==""&&m>Number(r)){d=!1;break}}if(d){for(const i of _){const s=n.bools[i.key];if(s==="any")continue;const r=!!o.metrics[i.key];if(s==="yes"&&!r){d=!1;break}if(s==="no"&&r){d=!1;break}}d&&l++}}return l}function lt(e,n){if(!e||!e.length)return null;const a={};for(const s of["all","old","new"])a[s]=q(e,{...n,testament:s,book:"all"})>0;const l={all:q(e,{...n,book:"all"})>0};for(const s of H)n.testament!=="all"&&s.testament!==n.testament||(l[s.apiName]=q(e,{...n,book:s.apiName})>0);const o={},d={verse:"any",subscript:"any",colophon:"any",heading:"any"};for(const s of["verse","subscript","colophon","heading"])o[s]={any:!0,yes:q(e,{...n,sectionStates:{...d,[s]:"yes"}})>0,no:q(e,{...n,sectionStates:{...n.sectionStates||d,[s]:"no"}})>0};const i={};for(const s of _)i[s.key]={any:!0,yes:q(e,{...n,bools:{...n.bools,[s.key]:"yes"}})>0,no:q(e,{...n,bools:{...n.bools,[s.key]:"no"}})>0};return{testaments:a,books:l,sections:o,bools:i}}function ct(e,n){const a=ee(n.textContains);let l=e.filter(s=>{if(n.testament!=="all"&&s.testament!==n.testament||n.book!=="all"&&s.book!==n.book||!ie(s,n.sectionStates)||a.length&&!de(s.plainText,a,n.textCaseSensitive,n.textWholeWord,n.textInOrder,n.textAdjacent,n.textWildcard))return!1;for(const r of T){const{min:m,max:u}=n.ranges[r.key],x=s.metrics[r.key];if(m!==""&&x<Number(m)||u!==""&&x>Number(u))return!1}for(const r of _){const m=n.bools[r.key];if(m==="any")continue;const u=!!s.metrics[r.key];if(m==="yes"&&!u||m==="no"&&u)return!1}return!0});const o=n.sortKey;if(o==="none")return l;const d=n.sortDir==="asc"?1:-1,i=s=>H.findIndex(r=>r.apiName===s);return o==="canonical"?(l=l.slice().sort((s,r)=>{const m=i(s.book),u=i(r.book);
21return m!==u?(m-u)*d:s.chapter!==r.chapter?(s.chapter-r.chapter)*d:(s.verse-r.verse)*d}),l):(l=l.slice().sort((s,r)=>{const m=s.metrics[o],u=r.metrics[o];if(m===u){const x=i(s.book),g=i(r.book);return x!==g?x-g:s.chapter!==r.chapter?s.chapter-r.chapter:s.verse-r.verse}return(m-u)*d}),l)}const it=[{key:"subscript",label:"Psalm superscriptions (the title above verse 1)"},{key:"colophon",label:"Chapter colophons (Pauline Epistle subscriptions)"},{key:"heading",label:"Hebrew stanza names (Psalm 119: ALEPH, BETH…)"}];function V({title:e,icon:n,open:a,onToggle:l,children:o}){return t.jsxs("div",{className:"rounded-2xl bg-card/70 border border-border/60 overflow-hidden",children:[t.jsxs("button",{onClick:l,className:"w-full flex items-center justify-between gap-2 px-4 py-3 hover:bg-accent/5 transition-colors text-left",children:[t.jsxs("span",{className:"flex items-center gap-2",children:[n&&t.jsx(n,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"font-sans text-sm font-semibold text-foreground",children:e})]}),t.jsx(Z,{className:`w-4 h-4 text-muted-foreground dark:text-white transition-transform ${a?"rotate-180":""}`})]}),a&&t.jsx("div",{className:"px-4 pb-4 space-y-3",children:o})]})}function ye({filters:e,onChange:n,onReset:a,availability:l,metricRanges:o,textDraft:d,onTextDraftChange:i}){const[s,r]=y.useState({scope:!0,sort:!0,numeric:!0,property:!0}),m=c=>r(k=>({...k,[c]:!k[c]})),u=c=>n({...e,...c}),x=(c,k,$)=>n({...e,ranges:{...e.ranges,[c]:{...e.ranges[c],[k]:$}}}),g=(c,k)=>n({...e,bools:{...e.bools,[c]:k}}),p=e.testament==="all"?H:H.filter(c=>c.testament===e.testament),C=e.sortKey==="none",j=e.sortKey==="canonical",w=e.testament==="old"?{asc:"Gen → Mal",desc:"Mal → Gen"}:e.testament==="new"?{asc:"Matt → Rev",desc:"Rev → Matt"}:{asc:"Gen → Rev",desc:"Rev → Gen"};return t.jsxs("div",{className:"space-y-4",children:[t.jsxs(V,{title:"Scope & text",open:s.scope,onToggle:()=>m("scope"),children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block font-sans text-xs text-muted-foreground mb-1",children:"Testament"}),t.jsxs("select",{value:e.testament,onChange:c=>u({testament:c.target.value,book:"all"}),className:"w-full px-3 pr-8 py-2 rounded-lg bg-secondary border border-border text-sm text-foreground",children:[t.jsx("option",{value:"all",disabled:l&&!l.testaments.all,children:"All (OT + NT)"}),t.jsx("option",{value:"old",disabled:l&&!l.testaments.old,children:"Old Testament"}),t.jsx("option",{value:"new",disabled:l&&!l.testaments.new,children:"New Testament"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block font-sans text-xs text-muted-foreground mb-1",children:"Book"}),t.jsxs("select",{value:e.book,onChange:c=>u({book:c.target.value}),className:"w-full px-3 pr-8 py-2 rounded-lg bg-secondary border border-border text-sm text-foreground",children:[t.jsx("option",{value:"all",disabled:l&&!l.books.all,children:"All books"}),p.map(c=>t.jsx("option",{value:c.apiName,disabled:l&&l.books[c.apiName]===!1,children:c.shortName},c.abbr))]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block font-sans text-xs text-muted-foreground mb-1",children:"Text contains (optional)"}),t.jsx("input",{type:"text",value:d,onChange:c=>i(c.target.value),placeholder:"e.g. love LORD begat…",className:"w-full px-3 py-2 rounded-lg bg-secondary border border-border text-sm text-foreground"}),t.jsxs("ul",{className:"font-sans text-[11px] text-muted-foreground mt-1.5 leading-relaxed list-disc pl-4 space-y-1",children:[t.jsxs("li",{children:["Separate terms with a ",t.jsx("strong",{children:"space"})," or a ",t.jsx("strong",{children:"comma"})," — both work the same way."]}),e.textAdjacent?t.jsxs(t.Fragment,{children:[t.jsxs("li",{children:["Terms must appear ",t.jsx("strong",{children:"adjacent, as an exact phrase, in the order typed"}),"."]}),t.jsxs("li",{children:["Example: ",t.jsx("span",{className:"italic",children:"love God"})," matches only where the words sit side by side."]})]}):e.textInOrder?t.jsxs(t.Fragment,{children:[t.jsxs("li",{children:["Each term is matched ",t.jsx("strong",{children:"in the order typed"}),", but any number of words may sit between them."]}),t.jsxs("li",{children:["Example: ",t.jsx("span",{className:"italic",children:"love God"})," matches when “love” appears before “God”."]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("li",{children:["Each term is matched ",t.jsx("strong",{children:"independently, anywhere in the verse and in any order"}),". A verse matches only when it contains ",t.jsx("strong",{children:"every"})," term."]}),t.jsxs("li",{children:["Example: ",t.jsx("span",{className:"italic",children:"love, God"})," finds verses containing both, even if far apart."]}
21)]}),e.textWildcard&&t.jsxs("li",{children:[t.jsx("strong",{children:"Wildcard"})," mode: ",t.jsx("span",{className:"italic",children:"*"})," matches any run of characters, ",t.jsx("span",{className:"italic",children:"?"})," matches a single character. Example: ",t.jsx("span",{className:"italic",children:"lov*"})," matches love, loved, lovely."]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2.5 mt-2.5",children:[t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:e.textCaseSensitive,onChange:c=>u({textCaseSensitive:c.target.checked}),className:"w-3.5 h-3.5 accent-[hsl(var(--accent))] cursor-pointer"}),t.jsx("span",{className:"font-sans text-xs text-foreground",children:"Match case"})]}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:e.textWholeWord,onChange:c=>u({textWholeWord:c.target.checked}),className:"w-3.5 h-3.5 accent-[hsl(var(--accent))] cursor-pointer"}),t.jsx("span",{className:"font-sans text-xs text-foreground",children:"Whole word"})]}),t.jsxs("label",{className:`flex items-center gap-1.5 select-none ${e.textAdjacent?"opacity-40 cursor-not-allowed":"cursor-pointer"}`,children:[t.jsx("input",{type:"checkbox",disabled:e.textAdjacent,checked:e.textInOrder||e.textAdjacent,onChange:c=>u({textInOrder:c.target.checked}),className:"w-3.5 h-3.5 accent-[hsl(var(--accent))] cursor-pointer disabled:cursor-not-allowed"}),t.jsx("span",{className:"font-sans text-xs text-foreground",children:"In order"})]}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:e.textAdjacent,onChange:c=>u({textAdjacent:c.target.checked}),className:"w-3.5 h-3.5 accent-[hsl(var(--accent))] cursor-pointer"}),t.jsx("span",{className:"font-sans text-xs text-foreground",children:"Adjacent (phrase)"})]}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:e.textWildcard,onChange:c=>u({textWildcard:c.target.checked}),className:"w-3.5 h-3.5 accent-[hsl(var(--accent))] cursor-pointer"}),t.jsx("span",{className:"font-sans text-xs text-foreground",children:"Wildcard (* ?)"})]})]})]})]}),t.jsxs(V,{title:"Sort by",icon:Ve,open:s.sort,onToggle:()=>m("sort"),children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[t.jsxs("select",{value:e.sortKey,onChange:c=>u({sortKey:c.target.value}),className:"w-full px-3 py-2 rounded-lg bg-secondary border border-border text-sm text-foreground",children:[t.jsx("option",{value:"none",children:"None (no sorting)"}),t.jsx("option",{value:"canonical",children:"Book order (canonical)"}),T.map(c=>t.jsx("option",{value:c.key,children:c.short||c.label},c.key))]}),t.jsx("select",{value:e.sortDir,onChange:c=>u({sortDir:c.target.value}),disabled:C,className:"w-full px-3 pr-8 py-2 rounded-lg bg-secondary border border-border text-sm text-foreground disabled:opacity-40",children:j?t.jsxs(t.Fragment,{children:[t.jsx("option",{value:"asc",children:w.asc}),t.jsx("option",{value:"desc",children:w.desc})]}):t.jsxs(t.Fragment,{children:[t.jsx("option",{value:"desc",children:"Highest first"}),t.jsx("option",{value:"asc",children:"Lowest first"})]})})]}),C&&t.jsx("p",{className:"font-sans text-xs text-muted-foreground -mt-1",children:"Results stay in Bible order, unsorted."})]}),t.jsxs(V,{title:"Numeric filters",open:s.numeric,onToggle:()=>m("numeric"),children:[t.jsx("p",{className:"font-sans text-xs text-muted-foreground -mt-1",children:"Leave blank for no limit."}),t.jsx("div",{className:"space-y-2",children:T.map(c=>{const k=o==null?void 0:o[c.key],$=e.ranges[c.key].min!==""||e.ranges[c.key].max!=="",A=o&&k===null&&!$;return t.jsxs("div",{className:`grid grid-cols-[1fr_auto_auto] items-center gap-2 ${A?"opacity-40":""}`,children:[t.jsx("span",{className:"font-sans text-xs text-foreground break-words",children:c.label}),t.jsx("input",{type:"number",inputMode:"numeric",disabled:A,value:e.ranges[c.key].min,onChange:b=>x(c.key,"min",b.target.value),placeholder:k?String(k.min):"min",className:"kjb-num-input w-20 px-2 py-1.5 rounded-lg bg-secondary border border-border text-xs text-foreground disabled:cursor-not-allowed"}),t.jsx("input",{type:"number",inputMode:"numeric",disabled:A,value:e.ranges[c.key].max,onChange:b=>x(c.key,"max",b.target.value),placeholder:k?String(k.max):"max",className:"kjb-num-input w-20 px-2 py-1.5 rounded-lg bg-secondary border border-border text-xs text-foreground disabled:cursor-not-allowed"})]},c.key)})})]}),t.jsx(V,{title:"Property filters",open:s.property,onToggle:()=>m("property"),children:t.jsxs("div",{className:"space-y-2.5",children:[it.map(c=>{const k=e.sectionStates[c.key]||"any",$=k!=="any";return t.jsxs("div",{className:`flex items-center justify-between gap-3 rounded-lg px-2 -mx-2 py-1 transition-colors ${$?"bg-primary/10 ring-1 ring-primary/30":""}`,children:[t.jsx("span",{className:`font-sans text-xs flex-1 min-w-0 break-words ${$?"text-foreground font-semibold":"text-foreground"}`,children:c.label}),t.jsx("div",{className:"flex rounded-lg overflow-hidden border border-border shrink-0",children:["any","yes","no"].map(A=>{var L;const b=k===A,N=l&&!b&&((L=l.sections[c.key])==null?void 0:L[A])===!1;return t.jsx("button",{disabled:N,onClick:()=>u({sectionStates:{...e.sectionStates,[c.key]:A}}),className:`px-2.5 sm:px-3 py-1.5 text-xs font-medium whitespace-nowrap transition-colors ${b?"bg-primary text-primary-foreground":"bg-secondary text-muted-foreground hover:text-foreground"}
21 ${N?"opacity-30 cursor-not-allowed hover:text-muted-foreground":""}`,children:A==="any"?"Any":A==="yes"?"Yes":"No"},A)})})]},c.key)}),_.map(c=>{const k=e.bools[c.key]!=="any";return t.jsxs("div",{className:`flex items-center justify-between gap-3 rounded-lg px-2 -mx-2 py-1 transition-colors ${k?"bg-primary/10 ring-1 ring-primary/30":""}`,children:[t.jsx("span",{className:`font-sans text-xs flex-1 min-w-0 break-words ${k?"text-foreground font-semibold":"text-foreground"}`,children:c.label}),t.jsx("div",{className:"flex rounded-lg overflow-hidden border border-border shrink-0",children:["any","yes","no"].map($=>{var N;const A=e.bools[c.key]===$,b=l&&!A&&((N=l.bools[c.key])==null?void 0:N[$])===!1;return t.jsx("button",{disabled:b,onClick:()=>g(c.key,$),className:`px-2.5 sm:px-3 py-1.5 text-xs font-medium whitespace-nowrap transition-colors ${A?"bg-primary text-primary-foreground":"bg-secondary text-muted-foreground hover:text-foreground"} ${b?"opacity-30 cursor-not-allowed hover:text-muted-foreground":""}`,children:$==="any"?"Any":$==="yes"?"Yes":"No"},$)})})]},c.key)})]})}),t.jsxs("button",{onClick:a,className:"w-full flex items-center justify-center gap-2 py-3 rounded-xl bg-secondary/50 border border-border text-foreground font-sans text-sm font-medium hover:border-accent transition-colors",children:[t.jsx(qe,{className:"w-4 h-4"}),"Reset all filters"]})]})}const ke=["bg-blue-100 text-blue-700 dark:bg-blue-500/20 dark:text-blue-300","bg-emerald-100 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-300","bg-amber-100 text-amber-700 dark:bg-amber-500/20 dark:text-amber-300","bg-violet-100 text-violet-700 dark:bg-violet-500/20 dark:text-violet-300","bg-rose-100 text-rose-700 dark:bg-rose-500/20 dark:text-rose-300","bg-cyan-100 text-cyan-700 dark:bg-cyan-500/20 dark:text-cyan-300","bg-fuchsia-100 text-fuchsia-700 dark:bg-fuchsia-500/20 dark:text-fuchsia-300"],dt=`[.,;:!?'")\\]]*`,Se="bg-yellow-200 dark:bg-yellow-500/40 text-foreground rounded px-[0.15em] mx-[0.04em] box-decoration-clone",we=(e,n)=>{let a=n;for(;a<e.length&&/[.,;:!?'")\]]/.test(e[a]);)a++;return a};function $e(e,n,a){if(!n||n.length===0)return e;const l=n.map(J),o=new RegExp(`((?:${l.join("|")})${dt})`,"gi");return e.split(o).map((i,s)=>s%2===1?t.jsx("mark",{className:Se,children:i},`${a}-${s}`):i)}function ut(e,n,a,l,o,d){if(!n||n.length===0)return e;const i=o?"":"i",s=d?`(?<![${Y}])`:"",r=d?`(?![${Y}
21])`:"",m=(p,C)=>t.jsx("mark",{className:Se,children:p},C);if(l){const p=s+n.map(J).join(`${r}[,;:.!?()\\u2013\\u2014\\s-]+${s}`)+r;let C;try{C=new RegExp(p,i)}catch{return $e(e,n,a)}const j=C.exec(e);if(!j)return e;const w=j.index,c=we(e,w+j[0].length);return[e.slice(0,w),m(e.slice(w,c),`${a}-m`),e.slice(c)]}const u=[];let x=0,g=!1;for(let p=0;p<n.length;p++){const C=new RegExp(`${s}${J(n[p])}${r}`,i+"g");C.lastIndex=x;const j=C.exec(e);if(!j)break;g=!0,u.push(e.slice(x,j.index));const w=we(e,j.index+j[0].length);u.push(m(e.slice(j.index,w),`${a}-${p}`)),x=w}return g?(u.push(e.slice(x)),u):e}const ht={commaCount:{type:"char",re:/,/g},periodCount:{type:"char",re:/\./g},semicolonCount:{type:"char",re:/;/g},colonCount:{type:"char",re:/:/g},questionCount:{type:"char",re:/\?/g},exclamationCount:{type:"char",re:/!/g},hyphenCount:{type:"char",re:/-/g},apostropheCount:{type:"char",re:/['’]/g},totalPunctuationCount:{type:"char",re:/[.,;:?!\-'’]/g},capitalWordCount:{type:"word",re:/\b[A-Z][A-Za-z'’-]*/g},allCapsWordCount:{type:"word",re:/\b[A-Z]{2,}\b/g}},je={hasComma:"commaCount",hasPeriod:"periodCount",hasSemicolon:"semicolonCount",hasColon:"colonCount",hasQuestion:"questionCount",hasExclamation:"exclamationCount",hasHyphen:"hyphenCount",hasApostrophe:"apostropheCount",hasAllCaps:"allCapsWordCount",hasCapital:"capitalWordCount"};function mt(e,n,a){const l=new RegExp(n.source,n.flags.includes("g")?n.flags:n.flags+"g"),o=[];let d=0,i,s=0;for(;(i=l.exec(e))!==null;)i.index>d&&o.push(e.slice(d,i.index)),o.push(t.jsx("mark",{className:"bg-yellow-200 dark:bg-yellow-500/40 text-foreground rounded",children:i[0]},`${a}-${s++}`)),d=i.index+i[0].length,i[0].length===0&&l.lastIndex++;return d<e.length&&o.push(e.slice(d)),o}function xt(e,n,a){const l=(a==null?void 0:a.textInOrder)||(a==null?void 0:a.textAdjacent),o=a==null?void 0:a.textAdjacent,d=a==null?void 0:a.textCaseSensitive,i=a==null?void 0:a.textWholeWord,s=n&&n.length>0,r=(w,c)=>l?ut(w,n,c,o,d,i):$e(w,n,c),m=!s&&ce(a,"hasPilcrow","pilcrowCount"),u=!s&&ce(a,"hasItalics","italicWordCount"),x=s?null:pt(a),g=(w,c)=>s?r(w,c):x?mt(w,x.re,c):w,p=/^¶\s*/.test(e),j=e.replace(/^¶\s*/,"").split(/(\[[^\]]*\])/g).filter(Boolean);return t.jsxs(t.Fragment,{children:[p&&(m?t.jsx("mark",{className:"pilcrow font-serif mr-1 bg-yellow-200 dark:bg-yellow-500/40 rounded",children:"¶"}):t.jsx("span",{className:"pilcrow font-serif mr-1",children:"¶"})),j.map((w,c)=>{if(w.startsWith("[")&&w.endsWith("]")){const k=g(w.slice(1,-1),`em${c}`);return u?t.jsx("em",{className:"text-muted-foreground",children:t.jsx("mark",{className:"bg-yellow-200 dark:bg-yellow-500/40 text-muted-foreground rounded",children:k})},c):t.jsx("em",{className:"text-muted-foreground",children:k},c)}return t.jsx("span",{children:g(w,`s${c}`)},c)})]})}function ce(e,n,a){var o,d;if(!e)return!1;if(n&&((o=e.bools)==null?void 0:o[n])==="yes"||a&&e.sortKey===a)return!0;const l=a?(d=e.ranges)==null?void 0:d[a]:null;return!!(l&&(l.min!==""||l.max!==""))}function pt(e){if(!e)return null;const n=[];for(const[a,l]of Object.entries(ht)){const o=Object.keys(je).find(d=>je[d]===a);ce(e,o,a)&&n.push(l.re.source)}return n.length===0?null:{re:new RegExp(n.join("|"),"g")}}const re={wordCount:"words",charCount:"chars",letterCount:"letters",uniqueWordCount:"unique words",longestWordLen:"longest word",avgWordLen:"avg word len",sentenceCount:"sentences",commaCount:"commas",periodCount:"full stops",semicolonCount:"semicolons",colonCount:"colons",questionCount:"question marks",exclamationCount:"exclamations",hyphenCount:"hyphens",apostropheCount:"apostrophes",totalPunctuationCount:"punctuation",capitalWordCount:"capitalised",allCapsWordCount:"ALL-CAPS",italicWordCount:"italics"},gt={hasPilcrow:"pilcrowCount",startsWithPilcrow:"pilcrowCount",hasItalics:"italicWordCount",hasComma:"commaCount",hasPeriod:"periodCount",hasSemicolon:"semicolonCount",hasColon:"colonCount",hasQuestion:"questionCount",hasExclamation:"exclamationCount",hasHyphen:"hyphenCount",hasApostrophe:"apostropheCount",hasAllCaps:"allCapsWordCount"},bt={pilcrowCount:"pilcrows",italicWordCount:"italics",commaCount:"commas",periodCount:"full stops",semicolonCount:"semicolons",questionCount:"question marks",exclamationCount:"exclamations",hyphenCount:"hyphens",apostropheCount:"apostrophes",colonCount:"colons",allCapsWordCount:"ALL-CAPS"};function ve({record:e,sortKey:n,sortLabel:a,filters:l}){const o=e.metrics,d=e.kind==="subscript"||e.kind==="colophon"?`/read?book=${e.abbr}&chapter=${e.chapter}&highlight=${e.kind}`:`/read?book=${e.abbr}&chapter=${e.chapter}&verse=${e.verse}`,i=ee(l==null?void 0:l.textContains),s=[],r=new Set,m=(u,x)=>{s.push({label:u,value:x})};
21return n&&n!=="none"&&n!=="canonical"&&o[n]!==void 0&&(m(a||re[n]||n,o[n]),r.add(n)),l&&(Object.entries(l.ranges||{}).forEach(([u,{min:x,max:g}])=>{(x!==""||g!=="")&&!r.has(u)&&o[u]!==void 0&&(m(re[u]||u,o[u]),r.add(u))}),Object.entries(l.bools||{}).forEach(([u,x])=>{if(x==="any")return;const g=gt[u];g&&!r.has(g)&&o[g]!==void 0&&(m(bt[g]||re[g]||g,o[g]),r.add(g))})),s.length===0&&(m("words",o.wordCount),m("chars",o.charCount),o.italicWordCount>0&&m("italics",o.italicWordCount)),t.jsxs(Le,{to:d,className:"block rounded-2xl bg-card/70 border border-border/60 p-4 hover:border-accent/50 hover:shadow-md transition-all group",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[t.jsx("span",{className:"font-sans text-sm font-semibold text-accent flex items-center gap-1.5",children:t.jsx("span",{className:"notranslate",children:e.ref})}),t.jsx(De,{className:"w-4 h-4 text-muted-foreground group-hover:text-accent transition-colors shrink-0"})]}),t.jsx("p",{className:"notranslate font-serif text-[15px] leading-relaxed text-foreground",children:xt(e.rawText,i,l)}),t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2.5",children:s.map((u,x)=>t.jsxs("span",{className:`px-2 py-0.5 rounded-full text-[11px] font-sans font-medium ${ke[x%ke.length]}`,children:[u.value," ",u.label]},x))})]})}function ft(e){var o,d;if(!e)return[];const n=[];if(e.testament==="old"?n.push({label:"Testament",value:"Old Testament"}):e.testament==="new"&&n.push({label:"Testament",value:"New Testament"}),e.book&&e.book!=="all"){const i=H.find(s=>s.apiName===e.book);n.push({label:"Book",value:i?i.shortName:e.book})}const a={verse:"Verses",subscript:"Psalm superscriptions",colophon:"Chapter colophons",heading:"Hebrew stanza names"};if(e.sectionStates){const i=Object.keys(e.sectionStates).filter(r=>e.sectionStates[r]==="yes"),s=Object.keys(e.sectionStates).filter(r=>e.sectionStates[r]==="no");i.length?n.push({label:"Record type",value:`Only ${i.map(r=>a[r]||r).join(", ")}`}):s.length&&n.push({label:"Record type",value:`Excluding ${s.map(r=>a[r]||r).join(", ")}`})}const l=(e.textContains||"").trim();if(l){n.push({label:"Search text",value:l});const i=e.textAdjacent?"Adjacent (exact phrase, in order)":e.textInOrder?"In the order typed":"Any order (all terms present)";n.push({label:"Match mode",value:i});const s=[];e.textCaseSensitive&&s.push("Match case"),e.textWholeWord&&s.push("Whole word"),s.length&&n.push({label:"Match options",value:s.join(", ")})}for(const i of T){const s=(o=e.ranges)==null?void 0:o[i.key];if(!s)continue;const r=s.min!==""&&s.min!=null,m=s.max!==""&&s.max!=null;if(!r&&!m)continue;let u;r&&m?u=`${s.min}–${s.max}`:r?u=`≥ ${s.min}`:u=`≤ ${s.max}`,n.push({label:i.label,value:u})}for(const i of _){const s=(d=e.bools)==null?void 0:d[i.key];!s||s==="any"||n.push({label:i.label,value:s==="yes"?"Yes":"No"})}if(e.sortKey==="canonical")n.push({label:"Sorted by",value:`Book order (${e.sortDir==="asc"?"Genesis → Revelation":"Revelation → Genesis"})`});else if(e.sortKey&&e.sortKey!=="none"){const i=T.find(s=>s.key===e.sortKey);i&&n.push({label:"Sorted by",value:`${i.label} (${e.sortDir==="asc"?"lowest first":"highest first"})`})}return n}function yt(e){try{const n=He().replace(/^https?:\/\/preview-sandbox--/,"https://"),a=e.kind||!e.verse?"":`&verse=${e.verse}`;return`${n}/read?book=${e.abbr}&chapter=${e.chapter}${a}`}catch{return""}}function kt(e){return{ref:e.ref,book:e.shortName,bookName:e.shortName,testament:e.testament,verse:e.verse,text:e.rawText,url:yt(e)}}function wt(e){return _e(e||"").replace(/¶\s*/g,"").replace(/\s+/g," ").trim()}function jt(e){if(!e)return"";const n=[];if(e.testament==="old"?n.push("OT"):e.testament==="new"&&n.push("NT"),e.book&&e.book!=="all"&&n.push(e.book),e.textAdjacent?n.push("phrase"):e.textInOrder&&n.push("inorder"),e.textWholeWord&&n.push("wholeword"),e.textCaseSensitive&&n.push("matchcase"),e.ranges)for(const[l,o]of Object.entries(e.ranges)){if(!o)continue;const d=o.min!==""&&o.min!=null,i=o.max!==""&&o.max!=null;d&&i?n.push(`${l}-${o.min}-${o.max}`):d?n.push(`${l}-min${o.min}`):i&&n.push(`${l}-max${o.max}`)}if(e.bools)for(const[l,o]of Object.entries(e.bools))o&&o!=="any"&&n.push(`${l}-${o}
21`);e.sortKey&&e.sortKey!=="none"&&e.sortKey!=="canonical"&&n.push(`sort-${e.sortKey}-${e.sortDir||"asc"}`);const a=n.join("-").replace(/[^a-zA-Z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"").slice(0,60);return a?`-${a}`:""}const vt=[{key:"pdf",label:"PDF",icon:Ye},{key:"docx",label:"Word (.doc)",icon:Ge},{key:"xls",label:"CSV / Excel",icon:tt},{key:"txt",label:"Plain text",icon:Qe}];function Ct({records:e,selectedRecords:n,filters:a}){const l=n&&n.length>0?n:e,[o,d]=y.useState(!1),[i,s]=y.useState(!1),r=y.useRef(null);y.useEffect(()=>{const b=N=>{r.current&&!r.current.contains(N.target)&&d(!1)};return o&&document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[o]);const m=((a==null?void 0:a.textContains)||"").trim(),u=m||"Advanced-Search",x=l.map(kt),g=ft(a),p=jt(a),C={titlePrefix:"KJB Advanced Search",filterSummary:g,filenameSuffix:p,showQuery:!!m},j=()=>{if(!m)return{hlQuery:u,hlFilters:a};const b=m.split(/[\s,]+/).map(N=>N.trim()).filter(Boolean);return a.textAdjacent?{hlQuery:`"${b.join(" ")}"`,hlFilters:{...a,caseSensitive:a.textCaseSensitive,wholeWord:a.textWholeWord}}:{hlQuery:b.join(", "),hlFilters:{...a,caseSensitive:a.textCaseSensitive,wholeWord:a.textWholeWord}}},w=b=>{if(d(!1),!x.length)return;const{hlQuery:N,hlFilters:L}=j();me(b,x,N,L,{...C,showQuery:!1}).then(()=>he.success(ze())).catch(F=>{console.error("Export failed:",F),he.error("Export failed. Please try again.")})},c=()=>{if(!x.length)return;const{hlQuery:b,hlFilters:N}=j();me("print",x,b,N,{...C,showQuery:!1}).catch(L=>console.error("Print failed:",L))},k=async()=>{if(!l.length)return;const b=l.map(N=>`${N.ref}
22"${wt(N.rawText)}"`).join(`
23
24`);try{await navigator.clipboard.writeText(b),s(!0),setTimeout(()=>s(!1),1500)}catch{const N=document.createElement("textarea");N.value=b,document.body.appendChild(N),N.select();try{document.execCommand("copy"),s(!0),setTimeout(()=>s(!1),1500)}catch{}document.body.removeChild(N)}},A=l.length===0;return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"relative",ref:r,children:[t.jsxs("button",{onClick:()=>d(b=>!b),disabled:A,className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-secondary/60 border border-border text-foreground text-sm font-medium hover:border-accent transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[t.jsx(Oe,{className:"w-4 h-4"}),"Export",t.jsx(Z,{className:`w-3.5 h-3.5 transition-transform ${o?"rotate-180":""}`})]}),o&&t.jsx("div",{className:"absolute right-0 z-30 mt-1 w-48 max-w-[calc(100vw-1.5rem)] rounded-xl bg-popover border border-border shadow-xl overflow-hidden",children:vt.map(b=>t.jsxs("button",{onClick:()=>w(b.key),className:"w-full flex items-center gap-2 px-3 py-2.5 text-left text-sm text-popover-foreground hover:bg-secondary transition-colors",children:[t.jsx(b.icon,{className:"w-4 h-4 text-muted-foreground"}),b.label]},b.key))})]}),t.jsxs("button",{onClick:c,disabled:A,className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-secondary/60 border border-border text-foreground text-sm font-medium hover:border-accent transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[t.jsx(Ke,{className:"w-4 h-4"}),"Print"]}),t.jsxs("button",{onClick:k,disabled:A,className:"flex items-center gap-1.5 px-3 py-2 rounded-xl bg-secondary/60 border border-border text-foreground text-sm font-medium hover:border-accent transition-colors disabled:opacity-40 disabled:pointer-events-none",children:[i?t.jsx(Te,{className:"w-4 h-4 text-green-600"}):t.jsx(Me,{className:"w-4 h-4"}),i?"Copied":"Copy"]}),n&&n.length>0&&t.jsxs("span",{className:"font-sans text-xs text-muted-foreground ml-1",children:[n.length," selected"]})]})}const le=50;function Ft(){const[e,n]=y.useState(null),[a,l]=y.useState(""),[o,d]=y.useState(fe),[i,s]=y.useState(le),[r,m]=y.useState(!1),[u,x]=y.useState(!1),[g,p]=y.useState(()=>new Set),[C,j]=y.useState(!1),w=y.useRef(null),[c,k]=y.useState(()=>new Set),[$,A]=y.useState(o.textContains);y.useEffect(()=>{const h=setTimeout(()=>{d(f=>f.textContains===$?f:{...f,textContains:$})},350);return()=>clearTimeout(h)},[$]),y.useEffect(()=>{A(o.textContains)},[o.textContains]);const[b,N]=y.useState(()=>{try{const h=localStorage.getItem("kjb-footer-mode");return h==="none"?"bar":["two","one","bar"].includes(h)?h:"one"}catch{return"one"}});y.useEffect(()=>{const h=()=>{try{const f=localStorage.getItem("kjb-footer-mode");N(f==="none"?"bar":["two","one","bar"].includes(f)?f:"one")}catch{}};return window.addEventListener("kjb-footer-mode-change",h),window.addEventListener("storage",h),()=>{window.removeEventListener("kjb-footer-mode-change",h),window.removeEventListener("storage",h)}},[]);const L=b==="two"?200:b==="one"?150:90,F=y.useCallback((h,f)=>{k(v=>{const S=new Set(v),R=S.has(h);return R?S.delete(h):S.add(h),R&&f&&requestAnimationFrame(()=>{const O=document.querySelector("[data-kjb-app-header]"),I=O?O.getBoundingClientRect().height:0,B=f.getBoundingClientRect().top+window.scrollY-I-8;window.scrollTo({top:Math.max(0,B),behavior:"smooth"})}),S})},[]);y.useEffect(()=>{let h=!1;return st().then(f=>{h||n(f)}).catch(f=>{h||l((f==null?void 0:f.message)||"Could not load Bible data.")}),()=>{h=!0}},[]);const Q=y.useMemo(()=>ot(o),[o]),M=Q&&!C,W=y.useMemo(()=>!e||M?[]:ct(e,o),[e,o,M]);y.useEffect(()=>{s(le),p(new Set),k(new Set),w.current&&w.current.scrollIntoView({behavior:"smooth",block:"start"})},[o]),y.useEffect(()=>{if(!r)return;const h=document.body,f=window.scrollY,v={position:h.style.position,top:h.style.top,left
24:h.style.left,right:h.style.right,width:h.style.width};return h.style.position="fixed",h.style.top=`-${f}px`,h.style.left="0",h.style.right="0",h.style.width="100%",()=>{h.style.position=v.position,h.style.top=v.top,h.style.left=v.left,h.style.right=v.right,h.style.width=v.width,window.scrollTo(0,f)}},[r]);const D=h=>`${h.abbr}-${h.chapter}-${h.verse}${h.kind?`-${h.kind}`:""}`,te=y.useCallback(h=>{p(f=>{const v=new Set(f),S=D(h);return v.has(S)?v.delete(S):v.add(S),v})},[]),ne=y.useMemo(()=>W.filter(h=>g.has(D(h))),[W,g]),K=y.useMemo(()=>{var h;return((h=T.find(f=>f.key===o.sortKey))==null?void 0:h.label.toLowerCase())||""},[o.sortKey]),z=y.useCallback(()=>{d(fe()),j(!1)},[]),P=y.useMemo(()=>e?lt(e,o):null,[e,o]);y.useEffect(()=>{if(!P||M)return;const{old:h,new:f}=P.testaments;if(o.testament==="all"){h&&!f?d(v=>({...v,testament:"old",book:"all"})):f&&!h&&d(v=>({...v,testament:"new",book:"all"}));return}if(!P.testaments[o.testament]){const v=o.testament==="old"?"new":"old";P.testaments[v]?d(S=>({...S,testament:v,book:"all"})):P.testaments.all&&d(S=>({...S,testament:"all",book:"all"}))}},[P,o.testament,M]);const E=y.useMemo(()=>e?at(e,o):null,[e,o]),U=y.useMemo(()=>{const h=new Map,f=new Map;for(const v of W)h.set(v.testament,(h.get(v.testament)||0)+1),f.set(v.abbr,(f.get(v.abbr)||0)+1);return{t:h,b:f}},[W]),Ae=y.useMemo(()=>{const h=W.slice(0,i),f=[],v=new Map;for(const S of h){const R=S.testament;let O=v.get(R);O||(O={key:R,label:R==="old"?"Old Testament":"New Testament",books:[],bMap:new Map},v.set(R,O),f.push(O));let I=O.bMap.get(S.abbr);I||(I={key:S.abbr,label:S.shortName,rows:[]},O.bMap.set(S.abbr,I),O.books.push(I)),I.rows.push(S)}return f},[W,i]);return t.jsxs("div",{className:"w-full max-w-[120rem] mx-auto px-5 sm:px-8 lg:px-12 pt-10 pb-32",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("div",{className:"inline-flex items-center justify-center w-14 h-14 rounded-2xl bg-gradient-to-br from-indigo-500 to-purple-600 shadow-lg shadow-indigo-500/30 mb-4",children:t.jsx(xe,{className:"w-7 h-7 text-white"})}),t.jsx("h1",{className:"font-serif text-4xl font-bold text-foreground mb-2",children:"Advanced Search"}),t.jsx("p",{className:"font-sans text-sm text-muted-foreground max-w-md mx-auto",children:"Research the King James Bible by verse properties — length, pilcrows, italics, capitals, punctuation and more."}),t.jsx("div",{className:"mt-4 w-16 h-px bg-accent mx-auto"})]}),t.jsx("div",{className:"max-w-md mx-auto mb-8 rounded-xl bg-amber-50 dark:bg-amber-900/15 border border-amber-200 dark:border-amber-900/40 p-4",children:t.jsxs("p",{className:"font-sans text-xs text-amber-700 dark:text-amber-400 font-medium leading-relaxed text-center",children:["⚠️ Advanced Search is in ",t.jsx("strong",{children:"beta"}),". If you run into any issues, please contact me at"," ",t.jsx("a",{href:"mailto:[email protected]",className:"underline",children:"[email protected]"}),"."]})}),e===null&&!a&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-24 gap-3",children:[t.jsx(Pe,{className:"w-6 h-6 animate-spin text-primary/70"}),t.jsx("p",{className:"font-sans text-sm text-muted-foreground",children:"Analysing every verse, superscription & colophon…"})]}),a&&t.jsx("div",{className:"rounded-2xl bg-destructive/10 border border-destructive/40 p-4 max-w-lg mx-auto",children:t.jsxs("p",{className:"font-sans text-sm text-destructive",children:[a," Make sure the Bible has downloaded, then try again."]})}),e&&!a&&t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[340px_1fr] gap-6 items-start",children:[t.jsx("div",{className:"hidden lg:block sticky top-4 max-h-[calc(100vh-2rem)] overflow-y-auto overscroll-contain pr-1 pb-8 scrollbar-hide",children:t.jsx(ye,{filters:o,onChange:d,onReset:z,availability:P,metricRanges:E,textDraft:$,onTextDraftChange:A})}),t.jsxs("div",{ref:w,className:"scroll-mt-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[t.jsx("p",{className:"font-sans text-sm text-muted-foreground",children:M?"Set a filter or search to begin":t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-semibold text-foreground",children:W.length.toLocaleStr
24ing()})," verse",W.length===1?"":"s"," match"]})}),t.jsxs("button",{onClick:()=>m(!0),className:"lg:hidden flex items-center gap-2 px-4 py-2 rounded-xl bg-primary text-primary-foreground text-sm font-medium",children:[t.jsx(Xe,{className:"w-4 h-4"}),"Filters"]})]}),!M&&W.length>0&&t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-4",children:[t.jsx(Ct,{records:W,selectedRecords:u?ne:null,filters:o}),t.jsxs("button",{onClick:()=>{x(h=>!h),p(new Set)},className:`flex items-center gap-1.5 px-3 py-2 rounded-xl border text-sm font-medium transition-colors ${u?"bg-primary text-primary-foreground border-primary":"bg-secondary/60 border-border text-foreground hover:border-accent"}`,children:[u?t.jsx(pe,{className:"w-4 h-4"}):t.jsx(ge,{className:"w-4 h-4"}),u?"Done":"Select"]})]}),u&&!M&&W.length>0&&t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("button",{onClick:()=>p(new Set(W.slice(0,i).map(D))),className:"font-sans text-xs text-primary font-medium hover:underline",children:"Select all shown"}),t.jsx("button",{onClick:()=>p(new Set),className:"font-sans text-xs text-muted-foreground font-medium hover:underline",children:"Clear"})]}),M?t.jsxs("div",{className:"rounded-2xl bg-card/70 border border-border/60 p-8 text-center",children:[t.jsx("p",{className:"font-sans text-sm text-muted-foreground mb-5",children:"Choose a testament, book, keyword, or metric filter to start exploring verses — or show every verse and sort by the selected metric."}),t.jsxs("button",{onClick:()=>j(!0),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-xl bg-primary text-primary-foreground font-sans text-sm font-medium hover:opacity-90 transition-all duration-200 active:scale-[0.98]",children:[t.jsx(xe,{className:"w-4 h-4"}),"Show all verses"]})]}):W.length===0?t.jsx("div",{className:"rounded-2xl bg-card/70 border border-border/60 p-8 text-center",children:t.jsx("p",{className:"font-sans text-sm text-muted-foreground",children:"No verses match these filters. Try loosening them."})}):t.jsxs("div",{className:"space-y-8",children:[Ae.map(h=>{const f=c.has(h.key),v=U.t.get(h.key)||0;return t.jsxs("div",{className:"space-y-5",children:[t.jsxs("button",{onClick:S=>F(h.key,S.currentTarget),className:"w-full flex items-center justify-between gap-2 border-b-2 border-accent/40 pb-1.5 text-left",children:[t.jsxs("h2",{className:"font-serif text-2xl font-bold text-foreground",children:[h.label," ",t.jsxs("span",{className:"font-sans text-sm font-normal text-muted-foreground",children:["(",v.toLocaleString(),")"]})]}),t.jsx(Z,{className:`w-6 h-6 text-muted-foreground transition-transform ${f?"-rotate-90":""}`})]}),!f&&h.books.map(S=>{const R=`${h.key}:${S.key}`,O=c.has(R),I=U.b.get(S.key)||0;return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("button",{onClick:B=>F(R,B.currentTarget),className:"w-full flex items-center justify-between gap-2 sticky top-0 bg-background/90 backdrop-blur-sm py-1 z-10 text-left",children:[t.jsxs("h3",{className:"font-serif text-lg font-semibold text-primary",children:[t.jsx("span",{className:"notranslate",children:S.label})," ",t.jsxs("span",{className:"font-sans text-xs font-normal text-muted-foreground",children:["(",I.toLocaleString(),")"]})]}),t.jsx(Z,{className:`w-5 h-5 text-muted-foreground transition-transform ${O?"-rotate-90":""}`})]}),!O&&S.rows.map(B=>{const se=D(B);if(u){const ue=g.has(se);return t.jsxs("button",{type:"button",onClick:()=>te(B),className:`w-full flex items-start gap-3 text-left rounded-2xl transition-colors ${ue?"ring-2 ring-primary rounded-2xl":""}`,children:[t.jsx("span",{className:"mt-4 shrink-0",children:ue?t.jsx(pe,{className:"w-5 h-5 text-primary"}):t.jsx(ge,{className:"w-5 h-5 text-muted-foreground"})}),t.jsx("span",{className:"flex-1 pointer-events-none",children:t.jsx(ve,{record:B,sortKey:o.sortKey,sortLabel:K,filters:o})})]},se)}return t.jsx(ve,{record:B,sortKey:o.sortKey,sortLabel:K,filters:o},se)})]},S.key)})]},h.key)}),i<W.length&&t.jsxs("button",{onClick:()=>s(h=>h+le),className:"w-full py-3 rounded-xl bg-secondary/50 border border-border text-foreground font-sans text-sm font-medium hover:border-accent transition-colors",children:["Show more (",(W.length-i).toLocaleStr
24ing()," remaining)"]})]})]})]}),r&&e&&t.jsxs("div",{className:"lg:hidden fixed inset-0 z-50 flex h-[100dvh]",children:[t.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:()=>m(!1)}),t.jsxs("div",{className:"relative ml-auto w-[88%] max-w-sm h-[100dvh] bg-background flex flex-col shadow-2xl",children:[t.jsxs("div",{className:"flex items-center justify-between px-5 pt-5 pb-4 shrink-0",children:[t.jsx("h2",{className:"font-serif text-lg font-semibold text-foreground",children:"Filters"}),t.jsx("button",{onClick:()=>m(!1),className:"p-2 rounded-lg hover:bg-secondary",children:t.jsx(Re,{className:"w-5 h-5 text-muted-foreground"})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto overscroll-contain px-5",style:{WebkitOverflowScrolling:"touch",paddingBottom:L},children:t.jsx(ye,{filters:o,onChange:d,onReset:z,availability:P,metricRanges:E,textDraft:$,onTextDraftChange:A})}),t.jsx("div",{className:"shrink-0 px-5 pt-3 bg-background border-t border-border/60",style:{paddingBottom:`calc(1rem + ${L}px)`},children:t.jsx("button",{onClick:()=>{Q&&j(!0),m(!1)},className:"w-full py-3 rounded-xl bg-primary text-primary-foreground font-sans text-sm font-medium",children:M?"Show all verses":`Show ${W.length.toLocaleString()} results`})})]})]})]})}export{Ft as default};

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.