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