(()=>{var e=Object.defineProperty,t={};((t,i)=>{for(var s in i)e(t,s,{get:i[s],enumerable:!0})})(t,{FilterPills:()=>u,Input:()=>n,Instance:()=>f,ResultList:()=>d,Summary:()=>c});var i,s=class e{constructor(e){this.element=document.createElement(e)}id(e){return this.element.id=e,this}class(e){return this.element.classList.add(e),this}attrs(e){for(let[t,i]of Object.entries(e))this.element.setAttribute(t,i);return this}text(e){return this.element.innerText=e,this}html(e){return this.element.innerHTML=e,this}handle(e,t){return this.element.addEventListener(e,t),this}addTo(t){return t instanceof e?t.element.appendChild(this.element):t.appendChild(this.element),this.element}},n=class{constructor(e={}){if(this.inputEl=null,this.clearEl=null,this.instance=null,this.searchID=0,this.debounceTimeoutMs=e.debounceTimeoutMs??300,e.inputElement){if(e.containerElement)return void console.warn("[Pagefind Input component]: inputElement and containerElement both supplied. Ignoring the container option.");this.initExisting(e.inputElement)}else{if(!e.containerElement)return void console.error("[Pagefind Input component]: No selector supplied for containerElement or inputElement");this.initContainer(e.containerElement)}this.inputEl.addEventListener("input",(async e=>{if(this.instance&&"string"==typeof e?.target?.value){this.updateState(e.target.value);let t=++this.searchID;if(await(async(e=100)=>new Promise((t=>setTimeout(t,e))))(this.debounceTimeoutMs),t!==this.searchID)return null;this.instance?.triggerSearch(e.target.value)}})),this.inputEl.addEventListener("keydown",(e=>{"Escape"===e.key&&(++this.searchID,this.inputEl.value="",this.instance?.triggerSearch(""),this.updateState("")),"Enter"===e.key&&e.preventDefault()})),this.inputEl.addEventListener("focus",(()=>{this.instance?.triggerLoad()}))}initContainer(e){let t=document.querySelector(e);if(t)if("INPUT"===t.tagName)console.warn(`[Pagefind Input component]: Encountered input element for ${e} when a container was expected`),console.warn("[Pagefind Input component]: Treating containerElement option as inputElement and proceeding"),this.initExisting(e);else{t.innerHTML="";let e=0;for(;document.querySelector(`#pfmod-input-${e}`);)e+=1;let i=new s("form").class("pagefind-modular-input-wrapper").attrs({role:"search","aria-label":"Search this site",action:"javascript:void(0);"});new s("label").attrs({for:`pfmod-input-${e}`,"data-pfmod-sr-hidden":"true"}).text("Search this site").addTo(i),this.inputEl=new s("input").id(`pfmod-input-${e}`).class("pagefind-modular-input").attrs({autocapitalize:"none",enterkeyhint:"search"}).addTo(i),this.clearEl=new s("button").class("pagefind-modular-input-clear").attrs({"data-pfmod-suppressed":"true"}).text("Clear").handle("click",(()=>{this.inputEl.value="",this.instance.triggerSearch(""),this.updateState("")})).addTo(i),i.addTo(t)}else console.error(`[Pagefind Input component]: No container found for ${e} selector`)}initExisting(e){let t=document.querySelector(e);t?"INPUT"===t.tagName?this.inputEl=t:console.error(`[Pagefind Input component]: Expected ${e} to be an element`):console.error(`[Pagefind Input component]: No input element found for ${e} selector`)}updateState(e){this.clearEl&&(e&&e?.length?this.clearEl.removeAttribute("data-pfmod-suppressed"):this.clearEl.setAttribute("data-pfmod-suppressed","true"))}register(e){this.instance=e,this.instance.on("search",((e,t)=>{this.inputEl&&document.activeElement!==this.inputEl&&(this.inputEl.value=e,this.updateState(e))}))}focus(){this.inputEl&&this.inputEl.focus()}},l=e=>{if(e instanceof Element)return[e];if(Array.isArray(e)&&e.every((e=>e instanceof Element)))return e;if("string"==typeof e||e instanceof String){let t=document.createElement("div");return t.innerHTML=e,[...t.childNodes]}return console.error("[Pagefind ResultList component]: Expected template function to return an HTML element or string, got "+typeof e),[]},r=()=>{let e=(e=30)=>". ".repeat(Math.floor(10+Math.random()*e));return`
  • \n
    \n
    \n

    ${e(30)}

    \n

    ${e(40)}

    \n
    \n
  • `},a=e=>{let t=new s("li").class("pagefind-modular-list-result"),i=new s("div").class("pagefind-modular-list-thumb").addTo(t);e?.meta?.image&&new s("img").class("pagefind-modular-list-image").attrs({src:e.meta.image,alt:e.meta.image_alt||e.meta.title}).addTo(i);let n=new s("div").class("pagefind-modular-list-inner").addTo(t),l=new s("p").class("pagefind-modular-list-title").addTo(n);return new s("a").class("pagefind-modular-list-link").text(e.meta?.title).attrs({href:e.meta?.url||e.url}).addTo(l),new s("p").class("pagefind-modular-list-excerpt").html(e.excerpt).addTo(n),t.element},o=e=>{if(!(e instanceof HTMLElement))return null;let t=window.getComputedStyle(e).overflowY;return"visible"!==t&&"hidden"!==t?e:o(e.parentNode)},h=class{constructor(e={}){this.rawResult=e.result,this.placeholderNodes=e.placeholderNodes,this.resultFn=e.resultFn,this.intersectionEl=e.intersectionEl,this.result=null,this.waitForIntersection()}waitForIntersection(){if(!this.placeholderNodes?.length)return;let e={root:this.intersectionEl,rootMargin:"0px",threshold:.01};new IntersectionObserver(((e,t)=>{null===this.result&&e?.[0]?.isIntersecting&&(this.load(),t.disconnect())}),e).observe(this.placeholderNodes[0])}async load(){if(!this.placeholderNodes?.length)return;this.result=await this.rawResult.data();let e=this.resultFn(this.result),t=l(e);for(;this.placeholderNodes.length>1;)this.placeholderNodes.pop().remove();this.placeholderNodes[0].replaceWith(...t)}},d=class{constructor(e){this.intersectionEl=document.body,this.containerEl=null,this.results=[],this.placeholderTemplate=e.placeholderTemplate??r,this.resultTemplate=e.resultTemplate??a,e.containerElement?this.initContainer(e.containerElement):console.error("[Pagefind ResultList component]: No selector supplied for containerElement")}initContainer(e){let t=document.querySelector(e);t?this.containerEl=t:console.error(`[Pagefind ResultList component]: No container found for ${e} selector`)}append(e){for(let t of e)this.containerEl.appendChild(t)}register(e){e.on("results",(e=>{this.containerEl&&(this.containerEl.innerHTML="",this.intersectionEl=o(this.containerEl),this.results=e.results.map((e=>{let t=l(this.placeholderTemplate());return this.append(t),new h({result:e,placeholderNodes:t,resultFn:this.resultTemplate,intersectionEl:this.intersectionEl})})))})),e.on("loading",(()=>{this.containerEl&&(this.containerEl.innerHTML="")}))}},c=class{constructor(e={}){this.containerEl=null,this.defaultMessage=e.defaultMessage??"",this.term="",e.containerElement?this.initContainer(e.containerElement):console.error("[Pagefind Summary component]: No selector supplied for containerElement")}initContainer(e){let t=document.querySelector(e);t?(this.containerEl=t,this.containerEl.innerText=this.defaultMessage):console.error(`[Pagefind Summary component]: No container found for ${e} selector`)}register(e){e.on("search",((e,t)=>{this.term=e})),e.on("results",(e=>{if(!this.containerEl||!e)return;if(!this.term)return void(this.containerEl.innerText=this.defaultMessage);let t=e?.results?.length??0;this.containerEl.innerText=`${t} result${1===t?"":"s"} for ${this.term}`})),e.on("loading",(()=>{this.containerEl&&(this.containerEl.innerText=`Searching for ${this.term}...`)}))}},u=class{constructor(e={}){this.instance=null,this.wrapper=null,this.pillContainer=null,this.available={},this.selected=["All"],this.total=0,this.filterMemo="",this.filter=e.filter,this.ordering=e.ordering??null,this.alwaysShow=e.alwaysShow??!1,this.selectMultiple=e.selectMultiple??!1,this.filter?.length?e.containerElement?this.initContainer(e.containerElement):console.error("[Pagefind FilterPills component]: No selector supplied for containerElement"):console.error("[Pagefind FilterPills component]: No filter option supplied, nothing to display")}initContainer(e){let t=document.querySelector(e);if(!t)return void console.error(`[Pagefind FilterPills component]: No container found for ${e} selector`);t.innerHTML="";let i=`pagefind_modular_filter_pills_${this.filter}`,n=new s("div").class("pagefind-modular-filter-pills-wrapper").attrs({role:"group","aria-labelledby":i});this.alwaysShow||n.attrs({"data-pfmod-hidden":!0}),new s("div").id(i).class("pagefind-modular-filter-pills-label").attrs({"data-pfmod-sr-hidden":!0}).text(`Filter results by ${this.filter}`).addTo(n),this.pillContainer=new s("div").class("pagefind-modular-filter-pills").addTo(n),this.wrapper=n.addTo(t)}update(){let e=this.available.map((e=>e[0])).join("~");e==this.filterMemo?this.updateExisting():(this.renderNew(),this.filterMemo=e)}pushFilters(){let e=this.selected.filter((e=>"All"!==e));this.instance.triggerFilter(this.filter,e)}pillInner(e,t){return this.total?`${e} (${t})`:`${e}`}renderNew(){this.available.forEach((([e,t])=>{new s("button").class("pagefind-modular-filter-pill").html(this.pillInner(e,t)).attrs({"aria-pressed":this.selected.includes(e),type:"button"}).handle("click",(()=>{"All"===e?this.selected=["All"]:this.selected.includes(e)?this.selected=this.selected.filter((t=>t!==e)):this.selectMultiple?this.selected.push(e):this.selected=[e],this.selected?.length?this.selected?.length>1&&(this.selected=this.selected.filter((e=>"All"!==e))):this.selected=["All"],this.update(),this.pushFilters()})).addTo(this.pillContainer)}))}updateExisting(){let e=[...this.pillContainer.childNodes];this.available.forEach((([t,i],s)=>{e[s].innerHTML=this.pillInner(t,i),e[s].setAttribute("aria-pressed",this.selected.includes(t))}))}register(e){this.instance=e,this.instance.on("filters",(e=>{if(!this.pillContainer)return;let t=(e=this.selectMultiple?e.available:e.total)[this.filter];t?(this.available=Object.entries(t),Array.isArray(this.ordering)?this.available.sort(((e,t)=>{let i=this.ordering.indexOf(e[0]),s=this.ordering.indexOf(t[0]);return(-1===i?1/0:i)-(-1===s?1/0:s)})):this.available.sort(((e,t)=>e[0].localeCompare(t[0]))),this.available.unshift(["All",this.total]),this.update()):console.warn(`[Pagefind FilterPills component]: No possible values found for the ${this.filter} filter`)})),e.on("results",(e=>{this.pillContainer&&(this.total=e?.unfilteredResultCount||0,"All"===this.available?.[0]?.[0]&&(this.available[0][1]=this.total),this.total||this.alwaysShow?this.wrapper.removeAttribute("data-pfmod-hidden"):this.wrapper.setAttribute("data-pfmod-hidden","true"),this.update())}))}},p=async(e=50)=>await new Promise((t=>setTimeout(t,e)));try{i=new URL(document.currentScript.src).pathname.match(/^(.*\/)(?:pagefind-)?modular-ui.js.*$/)[1]}catch{i="/pagefind/"}var f=class{constructor(e={}){this.__pagefind__=null,this.__initializing__=null,this.__searchID__=0,this.__hooks__={search:[],filters:[],loading:[],results:[]},this.components=[],this.searchTerm="",this.searchFilters={},this.searchResult={},this.availableFilters=null,this.totalFilters=null,this.options={bundlePath:e.bundlePath??i,mergeIndex:e.mergeIndex??[]},delete e.bundlePath,delete e.resetStyles,delete e.processResult,delete e.processTerm,delete e.debounceTimeoutMs,delete e.mergeIndex,delete e.translations,this.pagefindOptions=e}add(e){e?.register?.(this),this.components.push(e)}on(e,t){if(this.__hooks__[e])"function"==typeof t?this.__hooks__[e].push(t):console.error("[Pagefind Composable]: Expected callback to be a function, received "+typeof t);else{let t=Object.keys(this.__hooks__).join(", ");console.error(`[Pagefind Composable]: Unknown event type ${e}. Supported events: [${t}]`)}}triggerLoad(){this.__load__()}triggerSearch(e){this.searchTerm=e,this.__dispatch__("search",e,this.searchFilters),this.__search__(e,this.searchFilters)}triggerSearchWithFilters(e,t){this.searchTerm=e,this.searchFilters=t,this.__dispatch__("search",e,t),this.__search__(e,t)}triggerFilters(e){this.searchFilters=e,this.__dispatch__("search",this.searchTerm,e),this.__search__(this.searchTerm,e)}triggerFilter(e,t){this.searchFilters=this.searchFilters||{},this.searchFilters[e]=t,this.__dispatch__("search",this.searchTerm,this.searchFilters),this.__search__(this.searchTerm,this.searchFilters)}__dispatch__(e,...t){this.__hooks__[e]?.forEach((e=>e?.(...t)))}async __clear__(){this.__dispatch__("results",{results:[],unfilteredTotalCount:0}),this.availableFilters=await this.__pagefind__.filters(),this.totalFilters=this.availableFilters,this.__dispatch__("filters",{available:this.availableFilters,total:this.totalFilters})}async __search__(e,t){this.__dispatch__("loading"),await this.__load__();let i=++this.__searchID__;if(!e||!e.length)return this.__clear__();let s=await this.__pagefind__.search(e,{filters:t});s&&this.__searchID__===i&&(s.filters&&Object.keys(s.filters)?.length&&(this.availableFilters=s.filters,this.totalFilters=s.totalFilters,this.__dispatch__("filters",{available:this.availableFilters,total:this.totalFilters})),this.searchResult=s,this.__dispatch__("results",this.searchResult))}async __load__(){if(this.__initializing__)for(;!this.__pagefind__;)await p(50);else{if(this.__initializing__=!0,!this.__pagefind__){let e;try{e=await import(`${this.options.bundlePath}pagefind.js`)}catch(e){console.error(e),console.error([`Pagefind couldn't be loaded from ${this.options.bundlePath}pagefind.js`,"You can configure this by passing a bundlePath option to PagefindComposable Instance",`[DEBUG: Loaded from ${document?.currentScript?.src??"no known script location"}]`].join("\n"))}await e.options(this.pagefindOptions||{});for(let t of this.options.mergeIndex){if(!t.bundlePath)throw new Error("mergeIndex requires a bundlePath parameter");let i=t.bundlePath;delete t.bundlePath,await e.mergeIndex(i,t)}this.__pagefind__=e}this.availableFilters=await this.__pagefind__.filters(),this.totalFilters=this.availableFilters,this.__dispatch__("filters",{available:this.availableFilters,total:this.totalFilters})}}};window.PagefindModularUI=t})();