import{p as U,a as I,_ as j,u as q}from"./Button.8c8352d3.js";import{bN as M,bO as B,_ as E,N as W,b5 as F,v as b,o as f,c as L,aP as k,y as m,ao as c,z as g,F as D,aO as R}from"./entry.816e6e91.js";const l=M(B.ui.strategy,B.ui.pagination,U),X=M(B.ui.strategy,B.ui.button,I),H=W({components:{UButton:j},inheritAttrs:!1,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>=5&&e<Number.MAX_VALUE}},size:{type:String,default:()=>l.default.size,validator(e){return Object.keys(X.size).includes(e)}},activeButton:{type:Object,default:()=>l.default.activeButton},inactiveButton:{type:Object,default:()=>l.default.inactiveButton},showFirst:{type:Boolean,default:!1},showLast:{type:Boolean,default:!1},firstButton:{type:Object,default:()=>l.default.firstButton},lastButton:{type:Object,default:()=>l.default.lastButton},prevButton:{type:Object,default:()=>l.default.prevButton},nextButton:{type:Object,default:()=>l.default.nextButton},divider:{type:String,default:"…"},class:{type:[String,Object,Array],default:void 0},ui:{type:Object,default:void 0}},emits:["update:modelValue"],setup(e,{emit:y}){const{ui:h,attrs:z}=q("pagination",F(e,"ui"),l,F(e,"class")),i=b({get(){return e.modelValue},set(n){y("update:modelValue",n)}}),p=b(()=>Array.from({length:Math.ceil(e.total/e.pageCount)},(n,s)=>s+1)),r=b(()=>{const n=p.value.length,s=i.value,P=Math.max(e.max,5),o=Math.floor((Math.min(P,n)-5)/2),O=s-o,C=s+o,N=O-1>1,$=C+1<n,t=[];if(n<=P){for(let a=1;a<=n;a++)t.push(a);return t}if(t.push(1),N&&t.push(e.divider),!$){const a=s+o+2-n;for(let d=s-o-a;d<=s-o-1;d++)t.push(d)}for(let a=Math.max(2,O);a<=Math.min(n,C);a++)t.push(a);if(!N){const a=1-(s-o-2);for(let d=s+o+1;d<=s+o+a;d++)t.push(d)}return $&&t.push(e.divider),C<n&&t.push(n),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=b(()=>i.value>1),v=b(()=>i.value<p.value.length);function G(){u.value&&(i.value=1)}function V(){v.value&&(i.value=p.value.length)}function w(n){typeof n!="string"&&(i.value=n)}function A(){u.value&&i.value--}function S(){v.value&&i.value++}return{ui:h,attrs:z,currentPage:i,pages:p,displayedPages:r,canGoLastOrNext:v,canGoFirstOrPrev:u,onClickPrev:A,onClickNext:S,onClickPage:w,onClickFirst:G,onClickLast:V}}});function J(e,y,h,z,i,p){const r=j;return f(),L("div",c({class:e.ui.wrapper},e.attrs),[k(e.$slots,"first",{onClick:e.onClickFirst},()=>[e.firstButton&&e.showFirst?(f(),m(r,c({key:0,size:e.size,disabled:!e.canGoFirstOrPrev,class:[e.ui.base,e.ui.rounded]},{...e.ui.default.firstButton,...e.firstButton},{ui:{rounded:""},"aria-label":"First",onClick:e.onClickFirst}),null,16,["size","disabled","class","onClick"])):g("",!0)]),k(e.$slots,"prev",{onClick:e.onClickPrev},()=>[e.prevButton?(f(),m(r,c({key:0,size:e.size,disabled:!e.canGoFirstOrPrev,class:[e.ui.base,e.ui.rounded]},{...e.ui.default.prevButton,...e.prevButton},{ui:{rounded:""},"aria-label":"Prev",onClick:e.onClickPrev}),null,16,["size","disabled","class","onClick"])):g("",!0)]),(f(!0),L(D,null,R(e.displayedPages,(u,v)=>(f(),m(r,c({key:`${u}-${v}`,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)),k(e.$slots,"next",{onClick:e.onClickNext},()=>[e.nextButton?(f(),m(r,c({key:0,size:e.size,disabled:!e.canGoLastOrNext,class:[e.ui.base,e.ui.rounded]},{...e.ui.default.nextButton,...e.nextButton},{ui:{rounded:""},"aria-label":"Next",onClick:e.onClickNext}),null,16,["size","disabled","class","onClick"])):g("",!0)]),k(e.$slots,"last",{onClick:e.onClickLast},()=>[e.lastButton&&e.showLast?(f(),m(r,c({key:0,size:e.size,disabled:!e.canGoLastOrNext,class:[e.ui.base,e.ui.rounded]},{...e.ui.default.lastButton,...e.lastButton},{ui:{rounded:""},"aria-label":"Last",onClick:e.onClickLast}),null,16,["size","disabled","class","onClick"])):g("",!0)])],16)}const T=E(H,[["render",J]]);export{T as _};
