"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("vue"),v=require("../../../node_modules/.pnpm/@vueuse_shared@10.9.0_vue@3.4.21/node_modules/@vueuse/shared/index.js"),S=(t,f)=>{const u=a.shallowRef(!1),o=a.ref({success:!0,data:[],total:1}),s=a.ref({pageSize:10,currentPage:1}),l=async()=>{const e=t.data||[];if(t.pagination){const{pageSize:n,currentPage:d}=s.value,r=(d-1)*n;return{success:!0,total:e.length,data:r+n>=e.length?e.slice(r,e.length):e.slice(r,r+n)}}else return{total:e.length,data:e}},i=a.computed(()=>{if(t.pagination){const e={pageSizes:[10,20,50],layout:"total,sizes,prev,pager,next,jumper",background:!0,position:"center"};return typeof t.pagination=="boolean"?e:{...e,...t.pagination}}else return!1}),c=a.computed(()=>t.request?t.request:l),g=v.useDebounceFn(async()=>{if(!u.value){u.value=!0;try{const e=await c.value(f.value,s.value);e.success&&(o.value=e)}catch(e){console.error(e)}u.value=!1}},200);return a.onMounted(()=>{i.value&&(s.value.pageSize=i.value.pageSizes[0]),g()}),a.watch(()=>t.data,async e=>{if(e){const n=await l();o.value=n}},{deep:!0}),{dataSource:o,requestApi:c,paginationInfo:s,$pagination:i,loading:u,runReuestApi:g}};exports.default=S;
