import{d as dt,e as ut,m as pt,k as mt,a as vt,X as gt,j as ht}from"./AHiYuuv4.js";import{_ as ft}from"./lm07vBh-.js";import{_ as kt}from"./Dhhdq0pw.js";import{_ as X}from"./DNLPUXkS.js";import{b as _t,c as bt,a as yt}from"./rHjvo5f9.js";import{u as Z}from"./nLZJejse.js";import{g as wt,u as $t,b as Ct}from"./CdTn0kqS.js";import{l as G,b as It,k as I,E as p,F as z,N as g,V as n,L as k,O as T,Q as v,P as f,U as b,u as s,H as x,a0 as N,z as xt,J as j,Z as Q}from"./DEIzhR9A.js";import{u as zt}from"./BXzz6d_D.js";import{u as Pt}from"./Y9ipx7PE.js";import{i as Wt}from"./BNS08PCs.js";import{a as St}from"./DrWK9Uaw.js";import"./lZjBw0yj.js";import"./McvZN_Cb.js";import"./C5qvglTP.js";import"./Dqvtgzyr.js";import"./BJFSaJwp.js";import"./CYLXjrQd.js";import"./-IL9qb0M.js";import"./CKdW9TyB.js";import"./B5Zp2Vr1.js";import"./BlYltdjn.js";import"./ArJcqVXA.js";import"./D0Qws29C.js";import"./D8sTzVSg.js";import"./DW-wVgF4.js";import"./BQkHUO2l.js";import"./C4LJZt9n.js";import"./BZRkhowF.js";const Lt={class:"z-10 flex flex-row-reverse text-gray-700"},At={class:"py-3 pb-6"},Bt={class:"inline-flex w-full flex-col justify-between sm:flex-row"},Vt={key:0,class:"pr-3 font-default text-md"},Ft={class:"flex flex-wrap items-center gap-x-4 py-2 text-md md:h-12 md:py-0","data-test-id":"wishlist-card-product-size"},Tt={class:"py-2 text-md font-bold md:py-0"},Nt={key:"changingSize",class:"flex items-center py-2 md:py-0"},jt={class:"sm:hidden"},qt={class:"hidden sm:inline"},Mt=G({__name:"WishlistCard",props:{product:{type:Object,required:!0},index:{type:Number,required:!0},image:{type:Object,default:()=>{}},hoverImages:{type:Array,default:()=>[]},price:{type:Object,default:()=>{}},lowestPriorPrice:{type:Object,default:()=>({withTax:null})},size:{type:String,required:!0},title:{type:String,required:!0},isInBasket:{type:Boolean,default:()=>!1},isAvailable:{type:Boolean,default:()=>!0},variantId:{type:Number,default:-1}},emits:["click:change-size","click:remove-from-wishlist","click:add-to-cart"],setup(a,{emit:c}){const m=a,l=c,h=It(!1),y=dt(),{getProductDetailRoute:P}=Z(),W=u=>{var d,_;l("click:change-size",(_=(d=u==null?void 0:u.attributes)==null?void 0:d.vendorSize)==null?void 0:_.values),h.value=!1},S=I(()=>{var u;return{product:m.product,listingMetaData:{name:"WishlistList",id:"WL"},variant:((u=m.product.variants)==null?void 0:u.find(d=>d.id===m.variantId))||void 0,index:m.index+1,category:wt(m.product.categories),source:`${String(y.name)}|WishlistList`}});return(u,d)=>{const _=X,L=_t,A=bt,B=yt;return p(),z(B,{id:a.product.id,columns:4,class:"2xl:col-span-3 col-span-6 md:col-span-3",image:a.image,"hover-images":a.hoverImages,title:a.title,link:s(P)(a.product),price:a.price,loading:!1,"is-available":a.isAvailable,"tracking-payload":s(S)},{"header-actions":g(()=>[n("div",Lt,[k(_,{opacity:"0.5",icon:"UiClose","no-padding":!0,class:"px-1.5 sm:px-3.5",size:"sm","data-test-id":"remove-from-wishlist",onClick:d[0]||(d[0]=w=>l("click:remove-from-wishlist"))})])]),description:g(()=>[n("div",At,[n("div",Bt,[n("p",{class:T(["font-default text-md",{"opacity-50":!a.isAvailable}]),"data-test-id":"productName"},v(a.title),3),a.isAvailable?b("",!0):(p(),f("p",Vt,v(u.$t("wishlist.sold_out")),1))]),n("div",{class:T({"opacity-50":!a.isAvailable})},[n("div",null,[k(L,{price:a.price,"lowest-prior-price":a.product.lowestPriorPrice,"applied-reductions":a.price.appliedReductions,size:"sm","data-test-id":"product-price"},null,8,["price","lowest-prior-price","applied-reductions"])]),n("div",Ft,[n("span",Tt,v(a.size),1),s(h)?(p(),f("div",Nt,[k(A,{id:a.product.id,class:"justify-center",variants:a.product.variants||[],"data-test-id":"product-size",onInput:W},null,8,["id","variants"])])):b("",!0),k(_,{type:"link","data-test-id":"product-size-picker",class:T([{hidden:s(h)},"px-2"]),"no-padding":"",onClick:d[1]||(d[1]=w=>h.value=!s(h))},{default:g(()=>[x(v(u.$t("wishlist.change")),1)]),_:1},8,["class"])])],2),!a.isInBasket&&a.isAvailable?(p(),z(_,{key:0,type:"outline","data-test-id":"add-to-cart",onClick:d[2]||(d[2]=w=>l("click:add-to-cart"))},{default:g(()=>[n("span",jt,v(u.$t("wishlist.add")),1),n("span",qt,v(u.$t("wishlist.in_basket")),1)]),_:1})):b("",!0)])]),_:1},8,["id","image","hover-images","title","link","price","is-available","tracking-payload"])}}}),Rt={class:"container mb-20"},Dt={class:"mt-5 flex items-center justify-start space-x-2"},Ot={class:"text-sm text-gray-800"},Ht={key:0,class:"mt-8 grid w-auto grid-cols-12 gap-1"},Et={key:1,class:"mt-8 space-y-8"},Ut=["innerHTML"],Jt={key:0},Kt={class:"mt-10 flex space-x-4"},Ce=G({name:"WishListPage",__name:"wishlist",async setup(a){let c,m;const{$helpers:l}=ut(),{data:h,products:y,replaceItem:P,findItem:W,removeItem:S,count:u}=([c,m]=N(()=>Ct()),c=await c,m(),c),d=([c,m]=N(()=>zt()),c=await c,m(),c),{trackViewItemList:_,trackWishlist:L,collectProductListItems:A,trackAddToBasket:B,trackRemoveFromWishlist:w}=$t(),q=pt(),{isLoggedIn:M}=([c,m]=N(()=>Pt()),c=await c,m(),c),{getProductDetailRoute:Y}=Z(),R=mt();xt(()=>{h.value&&(_({items:y.value,listingMetaData:{name:"Wishlist",id:"Wishlist"},source:"wishlist"}),L(A(y.value,{listName:"WishlistList",listId:"WL"})))});const D=t=>{var i;return(i=h.value)==null?void 0:i.items.find(o=>o.key===t)},tt=async(t,i,o)=>{const r=gt(o,i,"vendorSize");Wt(r)||await P(t,{variantId:r.id})},et=(t,i)=>{const o=D(t);if(!o)return;const r=$(o);d.addItem({variantId:r.id,quantity:1}),B({product:o.product,variant:r,index:i,list:{name:"WishlistList",id:"WL"}})},it=t=>{const i=W({...t}),o=i&&D(i.key);if(!o)return;const r=$(o);S(t),w({product:o.product,variant:r})},at=async()=>{await q.push(R({name:l.route.routes.home.name}))},st=async()=>{await q.push(R({name:l.route.routes.signin.name}))},$=t=>{var i,o,r;return t.variantId?l.product.getVariant(((i=t.product)==null?void 0:i.variants)||[],t.variantId):l.product.getFirstAvailableVariant(((o=t.product)==null?void 0:o.variants)||[])||((r=t==null?void 0:t.product)==null?void 0:r.variants[0])},ot=t=>{if(t.variant)return t.variant.stock.quantity>0||t.variant.stock.isSellableWithoutStock;const i=$(t);return i?(i==null?void 0:i.stock.quantity)>0||(i==null?void 0:i.stock.isSellableWithoutStock):!1},rt=I(()=>{var t;return St(((t=h.value)==null?void 0:t.items)||[],i=>{var o,r;return((r=ht((o=i.product)==null?void 0:o.attributes,"name"))==null?void 0:r.label)??""})}),C=I(()=>u.value||0),nt=I(()=>d.contains);return(t,i)=>{const o=vt,r=ft,ct=kt,lt=Mt,O=X;return p(),f("div",Rt,[n("div",Dt,[k(o,{class:"!mb-0",size:"md",type:"loud","data-test-id":"headline"},{default:g(()=>[x(v(t.$t("wishlist.title")),1)]),_:1}),k(r,null,{default:g(()=>[n("p",Ot,v(s(C))+" "+v(t.$t("products",s(C))),1)]),_:1})]),k(r,null,{fallback:g(()=>[(p(),f(j,null,Q(20,e=>k(ct,{key:`product-loading-${e}`})),64))]),default:g(()=>[s(C)>0?(p(),f("div",Ht,[(p(!0),f(j,null,Q(s(rt),(e,V)=>{var H,E,U,J;return p(),f(j,null,[e.product?(p(),z(lt,{key:`product-${e.product.id}`,index:V,product:e.product,"variant-id":(H=e.variant)==null?void 0:H.id,link:s(Y)(e.product),price:e.variant?e.variant.price:s(l).product.getLowestPrice(e.product.variants||[]),"lowest-prior-price":s(l).product.getVariantWithLowestPrice(e.product.variants||[]).lowestPriorPrice,size:((U=s(l).attribute.getFirstAttributeValue((E=$(e))==null?void 0:E.attributes,"vendorSize"))==null?void 0:U.label)||"","is-available":ot(e),title:((J=s(l).attribute.getFirstAttributeValue(e.product.attributes,"name"))==null?void 0:J.label)||"",image:s(l).image.getFirstModelImage(e.product.images,V),"hover-images":s(l).image.getModelImages(e.product.images),"is-in-basket":s(nt)(e.variant?{variantId:e.variant.id}:{productId:e.product.id}),"onClick:changeSize":F=>{var K;return tt(e.variant?{variantId:e.variant.id}:{productId:e.product.id},F,((K=e.product)==null?void 0:K.variants)||[])},"onClick:addToCart":F=>et(e.key,V),"onClick:removeFromWishlist":F=>it(e.variant?{variantId:e.variant.id}:{productId:e.product.id})},null,8,["index","product","variant-id","link","price","lowest-prior-price","size","is-available","title","image","hover-images","is-in-basket","onClick:changeSize","onClick:addToCart","onClick:removeFromWishlist"])):b("",!0)],64)}),256))])):b("",!0),s(C)===0?(p(),f("div",Et,[n("div",null,[n("p",{innerHTML:t.$t("wishlist.empty_notification")},null,8,Ut),s(M)?b("",!0):(p(),f("p",Jt,v(t.$t("wishlist.empty_notification_login")),1))]),n("div",Kt,[k(O,{type:"outline",onClick:at},{default:g(()=>[x(v(t.$t("continue_shopping")),1)]),_:1}),s(M)?b("",!0):(p(),z(O,{key:0,type:"primary",onClick:st},{default:g(()=>[x(v(t.$t("sign_in")),1)]),_:1}))])])):b("",!0)]),_:1})])}}});export{Ce as default};