((t,e)=>{"use strict";const f=new Map;t.on("themify_overlay_search_init",(_=>{let r,a=_.closest(".tf_search_form")||e.tfId("searchform");if(!a)return;a=a.closest(".tf_search_form");const i=a.tfTag("form")[0],c=!!i.closest(".tf_search_overlay"),o=i.querySelector('input[name="s"]'),s=e.createElement("div"),l=e.createElement("div");if(s.className="tf_search_result tf_w tf_box tf_hide",l.className="tf_loader tf_hide",c){a=e.createElement("div");const t=e.createElement("div"),f=e.createElement("a"),c=e.createElement("span"),s=()=>{a.classList.toggle("search-active",o.value.length>0)};_.tfOn("click",(t=>{t.preventDefault(),s(),a.classList.add("tf_fd_in"),o.focus(),e.body.style.overflowY="hidden",e.body.classList.add("searchform-slidedown")})),f.tfOn("click",(t=>{t.preventDefault(),s(),r?.abort(),r=null,a.classList.remove("tf_fd_in"),e.body.style.overflowY="",e.body.classList.remove("searchform-slidedown")})),a.className="tf_search_lightbox tf_hide tf_w tf_box tf_opacity tf_h tf_scrollbar",t.className="tf_searchform_inner tf_opacity",f.className="tf_close_search tf_close",c.className="screen-reader-text",f.appendChild(c),a.append(t,f),i.after(a),t.appendChild(i)}else s.className+=" tf_scrollbar",s.setAttribute("tabindex","-1");o.after(s),o.before(l);const n=t=>{let e=t.getAttribute("href").replace("#",""),f=t.closest("li"),_=s.tfClass("tf_search_item");"all"===e&&(e="item");for(let t=_.length-1;t>-1;--t){let e=_[t].classList;e.remove("tf_fd_in"),e.add("tf_fd_out")}for(let t=f.parentNode.children,e=t.length-1;e>-1;--e)"LI"===t[e].tagName&&t[e].classList.remove("active");f.classList.add("active"),setTimeout((()=>{const t=s.tfClass("tf_view_button"),f=s.querySelector("#tf_result_link_"+e);for(let e=t.length-1;e>-1;--e)t[e].classList.add("tf_hide");f?.classList.remove("tf_hide");for(let t=_.length-1;t>-1;--t){let f=_[t].classList;f.contains("tf_search_"+e)?(f.remove("tf_hide","tf_fd_out"),f.add("tf_fd_in")):f.add("tf_hide")}}),401)};s.tfOn("click",(t=>{const e=t.target;"A"===e.tagName&&e.closest(".tf_search_tab")&&(t.preventDefault(),n(e))}));const h=new FormData(i);let d;h.set("action","themify_search_autocomplete"),o.tfOn("input",(e=>{clearTimeout(d),r?.abort();const _=e.currentTarget.value.trim(),i=()=>{s.innerHTML=f.get(_),(()=>{let t=s.querySelector(".tf_search_tab .active a");if(t){t=t.getAttribute("href");const e=t?s.querySelector('.tf_search_tab a[href="'+t+'"]'):null;e&&n(e)}})()};if(!_)return a.classList.remove("search-active"),void(s.innerHTML="");d=setTimeout((async()=>{if(a.classList.add("search-active"),f.has(_))i();else{a.classList.add("tf_search_loading"),r=new AbortController,h.set("s",_);try{const e=await t.fetch(h,"text",{signal:r.signal});e&&(f.set(_,e),i())}catch(t){"AbortError"!==t.name&&console.error("Uh oh, an error!",t)}a.classList.remove("tf_search_loading"),r=null}}),100)}),{passive:!0}).autocomplete="off",i.classList.remove("tf_hide"),o.value.trim()&&t.triggerEvent(o,"keyup")}))})(Themify,document);