import{u as f,a_ as p,r as c}from"./index.4dc78c2a.js";function d(n,u){const e=u?f([]):p([]),o=c(null);let l=1;function i(){setTimeout(()=>{var t;e.splice(0,e.length),(t=o.value)==null||t.refresh()},0)}return{list:e,scrollRef:o,refresh:i,reloadCurrentPage(){return n(l).then(t=>{if(!t.total&&!t.per_page)t.data.forEach((a,r)=>{e[r]=a}),e.length>t.data.length&&e.splice(t.data.length,e.length-t.data.length);else{let a=(l-1)*t.per_page;t.data.forEach((r,h)=>{e[a+h]=r})}})},load(t){return l=t||1,n(t||1).then(a=>((!t||t==1)&&e.splice(0,e.length),a.data?(Array.prototype.push.apply(e,a.data),!a.total||a.total/a.per_page<=a.current_page):!0))}}}export{d as u};