"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),t=require("prop-types"),s=require("react"),r=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("./SelectItem.js");require("../../../constants/goals.js"),require("../../../constants/segment.js"),require("../../../constants/alerts.js"),require("../../../constants/apps.js"),require("../../../constants/drillstring.js"),require("../../../constants/completion.js"),require("../../../constants/appPackages.js"),require("../../../constants/notifications.js"),require("../../../constants/feed.js"),require("../../../constants/bha.js");var c=require("../../../constants/assetTypes.js");require("../../../utils/env.js"),require("../../GradientManager/configuration/constants.js");var d=require("react/jsx-runtime");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=h(e),m=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}}),q=function(e){var t=e["data-testid"],h=e.appKey,m=e.assetFields,q=e.assetType,j=e.company,A=e.currentOption,C=e.currentValue,S=e.defaultValue,b=e.disableClearable,x=e.disabled,v=e.groups,I=e.isNullable,y=e.isRequiredAssetId,T=e.label,R=e.multiple,G=e.onActiveAssetIdChange,P=e.onChange,F=e.onGroupChange,O=e.onGroupReset,V=e.onInputReset,k=e.placeholder,E=e.selectedGroup,N=e.setCurrentOption,_=s.useState(""),L=g.default(_,2),M=L[0],D=L[1],H=q===c.ASSET_TYPES.rig.type?"Search Rig...":"Search Pad / Frac Fleet...",K=f(),U=u.usePrimaryAssetSelectData({appKey:h,assetType:q,company:j,groups:v,isRequiredAssetId:y,assetFields:m,selectedGroup:E,currentValue:C,setCurrentOption:N,onActiveAssetIdChange:G}),w=U.assets,z=U.loading,B=s.useCallback(r.debounce((function(e){D(e)}),200),[]);return d.jsx(n,{classes:{paper:K.paper,listbox:K.listbox,groupChip:K.groupChip},defaultValue:S,disableClearable:b,disabled:x,isNullable:I,loading:z,onGroupChange:F,onGroupReset:O,placeholder:k||H,selectedGroup:E,onChange:function(e,t){P(t)},"data-testid":t,multiple:R,onInputChange:B,onInputReset:function(){V(),N(null)},TextFieldProps:{label:T,value:M,endAdornment:(null==A?void 0:A.status)===l.ACTIVE_STATUS&&d.jsx(a.Chip,{"data-not-migrated-muichip":!0,className:K.activeChip,label:"Active"})},isHiddenAllOption:!0,value:A,options:w,renderCustomOption:function(e,s){var r=e.status,a=e.name,n=e.id,o=s.selected;return d.jsx(p,{className:K.option,assetName:a,multiple:R,selected:o,value:n,status:r&&l.ACTIVE_STATUS,"data-testid":"".concat(t,"_option_").concat(a,"MenuItem")},n)},getOptionLabel:function(e){return e.name||""},GroupsComponent:i,groups:v,InputProps:{startAdornment:d.jsx(o,{})}})};q.propTypes={assetFields:m.default.array,"data-testid":m.default.string,onInputReset:m.default.func,onActiveAssetIdChange:m.default.func,placeholder:m.default.string},q.defaultProps={assetFields:[],"data-testid":"PrimaryAssetEditorAutocomplete",onInputReset:function(){},onActiveAssetIdChange:function(){},placeholder:null},module.exports=q;
