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