import{__spreadArray as e}from'./../../../ext-esm/tslib/tslib.es6.js';import{jsxs as t,jsx as r}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 t=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:t.primary.text6,fontSize:"12px",padding:"16px 0 8px 16px"},recentSearchesIcon:{width:"16px",height:"16px",color:t.primary.text6,marginRight:"16px"}}})),s=function(e,t,r){e.setItem(t,JSON.stringify(r))},m=function(c){var m=c.className,d=c.title,u=c.Icon,f=c.onInputChange,h=c.inputValue,x=c.isHidden,g=c.maxCount,v=c.dataStorageKey,S=c.dataStorage,N=c.clearable,b=function(e,t){return JSON.parse(e.getItem(t))||[]}(S,v),I=p();if(n((function(){(null==h?void 0:h.trim())&&!b.includes(h)&&s(S,v,i(e([h],b,!0),g))}),[h]),a(b)||x)return null;var w=null==b?void 0:b.map((function(e){return t("div",{className:I.option,"data-testid":"".concat("RecentSearches","_").concat(e),onClick:function(){!function(e){s(S,v,N?b:b.filter((function(t){return t!==e}))),f(e)}(e)},children:[u&&r(u,{className:I.recentSearchesIcon}),r("div",{className:I.label,children:e})]},e)}));return t("div",{className:o(I.recentSearchesWrapper,m),children:[d&&r(l,{className:I.caption,children:d}),w]})};export{m as default};
