"use strict";var e=require("react"),t=require("prop-types"),n=require("@material-ui/core"),l=require("@material-ui/icons"),i=require("./NumberCircle.js"),a=require("react/jsx-runtime"),c=n.makeStyles({sectionContainer:{display:"flex",width:"100%",justifyContent:"space-between",marginRight:"4px",alignItems:"center"},itemLabel:{display:"flex",alignItems:"center","&:hover":{color:"#DADADA",cursor:"pointer"}},disabledItemLabel:{display:"flex",alignItems:"center","&:hover":{cursor:"pointer"}},itemLabelToggle:{},sectionName:{marginLeft:"6px",marginRight:"10px"},checkbox:{width:"11px",height:"11px"},sectionTitle:{display:"flex",alignItems:"center"},expandIcon:{fontSize:"14px",marginRight:"8px"}});function r(e){return(e.wells.filter((function(e){return e.checked}))||[]).length}function o(e){var t=r(e);return t===e.wells.length?"".concat(t):"".concat(t," of ").concat(e.wells.length," Selected")}function s(e){return e.wells.filter((function(e){return e.checked})).length>0}function d(e){return e.wells.filter((function(e){return e.checked})).length!==e.wells.length}function m(e){var t=e.section,m=e.disabled,u=e.onExpandCollapse,p=e.onSelectAll,h=e.onClearAll,x=c(),f=n.useTheme(),b=function(e){e.stopPropagation(),!d(t)&&h&&h(t),d(t)&&p&&p(t)};return a.jsxs("div",{"data-testid":"".concat("SectionItem","_section_").concat(t.name),className:x.sectionContainer,children:[a.jsxs("div",{className:m?x.disabledItemLabel:x.itemLabel,onClick:function(){return u&&u(t)},children:[a.jsx(n.Tooltip,{title:"No Wells",placement:"right",children:a.jsxs("div",{className:x.sectionTitle,children:[m&&a.jsx(l.ExpandMore,{className:x.expandIcon}),a.jsxs("span",{className:x.sectionName,children:[" ",t.name]})]})}),r(t)>0&&a.jsx(i,{"data-testid":"".concat("SectionItem","_wellsNumber"),bgColor:f.palette.primary.text9,textColor:"#fff",width:20+6*(o(t).length-2),children:o(t)})]}),s(t)?a.jsx(n.Checkbox,{"data-testid":"".concat("SectionItem","_checkbox"),className:x.checkbox,size:"small",checked:!0,indeterminate:d(t),color:"primary",onClick:b,disabled:m}):a.jsx(n.Checkbox,{"data-testid":"".concat("SectionItem","_checkbox"),className:x.checkbox,checked:!1,size:"small",color:"primary",onClick:b,indeterminate:!1,disabled:m})]})}m.propTypes={section:t.shape({expanded:t.bool,name:t.string,wells:t.arrayOf(t.shape({}))}).isRequired,disabled:t.bool,onExpandCollapse:t.func,onSelectAll:t.func,onClearAll:t.func},m.defaultProps={disabled:!1,onSelectAll:null,onExpandCollapse:null,onClearAll:null};var u=e.memo(m);module.exports=u;
//# sourceMappingURL=SectionItem.js.map
