import{s as h}from"./app-CJCAnMrx.js";import{r as u,ak as S,W as f,o as d,c as w,u as g,J as m,aa as p}from"./app-BYcXwl4U.js";const z={__name:"TPaginator",props:{total:0,rows:0,offset:0,page:0},emits:["change"],setup(r,{emit:l}){const a=r;let o=a.rows;(f.isNull(o)||o<1)&&(o=10);let n=u(a.offset);a.page>0?n.value=(a.page-1)*o:n.value=0;const i=l,t=e=>{i("change",{page:e.page+1,offset:e.first,rows:e.rows,count:e.pageCount,total:a.total})},s=e=>{i("change",{page:1,offset:0,rows:e,count:Math.ceil(a.total/e),total:a.total})};return S(()=>{a.total>0&&t({page:f.isNull(a.page)?0:a.page-1,first:n.value,rows:o,pageCount:Math.ceil(a.total/o)})}),(e,c)=>(d(),w(g(h),{"total-records":r.total,rows:g(o),pageLinkSize:5,first:g(n),alwaysShow:!0,rowsPerPageOptions:[5,10,20,30,40,50,100],onPage:t,"onUpdate:rows":s},null,8,["total-records","rows","first"]))}},O={__name:"Pager",props:["data"],setup(r){const l=p("$Tea"),a=r,o=p("$popupState",null),n=u();m(()=>a.data,t=>{n.value=t.current+"_"+t.size});const i=t=>{let s=t.page;if(a.data&&s==a.data.current&&t.rows==a.data.size)return;a.data.current=s;let e=l.currentURL();e.indexOf("?")<0?e=e+"?page="+s+"&pageSize="+t.rows:e.indexOf("?page=")>0?e=e.replace(/\?page=(\d+)?/g,"?page="+s):e.indexOf("&page=")>0?e=e.replace(/&page=(\d+)?/g,"&page="+s):e+="&page="+s,e.indexOf("?pageSize=")>0?e=e.replace(/\?pageSize=(\d+)?/g,"?pageSize="+t.rows):e.indexOf("&pageSize=")>0?e=e.replace(/&pageSize=(\d+)?/g,"&pageSize="+t.rows):e+="&pageSize="+t.rows,o?l.reloadViewData(e,{onDone:()=>{if(o!=null){const c=document.querySelectorAll(".p-dialog-content");c.length>0&&(c[c.length-1].scrollTop=0)}}}):window.location.href=e};return(t,s)=>(d(),w(z,{total:r.data.total,rows:r.data.size,page:r.data.current,offset:r.data.offset,onChange:i,key:n.value,alwaysShow:!1},null,8,["total","rows","page","offset"]))}};export{O as _};
