import H from"./C94c7PuK.js";import z from"./a5umXhxZ.js";import F from"./BT_icyIK.js";import{_ as J}from"./CglRsQQc.js";import{u as K,s as o,a as Q,b as X,c as Y,o as Z,n as tt,d as et,e as at,r as l,f as y,g as st,h as ot,i as ct,w as nt,j as m,k as e,l as _,m as S,t as c,p as s,q as rt,v as C}from"./BCLrUOBx.js";import{u as lt}from"./D7xsgz5m.js";import{u as it}from"./CCot8u0_.js";import"./CWalxxGV.js";import"./BdN5-h2q.js";import"./CTAcmMAz.js";import"./BmK4YjMY.js";import"./Bvs3L9q-.js";import"./Ce8lFovl.js";import"./DamcjH0I.js";import"./Di7fl9dA.js";import"./Bxmfm8sn.js";import"./ScxedDBk.js";const ut={class:"container-fluid mtb-20 mtb-sm-15"},dt={class:"product-detail checkout-detail"},pt={class:"detail-left ptb-10 plr-20 plr-sm-15 mr-sm area mr-20 mb-sm-15"},mt={class:"b-b pb-10 mb-10 flex sided"},_t={class:"bold"},ht={key:0},ft={key:1},gt={class:"flex sided pb-5"},vt={class:"price"},kt={class:"price"},Ot={__name:"cart",setup(bt){var b;const w=K(),{langCode:n}=o(w),h=lt(),{cartProducts:i}=o(h),{getCartByUser:I,cartChanged:u}=h,f=Q(),{getUserToken:P}=f,{profile:x}=o(f),g=X(),{currencyIcon:yt,setting:$,customScripts:St,site_setting:v}=o(g),{fetchLocation:Ct}=g,B=Y(),{authenticated:A}=o(B);Z(()=>{var t;if(!((t=$.value)!=null&&t.guest_checkout)&&!A.value)return tt("/login")});const{t:M}=et(),{pageMeta:T}=it();at(T({...v.value,meta_title:`${M("header.cart")} | ${(b=v.value)==null?void 0:b.meta_title}`}));const N=t=>{p.value=t},k=l(!0),a=l([]),d=l(!1),p=l({totalItems:0,totalPriceWithOffer:0,totalPrice:0}),D=y(()=>{a.value=[];let t=[];return i.value.forEach(r=>{parseInt(r.selected)===1&&(a.value.push(r.id),t.push(r))}),k.value=t.length===0,t});y(()=>{var t;return(t=x.value)==null?void 0:t.cart_count});const U=st(),V=()=>{U.push("/shipping")},j=async()=>{a.value=i.value.map(t=>t.id),await u({payload:{checked:a.value},lang:n.value}),await G()},E=async()=>{a.value=[],await u({payload:{checked:[]},lang:n.value})},G=async(t=!1)=>{await u({payload:{checked:a.value,isBundle:t},lang:n.value})},L=async()=>{d.value=!0,await I({lang:n.value,params:{user_token:await P()}}),d.value=!1};return ot(async()=>{await L()}),(t,r)=>{const O=H,R=z,W=F,q=J;return m(),ct(q,null,{default:nt(()=>[e("div",ut,[e("div",dt,[e("div",pt,[e("div",mt,[e("h5",_t,c(t.$t("cart.shoppingCart")),1),s(a).length?(m(),S("p",ft,[e("button",{"aria-label":"submit",class:"link f-9",onClick:C(E,["prevent"])},c(t.$t("cart.deselectItems")),1)])):(m(),S("p",ht,[rt(c(t.$t("cart.noSelected"))+" ",1),e("button",{"aria-label":"submit",class:"link ml-10 f-9",onClick:C(j,["prevent"])},c(t.$t("cart.selectItems")),1)]))]),_(O,{"cart-products":s(i),ajaxing:s(d),checked:s(a)},null,8,["cart-products","ajaxing","checked"]),e("div",gt,[e("h5",vt,c(t.$t("cart.subtotal",{items:s(p).totalItems})),1),e("h4",kt,[_(R,{price:s(p).totalPriceWithOffer},null,8,["price"])])])]),_(W,{disabled:s(k),"checked-product":s(D),onCalculatedPrice:N,onGoNext:V},null,8,["disabled","checked-product"])])])]),_:1})}}};export{Ot as default};
