import e from"@babel/runtime/helpers/toConsumableArray";import t from"@babel/runtime/helpers/slicedToArray";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{memo as n,useState as i,useCallback as l,useMemo as a,useEffect as s}from"react";import{Button as d}from"../../Button/Button.js";import{TableBody as c,TableRow as m}from"@material-ui/core";import{TableCell as f}from"../../../components/Table/TableCell/TableCell.js";import{LoaderLogo as u}from"../../LoaderLogo/LoaderLogo.js";import{MAX_TVD as p}from"../constants.js";import h from"./PadTableRow.js";import{useFilteredData as g}from"./helpers/useFilteredData.js";import S from"./PadsTableBody.scss.js";var b=n((function(n){var b,T=n.pads,j=n.selectedPadId,v=n.searchText,x=n.sortBy,I=n.sortDirection,P=n.selectedOffsetWellIds,L=n.filters,M=n.isSelectedPadsLoading,y=n.handleSelectPad,B=n.handleSelectWellId,C=i(50),W=t(C,2),F=W[0],D=W[1],A=l((function(){D((function(e){return e+50}))}),[]),O=a((function(){return T.filter((function(e){return e.id.toString()!==j.toString()}))}),[T,j]),k=a((function(){return T.find((function(e){return e.id.toString()===j.toString()}))}),[T,j]),w=a((function(){return!!(v||L.selectedFormations.length||L.selectedFracFleets.length||L.tvdMin||L.tvdMax!==p||L.radiusMiles)}),[v,L]),E=g({data:O,searchText:v,sortBy:x,sortDirection:I,selectedWellIds:P,filters:L,mainItem:k});s((function(){D(50)}),[v,L]);var N=a((function(){return E.slice(0,F)}),[E,F]);return!k||M?r(u,{}):o(c,{children:[null===(b=[k].concat(e(N)))||void 0===b?void 0:b.map((function(e){return r(h,{isMainPad:e.id.toString()===j.toString(),data:e,isExpanded:w,searchText:v,handleSelectPad:y,selectedOffsetWellIds:P,handleSelectWellId:B},e.id)})),E.length>50&&F<E.length&&r(m,{children:r(f,{colSpan:4,className:S.loadMoreCell,children:r(d,{onClick:A,children:"Load More"})})})]})}));export{b as PadsTableBody};
//# sourceMappingURL=PadsTableBody.js.map
