var Mfn_livesearch={that:this,postsLoaded:[],dom:{ajaxFetchedPage:"",get resultsFromPage(){return this.ajaxFetchedPage},isItem:e=>e.target.closest(".mfn-live-search-wrapper"),itemAttr(e){const t=document.querySelector(".mfn-live-search-wrapper");return parseInt(t.getAttribute("data-"+e))},get searchForm(){return Array.from(document.querySelectorAll(".search_wrapper #searchform, .top_bar_right #searchform, #Side_slide #side-form, .mfn-live-search-wrapper .mfn-live-searchform"))},get searchField(){return Array.from(document.querySelectorAll(".search_wrapper input[type=text], .top_bar_right #searchform input[type=text], #Side_slide #side-form input[type=text], .mfn-live-search-wrapper input[type=text]"))},get liveSearchNoResults(){return Array.from(document.querySelectorAll(".mfn-live-search-box .mfn-live-search-noresults"))},get liveSearchBox(){return Array.from(document.querySelectorAll(".mfn-live-search-box"))},get liveSearchResultsList(){return Array.from(document.querySelectorAll(".mfn-live-search-list"))},get liveSearchResultsListShop(){return Array.from(document.querySelectorAll(".mfn-live-search-list-shop ul"))},get liveSearchResultsListBlog(){return Array.from(document.querySelectorAll(".mfn-live-search-list-blog ul"))},get liveSearchResultsListPortfolio(){return Array.from(document.querySelectorAll(".mfn-live-search-list-portfolio ul"))},get liveSearchResultsListPages(){return Array.from(document.querySelectorAll(".mfn-live-search-list-pages ul"))},get liveSearchResultsListCategories(){return Array.from(document.querySelectorAll(".mfn-live-search-list-categories ul"))}},create:{that:this,linkToLivesearch:e=>`${mfn.site_url}?s=${e}&mfn_livesearch`,Li:()=>document.createElement("li"),Heading:e=>e.querySelector(".post-title"),Link:e=>e.querySelector(".post-title a"),Excerpt:e=>e.querySelector(".post-excerpt p"),WooPrice:e=>e.querySelector(".post-product-price"),Image(e){const t=e.querySelector(".post-featured-image img");if(t){let e=document.createElement("img");return e.src=t.src,e}},Category(e){switch(!0){case e.classList.contains("product"):return"product";case e.classList.contains("page"):return"page";case e.classList.contains("portfolio"):return"portfolio";case e.classList.contains("post"):return"post"}},Textbox(e,t,r,s){let a=document.createElement("a"),i=document.createElement("p"),o=document.createElement("span"),l=document.createElement("div");if(l.classList.add("mfn-live-search-texts"),e.textContent&&t.href&&(a.innerHTML=e.textContent,a.href=t.href,l.appendChild(a)),s&&(o.innerHTML=s.innerHTML,l.appendChild(o)),null!=r&&r.textContent.match(/\w/)){let e="";const t=90,s=r.innerHTML;e=t>=s.length?s:`${s.substr(0,s.lastIndexOf(" ",t))}...`,i.innerHTML=e,l.appendChild(i)}return l},readyList(e){var t=this.that;let r=mfn.livesearch.loadPosts,s=t.Mfn_livesearch.dom.resultsFromPage;if(s=jQuery(s).find(".posts_group"),s.length){const[{children:e}]=s;Array.from(e).forEach((e=>{if(r>0){let r=this.Li();this.postId=e.id.match(/\d+/g).toString(),_.isObject(this.Image(e))&&r.appendChild(this.Image(e));const s=this.Textbox(this.Heading(e),this.Link(e),this.Excerpt(e),this.WooPrice(e));r.setAttribute("data-category",this.Category(e)),r.appendChild(s),t.Mfn_livesearch.postsLoaded.push(r)}r--}))}else e.target.value.length&&!t.Mfn_livesearch.postsLoaded.length&&jQuery(t.Mfn_livesearch.dom.liveSearchNoResults).fadeIn()},categoryPills(e){var t=this.that;if(mfn_livesearch_categories){const r=new RegExp(`[a-zA-Z]*${e}[a-zA-Z]*`,"gi");Object.values(mfn_livesearch_categories).filter((function(e){return e.match(r)})).forEach((e=>{let r=this.Li();r.setAttribute("data-category","category");let s=document.createElement("a");s.innerHTML=e,s.href=Object.keys(mfn_livesearch_categories).find((t=>mfn_livesearch_categories[t]===e)),r.appendChild(s),t.Mfn_livesearch.postsLoaded.push(r)}))}}},ajaxSearch(e,t){let r=null!==e.Mfn_livesearch.dom.isItem(t)?e.Mfn_livesearch.dom.itemAttr("char"):mfn.livesearch.minChar;if(t.target.value.length>=r){jQuery(e.Mfn_livesearch.dom.searchForm).addClass("mfn-livesearch-loading");let r=t.target.value.trim();jQuery.ajax({url:this.Mfn_livesearch.create.linkToLivesearch(r),type:"GET",success:function(r){e.Mfn_livesearch.dom.ajaxFetchedPage=r,setTimeout((function(){jQuery(e.Mfn_livesearch.dom.searchForm).removeClass("mfn-livesearch-loading"),e.Mfn_livesearch.postsLoaded=[],jQuery(e.Mfn_livesearch.dom.liveSearchNoResults).fadeOut(),e.Mfn_livesearch.create.categoryPills(t.target.value),e.Mfn_livesearch.create.readyList(t),e.Mfn_livesearch.refreshCategoryContainers(),e.Mfn_livesearch.assignToProperContainer(e.Mfn_livesearch.postsLoaded),e.Mfn_livesearch.hideNotUsedCategories(),e.Mfn_livesearch.toggleDropdown(t),e.Mfn_livesearch.toggleMoreResultsButton(t)}),0)}})}else e.Mfn_livesearch.toggleDropdown(t)},refreshCategoryContainers(){const e=this.that.Mfn_livesearch.dom,{pages:t,categories:r,portfolio:s,post:a,products:i}=mfn.livesearch.translation;jQuery(e.liveSearchResultsListShop).html(`