import{_ as t}from"./BdLjlOHY.js";import{a as e,l as a,_ as l}from"./Dbd0Y8WE.js";import{_ as s,a as o}from"./mqjJGHgV.js";import{c as i,L as r,M as d,$ as c,W as n,H as u,a5 as p,a2 as v,u as m,V as x,P as f,_ as g,G as y,O as b,a0 as _}from"./DOfEu912.js";const h={class:"relative overflow-hidden bg-[#FAFAFA]"},k={key:1,class:"absolute bottom-2 start-2 z-10 flex items-center gap-1 bg-[#000000B2] px-2.5 py-1.5 text-xs text-white"},$=["disabled"],w=["src","alt"],F={class:"py-3 flex-1 space-y-2 bg-[#FAFAFA] px-3"},E={key:0,class:"flex items-center gap-2 justify-between"},T={key:1,class:"font-medium text-xs text-[#E74924] py-2 px-2 2xl:px-4 bg-[#FFE1DA]"},j={class:"text-base line-clamp-1 font-medium"},z={class:"flex items-center gap-2 justify-between"},A={class:"flex items-center gap-2"},L={class:"font-semibold text-xl"},S={key:0},I={class:"text-[#606060] text-sm"},P={key:1,class:"flex items-center gap-2"},C={class:"flex items-center gap-2"},D={class:"text-[#606060] text-sm"},O={class:"text-primary line-through text-sm flex items-center gap-1"},q={class:"text-[#606060] text-xs"},M=["disabled"],B={class:"flex items-center gap-2"},G={key:0,src:s,alt:"star",class:"w-4 h-4"},H={key:1,src:o,alt:"star",class:"w-4 h-4"},V={class:"text-sm font-semibold text-gray-500"},W={__name:"ProductCard",props:{product:{type:Object,required:!0}},setup(s){const o=s,W=e().$axios,J=i(!1),K=i(!1);return(e,i)=>{var N,Q,R,U,X,Y,Z,tt,et,at,lt,st,ot,it,rt,dt;const ct=t,nt=l;return s.product?(r(),d("div",{key:0,class:"relative h-full flex flex-col group","data-aos":"fade-end",style:_({animationDelay:100*s.product.id+"ms"})},[c("div",h,[n("",!0),s.product.is_trendy?(r(),d("div",k,[u(ct,{name:"trending"}),p(" "+v(e.$t("TITLES.trending")),1)])):n("",!0),c("button",{onClick:i[0]||(i[0]=t=>{return e=s.product,J.value=!0,void W.get(`make_fave/${e.id}`).then((t=>{o.product.is_fave=!o.product.is_fave,a.success(t.data.message)})).catch((t=>{a.error(t.response.data.message)})).finally((()=>{J.value=!1}));var e}),disabled:m(J),class:"absolute disabled:opacity-80 disabled:cursor-not-allowed end-3 top-3 z-[100] rounded-full bg-white p-1.5 transition hover:bg-gray-100"},[s.product.is_fave?(r(),x(ct,{key:0,name:"fill-heart",class:"text-2xl transition-colors duration-500"})):(r(),x(ct,{key:1,name:"heart",class:"text-2xl transition-colors [&_path]:!fill-primary duration-500"}))],8,$),u(nt,{to:e.localePath(`/product/${s.product.id}?color=${null==(Q=null==(N=s.product.detail)?void 0:N.color)?void 0:Q.id}&size=${null==(U=null==(R=s.product.detail)?void 0:R.size)?void 0:U.id}`),class:"block relative z-0"},{default:f((()=>{var t;return[c("img",{src:null==(t=s.product.main_image)?void 0:t.media,alt:s.product.name,class:"h-[300px] w-full object-cover transition duration-300 group-hover:scale-105"},null,8,w)]})),_:1},8,["to"])]),c("div",F,[(null==(X=s.product.detail)?void 0:X.in_stock)?n("",!0):(r(),d("div",E,[n("",!0),(null==(Y=s.product.detail)?void 0:Y.in_stock)?n("",!0):(r(),d("span",T,v(e.$t("TITLES.outOfStock")),1))])),u(nt,{to:e.localePath(`/product/${s.product.id}?color=${null==(tt=null==(Z=s.product.detail)?void 0:Z.color)?void 0:tt.id}&size=${null==(at=null==(et=s.product.detail)?void 0:et.size)?void 0:at.id}`),class:"block"},{default:f((()=>{var t;return[c("h3",j,v(null==(t=s.product)?void 0:t.title),1)]})),_:1},8,["to"]),c("div",z,[c("div",A,[c("div",L,[s.product.offer_price?(r(),d("div",P,[c("div",C,[c("span",null,v(null==(st=s.product.detail)?void 0:st.price_after_offer),1),c("span",D,v(e.$t("TITLES.egp")),1)]),c("div",O,[p(v(null==(ot=s.product.detail)?void 0:ot.price)+" ",1),c("span",q,v(e.$t("TITLES.egp")),1)])])):(r(),d("p",S,[p(v(null==(lt=s.product.detail)?void 0:lt.price)+" ",1),c("span",I,v(e.$t("TITLES.egp")),1)]))])]),c("button",{onClick:i[1]||(i[1]=t=>(t=>{var e;K.value=!0,W.post("cart",{product_detail_id:null==(e=t.detail)?void 0:e.id,quantity:1}).then((t=>{a.success(t.data.message)})).catch((t=>{a.error(t.response.data.message)})).finally((()=>{K.value=!1}))})(s.product)),class:g(["rounded-full disabled:opacity-70 disabled:cursor-not-allowed disabled:bg-[#FDEFE4]/70 bg-[#FDEFE4] p-2 text-white transition hover:bg-opacity-90 hover:scale-105",s.product.detail&&(null==(it=s.product.detail)?void 0:it.in_stock)?"":"opacity-50 cursor-not-allowed"]),disabled:!s.product.detail||!(null==(rt=s.product.detail)?void 0:rt.in_stock)||m(K)},[u(ct,{name:"cart",class:"text-2xl transition-all duration-500 [&_path]:!fill-primary"})],10,M)]),c("div",B,[(r(),d(y,null,b(5,(t=>{var e;return c("span",{key:t,class:"flex items-center gap-1 cursor-pointer transition duration-300 hover:scale-110"},[t<=Math.floor((null==(e=s.product.detail)?void 0:e.rate_avg)||0)?(r(),d("img",G)):(r(),d("img",H))])})),64)),c("span",V," ("+v((null==(dt=s.product.detail)?void 0:dt.rate_avg)||0)+") ",1)])])],4)):n("",!0)}}};export{W as _};
