'use strict';
import { jsxs, jsx } from 'react/jsx-runtime';
import { Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectItem } from '../../../../fd-component-toolbox/select/Select.js';
import { MultiSelect, MultiselectTrigger, MultiselectInput, MultiselectContent, MultiselectList, MultiselectItem } from '../../../../fd-component-toolbox/multiselect/Multiselect.js';
import { cn } from '../../../../../fd-toolbox/lib/utils.js';
import { getFilterShortValue } from '../filter-display.js';
import { elementSuffixes } from '../../../../../fd-toolbox/constants/element-suffixes.js';
import { enumFilterTypes } from '../filter-constants.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function EnumFilter({
  filterOperatorType,
  onOperatorTypeChange,
  rightHandResult,
  onRightHandChange,
  displayValues,
  disableEnumFilter,
  displayName,
  propertyMeta,
  inputId,
  onOpenChangeCallback,
  ref
}) {
  return /* @__PURE__ */jsxs("div", {
    className: "flex items-center",
    children: [/* @__PURE__ */jsx("div", {
      className: "mr-1 w-full max-w-9",
      children: /* @__PURE__ */jsxs(Select, {
        value: filterOperatorType,
        onValueChange: value => onOperatorTypeChange(value ?? void 0),
        children: [/* @__PURE__ */jsx(SelectTrigger, {
          id: propertyMeta.name + elementSuffixes.filterOperator,
          variant: "float",
          className: "flex justify-center gap-px",
          size: "short",
          children: /* @__PURE__ */jsx(SelectValue, {
            children: getFilterShortValue(enumFilterTypes, filterOperatorType)
          })
        }), /* @__PURE__ */jsx(SelectContent, {
          children: /* @__PURE__ */jsx(SelectGroup, {
            children: enumFilterTypes.map(item => /* @__PURE__ */jsx(SelectItem, {
              value: item.type,
              className: "min-h-6",
              children: item.text
            }, item.type))
          })
        })]
      })
    }), /* @__PURE__ */jsx("div", {
      className: "inline-block flex-1",
      children: /* @__PURE__ */jsxs(MultiSelect, {
        id: inputId,
        values: rightHandResult,
        onValuesChange: onRightHandChange,
        displayValues,
        disabled: disableEnumFilter,
        variant: "float",
        onOpenChange: onOpenChangeCallback,
        ref,
        children: [/* @__PURE__ */jsx(MultiselectTrigger, {
          children: /* @__PURE__ */jsx(MultiselectInput, {
            id: inputId,
            className: "mt-0 w-full",
            placeholder: displayName,
            animatedPlaceholder: displayName
          })
        }), /* @__PURE__ */jsx(MultiselectContent, {
          children: /* @__PURE__ */jsx(MultiselectList, {
            className: "z-20",
            children: propertyMeta.enumerationValues?.map(value => /* @__PURE__ */jsx(MultiselectItem, {
              className: cn("min-h-6 whitespace-nowrap"),
              value: value.toString(),
              children: propertyMeta.enumerationDisplayName?.[Number(value)]
            }, value.toString()))
          })
        })]
      })
    })]
  });
}
__name(EnumFilter, "EnumFilter");

export { EnumFilter };
