import{o as g,G as p,e as n,d as I,r as v,k as h,z as N,az as L,L as E,t as m,P as x,U,f as l,q as z,V as D,W as K,Q as R,aC as w,C as S,O as y,n as C}from"./llFuKhWI.js";import{I as T}from"./CMRDQou7.js";const j={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 12 12"},q=n("path",{fill:"currentColor","fill-rule":"evenodd",d:"M3 6a.5.5 0 0 1 .17-.376l4-3.5a.5.5 0 1 1 .66.752L4.26 6l3.57 3.124a.5.5 0 0 1-.66.752l-4-3.5A.5.5 0 0 1 3 6","clip-rule":"evenodd"},null,-1),A=[q];function F(b,f){return g(),p("svg",j,[...A])}const G={render:F},O={class:"container is-max-widescreen"},Q={class:"columns is-multiline"},W={class:"column is-flex-tablet is-align-items-center"},H={class:"has-text-weight-bold mr-2"},J={class:"select is-x-small"},X=["disabled"],Y=["value"],Z={class:"column is-flex-tablet is-align-items-center is-justify-content-end"},ee=n("span",{class:"has-text-weight-bold mr-2"},"Page:",-1),te=["disabled"],ae={key:0,class:"ml-2"},se=["disabled"],ne=["disabled"],oe=I({__name:"Pagination",props:{pagesizes:{default:()=>[25,50,100]},initialPagesize:{default:void 0},pagesize:{default:void 0},initialPage:{default:void 0},currentPage:{default:void 0},maxPage:{default:void 0},disabled:{type:Boolean,default:!1},label:{default:"Posts per page"}},emits:["update:pagesize","update:current-page","fetch"],setup(b,{emit:f}){const a=b,c=f,P=v(a.initialPagesize??a.pagesizes[0]),_=v(a.initialPage??a.currentPage??1),o=v(a.initialPage??a.currentPage??1),d=h({get(){return a.pagesize??P.value},set(t){P.value=t,c("update:pagesize",t),r(1,!0)}}),i=h({get(){return a.currentPage??_.value},set(t){_.value=t,c("update:current-page",t)}});N(()=>a.currentPage,t=>{o.value=t??1});const k=()=>{r(i.value-1)},B=()=>{r(i.value+1)},M=t=>{var e;o.value=i.value,(e=t.target)==null||e.blur()},V=t=>{var e;r(o.value),(e=t.target)==null||e.blur()},$=()=>{r(o.value)},r=(t,e=!1)=>{const s=i.value,u=Math.min(Math.max(t,1),a.maxPage??1/0);o.value=u,s!==u&&(i.value=u),(s!==u||e)&&L(()=>c("fetch"))};return E(()=>{a.pagesize!==d.value&&c("update:pagesize",d.value)}),(t,e)=>(g(),p("div",O,[n("div",Q,[n("div",W,[n("span",H,m(t.label)+":",1),n("div",J,[x(n("select",{"onUpdate:modelValue":e[0]||(e[0]=s=>z(d)?d.value=s:null),disabled:t.disabled||t.pagesizes.length<=1},[(g(!0),p(D,null,K(t.pagesizes,(s,u)=>(g(),p("option",{key:u,value:s},m(s),9,Y))),128))],8,X),[[U,l(d)]])])]),n("div",Z,[ee,x(n("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>z(o)?o.value=s:null),disabled:t.disabled,class:"input is-inline is-x-small pagination__input",onKeydown:[e[2]||(e[2]=w(s=>M(s),["esc"])),e[3]||(e[3]=w(s=>V(s),["enter"]))],onBlur:e[4]||(e[4]=s=>$())},null,40,te),[[R,l(o)]]),a.maxPage?(g(),p("span",ae,m(l(i))+" / "+m(a.maxPage),1)):S("",!0),n("button",{class:y(["button is-x-small ml-7 mr-1 pagination__button",{"is-blue-800":l(i)>1}]),type:"button","aria-label":"previous page",disabled:t.disabled||l(i)===1,onClick:e[5]||(e[5]=s=>k())},[C(l(G),{width:"12px"})],10,se),n("button",{class:y(["button is-x-small pagination__button",{"is-blue-800":typeof a.maxPage=="number"?l(i)+1<=a.maxPage:!0}]),type:"button","aria-label":"next page",disabled:t.disabled||(typeof a.maxPage=="number"?l(i)+1>a.maxPage:!1),onClick:e[6]||(e[6]=s=>B())},[C(l(T),{width:"12px"})],10,ne)])])]))}});export{G as I,oe as _};