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