import e from"@babel/runtime/helpers/slicedToArray";import{useState as r,useRef as l,useEffect as t,useLayoutEffect as o,useMemo as n}from"react";import{ROWS_PER_PAGE as c}from"../../../constants.js";import s from"../OffsetWellsTable.module.css.js";var i=function(i){var u=i.sortedWells,a=i.subjectWell,f=i.isLimitedOffsetWells,d=i.isHScrollMoved,h=i.setIsHScrollMoved,m=i.isVScrollMoved,v=i.setIsVScrollMoved,p=i.isAdvancedSearchHidden,S=i.setIsAdvancedSearchHidden,g=r(c),H=e(g,2),T=H[0],b=H[1],L=r([]),W=e(L,2),A=W[0],M=W[1],w=l(null),R=l(null),j=l(0),I=l(!1);t((function(){if(u){var e=u.slice(0,T);M(e)}}),[u,T,a]),o((function(){I.current||R.current&&j.current>0&&(R.current.scrollTop=j.current)}),[A]),t((function(){if(w.current){var e=w.current.querySelector(".".concat(s.wellNameFixed));e&&(d?e.classList.remove(s.noShadow):e.classList.add(s.noShadow))}}),[d,A]);var x=n((function(){if(!u)return[!1,!1];var e=null==a?void 0:a.id,r=e?u.filter((function(r){return r.id!==e})):u,l=r.length,t=r.filter((function(e){return e.checked})).length,o=f&&t>0;return[t>0&&t<l&&!o,l>0&&t===l||o]}),[u,a,f]),y=e(x,2),C=y[0],O=y[1];return{tableWells:A,tableRowsCount:T,headTableRef:w,rightColumnRef:R,isAnimatingRef:I,indeterminate:C,isAllWellsSelected:O,handleScroll:function(e){var r=e.target;r&&(j.current=r.scrollTop,p&&(r.scrollLeft=0,S(!1)),r.scrollLeft<=5&&d&&h(!1),r.scrollLeft>5&&!d&&h(!0),r.scrollTop<=0&&m&&v(!1),r.scrollTop>0&&!m&&v(!0),r.scrollHeight!==r.offsetHeight&&Math.round(r.scrollTop+r.offsetHeight+2)>=r.scrollHeight&&u&&T<u.length&&b((function(e){return e+c})))}}};export{i as useTablePagination};
//# sourceMappingURL=useTablePagination.js.map
