'use strict';
import { jsxs, jsx } from 'react/jsx-runtime';
import { Select, SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectItem } from '../../../fd-component-toolbox/select/Select.js';
import { enumFilterTypes } from './filter-constants.js';
import { elementSuffixes } from '../../../../fd-toolbox/constants/element-suffixes.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function EnumFlagFilter({
  rightHandResult,
  displayName,
  propertyMeta,
  onOperatorTypeChangeCallback,
  onRightHandChangeCallback,
  inputId,
  onOpenChangeCallback,
  buttonRef
}) {
  return /* @__PURE__ */jsxs("div", {
    className: "flex items-center",
    children: [/* @__PURE__ */jsx("div", {
      className: "mr-1 w-10",
      children: /* @__PURE__ */jsxs(Select, {
        value: rightHandResult,
        onValueChange: value => onOperatorTypeChangeCallback(value ?? void 0),
        children: [/* @__PURE__ */jsx(SelectTrigger, {
          id: propertyMeta.name + elementSuffixes.filterOperator,
          variant: "float",
          children: /* @__PURE__ */jsx(SelectValue, {})
        }), /* @__PURE__ */jsx(SelectContent, {
          children: /* @__PURE__ */jsx(SelectGroup, {
            children: enumFilterTypes.map(item => /* @__PURE__ */jsx(SelectItem, {
              value: item.type,
              children: item.text
            }, `${item.text}_${item.type}`))
          })
        })]
      })
    }), /* @__PURE__ */jsx("div", {
      className: "inline-block flex-1",
      children: /* @__PURE__ */jsxs(Select, {
        value: displayName,
        onValueChange: value => onRightHandChangeCallback(value ?? void 0),
        onOpenChange: onOpenChangeCallback,
        children: [/* @__PURE__ */jsx(SelectTrigger, {
          ref: buttonRef,
          id: inputId,
          label: propertyMeta.displayName,
          shouldAnimate: !!rightHandResult && rightHandResult !== "None",
          variant: "float",
          children: /* @__PURE__ */jsx(SelectValue, {
            className: "mt-0 w-full",
            placeholder: displayName
          })
        }), /* @__PURE__ */jsx(SelectContent, {
          children: /* @__PURE__ */jsx(SelectGroup, {
            children: propertyMeta.enumerationValues?.map((value, index) => /* @__PURE__ */jsx(SelectItem, {
              className: "min-h-6 whitespace-nowrap",
              value: propertyMeta.enumerationDisplayName[index],
              children: propertyMeta.enumerationDisplayName[index]
            }, value))
          })
        })]
      })
    })]
  });
}
__name(EnumFlagFilter, "EnumFlagFilter");

export { EnumFlagFilter };
