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