import e from"@babel/runtime/helpers/toConsumableArray";import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useEffect as n}from"react";import{isEmpty as a,take as i}from"lodash";import o from"classnames";import{makeStyles as c,Typography as l}from"@material-ui/core";var p=c((function(e){var r=e.palette;return{recentSearchesWrapper:{paddingBottom:"8px"},option:{display:"flex",alignItems:"center",padding:"0 16px","&:hover":{cursor:"pointer",backgroundColor:"rgba(255, 255, 255, 0.16)"}},label:{lineHeight:"36px",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},caption:{color:r.primary.text6,fontSize:"12px",padding:"16px 0 8px 16px"},recentSearchesIcon:{width:"16px",height:"16px",color:r.primary.text6,marginRight:"16px"}}})),s=function(e,r,t){e.setItem(r,JSON.stringify(t))},m=function(c){var m=c.className,u=c.title,d=c.Icon,f=c.onInputChange,h=c.inputValue,x=c.isHidden,g=c.maxCount,v=c.dataStorageKey,S=c.dataStorage,b=c.clearable,N=function(e,r){return JSON.parse(e.getItem(r))||[]}(S,v),I=p();if(n((function(){null!=h&&h.trim()&&!N.includes(h)&&s(S,v,i([h].concat(e(N)),g))}),[h]),a(N)||x)return null;var y=null==N?void 0:N.map((function(e){return r("div",{className:I.option,"data-testid":"".concat("RecentSearches","_").concat(e),onClick:function(){!function(e){s(S,v,b?N:N.filter((function(r){return r!==e}))),f(e)}(e)},children:[d&&t(d,{className:I.recentSearchesIcon}),t("div",{className:I.label,children:e})]},e)}));return r("div",{className:o(I.recentSearchesWrapper,m),children:[u&&t(l,{className:I.caption,children:u}),y]})};export{m as default};
//# sourceMappingURL=RecentSearches.js.map
