"use strict";var e=require("@babel/runtime/helpers/defineProperty"),o=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),i=require("prop-types"),r=require("classnames"),n=require("react-sortable-hoc"),a=require("@material-ui/core"),l=require("@material-ui/icons/DragIndicator"),u=require("./Component.js"),d=require("../../../../constants/bha.js"),s=require("react/jsx-runtime");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=p(e),b=p(o),m=p(i),f=p(r),g=p(l),v=a.makeStyles((function(e){return{sortableComponent:{position:"relative","&:hover":{"& $dragIndicatorButton":{visibility:"visible"}},zIndex:"99999999 !important",background:function(o){return o.isSortable&&e.palette.background.b5},boxShadow:function(e){return e.isSortable&&"0px 0px 6px rgba(0, 0, 0, 0.5)"}},topComponent:{marginTop:"16px"},bottomComponent:{marginBottom:"8px"},dragInidicationHidden:{"&:hover":{"& $dragIndicatorButton":{visibility:"hidden"}}},dragIndicatorWrapper:{position:"absolute",left:function(e){return e.isMobile?"8px":0},top:function(e){return e.isMobile?"20px":"8px"}},dragIndicatorButton:{visibility:function(e){return e.isMobile?"visible":"hidden"},padding:"8px",background:function(o){return o.isMobile?"none":e.palette.background.b9},"&:hover":{background:e.palette.background.b7,"& $dragIndicatorIcon":{color:e.palette.primary.text1}}},dragIndicatorIcon:{cursor:"pointer",color:e.palette.primary.text6,fontSize:"16px"}}})),x=n.sortableHandle((function(e){var o=e.isMobile,t=v({isMobile:o});return s.jsx("div",{className:t.dragIndicatorWrapper,children:s.jsx(a.Tooltip,{title:o?"":"Click & Drag to reorder",children:s.jsx(a.IconButton,{className:t.dragIndicatorButton,children:s.jsx(g.default,{className:t.dragIndicatorIcon})})})})})),q=n.SortableElement((function(e){var o,i=e.isActualBha,r=e.component,n=e.isTopComponent,a=e.isLastCompnent,l=e.isSortable,p=e.sortableIndex,m=e.validate,g=e.onDelete,q=e.onSave,C=e.isMobile,I=e.viewColumnsPerRow,h=e.editColumnsPerRow,R=e.onAutocompleteApplied,S=v({isMobile:C,isSortable:l}),y=t.useState(!1),A=b.default(y,2),M=A[0],j=A[1];return s.jsxs("div",{className:f.default(S.sortableComponent,(o={},c.default(o,S.topComponent,!C&&n),c.default(o,S.bottomComponent,!C&&a),c.default(o,S.dragInidicationHidden,!l&&-1!==p),o)),children:[r.family!==d.BHA_FAMILY.bit&&!M&&s.jsx(x,{isMobile:C}),s.jsx(u,{isMobile:C,isActualBha:i,viewColumnsPerRow:I,editColumnsPerRow:h,component:r,validate:m,onSave:q,onDelete:g,onChangeEditing:j,onAutocompleteApplied:R,isDragComponent:-1!==p})]})}));q.propTypes={isActualBha:m.default.bool.isRequired,isMobile:m.default.bool.isRequired,component:m.default.shape({}).isRequired,isTopComponent:m.default.bool.isRequired,isLastCompnent:m.default.bool.isRequired,isSortable:m.default.bool.isRequired,sortableIndex:m.default.number.isRequired,validate:m.default.func.isRequired,onDelete:m.default.func.isRequired,onSave:m.default.func.isRequired,viewColumnsPerRow:m.default.number.isRequired,editColumnsPerRow:m.default.number.isRequired,onAutocompleteApplied:m.default.func.isRequired};var C=t.memo(q);module.exports=C;
