import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useMemo as o,useRef as n,useEffect as r,useCallback as i}from"react";import a from"lodash/startCase";import{StatusOptions as s}from"../../../../constants.js";import{useIsAllWellsLoading as l}from"../../../../hooks/useIsAllWellsLoading.js";import{useMultiSelectDraftValue as u}from"../../hooks/useMultiSelectDraftValue.js";import{VirtualizedListBox as c}from"../VirtualizedListBox/VirtualizedListBox.js";import p from"../../Filter.module.css.js";import{AutocompleteNext as m}from"../../../../../../componentsV2/Autocomplete/Autocomplete.js";import{Chip as d}from"../../../../../../componentsV2/Chip/Chip.js";import{TextMiddleTruncated as f}from"../../../../../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.js";import"../../../../../../componentsV2/TextMiddleTruncated/TextMiddleTruncated.constants.js";import v from"../../../../../../effects/useOutsideClick.js";var h=function(e){var o=e.color;return t("div",{className:p.statusIcon,style:{background:o}})};h.displayName="StatusIcon";var C=function(C){var j=C.value,x=C.availableStatuses,T=C.onChange,I=C.testId,N=C.dropdownClassName,y=l(),b=x?s.filter((function(t){return x.includes(t.value)})):s,g=o((function(){return b.map((function(e){return{id:e.value,title:a(e.value),prefix:t(h,{color:e.color})}}))}),[b]),k=o((function(){return g.map((function(t){return t.id}))}),[g]),V=n(null),A=u({value:j,optionIds:k,onChange:T}),M=A.value,S=A.onChange,w=A.startInteraction,O=A.endInteraction;v(V,(function(){return O()}),[".MuiAutocomplete-popper"]),r((function(){y&&O()}),[y,O]);var z=i((function(){y||w()}),[y,w]),B=i((function(t){var e=t.map((function(t){return t.id}));S(e)}),[S]),F=i((function(t){return function(e){e.stopPropagation(),S([t])}}),[S]),L=i((function(o){return e("div",{className:p.optionRow,children:[t(f,{className:p.optionTitle,children:o.title}),t(d,{state:"neutral",size:"small",shape:"square",className:p.onlyButton,onClick:F(o.id),children:"Only"})]})}),[F]),D=i((function(t){"Escape"!==t.key&&"Tab"!==t.key||O()}),[O]);return t("div",{ref:V,onFocusCapture:z,onKeyDownCapture:D,children:t(m,{label:"Status",options:g,value:y?[]:M,onChange:B,renderOption:L,multiple:!0,useAllOption:!0,clearable:!1,testId:I,dropdownClassName:N,listboxComponent:c,elementsClassNames:{input:p.filterInput},disabled:y,placeholder:y?"All":void 0})})};C.displayName="StatusFilterSelect";export{C as StatusFilterSelect};
//# sourceMappingURL=StatusFilterSelect.js.map
