import R from"./BMc5KkT2.js";import{d as U,a as V,Z as A,O as F,r as I,e as $,b7 as M,j as P,b8 as Q,t as S,C as l,o as i,h as r,f as m,x as w,i as c,g as p,a0 as Z,v as _,A as B,aL as G,_ as H}from"./BxiWQxwE.js";import{_ as J}from"./4HfP1VOY.js";import K from"./DXn7UZRN.js";import W from"./BpaGfDpb.js";import{_ as X}from"./CCb6Ii9b.js";import"./QMEN6lyk.js";import"./CxeYIrhH.js";import"./DKUQAchG.js";const Y={key:0,class:"toggle"},ee=["src","alt"],te={class:"price"},oe={key:0,class:"error"},re={class:"product__card--price"},ne={key:0,class:"loading"},ce=U({__name:"product-card",props:{product:{type:Object,required:!0},list:{type:Object,required:!0},loading:{type:Boolean,required:!1,default:!1},error:{type:Boolean,required:!1,default:!1},strikeOption:{type:Boolean,required:!1,default:!1}},emits:["item-observed","remove-from-list","toggle-list","striked"],setup(e,{emit:q}){const t=e,{$gtm:C,$messages:L}=V(),{lastItemRemoved:O}=A(),{strikeShoppingListItem:T}=F(),g=I(null),a=q,z=async()=>{var o,s;try{const n=await T(String(t.product.productId),t.list.shoppingListId);(o=n.strikeShoppingListItem)!=null&&o.isSuccess&&a("striked",!!((s=n.strikeShoppingListItem)!=null&&s.isSuccess))}catch(n){console.error("Error while trying to strike product",n)}},f=()=>{O.value=t.product,a("remove-from-list",t.product)},h=$(()=>G(`/producten/${t.product.department}/${t.product.webgroup}/${encodeURIComponent(t.product.headerText??"")}/${t.product.productId}`)??""),k=$(()=>({item_id:t.product.productId,item_brand:t.product.brand,item_category:t.product.department,item_category2:t.product.webgroup,item_name:t.product.headerText,item_variant:t.product.packaging,item_list_name:"shopping-list",item_list_id:"shopping-list",price:t.product.price.priceToShow,quantity:t.product.quantity??0})),{stop:v}=M(g,([{isIntersecting:o}])=>{o&&(a("item-observed",k.value),v())},{threshold:.8}),d=I(),y=()=>{var o;return(o=d.value)==null?void 0:o.classList.remove("lazy_img--unloaded")};P(()=>{d.value.complete&&y()}),Q(()=>v());const E=()=>{C("products.select_item",{ecommerce:{items:[k.value]}})};return(o,s)=>{const n=R,x=Z,b=J,N=K,j=W,D=X;return i(),S(D,{onDragged:f},{default:l(()=>[r("div",{ref_key:"productElement",ref:g,class:B(["product__card",{"product__card--strike-option":e.strikeOption,striked:e.product.strike}])},[e.strikeOption?(i(),m("div",Y,[c(n,{id:`item__${e.product.productId}`,checked:e.product.strike,onInput:z},null,8,["id","checked"])])):w("",!0),c(x,{to:p(h),class:"product__card--image"},{default:l(()=>{var u;return[r("img",{ref_key:"imgEl",ref:d,class:"image lazy_img lazy_img--unloaded",src:`${e.product.image}?width=190`,alt:(u=e.product.headerText)==null?void 0:u.trim(),loading:"lazy",onLoad:y},null,40,ee)]}),_:1},8,["to"]),c(x,{class:"product__card--content",to:p(h),onClick:E},{default:l(()=>[r("h4",null,_(e.product.headerText),1),r("p",null,_(e.product.packaging),1),r("div",te,[c(b,{product:e.product,"force-show":"regular"},null,8,["product"])]),e.error?(i(),m("small",oe,_(p(L)("error.common")),1)):w("",!0)]),_:1},8,["to"]),r("div",re,[c(b,{product:e.product,"force-show":"regular"},null,8,["product"])]),r("div",{class:B(["product__card--actions",{loading:e.loading}])},[c(N,{pending:e.loading,"show-filled":!0,onToggleFavorite:s[0]||(s[0]=u=>o.$emit("toggle-list",e.product))},null,8,["pending"]),e.loading?(i(),m("span",ne)):(i(),S(j,{key:1,pending:e.loading,onDelete:f},null,8,["pending"]))],2)],2)]),_:1})}}}),ge=H(ce,[["__scopeId","data-v-e87b450a"]]);export{ge as default};
