"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("prop-types"),r=require("react"),s=require("lodash"),a=require("@material-ui/core"),n=require("../../Search/Search.js");require("../../Search/components/Listbox.js"),require("../../Search/components/Paper.js"),require("../../Search/components/RecentSearches.js");var o=require("../../Search/components/InputAdornmentLeft.js"),i=require("../../Search/components/Groups.js");require("../../Search/components/SelectAllListItem.js");var u=require("../effects/index.js"),l=require("../constants.js"),p=require("../utils/index.js"),c=require("./SelectItem.js"),d=require("react/jsx-runtime");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var m=h(e),g=h(t),f=a.makeStyles({paper:{boxShadow:"0px 3px 10px 0px #00000066"},listbox:{maxHeight:210,"& .MuiAutocomplete-option":{padding:"0px 0px 0px 16px"}},option:{padding:"6px 0","&:hover":{backgroundColor:"initial"}},groupChip:{height:32,padding:0},activeChip:{fontWeight:500,backgroundColor:"#75DB29",color:"#212121",fontSize:10,cursor:"pointer",height:12,textTransform:"uppercase",marginRight:12,letterSpacing:1}}),A=function(e){var t=e["data-testid"],h=e.appKey,g=e.assetFields,A=e.assetType,C=e.company,S=e.currentOption,b=e.currentValue,x=e.defaultValue,q=e.disableClearable,v=e.disabled,I=e.groups,j=e.isNullable,y=e.isRequiredAssetId,T=e.isSecondaryAssetPresent,P=e.label,R=e.multiple,G=e.onActiveAssetIdChange,O=e.onChange,V=e.onGroupChange,F=e.onGroupReset,N=e.onInputReset,k=e.placeholder,L=e.selectedGroup,_=e.setCurrentOption,E=r.useState(""),D=m.default(E,2),H=D[0],K=D[1],M=p.getSearchPlaceholder(A,T),U=f(),w=u.usePrimaryAssetSelectData({appKey:h,assetType:A,company:C,groups:I,isRequiredAssetId:y,assetFields:g,selectedGroup:L,currentValue:b,setCurrentOption:_,onActiveAssetIdChange:G}),z=w.assets,B=w.loading,W=r.useCallback(s.debounce((function(e){K(e)}),200),[]);return d.jsx(n.Search,{classes:{paper:U.paper,listbox:U.listbox,groupChip:U.groupChip},defaultValue:x,disableClearable:q,disabled:v,isNullable:j,loading:B,onGroupChange:V,onGroupReset:F,placeholder:k||M,selectedGroup:L,onChange:function(e,t){O(t)},"data-testid":t,multiple:R,onInputChange:W,onInputReset:function(){N(),_(null)},TextFieldProps:{label:P,value:H,endAdornment:(null==S?void 0:S.status)===l.ACTIVE_STATUS&&d.jsx(a.Chip,{"data-not-migrated-muichip":!0,className:U.activeChip,label:"Active"})},isHiddenAllOption:!0,value:S,options:z,renderCustomOption:function(e,r){var s=e.status,a=e.name,n=e.id,o=r.selected;return d.jsx(c,{className:U.option,assetName:a,multiple:R,selected:o,value:n,status:s&&l.ACTIVE_STATUS,"data-testid":"".concat(t,"_option_").concat(a,"MenuItem")},n)},getOptionLabel:function(e){return e.name||""},GroupsComponent:i,groups:I,InputProps:{startAdornment:d.jsx(o,{})}})};A.propTypes={assetFields:g.default.array,isSecondaryAssetPresent:g.default.bool,"data-testid":g.default.string,onInputReset:g.default.func,onActiveAssetIdChange:g.default.func,placeholder:g.default.string},A.defaultProps={assetFields:[],isSecondaryAssetPresent:!0,"data-testid":"PrimaryAssetEditorAutocomplete",onInputReset:function(){},onActiveAssetIdChange:function(){},placeholder:null},module.exports=A;
//# sourceMappingURL=PrimaryAssetSelect.js.map
