import React from 'react';
import { useTranslation } from '../../hooks/use-translation';
import { Button, ACCENT_TYPES } from '../../button';
import { Badge } from '../../badge';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export function TableFiltersBody({
  filters,
  children,
  isOpen,
  onFilterClose,
  onClearAllFilters,
  onCancel,
  onApply,
  localizationText,
  cancelButtonProps = {},
  applyButtonProps = {},
  clearButtonProps = {}
}) {
  const {
    t
  } = useTranslation();
  return /*#__PURE__*/_jsxs("div", {
    className: "table-filter-body",
    children: [!!filters.length && /*#__PURE__*/_jsxs("div", {
      className: "table-filter-applied",
      children: [/*#__PURE__*/_jsx("span", {
        className: "table-filter-title",
        children: localizationText?.appliedFilters || t('Filters applied:')
      }), filters.map(item => /*#__PURE__*/_jsx(Badge, {
        badgeContainerTestId: item.badgeContainerTestId,
        plain: true,
        onClose: () => onFilterClose(item),
        children: item.label
      }, item.key)), /*#__PURE__*/_jsx(Button, {
        onClick: onClearAllFilters,
        accentType: ACCENT_TYPES.GHOST,
        ...clearButtonProps,
        children: localizationText?.clearFilters ?? t('Clear all')
      })]
    }), isOpen && /*#__PURE__*/_jsxs("div", {
      className: "table-filter-active",
      children: [/*#__PURE__*/_jsx("div", {
        children: children
      }), /*#__PURE__*/_jsxs("div", {
        className: "table-filter-buttons",
        children: [/*#__PURE__*/_jsx(Button, {
          onClick: onCancel,
          accentType: ACCENT_TYPES.SECONDARY,
          ...cancelButtonProps,
          children: localizationText?.cancelFilters ?? t('Cancel')
        }), /*#__PURE__*/_jsx(Button, {
          onClick: onApply,
          accentType: ACCENT_TYPES.PRIMARY,
          ...applyButtonProps,
          children: localizationText?.applyFilters ?? t('Apply filters')
        })]
      })]
    })]
  });
}