import{j as m}from"./jsx-runtime.CyXy1Ci3.js";import{r as v}from"./index.CaZlGE7t.js";import{m as et}from"./marked.esm.BhM9K_2c.js";function _(e){return Array.isArray?Array.isArray(e):rt(e)==="[object Array]"}function dt(e){if(typeof e=="string")return e;let t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ft(e){return e==null?"":dt(e)}function w(e){return typeof e=="string"}function st(e){return typeof e=="number"}function gt(e){return e===!0||e===!1||pt(e)&&rt(e)=="[object Boolean]"}function nt(e){return typeof e=="object"}function pt(e){return nt(e)&&e!==null}function x(e){return e!=null}function K(e){return!e.trim().length}function rt(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const mt="Incorrect 'index' type",xt=e=>`Invalid value for key ${e}`,Mt=e=>`Pattern length exceeds max of ${e}.`,yt=e=>`Missing ${e} property in key`,St=e=>`Property 'weight' in key '${e}' must be a positive integer`,J=Object.prototype.hasOwnProperty;class wt{constructor(t){this._keys=[],this._keyMap={};let s=0;t.forEach(n=>{let r=it(n);s+=r.weight,this._keys.push(r),this._keyMap[r.id]=r,s+=r.weight}),this._keys.forEach(n=>{n.weight/=s})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function it(e){let t=null,s=null,n=null,r=1,i=null;if(w(e)||_(e))n=e,t=X(e),s=B(e);else{if(!J.call(e,"name"))throw new Error(yt("name"));const c=e.name;if(n=c,J.call(e,"weight")&&(r=e.weight,r<=0))throw new Error(St(c));t=X(c),s=B(c),i=e.getFn}return{path:t,id:s,weight:r,src:n,getFn:i}}function X(e){return _(e)?e:e.split(".")}function B(e){return _(e)?e.join("."):e}function Et(e,t){let s=[],n=!1;const r=(i,c,a)=>{if(x(i))if(!c[a])s.push(i);else{let o=c[a];const h=i[o];if(!x(h))return;if(a===c.length-1&&(w(h)||st(h)||gt(h)))s.push(ft(h));else if(_(h)){n=!0;for(let l=0,d=h.length;le.score===t.score?e.idx{this._keysMap[s.id]=n})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,w(this.docs[0])?this.docs.forEach((t,s)=>{this._addString(t,s)}):this.docs.forEach((t,s)=>{this._addObject(t,s)}),this.norm.clear())}add(t){const s=this.size();w(t)?this._addString(t,s):this._addObject(t,s)}removeAt(t){this.records.splice(t,1);for(let s=t,n=this.size();s{let c=r.getFn?r.getFn(t):this.getFn(t,r.path);if(x(c)){if(_(c)){let a=[];const o=[{nestedArrIndex:-1,value:c}];for(;o.length;){const{nestedArrIndex:h,value:l}=o.pop();if(x(l))if(w(l)&&!K(l)){let d={v:l,i:h,n:this.norm.get(l)};a.push(d)}else _(l)&&l.forEach((d,f)=>{o.push({nestedArrIndex:f,value:d})})}n.$[i]=a}else if(w(c)&&!K(c)){let a={v:c,n:this.norm.get(c)};n.$[i]=a}}}),this.records.push(n)}toJSON(){return{keys:this.keys,records:this.records}}}function ct(e,t,{getFn:s=u.getFn,fieldNormWeight:n=u.fieldNormWeight}={}){const r=new G({getFn:s,fieldNormWeight:n});return r.setKeys(e.map(it)),r.setSources(t),r.create(),r}function kt(e,{getFn:t=u.getFn,fieldNormWeight:s=u.fieldNormWeight}={}){const{keys:n,records:r}=e,i=new G({getFn:t,fieldNormWeight:s});return i.setKeys(n),i.setIndexRecords(r),i}function T(e,{errors:t=0,currentLocation:s=0,expectedLocation:n=0,distance:r=u.distance,ignoreLocation:i=u.ignoreLocation}={}){const c=t/e.length;if(i)return c;const a=Math.abs(n-s);return r?c+a/r:a?1:c}function Nt(e=[],t=u.minMatchCharLength){let s=[],n=-1,r=-1,i=0;for(let c=e.length;i=t&&s.push([n,r]),n=-1)}return e[i-1]&&i-n>=t&&s.push([n,i-1]),s}const k=32;function $t(e,t,s,{location:n=u.location,distance:r=u.distance,threshold:i=u.threshold,findAllMatches:c=u.findAllMatches,minMatchCharLength:a=u.minMatchCharLength,includeMatches:o=u.includeMatches,ignoreLocation:h=u.ignoreLocation}={}){if(t.length>k)throw new Error(Mt(k));const l=t.length,d=e.length,f=Math.max(0,Math.min(n,d));let g=i,p=f;const M=a>1||o,A=M?Array(d):[];let E;for(;(E=e.indexOf(t,p))>-1;){let y=T(t,{currentLocation:E,expectedLocation:f,distance:r,ignoreLocation:h});if(g=Math.min(y,g),p=E+l,M){let I=0;for(;I=Y;S-=1){let C=S-1,Q=s[e.charAt(C)];if(M&&(A[C]=+!!Q),$[S]=($[S+1]<<1|1)&Q,y&&($[S]|=(N[S+1]|N[S])<<1|1|N[S+1]),$[S]&ut&&(b=T(t,{errors:y,currentLocation:C,expectedLocation:f,distance:r,ignoreLocation:h}),b<=g)){if(g=b,p=C,p<=f)break;Y=Math.max(1,2*f-p)}}if(T(t,{errors:y+1,currentLocation:f,expectedLocation:f,distance:r,ignoreLocation:h})>g)break;N=$}const F={isMatch:p>=0,score:Math.max(.001,b)};if(M){const y=Nt(A,a);y.length?o&&(F.indices=y):F.isMatch=!1}return F}function jt(e){let t={};for(let s=0,n=e.length;s{this.chunks.push({pattern:f,alphabet:jt(f),startIndex:g})},d=this.pattern.length;if(d>k){let f=0;const g=d%k,p=d-g;for(;f{const{isMatch:E,score:N,indices:b}=$t(t,p,M,{location:r+A,distance:i,threshold:c,findAllMatches:a,minMatchCharLength:o,includeMatches:n,ignoreLocation:h});E&&(f=!0),d+=N,E&&b&&(l=[...l,...b])});let g={isMatch:f,score:f?d/this.chunks.length:1};return f&&n&&(g.indices=l),g}}class R{constructor(t){this.pattern=t}static isMultiMatch(t){return Z(t,this.multiRegex)}static isSingleMatch(t){return Z(t,this.singleRegex)}search(){}}function Z(e,t){const s=e.match(t);return s?s[1]:null}class vt extends R{constructor(t){super(t)}static get type(){return"exact"}static get multiRegex(){return/^="(.*)"$/}static get singleRegex(){return/^=(.*)$/}search(t){const s=t===this.pattern;return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Ot extends R{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const n=t.indexOf(this.pattern)===-1;return{isMatch:n,score:n?0:1,indices:[0,t.length-1]}}}class Ct extends R{constructor(t){super(t)}static get type(){return"prefix-exact"}static get multiRegex(){return/^\^"(.*)"$/}static get singleRegex(){return/^\^(.*)$/}search(t){const s=t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,this.pattern.length-1]}}}class Tt extends R{constructor(t){super(t)}static get type(){return"inverse-prefix-exact"}static get multiRegex(){return/^!\^"(.*)"$/}static get singleRegex(){return/^!\^(.*)$/}search(t){const s=!t.startsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class Pt extends R{constructor(t){super(t)}static get type(){return"suffix-exact"}static get multiRegex(){return/^"(.*)"\$$/}static get singleRegex(){return/^(.*)\$$/}search(t){const s=t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[t.length-this.pattern.length,t.length-1]}}}class Ft extends R{constructor(t){super(t)}static get type(){return"inverse-suffix-exact"}static get multiRegex(){return/^!"(.*)"\$$/}static get singleRegex(){return/^!(.*)\$$/}search(t){const s=!t.endsWith(this.pattern);return{isMatch:s,score:s?0:1,indices:[0,t.length-1]}}}class at extends R{constructor(t,{location:s=u.location,threshold:n=u.threshold,distance:r=u.distance,includeMatches:i=u.includeMatches,findAllMatches:c=u.findAllMatches,minMatchCharLength:a=u.minMatchCharLength,isCaseSensitive:o=u.isCaseSensitive,ignoreLocation:h=u.ignoreLocation}={}){super(t),this._bitapSearch=new ot(t,{location:s,threshold:n,distance:r,includeMatches:i,findAllMatches:c,minMatchCharLength:a,isCaseSensitive:o,ignoreLocation:h})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class ht extends R{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let s=0,n;const r=[],i=this.pattern.length;for(;(n=t.indexOf(this.pattern,s))>-1;)s=n+i,r.push([n,s-1]);const c=!!r.length;return{isMatch:c,score:c?0:1,indices:r}}}const D=[vt,ht,Ct,Tt,Ft,Pt,Ot,at],q=D.length,Wt=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Kt="|";function Bt(e,t={}){return e.split(Kt).map(s=>{let n=s.trim().split(Wt).filter(i=>i&&!!i.trim()),r=[];for(let i=0,c=n.length;i!!(e[P.AND]||e[P.OR]),Ut=e=>!!e[U.PATH],Vt=e=>!_(e)&&nt(e)&&!V(e),tt=e=>({[P.AND]:Object.keys(e).map(t=>({[t]:e[t]}))});function lt(e,t,{auto:s=!0}={}){const n=r=>{let i=Object.keys(r);const c=Ut(r);if(!c&&i.length>1&&!V(r))return n(tt(r));if(Vt(r)){const o=c?r[U.PATH]:i[0],h=c?r[U.PATTERN]:r[o];if(!w(h))throw new Error(xt(o));const l={keyId:B(o),pattern:h};return s&&(l.searcher=H(h,t)),l}let a={children:[],operator:i[0]};return i.forEach(o=>{const h=r[o];_(h)&&h.forEach(l=>{a.children.push(n(l))})}),a};return V(e)||(e=tt(e)),n(e)}function Gt(e,{ignoreFieldNorm:t=u.ignoreFieldNorm}){e.forEach(s=>{let n=1;s.matches.forEach(({key:r,norm:i,score:c})=>{const a=r?r.weight:null;n*=Math.pow(c===0&&a?Number.EPSILON:c,(a||1)*(t?1:i))}),s.score=n})}function Yt(e,t){const s=e.matches;t.matches=[],x(s)&&s.forEach(n=>{if(!x(n.indices)||!n.indices.length)return;const{indices:r,value:i}=n;let c={indices:r,value:i};n.key&&(c.key=n.key.src),n.idx>-1&&(c.refIndex=n.idx),t.matches.push(c)})}function Qt(e,t){t.score=e.score}function Jt(e,t,{includeMatches:s=u.includeMatches,includeScore:n=u.includeScore}={}){const r=[];return s&&r.push(Yt),n&&r.push(Qt),e.map(i=>{const{idx:c}=i,a={item:t[c],refIndex:c};return r.length&&r.forEach(o=>{o(i,a)}),a})}class j{constructor(t,s={},n){this.options={...u,...s},this.options.useExtendedSearch,this._keyStore=new wt(this.options.keys),this.setCollection(t,n)}setCollection(t,s){if(this._docs=t,s&&!(s instanceof G))throw new Error(mt);this._myIndex=s||ct(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){x(t)&&(this._docs.push(t),this._myIndex.add(t))}remove(t=()=>!1){const s=[];for(let n=0,r=this._docs.length;n-1&&(o=o.slice(0,s)),Jt(o,this._docs,{includeMatches:n,includeScore:r})}_searchStringList(t){const s=H(t,this.options),{records:n}=this._myIndex,r=[];return n.forEach(({v:i,i:c,n:a})=>{if(!x(i))return;const{isMatch:o,score:h,indices:l}=s.searchIn(i);o&&r.push({item:i,idx:c,matches:[{score:h,value:i,norm:a,indices:l}]})}),r}_searchLogical(t){const s=lt(t,this.options),n=(a,o,h)=>{if(!a.children){const{keyId:d,searcher:f}=a,g=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(o,d),searcher:f});return g&&g.length?[{idx:h,item:o,matches:g}]:[]}const l=[];for(let d=0,f=a.children.length;d{if(x(a)){let h=n(s,a,o);h.length&&(i[o]||(i[o]={idx:o,item:a,matches:[]},c.push(i[o])),h.forEach(({matches:l})=>{i[o].matches.push(...l)}))}}),c}_searchObjectList(t){const s=H(t,this.options),{keys:n,records:r}=this._myIndex,i=[];return r.forEach(({$:c,i:a})=>{if(!x(c))return;let o=[];n.forEach((h,l)=>{o.push(...this._findMatches({key:h,value:c[l],searcher:s}))}),o.length&&i.push({idx:a,item:c,matches:o})}),i}_findMatches({key:t,value:s,searcher:n}){if(!x(s))return[];let r=[];if(_(s))s.forEach(({v:i,i:c,n:a})=>{if(!x(i))return;const{isMatch:o,score:h,indices:l}=n.searchIn(i);o&&r.push({score:h,key:t,value:i,idx:c,norm:a,indices:l})});else{const{v:i,n:c}=s,{isMatch:a,score:o,indices:h}=n.searchIn(i);a&&r.push({score:o,key:t,value:i,norm:c,indices:h})}return r}}j.version="6.6.2";j.createIndex=ct;j.parseIndex=kt;j.config=u;j.parseQuery=lt;Ht(zt);et.use({mangle:!1,headerIds:!1});const Xt=e=>{const n=et.parse(e).replace(/<\/?[^>]+(>|$)/gm,"").replace(/[\r\n]\s*[\r\n]/gm,"");return Zt(n)},Zt=e=>{let t={" ":" ","<":"<",">":">","&":"&",""":'"',"'":"'"};return e.replace(/(&|<|>|"|')/g,n=>t[n])},qt=200,te=e=>`${e.collection}/${e.id.replace("-index","")}`,ie=({searchList:e})=>{const t=v.useRef(null),[s,n]=v.useState(""),[r,i]=v.useState([]),c=o=>{n(o.currentTarget.value)},a=new j(e,{keys:["data.title","data.description","id","collection","body"],includeMatches:!0,minMatchCharLength:3,threshold:.5});return v.useEffect(()=>{const h=new URLSearchParams(window.location.search).get("q");h&&n(h),setTimeout(function(){t.current.selectionStart=t.current.selectionEnd=h?.length||0},50)},[]),v.useEffect(()=>{let o=s.length>2?a.search(s):[];if(i(o),s.length>0){const h=new URLSearchParams(window.location.search);h.set("q",s);const l=window.location.pathname+"?"+h.toString();history.pushState(null,"",l)}else history.pushState(null,"",window.location.pathname)},[s]),m.jsx("section",{className:"section-sm",children:m.jsxs("div",{className:"container",children:[m.jsx("div",{className:"row mb-10 justify-center",children:m.jsx("div",{className:"col-10 lg:col-8 px-0",children:m.jsx("div",{className:"flex flex-nowrap",children:m.jsx("input",{className:"w-full glass rounded-lg px-6 py-4 text-txt-p placeholder:text-txt-light dark:placeholder:text-darkmode-txt-light focus:border-darkmode-border focus:ring-transparent dark:text-darkmode-txt-light intersect:animate-fadeDown opacity-0 intersect-no-queue",placeholder:"search posts",type:"search",name:"search",value:s,onChange:c,autoComplete:"off",autoFocus:!0,ref:t})})})}),m.jsx("div",{className:"row",children:r?.length<1?m.jsx("div",{className:"col-10 lg:col-8 mx-auto p-2 text-center glass rounded-lg intersect:animate-fadeUp opacity-0",children:m.jsx("p",{children:s.length<1?"Looking for something?":"We couldn't find what you searched for. Try searching again."})}):r?.map(({item:o},h)=>m.jsx("div",{className:"py-2 px-0",children:m.jsxs("div",{className:"h-full glass col-10 lg:col-8 mx-auto rounded-lg p-4 intersect:animate-fade opacity-0",children:[m.jsx("h4",{className:"mb-2",children:m.jsx("a",{href:"/"+te(o),children:o.data.title})}),o.data.description&&m.jsx("p",{className:"",children:o.data.description}),!o.data.description&&o.data.autodescription&&o.body&&m.jsx("p",{className:"",children:Xt(o.body.slice(0,qt))})]})},`search-${h}`))})]})})};export{ie as default};