import O from"./CWalxxGV.js";import U from"./BdN5-h2q.js";import{Y as D,u as I,s as L,a as P,r as g,y as V,m as i,j as s,l as h,w as q,p as c,F as R,B as E,i as N,T as Q}from"./BCLrUOBx.js";import{u as Y}from"./D7xsgz5m.js";import"./CTAcmMAz.js";import"./a5umXhxZ.js";import"./Bxmfm8sn.js";import"./BmK4YjMY.js";import"./Bvs3L9q-.js";import"./Ce8lFovl.js";import"./DamcjH0I.js";import"./Di7fl9dA.js";const $={key:0,class:"spinner-wrapper flex"},z={key:1},ne={__name:"CartList",props:{cartProducts:{type:Array},checked:{type:Array},cartShipping:{type:Object,default(){return null}},isShipping:{type:Boolean,default:!1},ajaxing:{type:Boolean,default:!1},currentAddresses:{type:Array,default(){return[]}},errorFromApi:{type:Object,default(){return null}},address:{type:Object,default(){return null}}},emits:["current-shipping","shipping-changed","cart-changed"],setup(t,{emit:m}){const f=t,{cartShipping:l,checked:o}=D(f),d=m,y=I(),{langCode:p}=L(y),k=P(),{getUserToken:C}=k,S=Y(),{cartDelete:x,cartAction:A,cartChanged:_}=S,b=g(!1);g(0);const{dataFromObject:j}=V(),v=e=>{d("current-shipping",e)},w=()=>{d("shipping-changed",l.value)},B=async({bundleDeal:e,product:a,inventory:r,direction:n})=>{await A({payload:{apiVal:{user_token:await C(),product_id:a.id,inventory_id:r.id,quantity:n},storeVal:{product:a,inventory:r,quantity:n,selected:"1"},isBundle:!!e},lang:p.value})},F=async e=>{await x({payload:e,lang:p.value})},T=async e=>{const a=o.value;if(e.checked.target.checked)a.push(e.id);else{const r=o.value.findIndex(n=>parseInt(n)===parseInt(e.id));delete a[r]}await _({lang:p.value,payload:{checked:a}}),d("cart-changed",!0)};return(e,a)=>{const r=O,n=U;return s(),i("div",null,[h(Q,{name:"fade",mode:"out-in"},{default:q(()=>[c(b)||t.ajaxing?(s(),i("div",$,[h(r,{radius:100})])):(s(),i("div",z,[(s(!0),i(R,null,E(t.cartProducts,u=>(s(),N(n,{key:u.id,cart:u,checked:c(o),"is-shipping":t.isShipping,"cart-shipping":c(l),"current-addresses":t.currentAddresses,address:t.address,error:c(j)(t.errorFromApi,u.id,null),onCbChanged:T,onDeleting:F,onQuantity:B,onUpdateCartShipping:w,onCurrentShipping:v},null,8,["cart","checked","is-shipping","cart-shipping","current-addresses","address","error"]))),128))]))]),_:1})])}}};export{ne as default};
