import{computed as c}from"vue";import g from"../../_util/extendsObject.mjs";import m from"../../_util/hooks/useState.mjs";const p=10;function b(u,e){const l={current:u.current,pageSize:u.pageSize};return Object.keys(e&&typeof e=="object"?e:{}).forEach(r=>{const o=u[r];typeof o!="function"&&(l[r]=o)}),l}function d(u,e,l){const t=c(()=>e.value&&typeof e.value=="object"?e.value:{}),r=c(()=>t.value.total||0),[o,s]=m(()=>({current:"defaultCurrent"in t.value?t.value.defaultCurrent:1,pageSize:"defaultPageSize"in t.value?t.value.defaultPageSize:p})),i=c(()=>{const a=g(o.value,t.value,{total:r.value>0?r.value:u.value}),n=Math.ceil((r.value||u.value)/a.pageSize);return a.current>n&&(a.current=n||1),a}),v=(a,n)=>{e.value!==!1&&s({current:a??1,pageSize:n||i.value.pageSize})},f=(a,n)=>{e.value&&t.value.onChange?.(a,n),v(a,n),l(a,n||i.value.pageSize)};return[c(()=>e.value===!1?{}:{...i.value,onChange:f}),v]}export{p as DEFAULT_PAGE_SIZE,d as default,b as getPaginationParam};
