import{x as P,g as b,b as V,d as C,o as t,c as o,t as a,e as S,a as c,F as g,l as h,h as p,S as _,p as w,r as u}from"./app-B-4i4xU3.js";import{P as $}from"./ProductCard-Bre1aBlK.js";const B={class:"main-container pt-8 pb-12"},L={key:0,class:"text-slate-800 dark:text-slate-100 text-lg lg:text-xl font-bold"},M={class:"grid grid-cols-1 xs:grid-cols-2 sm:grid-cols-3 md:grid-cols-4 xl:grid-cols-6 gap-3 sm:gap-6 items-start mt-6"},N={key:2,class:"text-slate-950 dark:text-white text-xl font-medium leading-7"},A={key:2,class:"flex justify-between items-center w-full mt-8 gap-4 flex-wrap"},F={class:"text-slate-800 dark:text-slate-100 text-base font-normal leading-normal"},D={__name:"MostPopular",setup(T){const x=P(),f=b(),l=u(1),d=u(12),n=u([]),i=u(0),s=u(!0);V(()=>{m(),window.scrollTo(0,0)});const k=async e=>{l.value=e,m()},m=async()=>{window.scrollTo({top:0,behavior:"smooth"}),s.value=!0,axios.get("/products",{params:{page:l.value,per_page:d.value,sort_type:"popular_product"},headers:{"Accept-Language":f.locale||"en",Authorization:x.token}}).then(e=>{i.value=e.data.data.total,n.value=e.data.data.products,setTimeout(()=>{s.value=!1},300)}).catch(e=>{s.value=!1})};return(e,v)=>{const y=C("vue-awesome-paginate");return t(),o("div",B,[s.value?(t(),S(_,{key:1,class:"w-48 sm:w-60 md:w-72 lg:w-96 h-12 rounded-lg"})):(t(),o("div",L,a(e.$t("Most Popular")),1)),c("div",M,[s.value?(t(),o(g,{key:1},h(12,r=>c("div",{key:r},[p(_,{class:"w-full h-[220px] sm:h-[330px] rounded-lg"})])),64)):(t(!0),o(g,{key:0},h(n.value,r=>(t(),o("div",{key:r.id,class:"w-full"},[p($,{product:r},null,8,["product"])]))),128)),n.value.length==0&&!s.value?(t(),o("div",N,a(e.$t("No Products Found")),1)):w("",!0)]),n.value.length>0&&!s.value?(t(),o("div",A,[c("div",F,a(e.$t("Showing"))+" "+a(d.value*(l.value-1)+1)+" to "+a(d.value*(l.value-1)+n.value.length)+" "+a(e.$t("of"))+" "+a(i.value)+" "+a(e.$t("results")),1),c("div",null,[p(y,{"total-items":i.value,"items-per-page":d.value,type:"button","max-pages-shown":5,modelValue:l.value,"onUpdate:modelValue":v[0]||(v[0]=r=>l.value=r),"hide-prev-next-when-ends":!0,onClick:k},null,8,["total-items","items-per-page","modelValue"])])])):w("",!0)])}}};export{D as default};
