"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("prop-types"),t=require("@material-ui/core"),r=require("../../constants.js"),i=require("../../../../utils/index.js"),n=require("../../../Select/index.js"),a=require("react/jsx-runtime");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=o(e),c=t.makeStyles((function(e){return{metricsForm:{width:"calc(100% - 32px)","& .MuiInputBase-root":{"&:hover $primaryText":{color:e.palette.primary.text1},"&:hover $primaryIcon":{color:e.palette.primary.text1},"&:focused $primaryIcon":{color:e.palette.primary.main}}},metricsSelect:{"&:before":{borderBottom:"none !important"},"&:after":{borderBottom:"none !important"}},primaryText:{fontWeight:500,fontSize:"12px",lineHeight:"14px",letterSpacing:"0.4px",color:e.palette.primary.text7,overflow:"hidden",textOverflow:"ellipsis"},primaryIcon:{color:e.palette.primary.text6},metricsMenuPaper:{backgroundColor:e.palette.background.b9,maxHeight:"calc(100% - 300px)",top:"150px !important"},valueLabel:{display:"-webkit-box",alignItems:"center",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflowWrap:"break-word",fontWeight:500,fontSize:"12px",lineHeight:"14px",letterSpacing:"0.4px",overflow:"hidden",whiteSpace:"normal"}}}));function u(e){var t=r.METRICS_LIST.find((function(t){return t.key===e}));if(!t)return"";var n=t.unitType?" (".concat(i.getUnitDisplay(t.unitType),")"):"";return t.label+n}var s=function(e){var i=e.isTooltipVisible,o=e.currentValue,l=e.metricsKeys,s=e.onChange,p=e.setIsMenuOpen,d=c(),m=r.METRICS_LIST.filter((function(e){return!l.includes(e.key)}));return o!==r.DEFAULT_METRICS_KEY?a.jsx(t.FormControl,{className:d.metricsForm,children:a.jsx(n,{"data-testid":"".concat("MetricsSelect","_select_").concat(o),className:d.metricsSelect,classes:{select:d.primaryText,icon:d.primaryIcon},MenuProps:{paper:d.metricsMenuPaper},value:o,renderValue:function(e){return a.jsx(t.Tooltip,{title:i?u(e):"",children:a.jsx(t.Typography,{className:d.valueLabel,children:u(e)})})},onOpen:function(){return p(!0)},onClose:function(){return p(!1)},onChange:function(e){return s(e.target.value)},children:m.map((function(e){return a.jsx(t.MenuItem,{"data-testid":"".concat("MetricsSelect","_option_").concat(e.key,"MenuItem"),value:e.key,children:e.label},e.key)}))})}):a.jsx(t.Tooltip,{title:i?u(o):"",children:a.jsx(t.Typography,{className:d.valueLabel,children:u(o)})})};s.propTypes={isTooltipVisible:l.default.bool.isRequired,currentValue:l.default.string.isRequired,metricsKeys:l.default.arrayOf(l.default.string).isRequired,onChange:l.default.func.isRequired,setIsMenuOpen:l.default.func.isRequired},exports.MetricsSelect=s;
