import{e as it,d as ot,a as rt,j as nt,A as at}from"./AHiYuuv4.js";import{a as lt,u as ct,_ as ut,t as mt,g as pt,b as dt,c as gt,d as _t,s as ft}from"./odqmWp2Z.js";import{_ as ht}from"./Jzjg1sWV.js";import{_ as wt}from"./CAQNniay.js";import{s as vt}from"./CigU-tWz.js";import{u as yt,b as Ct}from"./CdTn0kqS.js";import{u as Ft}from"./Bdrg8SNY.js";import{u as Pt}from"./CYYWD2qY.js";import{u as bt}from"./DX_4PFwR.js";import{i as kt}from"./BNS08PCs.js";import{l as St,a0 as w,k as m,c as $t,E as v,F as y,N as C,V as n,L as p,H as A,Q as I,u as t,U as V}from"./DEIzhR9A.js";import"./DNLPUXkS.js";import"./C5qvglTP.js";import"./ArJcqVXA.js";import"./DdY_a9Gh.js";import"./B_tyb2-9.js";import"./CKdW9TyB.js";import"./B8i0axnd.js";import"./Dqvtgzyr.js";import"./BJFSaJwp.js";import"./CXSUenga.js";import"./BZRkhowF.js";import"./D8sTzVSg.js";import"./C4LJZt9n.js";import"./Bax9ooNF.js";import"./rHjvo5f9.js";import"./lZjBw0yj.js";import"./McvZN_Cb.js";import"./CYLXjrQd.js";import"./-IL9qb0M.js";import"./lm07vBh-.js";import"./B5Zp2Vr1.js";import"./BlYltdjn.js";import"./D0Qws29C.js";import"./nLZJejse.js";import"./DW-wVgF4.js";import"./BQkHUO2l.js";import"./BXzz6d_D.js";const At={class:"items-center md:flex"},It={class:"hidden w-1/4 md:block"},Vt=["innerHTML"],Lt={class:"flex w-full justify-end md:w-3/4"},xt={class:"relative mt-4"},we=St({__name:"search",async setup(Nt){let i,a;const{$alert:L,$helpers:x,i18n:d}=it(),F=ot(),{products:N,productsFetching:P,pagination:o,filters:g,fetchProducts:b,refreshProductCount:W,productCountData:T}=([i,a]=w(()=>ct({key:"useSearchFacet",params:{initialPath:"/women",with:{product:{attributes:{withKey:["colorDetail","brand","name","editedOnlineExclusive","editedPremium",...vt]},variants:{attributes:{withKey:["price"]},lowestPriorPrice:!0},images:{attributes:{withKey:["imageType","imageView","imageBackground","imageKind"]}},priceRange:!0,lowestPriorPrice:!0}}}})),i=await i,a(),i),{applyFilters:j,activeFilters:D,isActiveFilter:E,productConditions:_,resetFilterUrl:K}=lt(),{trackFilterApply:R,trackViewItemList:B}=yt(),f=([i,a]=w(()=>Ct()),i=await i,a(),i),{toggle:H}=Ft("FilterSlideIn"),{setColumns:M,listingColumns:O}=Pt(),l=m(()=>F.query.term||""),U=async e=>{await W({where:{...mt(e)}})},k=()=>({path:"/women",..._.value,where:{..._.value.where,term:l.value.toString()},sort:{..._.value.sort}});[i,a]=w(()=>b(k())),await i,a(),$t(()=>F.query,async()=>{await b(k())});const q=async e=>{var u;const s=((u=nt(e.attributes,"name"))==null?void 0:u.label)||d.t("wishlist.product");await f.toggleItem({productId:e.id});const h=f.findItem({productId:e.id})?d.t("wishlist.notification.add_to_wishlist",{productName:s}):d.t("wishlist.notification.remove_from_wishlist",{productName:s});L.show(h.toString(),at.route,x.route.routes.wishlist.name)},S=m(()=>{var e;return(e=o.value)==null?void 0:e.total});bt({title:`Deine Suche nach "${l==null?void 0:l.value}" hat ${S.value} Treffer ergeben.`});const z=e=>{kt(e)||Object.keys(e).forEach(s=>{const r=Array.isArray(e[s])?e[s].join("|"):e[s];R(s,r)}),j(e)},Q={name:"Search Page",id:"SearchPage"},G=({items:e})=>{var r;const s=((((r=o.value)==null?void 0:r.page)||1)-1)*20;B({items:e,listingMetaData:Q,paginationOffset:s,source:`search|${l.value}`})},J=m(()=>Object.values(pt(ft))),X=m(()=>f.findItem),Y=e=>q(e);return(e,s)=>{const r=rt,h=dt,u=ht,Z=gt,tt=_t,et=wt,st=ut;return v(),y(st,null,{default:C(()=>{var $;return[n("div",At,[n("div",It,[p(r,{size:"sm"},{default:C(()=>[n("span",null,[A(I(e.$t("search_intro"))+" ",1),n("strong",null,I(t(l)),1),s[3]||(s[3]=A(" ")),n("span",{innerHTML:e.$t("search_outro",{count:t(S)})},null,8,Vt)])]),_:1})]),n("div",Lt,[p(h,{"onClick:filter":t(H),"onClick:selectedColumn":t(M)},null,8,["onClick:filter","onClick:selectedColumn"])])]),n("div",xt,[p(u,{refreshing:t(P),loading:t(P),columns:t(O),products:t(N),"is-in-wishlist":t(X),"onClick:toggleProductWishlist":s[0]||(s[0]=c=>Y(c)),"onIntersect:row":G},null,8,["refreshing","loading","columns","products","is-in-wishlist"]),t(g)&&t(g).length?(v(),y(Z,{key:0,filters:t(g),sorting:t(J),"active-filters":t(D),"product-count":(($=t(T))==null?void 0:$.count)||t(o)&&t(o).total,"is-active-filter":t(E),onFilterStateChanged:s[1]||(s[1]=c=>U(c)),onFilter:s[2]||(s[2]=c=>z(c)),onReset:t(K)},null,8,["filters","sorting","active-filters","product-count","is-active-filter","onReset"])):V("",!0)]),p(et,{"placeholder-ratio":"16/9"},{default:C(()=>[t(o)?(v(),y(tt,{key:0,"current-page":t(o).page,"first-page":t(o).first,"last-page":t(o).last},null,8,["current-page","first-page","last-page"])):V("",!0)]),_:1})]}),_:1})}}});export{we as default};