import e from"@babel/runtime/helpers/slicedToArray";import{useState as r,useEffect as i}from"react";import t from"prop-types";import{makeStyles as n,FormControl as a,InputLabel as l,Select as o,MenuItem as c,Checkbox as s,ListItemText as u,Divider as m}from"@material-ui/core";import{jsxs as p,jsx as d}from"react/jsx-runtime";var f=n({checkBox:{color:"grey",paddingLeft:0},formControl:{width:function(e){return e.size}},listItemPrimaryText:{color:"#fff"},paper:{backgroundColor:"#414141"}});function h(t){var n=t.options,h=t.currentValues,y=t.title,g=t.size,x=t.renderValue,k=t.onChange,v=r([]),C=e(v,2),q=C[0],R=C[1],P=r(!1),T=e(P,2),V=T[0],b=T[1],w=r(!1),z=e(w,2),N=z[0],O=z[1],B=f({size:g});i((function(){R(h.filter((function(e){return n.includes(e)})))}),[h,n]);return p(a,{className:B.formControl,children:[d(l,{shrink:!0,htmlFor:"c-owp-multi-select-".concat(y),children:y}),p(o,{className:B.select,MenuProps:{classes:{paper:B.paper}},multiple:!0,displayEmpty:!0,fullWidth:!0,value:q,inputProps:{name:"c-owp-multi-select-".concat(y),id:"c-owp-multi-select-".concat(y)},renderValue:function(e){return x(e.length)},open:V,onOpen:function(){b(!0),O(!1)},onClose:function(){b(!1),N&&k(q),O(!1)},onChange:function(e){var r=e.target.value;R(r.includes("all")?[]:r),O(!0)},children:[p(c,{value:"all",children:[d(s,{checked:!0,indeterminate:q.length>0,className:B.checkBox}),d(u,{primary:x(0),classes:{primary:B.listItemPrimaryText}})]},"all"),d(m,{}),n.map((function(e){return p(c,{value:e,children:[d(s,{checked:q.indexOf(e)>-1,className:B.checkBox}),d(u,{primary:e,classes:{primary:B.listItemPrimaryText}})]},e)}))]})]})}h.propTypes={options:t.arrayOf(t.string).isRequired,currentValues:t.arrayOf(t.string).isRequired,title:t.string.isRequired,size:t.number.isRequired,renderValue:t.func.isRequired,onChange:t.func.isRequired};export{h as default};
