import u from"./CcKtUwWJ.js";import{u as p}from"./Bxmfm8sn.js";import{K as P,M as _,m as f,j as g,k as r,t as d,D as l,v as c,i as h}from"./BCLrUOBx.js";import"./Dyp1qGEf.js";import"./CTAcmMAz.js";import"./B2sEaWda.js";import"./a5umXhxZ.js";import"./BnLnKt_p.js";import"./Di7fl9dA.js";import"./Ce8lFovl.js";import"./CE4It_C4.js";const w={name:"ProductsDynamic",data(){return{currentPage:1,draggedWidth:0,pagination:[6,4,3,2,2]}},watch:{},props:{itemList:{type:Array,default(){return[]}},title:{type:String,default:""},totalItem:{type:Number},perPage:{type:Number}},components:{SuggestedAjaxSlider:u},computed:{loadedPage(){const t=this.itemList.length,i=t%this.itemPerPage;return(t-i)/this.itemPerPage},totalPage(){if(this.currentPagination<this.totalItem){const t=this.totalItem%parseInt(this.currentPagination);return(this.totalItem-t)/parseInt(this.currentPagination)+(t>0?1:0)}return 1},itemPerPage(){return window.innerWidth>1200?this.pagination[0]:window.innerWidth>992?this.pagination[1]:window.innerWidth>=768?this.pagination[2]:window.innerWidth>576?this.pagination[3]:this.pagination[4]},currentPagination(){return this.itemPerPage<this.perPage?this.itemPerPage:this.perPage}},mixins:[p],methods:{onDragging(t){this.draggedWidth=-1*t},onDragEnd(){this.draggedWidth>0?this.change(1):this.draggedWidth<0&&this.change(-1)},change(t){this.currentPage+=t,this.currentPage<1?this.currentPage=this.totalPage:this.currentPage>this.totalPage&&(this.currentPage=1),this.draggedWidth=0,this.loadedPage<this.currentPage&&this.$emit("change",t)}},created(){},mounted(){}},D={class:"flex sided align-start"},v={class:"bold"},b={class:"mn-w-90x right-text"},W={class:"c_slider__wrapper"},k={class:"c_slider__nav"};function x(t,i,a,y,n,e){const s=u,o=_("drag");return g(),f("div",null,[r("div",D,[r("h4",v,d(a.title),1),r("p",b,d(t.$t("productDynamic.pageOf",{current:n.currentPage,total:e.totalPage})),1)]),r("div",W,[r("div",k,[r("button",{"aria-label":"submit",class:"prev-btn clear-height",onClick:i[0]||(i[0]=c(m=>e.change(-1),["prevent"]))},i[2]||(i[2]=[r("i",{class:"icon arrow-left black m-0"},null,-1)])),r("button",{"aria-label":"submit",class:"next-btn clear-height",onClick:i[1]||(i[1]=c(m=>e.change(1),["prevent"]))},i[3]||(i[3]=[r("i",{class:"icon arrow-right black m-0"},null,-1)]))]),t.isMobile()?l((g(),h(s,{key:1,class:"touch-action","item-list":a.itemList,"current-pagination":e.currentPagination,"total-page":e.totalPage,"current-page":n.currentPage,"dragged-width":n.draggedWidth},null,8,["item-list","current-pagination","total-page","current-page","dragged-width"])),[[o,{onDragging:e.onDragging,onDragEnd:e.onDragEnd}]]):l((g(),h(s,{key:0,class:"touch-action","item-list":a.itemList,"current-pagination":e.currentPagination,"total-page":e.totalPage,"current-page":n.currentPage,"dragged-width":n.draggedWidth},null,8,["item-list","current-pagination","total-page","current-page","dragged-width"])),[[o,{onDragging:e.onDragging,onDragEnd:e.onDragEnd}]])])])}const O=P(w,[["render",x]]);export{O as default};
