import e from"@babel/runtime/helpers/defineProperty";import o from"@babel/runtime/helpers/slicedToArray";import{useState as n,useRef as r,useMemo as t}from"react";import i from"classnames";import s from"prop-types";import{isEmpty as l}from"lodash";import a from"./components/Header.js";import m from"./components/Component.js";import d from"./components/SortableComponents.js";import p from"./CasingTableV2.css.js";import c from"../../Drillstring/BHACasingEmptyView/BHACasingEmptyView.js";import{jsxs as u,jsx as f}from"react/jsx-runtime";function C(s){var C=s.viewColumnsPerRow,v=s.editColumnsPerRow,w=s.components,R=s.draftComponent,b=s.validate,P=s.onSort,y=s.onAdd,S=s.onDelete,h=s.onSave,g=s.onCancel,q=s.isMobile,A=n(-1),j=o(A,2),D=j[0],x=j[1],M=n(!1),T=o(M,2),E=T[0],H=T[1],N=r(null),O=t((function(){return!(w&&!l(w)||R)}),[w,R]);return u("div",{className:p.container,children:[O?f(c,{type:"Casing",onAdd:y}):u("div",{className:i(p.tableContent,e({},p.contentMobile,q)),ref:N,onScroll:function(){N.current&&H(!!N.current.scrollTop)},children:[!q&&f(a,{}),u("div",{children:[R&&f(m,{isMobile:q,viewColumnsPerRow:C,editColumnsPerRow:v,component:R,isDraft:!0,validate:b,onCancel:g,onSave:h}),f(d,{useDragHandle:!0,lockAxis:"y",lockToContainerEdges:!0,components:w,sortableIndex:D,validate:b,onSaveComponent:h,onDeleteComponent:S,onSortEnd:function(e,o){x(-1),P(e,o)},onSortStart:function(e){x(e.index)},isMobile:q,viewColumnsPerRow:C,editColumnsPerRow:v})]})]}),f("div",{className:i(p.topGradient,e({},p.visible,E)),style:{top:q?0:50}}),f("div",{className:p.bottomGradient})]})}C.propTypes={viewColumnsPerRow:s.oneOf([1,2,3,4,6]),editColumnsPerRow:s.oneOf([1,2,3,4,6]),components:s.arrayOf(s.shape({})),draftComponent:s.arrayOf(s.shape({})),validate:s.func.isRequired,onSort:s.func.isRequired,onAdd:s.func.isRequired,onDelete:s.func.isRequired,onSave:s.func.isRequired,onCancel:s.func.isRequired,isMobile:s.bool.isRequired},C.defaultProps={viewColumnsPerRow:3,editColumnsPerRow:3,components:null,draftComponent:null};export{C as default};
