import N from"./CTMooejj.js";import{c as R,r as S}from"./5LXQy1qV.js";import{v as B,m as D,u as E,r as y,E as k,e as K,_ as V,R as j,o as i,c as s,L as w,b as x,q as l,C as p,I,K as L,t as b,a as O}from"./CibDhUcP.js";const P=1,z=B({__name:"Pagination",props:{total:{type:Number,default:0},perPage:{type:Number,default:20},queryKey:{type:String,default:"page"},totalPages:{type:Number,default:0}},emits:["switchPagination","switchPage"],setup(u,{expose:a,emit:m}){a();const e=m,o=u,d=D(),c=E(),r=y(1),n=y(0),g=k(()=>o.totalPages>0?o.totalPages:Math.ceil(o.total/o.perPage)),C=k(()=>{if(!g.value)return[];const t=R(1,g.value),_=t(r.value-(1+P)),h=t(r.value+(1+P));return S(_,h)}),f=(t,_)=>({...c.query,[t]:_}),q=t=>{t!==r.value&&d.replace({query:f("page",t)})};K(()=>{const t=c.query[o.queryKey];t&&(r.value=Number(t),n.value=(Number(t)-1)*o.perPage,e("switchPagination",n.value),e("switchPage",r.value))});const v={emit:e,props:o,router:d,route:c,currentPage:r,resultStartBy:n,paginationPages:g,buttonCount:P,paginationRider:C,addPropToQuery:f,switchPage:q};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),F={key:0,class:"pagination flex-center gap-2 flex-wrap py-4"},M={key:2,class:"h-8 w-8 rounded flex-center flex-shrink-0"},Q=["onClick"],T={key:3,class:"h-8 w-8 rounded flex-center flex-shrink-0"};function A(u,a,m,e,o,d){const c=N,r=j("tippy");return e.paginationPages?(i(),s("nav",F,[e.currentPage>1?w((i(),s("div",{key:0,class:"pagination__element h-8 w-8 rounded cursor-pointer flex-center flex-shrink-0",onClick:a[0]||(a[0]=n=>e.currentPage>1?e.switchPage(e.currentPage-1):null)},[x(c,{name:"material-symbols:chevron-left-rounded",class:"w-5 h-5"})])),[[r,{content:u.$t("back"),placement:"top"}]]):l("",!0),e.currentPage>3?(i(),s("div",{key:1,class:p(["h-8 w-8 rounded flex-center flex-shrink-0",[e.currentPage===1?"pagination__active":"pagination__element cursor-pointer"]]),onClick:a[1]||(a[1]=n=>e.switchPage(1))}," 1 ",2)):l("",!0),e.currentPage>4?(i(),s("div",M," … ")):l("",!0),(i(!0),s(I,null,L(e.paginationRider,n=>(i(),s("div",{key:n,class:p(["h-8 w-8 rounded flex-center flex-shrink-0",[n===e.currentPage?"pagination__active":"pagination__element cursor-pointer"]]),onClick:g=>e.switchPage(n)},b(n),11,Q))),128)),e.paginationPages-e.currentPage>2?(i(),s("div",T," … ")):l("",!0),O("div",{class:p(["h-8 w-8 rounded flex-center flex-shrink-0",[e.paginationPages===e.currentPage?"pagination__active":"pagination__element cursor-pointer"]]),onClick:a[2]||(a[2]=n=>e.switchPage(e.paginationPages))},b(e.paginationPages),3),e.currentPage<e.paginationPages?w((i(),s("div",{key:4,class:"pagination__element h-8 w-8 rounded cursor-pointer flex-center flex-shrink-0",onClick:a[3]||(a[3]=n=>e.currentPage<e.paginationPages?e.switchPage(e.currentPage+1):null)},[x(c,{name:"material-symbols:chevron-right-rounded",class:"w-5 h-5"})])),[[r,{content:u.$t("forward"),placement:"top"}]]):l("",!0)])):l("",!0)}const U=Object.assign(V(z,[["render",A],["__file","Pagination.vue"]]),{__name:"Pagination"});export{U as _};
