import $ from"./Button.8a478b7a.js";import{g as M,E as s,G as A,j as c,H as E,o as p,c as P,I as N,k,L as C,l as j,F as I,x as L,y as S}from"./entry.eb978f24.js";import{_ as U}from"./_plugin-vue_export-helper.c27b6911.js";import"./Icon.30f6becb.js";import"./Link.a86a4ec7.js";import"./nuxt-link.0033bf2d.js";import"./_baseIsEqual.8f3c5dea.js";import"./_MapCache.e1952f2e.js";const q=M({components:{UButton:$},props:{modelValue:{type:Number,required:!0},pageCount:{type:Number,default:10},total:{type:Number,required:!0},max:{type:Number,default:7,validate(e){return e>=7&&e<Number.MAX_VALUE}},size:{type:String,default:()=>s.ui.pagination.default.size,validator(e){return Object.keys(s.ui.button.size).includes(e)}},activeButton:{type:Object,default:()=>s.ui.pagination.default.activeButton},inactiveButton:{type:Object,default:()=>s.ui.pagination.default.inactiveButton},prevButton:{type:Object,default:()=>s.ui.pagination.default.prevButton},nextButton:{type:Object,default:()=>s.ui.pagination.default.nextButton},divider:{type:String,default:"…"},ui:{type:Object,default:()=>s.ui.pagination}},emits:["update:modelValue"],setup(e,{emit:B}){const b=A(),h=c(()=>E({},e.ui,b.ui.pagination)),i=c({get(){return e.modelValue},set(n){B("update:modelValue",n)}}),d=c(()=>Array.from({length:Math.ceil(e.total/e.pageCount)},(n,a)=>a+1)),f=c(()=>{if(!e.max||d.value.length<=5)return d.value;{const n=i.value,a=d.value.length,o=Math.floor((Math.min(e.max,a)-5)/2),v=n-o,g=n+o,y=v-1>1,z=g+1<a,t=[1];if(y&&t.push(e.divider),!z){const l=n+o+2-a;for(let r=n-o-l;r<=n-o-1;r++)t.push(r)}for(let l=v>2?v:2;l<=Math.min(a,g);l++)t.push(l);if(!y){const l=1-(n-o-2);for(let r=n+o+1;r<=n+o+l;r++)t.push(r)}return z&&t.push(e.divider),g<a&&t.push(a),t.length>=3&&t[1]===e.divider&&t[2]===3&&(t[1]=2),t.length>=3&&t[t.length-2]===e.divider&&t[t.length-1]===t.length&&(t[t.length-2]=t.length-1),t}}),u=c(()=>i.value>1),m=c(()=>i.value<d.value.length);function O(n){typeof n!="string"&&(i.value=n)}function V(){u.value&&i.value--}function G(){m.value&&i.value++}return{ui:h,currentPage:i,pages:d,displayedPages:f,canGoPrev:u,canGoNext:m,onClickPrev:V,onClickNext:G,onClickPage:O}}});function F(e,B,b,h,i,d){const f=$;return p(),P("div",{class:S(e.ui.wrapper)},[N(e.$slots,"prev",{onClick:e.onClickPrev},()=>[e.prevButton?(p(),k(f,C({key:0,size:e.size,disabled:!e.canGoPrev,class:[e.ui.base,e.ui.rounded]},{...e.ui.default.prevButton,...e.prevButton},{ui:{rounded:""},onClick:e.onClickPrev}),null,16,["size","disabled","class","onClick"])):j("",!0)]),(p(!0),P(I,null,L(e.displayedPages,(u,m)=>(p(),k(f,C({key:m,size:e.size,label:`${u}`},u===e.currentPage?{...e.ui.default.activeButton,...e.activeButton}:{...e.ui.default.inactiveButton,...e.inactiveButton},{class:[{"pointer-events-none":typeof u=="string","z-[1]":u===e.currentPage},e.ui.base,e.ui.rounded],ui:{rounded:""},onClick:()=>e.onClickPage(u)}),null,16,["size","label","class","onClick"]))),128)),N(e.$slots,"next",{onClick:e.onClickNext},()=>[e.nextButton?(p(),k(f,C({key:0,size:e.size,disabled:!e.canGoNext,class:[e.ui.base,e.ui.rounded]},{...e.ui.default.nextButton,...e.nextButton},{ui:{rounded:""},onClick:e.onClickNext}),null,16,["size","disabled","class","onClick"])):j("",!0)])],2)}const R=U(q,[["render",F]]);export{R as default};
