import e from"@babel/runtime/helpers/slicedToArray";import{useState as t,useRef as o}from"react";import r from"prop-types";import i from"lodash/get";import{withStyles as n,Tooltip as l,makeStyles as a,Input as s,Chip as c}from"@material-ui/core";import p from"@material-ui/icons/Close";import u from"./AssetTypesSection.js";import d from"./AssetResultSection.js";import{useAssetsData as f}from"./effects/useAssetsData.js";import{SEARCH_CATEGORIES as m,CATEGORY_KEY_VALUES as h}from"./constants.js";import{jsxs as x,jsx as b}from"react/jsx-runtime";var g=n((function(){return{tooltip:{backgroundColor:"#414141",color:"#ffffff",fontSize:"11px",lineHeight:"16px",borderRadius:"4px",boxShadow:"0px 4px 4px rgba(0, 0, 0, 0.12)",padding:"4px"}}}))(l),y=a((function(e){return{wrapper:{width:function(e){var t=e.isTablet,o=e.isMobile;return!t&&o?"100%":"472px"},height:function(e){var t=e.isTablet,o=e.isMobile;return!t&&o&&"100%"},display:"flex",flexDirection:"column",padding:"12px 16px"},inputWrapper:{display:"flex",width:"auto",marginBottom:"16px",alignItems:"center",flexWrap:"nowrap",justifyContent:"space-between"},selectedChip:{width:"fit-content",marginBottom:"10px",fontSize:"14px"},selectedChipDeleteIcon:{width:"16px",height:"16px",color:e.palette.primary.text6,"&:hover":{color:e.palette.primary.text1}},disabledIcon:{width:"16px",height:"16px",color:e.palette.primary.text6,opacity:.4},closeIconButton:{padding:0,"&:hover $closeIcon":{color:e.palette.primary.text1}},searchInput:{width:"100%",display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center",borderBottom:"2px solid #03BCD4"},closeIcon:{color:e.palette.primary.text6,fontSize:"18px"},deleteIcon:{color:e.palette.primary.text1,height:"16px"}}})),C=function(r){var n=r.onClickAsset,l=r.company,a=r.isTablet,C=r.isMobile,v=t(null),I=e(v,2),w=I[0],A=I[1],T=t(null),S=e(T,2),R=S[0],j=S[1],k=t(1),D=e(k,2),M=D[0],B=D[1],q=y({isTablet:a,isMobile:C}),z=o(),N=f(R,w,M,l),W=e(N,2),K=W[0],P=W[1];return x("div",{className:q.wrapper,children:[b("div",{className:q.inputWrapper,children:x("div",{className:q.searchInput,children:[b(s,{"data-testid":"".concat("AutoCompleteAssetSearch","_searchInput"),inputRef:z,autoFocus:!0,disableUnderline:!0,fullWidth:!0,value:R||"",placeholder:"Search ".concat(i(m,[w,"labelPlural"],"assets"),"..."),onChange:function(e){var t=e.target.value;j(t),B(1)},onKeyUp:function(t){var o=t.target.value,r=t.keyCode,i=h.find((function(t){var r=e(t,2);return r[0],r[1].autoCategorizedKey===o.trim().toLowerCase()}));if(i&&(13===r||32===r))return j(""),A(i[0]),void B(1);""===o&&8===r&&(A(null),B(1))}}),b(g,{title:"Clear",children:b(p,{className:w||R?q.selectedChipDeleteIcon:q.disabledIcon,onClick:function(){z.current.focus(),j(""),A(null),B(1)}})})]})}),w&&b(c,{"data-not-migrated-muichip":!0,classes:{root:q.selectedChip,deleteIcon:q.deleteIcon},color:"primary",label:i(m,[w,"labelPlural"],"Assets"),deleteIcon:b(p,{}),onDelete:function(){A(null),B(1)}}),!w&&!R&&b(u,{onClickAssetType:function(e){z.current.focus(),A(e),B(1)}}),(w||R)&&b(d,{loading:K,page:M,groupedAssets:P,onClickAsset:n,onScrollReached:function(e){"top"===e&&M>1&&B((function(e){return e-1})),"bottom"===e&&B((function(e){return e+1}))},isTablet:a,isMobile:C})]})};C.propTypes={company:r.number.isRequired,onClickAsset:r.func.isRequired,isTablet:r.bool.isRequired,isMobile:r.bool.isRequired};export{C as default};
//# sourceMappingURL=AutoCompleteAssetSearch.js.map
