import{aP as l,r as f,i as X,b_ as N,b$ as P,k as v,c0 as Z,c1 as ee,c2 as c,c3 as V,m,c as re,j as te}from"./index-DR3HTfO6.js";var ne=function(a){return a===document||a===document.documentElement||a===document.body?Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop):a.scrollTop},$=function(a){return a.scrollHeight||Math.max(document.documentElement.scrollHeight,document.body.scrollHeight)},ae=function(a){return a.clientHeight||Math.max(document.documentElement.clientHeight,document.body.clientHeight)},le=function(a,n){n===void 0&&(n={});var g=n.target,A=n.isNoMore,p=n.threshold,F=p===void 0?100:p,w=n.direction,k=w===void 0?"bottom":w,L=n.reloadDeps,q=L===void 0?[]:L,O=n.manual,h=n.onBefore,_=n.onSuccess,D=n.onError,M=n.onFinally,j=l(f.useState(),2),i=j[0],y=j[1],B=l(f.useState(!1),2),E=B[0],s=B[1],b=k==="top",S=f.useRef(void 0),R=f.useRef(0),T=f.useMemo(function(){return A?A(i):!1},[i]),d=X(function(e){return N(void 0,void 0,void 0,function(){var r;return P(this,function(t){switch(t.label){case 0:return[4,a(e)];case 1:return r=t.sent(),[2,{currentData:r,lastData:e}]}})})},{manual:O,onFinally:function(e,r,t){s(!1),M?.(r?.currentData,t)},onBefore:function(){return h?.()},onSuccess:function(e){var r,t,u;e.lastData?y(m(m({},e.currentData),{list:b?c(c([],l(e.currentData.list),!1),l((t=e.lastData.list)!==null&&t!==void 0?t:[]),!1):c(c([],l((u=e.lastData.list)!==null&&u!==void 0?u:[]),!1),l(e.currentData.list),!1)})):y(m(m({},e.currentData),{list:c([],l((r=e.currentData.list)!==null&&r!==void 0?r:[]),!1)})),setTimeout(function(){if(b){var o=V(g);if(o=o===document?document.documentElement:o,o){var W=$(o);o.scrollTo(0,W-R.current)}}else C()}),_?.(e.currentData)},onError:function(e){return D?.(e)}}),z=d.loading,Y=d.error,H=d.run,G=d.runAsync,J=d.cancel,x=v(function(){T||(s(!0),H(i))}),I=function(e){return N(void 0,void 0,void 0,function(){var r;return P(this,function(t){switch(t.label){case 0:return[4,G(e)];case 1:return r=t.sent(),[2,r.currentData]}})})},K=v(function(){return T?Promise.reject():(s(!0),I(i))}),Q=function(){return s(!1),H()},U=function(){return s(!1),I()},C=function(){var e=V(g);if(e){var r=e===document?document.documentElement:e,t=ne(r),u=$(r),o=ae(r);b?(S.current!==void 0&&S.current>t&&t<=F&&x(),S.current=t,R.current=u-t):u-t<=o+F&&x()}};return Z("scroll",function(){z||E||C()},{target:g}),ee(function(){H()},c([],l(q),!1)),{data:i,loading:!E&&z,error:Y,loadingMore:E,noMore:T,loadMore:x,loadMoreAsync:K,reload:v(Q),reloadAsync:v(U),mutate:y,cancel:J}};const ue=re(te.jsx("path",{d:"m23 12-2.44-2.79.34-3.69-3.61-.82-1.89-3.2L12 2.96 8.6 1.5 6.71 4.69 3.1 5.5l.34 3.7L1 12l2.44 2.79-.34 3.7 3.61.82L8.6 22.5l3.4-1.47 3.4 1.46 1.89-3.19 3.61-.82-.34-3.69zm-12.91 4.72-3.8-3.81 1.48-1.48 2.32 2.33 5.85-5.87 1.48 1.48z"}));export{ue as V,le as u};
