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