import e from"@babel/runtime/helpers/defineProperty";import{useRef as r,useMemo as t,useEffect as n}from"react";import{uniq as a}from"lodash";import{makeStyles as o,MenuItem as i}from"@material-ui/core";import{jsx as p,jsxs as c}from"react/jsx-runtime";function u(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function l(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?u(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}var b=o((function(e){return{content:{width:"342px",maxHeight:"166px",borderRadius:"4px",marginLeft:"50px",marginTop:"-16px",overflowY:"auto",background:e.palette.background.b9,boxShadow:"0px 5px 5px -3px rgb(0 0 0 / 20%), 0px 8px 10px 1px rgb(0 0 0 / 14%), 0px 3px 14px 2px rgb(0 0 0 / 12%)","&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-corner":{background:"rgba(0, 0, 0, 0)"},"&::-webkit-scrollbar-thumb":{backgroundColor:"rgba(164, 164, 167, 0.7)",borderRadius:"10px",border:"5px solid rgba(0, 0, 0, 0.01)",backgroundClip:"padding-box"},zIndex:999},label:{background:e.palette.background.b9},labelWrapper:{height:"24px",padding:"0 4px",background:e.palette.background.b9},itemWrapper:{display:"flex",alignItems:"center"},unit:{color:e.palette.primary.text7,marginLeft:"4px"}}}));function d(e){var o=e.suggestions,u=e.keyStr,d=e.onAddSuggestion,s=e.onChangeHeight,g=b(),f=r(),m=t((function(){var e=o.filter((function(e){return e.label.toUpperCase().includes(u.toUpperCase())})),r=a(e.map((function(e){return e.type}))).reduce((function(r,t){var n=e.filter((function(e){return e.type===t}));return r.concat([{value:t,label:t,isSubHeader:!0}]).concat(n.map((function(e){return l(l({},e),{},{value:e.key})})))}),[]);return r.length?r:[{value:"noOptions",label:"No Options",isSubHeader:!0}]}),[o,u]);n((function(){f.current&&s(f.current.clientHeight)}),[o,u,f.current]);var x=function(e){var r=e.label,t=e.isSubHeader,n=e.unit;return t?p("div",{className:g.labelWrapper,children:p("span",{children:r})}):c("div",{className:g.itemWrapper,children:[p("span",{children:r}),!!n&&p("span",{className:g.unit,children:n})]})};return p("div",{className:g.content,ref:f,children:m.map((function(e){return p(i,{selected:!1,disabled:e.isSubHeader,onClick:function(){return d(e.value)},children:x(e)},e.value)}))})}export{d as default};
//# sourceMappingURL=SuggestionsMenu.js.map
