import K from"./CWalxxGV.js";import Q from"./CTAcmMAz.js";import{aj as W,u as X,s as R,b as Y,H as Z,I as ee,y as te,f as k,r as se,P as oe,h as ne,m as n,j as s,k as o,p as a,l as B,A as D,t as p,F as E,B as j,v as re,i as N,w as ae,q as O,_ as ce}from"./BCLrUOBx.js";import ie from"./Chg4k-Cc.js";import{u as le}from"./DRQhQ4ga.js";import"./a5umXhxZ.js";import"./Bxmfm8sn.js";import"./Di7fl9dA.js";import"./BnLnKt_p.js";import"./Ce8lFovl.js";var w={exports:{}},A;function ue(){if(A)return w.exports;A=1;function b(g,h=100,u={}){if(typeof g!="function")throw new TypeError(`Expected the first parameter to be a function, got \`${typeof g}\`.`);if(h<0)throw new RangeError("`wait` must not be negative.");const{immediate:v}=typeof u=="boolean"?{immediate:u}:u;let l,m,t,x,d;function f(){const i=l,_=m;return l=void 0,m=void 0,d=g.apply(i,_),d}function S(){const i=Date.now()-x;i<h&&i>=0?t=setTimeout(S,h-i):(t=void 0,v||(d=f()))}const c=function(...i){if(l&&this!==l&&Object.getPrototypeOf(this)===Object.getPrototypeOf(l))throw new Error("Debounced method called with different contexts of the same prototype.");l=this,m=i,x=Date.now();const _=v&&!t;return t||(t=setTimeout(S,h)),_&&(d=f()),d};return Object.defineProperty(c,"isPending",{get(){return t!==void 0}}),c.clear=()=>{t&&(clearTimeout(t),t=void 0)},c.flush=()=>{t&&c.trigger()},c.trigger=()=>{d=f(),c.clear()},c}return w.exports.debounce=b,w.exports=b,w.exports}var de=ue();const pe=W(de),he={class:"search-popup"},me={class:"sb popup-inner"},ge={class:"pop-over-content"},fe={key:0,class:"spinner-wrapper flex layer-white"},_e={key:1},ye={key:0,class:"mb-15"},be={class:"bold"},ve={class:"search-section"},Se=["onClick"],ke={key:1,class:"mb-15"},we={class:"bold"},xe={class:"search-section category-wrapper"},$e={class:"img-wrapper"},Pe={class:"title ellipsis ellipsis-1"},Te={key:2,class:"mb-15"},Ce={class:"bold"},De={class:"search-section search-product-tile"},Ee={key:2},je={class:"color-primary semi-bold"},Ue={__name:"SearchPopup",props:{searchedText:{type:String,default:""}},emits:["close"],setup(b,{emit:g}){const h=g,u=b,v=X(),{langCode:l}=R(v),m=le(),{searchedSuggestion:t,searched:x}=R(m),{fetchSearchedSuggestion:d,updateSearch:f,setSearchedSuggestion:S}=m,c=Y(),{unAuthGet:i}=c,_=Z(),F=e=>{e!==e.value&&(_.push({path:"search",query:{q:e}}),f(e))},I=pe(e=>{e?q():h("close")},700);ee(()=>u.searchedText,e=>{I(e)});const{getImageURL:V,categoryLink:z}=te(),U=k(()=>$.value.length||P.value.length||T.value.length),$=k(()=>{var e;return((e=t.value)==null?void 0:e.product)||[]}),P=k(()=>{var e;return((e=t.value)==null?void 0:e.suggested)||[]}),T=k(()=>{var e;return((e=t.value)==null?void 0:e.category)||[]}),C=se(!1),q=async()=>{C.value=!0;const e=await i({api:"search",params:`?${oe({q:u.searchedText})}`,lang:l.value});C.value=!1,S(e.data)};return ne(async()=>{t.value||await q()}),(e,L)=>{const G=K,M=Q,H=ce,J=ie;return s(),n("div",he,[o("div",me,[o("div",ge,[a(C)?(s(),n("div",fe,[B(G,{radius:100})])):a(U)?(s(),n("div",_e,[a(P).length?(s(),n("div",ye,[o("h4",be,p(e.$t("searchPopup.suggestedSearch")),1),o("div",ve,[(s(!0),n(E,null,j(a(P),(r,y)=>(s(),n("button",{key:`sug-${y}`,onClick:re(qe=>F(r.title),["prevent"]),class:"item lite-btn","aria-label":"search"},p(r.title),9,Se))),128))])])):D("",!0),a(T).length?(s(),n("div",ke,[o("h4",we,p(e.$t("searchPopup.categories")),1),o("div",xe,[(s(!0),n(E,null,j(a(T),(r,y)=>(s(),N(H,{key:`c-${y}`,to:a(z)(r),class:"page-link center-text item"},{default:ae(()=>[o("div",$e,[B(M,{"lazy-src":a(V)(r.image),title:r.title,alt:r.title,height:"50",width:"50"},null,8,["lazy-src","title","alt"])]),o("h5",Pe,p(r.title),1)]),_:2},1032,["to"]))),128))])])):D("",!0),a($).length?(s(),n("div",Te,[o("h4",Ce,p(e.$t("searchPopup.products")),1),o("div",De,[(s(!0),n(E,null,j(a($),(r,y)=>(s(),N(J,{key:`prod-${y}`,product:r},null,8,["product"]))),128))])])):D("",!0)])):(s(),n("div",Ee,[o("h4",null,[O(p(e.$t("searchPopup.nothingFound"))+' "',1),o("span",je,p(u.searchedText),1),L[0]||(L[0]=O('"'))])]))])])])}}};export{Ue as default};
