import{l}from"./vendor-sJIIH5Cr.js";import{x as o,y as p,z as s,A as u,g as _,L as m,B as r}from"./index-BGo1APpE.js";const{currencyCode:a}=_,g={viewItemList(e,t){o("view_item_list",{...t,items_skus:p((e??[]).map(n=>n.code)),items_count:e?.length??0})},selectItem(e,t){const n=e&&typeof e=="object"&&"productId"in e?s(e):u(e);o("select_item",{...t,items:[n]})},viewItem(e,t){o("view_item",{...t,currency:a,value:e.price?.actual?.amount,items:[u(e)]})},addItemToWishList(e,t){o("add_to_wishlist",{...t,currency:a,value:e.price?.actual?.amount,items:[u(e)]})},addItemToCart(e,t,n){const c=u(e);c.quantity=t,o("add_to_cart",{...n,currency:a,value:(e.price?.actual?.amount||0)*(t??1),items:[c]})},addItemsToCart(e,t){const n=l.sumBy(e,i=>i?.price?.actual?.amount),c=e.filter(Boolean).map(i=>u(i));o("add_to_cart",{...t,currency:a,value:n,items:c,items_count:c.length})},updateCartItem(e,t,n,c){o("update_cart_item",{...c,item_id:e,new_quantity:t,previous_quantity:n})},removeItemsFromCart(e,t){const n=l.sumBy(e,i=>i.extendedPrice?.amount),c=e.map(s);o("remove_from_cart",{...t,currency:a,value:n,items:c,items_count:c.length})},viewCart(e,t){o("view_cart",{...t,currency:a,value:e.total.amount,items:e.items.map(s),items_count:e.items.length})},clearCart(e,t){o("clear_cart",{...t,currency:a,value:e.total.amount,items:e.items.map(s),items_count:e.items.length})},beginCheckout(e,t){try{o("begin_checkout",{...t,currency:e.currency.code,value:e.total.amount,items:e.items.map(s),items_count:e.items.length,coupon:e.coupons?.[0]?.code})}catch(n){m.error(r,"beginCheckout",n)}},addShippingInfo(e,t,n){try{o("add_shipping_info",{...t,shipping_tier:n,currency:e?.shippingPrice.currency.code,value:e?.shippingPrice.amount,coupon:e?.coupons?.[0]?.code,items:e?.items.map(s),items_count:e?.items.length})}catch(c){m.error(r,"addShippingInfo",c)}},addPaymentInfo(e,t,n){try{o("add_payment_info",{...t,payment_type:n,currency:e?.currency?.code,value:e?.total?.amount,coupon:e?.coupons?.[0]?.code,items:e?.items.map(s),items_count:e?.items.length})}catch(c){m.error(r,"addPaymentInfo",c)}},purchase(e,t,n){try{o("purchase",{...n,currency:e.currency?.code,transaction_id:t,value:e.total.amount,coupon:e.coupons?.[0],shipping:e.shippingTotal?.amount,tax:e.taxTotal?.amount,items:e.items.map(s),items_count:e?.items?.length})}catch(c){m.error(r,"purchase",c)}},placeOrder(e,t){try{o("place_order",{...t,currency:e.currency?.code,value:e.total?.amount,coupon:e.coupons?.[0],shipping:e.shippingTotal.amount,tax:e.taxTotal.amount,items_count:e.items?.length})}catch(n){m.error(r,"placeOrder",n)}},search(e,t=[],n=0){o("search",{search_term:e,items_count:n,visible_items:p(t.map(c=>c.code))})},viewSearchResults(e,t){o("view_search_results",{...t,search_term:e,visible_items:p(t?.visible_items?.map(n=>n.code)??[]),results_count:t?.results_count,results_page:t?.results_page})},login(e,t){o("login",{...t,method:e})},signUp(e,t){o("sign_up",{...t,method:e})}};export{g as events};
//# sourceMappingURL=events-BwL_3xPc.js.map
