import{_ as u}from"./Bgk-2nau.js";import{h as O,r as d,d as r,e as c,v as g,c as P,a6 as H,l as S}from"./BmsEUx_s.js";import{_ as aa}from"./CO0TJbSZ.js";import{_ as ea}from"./MNvGvCi9.js";import{u as ta}from"./CGa_SUqF.js";import{g as sa}from"./Uxv2zAsR.js";import{k as na,a as ma,a0 as ia,G as s,M as h,u as n,a1 as $,O as f,P as B,a7 as _a,H as b,I as Q,Q as R,V as X,X as N}from"./BO9AmBA3.js";const ha=()=>{async function o(i,k){const{data:w}=await k.invoke.post(`/store-api/product/${i}/cross-selling`);return w.length?w[0].products:[]}return{getCrossSellingItems:o}},fa=f("div",{class:"w-11/12 mx-auto border-t border-gray-950 mb-6"},null,-1),pa={class:""},ya={key:0,class:"w-11/12 flex space-x-6 items-center mt-4 mb-8 ml-6"},va={class:"mr-4 h-25 w-25 flex-shrink-0 overflow-hidden"},ka={class:"space-y-2 w-6/12"},wa={class:"headline-5"},Ca={key:1,class:"headline-5"},la={class:"w-full"},Na=na({__name:"CheckoutPopupCrossselling",props:{cartItem:{},controller:{}},async setup(o){var V;let i,k;const w=o,{apiInstance:q}=O(),{startLoading:A,endLoading:J}=d(),K=r(),{formatLink:U}=c(K),{getCrossSellingItems:W}=ha(),{desktop:Y}=ta(),{getCurrentLanguage:Z}=g(),j=Z(),C=ma();try{A();const p=([i,k]=ia(()=>W(w.cartItem.id,q)),i=await i,k(),i);C.value=(V=[...p].map(t=>{var y,v;if((y=t==null?void 0:t.extensions)!=null&&y.availability){const{emwa:I,availability:L,preorder:l,preorderDate:a}=(v=t==null?void 0:t.extensions)==null?void 0:v.availability,{t:x}=P(),e=sa({emwa:I,availability:L,preorder:l,preorderDate:a},j.namedPath,x),_={availabilityStatus:e==null?void 0:e.status,availabilityMessage:e==null?void 0:e.message};return _.availabilityStatus=e==null?void 0:e.status,_.availabilityMessage=e==null?void 0:e.message,{...t,productAvailability:_}}else return}))==null?void 0:V.filter(t=>t.productAvailability.availabilityStatus!=="outofstock")}catch{}finally{J()}return(p,t)=>{var l;const y=u,v=S,I=aa,L=ea;return s(),h(B,null,[fa,n(C)?(s(),h("div",{key:0,class:$(["mx-4 mb-4",{"h-screen max-h-50vh overflow-y-scroll":!n(Y)||((l=n(C))==null?void 0:l.length)>3}])},[f("ol",pa,[(s(!0),h(B,null,_a(n(C),a=>{var x,e,_,F,M,z,D,G,T;return s(),h(B,{key:a.id},[(x=a==null?void 0:a.productAvailability)!=null&&x.availabilityStatus?(s(),h("li",ya,[f("div",va,[(e=a==null?void 0:a.seoUrls)!=null&&e.length?(s(),b(v,{key:0,to:n(U)(`/${a.seoUrls[0].seoPathInfo}`),onClick:t[0]||(t[0]=m=>p.controller.close())},{default:Q(()=>{var m,E;return[R(y,{src:n(H)((m=a==null?void 0:a.cover)==null?void 0:m.media),alt:(a==null?void 0:a.label)||"",class:$(["w-full object-cover object-center",[(E=a==null?void 0:a.customFields)!=null&&E.riding_style?"h-fit":"h-full"]]),"data-testid":"cross-selling-product-image"},null,8,["src","alt","class"])]}),_:2},1032,["to"])):(s(),b(y,{key:1,src:n(H)((_=a==null?void 0:a.cover)==null?void 0:_.media),alt:(a==null?void 0:a.label)||"",class:$(["w-full object-cover object-center",[(F=a==null?void 0:a.customFields)!=null&&F.riding_style?"h-fit":"h-full"]]),"data-testid":"cross-selling-product-image"},null,8,["src","alt","class"]))]),f("div",ka,[(M=a==null?void 0:a.seoUrls)!=null&&M.length?(s(),b(v,{key:0,to:n(U)(`/${a.seoUrls[0].seoPathInfo}`),onClick:t[1]||(t[1]=m=>p.controller.close())},{default:Q(()=>{var m;return[f("p",wa,X((m=a==null?void 0:a.translated)==null?void 0:m.name),1)]}),_:2},1032,["to"])):(s(),h("p",Ca,X((z=a==null?void 0:a.translated)==null?void 0:z.name),1)),(D=a==null?void 0:a.calculatedPrice)!=null&&D.totalPrice?(s(),b(I,{key:2,class:"flex gap-1 para-4",value:(G=a==null?void 0:a.calculatedPrice)==null?void 0:G.totalPrice,"data-testid":"cross-selling-product-price"},null,8,["value"])):N("",!0),f("div",la,[R(L,{"selected-child":a,product:a,status:(T=a==null?void 0:a.productAvailability)==null?void 0:T.availabilityStatus,"is-cross-selling-item":!0,theme:"transparent","full-width":!1,disableable:!1},null,8,["selected-child","product","status"])])])])):N("",!0)],64)}),128))])],2)):N("",!0)],64)}}});export{Na as _};