import O from"./Button.b41c8ed4.js";import{C as U,b as E,u as I}from"./ui.config.7ae255de.js";import{E as V,G as g,g as S,j as f,o as p,c as N,H as $,k as C,K as v,l as j,F as W,x as q}from"./entry.9e31e8a4.js";import{_ as F}from"./_plugin-vue_export-helper.c27b6911.js";import"./Icon.fe8c0e68.js";import"./Link.cc0949f5.js";import"./nuxt-link.f786ecc0.js";import"./tw-merge.27ca352e.js";const d=V(g.ui.strategy,g.ui.pagination,U),L=V(g.ui.strategy,g.ui.button,E),w=S({components:{UButton:O},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>=7&&e<Number.MAX_VALUE}},size:{type:String,default:()=>d.default.size,validator(e){return Object.keys(L.size).includes(e)}},activeButton:{type:Object,default:()=>d.default.activeButton},inactiveButton:{type:Object,default:()=>d.default.inactiveButton},prevButton:{type:Object,default:()=>d.default.prevButton},nextButton:{type:Object,default:()=>d.default.nextButton},divider:{type:String,default:"…"},ui:{type:Object,default:void 0}},emits:["update:modelValue"],setup(e,{emit:h}){const{ui:B,attrs:y}=I("pagination",e.ui,d,{mergeWrapper:!0}),u=f({get(){return e.modelValue},set(n){h("update:modelValue",n)}}),s=f(()=>Array.from({length:Math.ceil(e.total/e.pageCount)},(n,a)=>a+1)),c=f(()=>{if(!e.max||s.value.length<=5)return s.value;{const n=u.value,a=s.value.length,o=Math.floor((Math.min(e.max,a)-5)/2),b=n-o,k=n+o,P=b-1>1,z=k+1<a,t=[1];if(P&&t.push(e.divider),!z){const r=n+o+2-a;for(let l=n-o-r;l<=n-o-1;l++)t.push(l)}for(let r=b>2?b:2;r<=Math.min(a,k);r++)t.push(r);if(!P){const r=1-(n-o-2);for(let l=n+o+1;l<=n+o+r;l++)t.push(l)}return z&&t.push(e.divider),k<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}}),i=f(()=>u.value>1),m=f(()=>u.value<s.value.length);function G(n){typeof n!="string"&&(u.value=n)}function M(){i.value&&u.value--}function A(){m.value&&u.value++}return{ui:B,attrs:y,currentPage:u,pages:s,displayedPages:c,canGoPrev:i,canGoNext:m,onClickPrev:M,onClickNext:A,onClickPage:G}}});function H(e,h,B,y,u,s){const c=O;return p(),N("div",v({class:e.ui.wrapper},e.attrs),[$(e.$slots,"prev",{onClick:e.onClickPrev},()=>[e.prevButton?(p(),C(c,v({key:0,size:e.size,disabled:!e.canGoPrev,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"])):j("",!0)]),(p(!0),N(W,null,q(e.displayedPages,(i,m)=>(p(),C(c,v({key:`${i}-${m}`,size:e.size,label:`${i}`},i===e.currentPage?{...e.ui.default.activeButton,...e.activeButton}:{...e.ui.default.inactiveButton,...e.inactiveButton},{class:[{"pointer-events-none":typeof i=="string","z-[1]":i===e.currentPage},e.ui.base,e.ui.rounded],ui:{rounded:""},onClick:()=>e.onClickPage(i)}),null,16,["size","label","class","onClick"]))),128)),$(e.$slots,"next",{onClick:e.onClickNext},()=>[e.nextButton?(p(),C(c,v({key:0,size:e.size,disabled:!e.canGoNext,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"])):j("",!0)])],16)}const Z=F(w,[["render",H]]);export{Z as default};
