import{aT as c,cH as m,aq as I,cI as f}from"./app-BgLa5dit.js";import{u as S}from"./g56uS58q.chunk.js";function E(r,a,n,h,o,C){const[F,l]=c.useState(0),e=a;function d(i){if(!r)return null;const u=r(i);return u?u.key:null}const t=m(d,h,o);function g(){if(!(!a||!r||!t))return l(i=>i+1),e(t.nextCursor)}return S({fetchNextPage:g,hasMore:!!(t!=null&&t.nextCursor),isFetching:t==null?void 0:t.isFetching,scrollContainer:C}),c.useEffect(()=>{t&&t.shouldInitialFetch&&a&&(e(),l(i=>i+1))},[t==null?void 0:t.shouldInitialFetch,a]),c.useEffect(()=>{var u,s;if(!(t!=null&&t.statusCode)||!I.isFunction(n))return;const i=+((s=(u=t.statusCode)==null?void 0:u.toString())==null?void 0:s.substr(0,1));i!==f.ClientError&&i!==f.ServerError||n(F,t.statusCode)},[t==null?void 0:t.statusCode]),{items:t==null?void 0:t.items,hasMore:!!(t!=null&&t.nextCursor),nextCursor:t==null?void 0:t.nextCursor,isFetching:t==null?void 0:t.isFetching,totalItems:t==null?void 0:t.totalItems,hasFirstPageCompleted:t==null?void 0:t.hasFirstPageCompleted}}export{E as u};
//# sourceMappingURL=8Im-OACs.chunk.js.map
