import _toString from "lodash/fp/toString";
import _size from "lodash/fp/size";
import _pipe from "lodash/fp/pipe";
import _map from "lodash/fp/map";
import _filter from "lodash/fp/filter";
import React from 'react';
import Chip from '../../atom/chip';
import Title from '../../atom/title';
import Tag from '../../atom/tag';
import ButtonLink from '../../atom/button-link';
import Provider, { GetTranslateFromContext } from '../../atom/provider';
import propTypes from './prop-types';
import style from './style.css';
const FilterChip = (props, context) => {
  const {
    options,
    title,
    onClear
  } = props;
  const selectedFiltersCount = _pipe(_filter({
    selected: true
  }), _size)(options);
  const hasSelectedFilters = selectedFiltersCount > 0;
  const translate = GetTranslateFromContext(context);
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
    className: style.header
  }, /*#__PURE__*/React.createElement("div", {
    className: style.titleContainer
  }, /*#__PURE__*/React.createElement(Title, {
    title: title
  }), hasSelectedFilters ? /*#__PURE__*/React.createElement(Tag, {
    label: _toString(selectedFiltersCount),
    type: "info",
    size: "S"
  }) : null), hasSelectedFilters ? /*#__PURE__*/React.createElement("div", {
    className: style.buttonContainer
  }, /*#__PURE__*/React.createElement(ButtonLink, {
    customStyle: {
      fontWeight: 'normal',
      padding: 0
    },
    label: translate('clear'),
    type: "text",
    "data-name": "filter-chip-clear-button",
    "aria-label": "filter chip clear button",
    onClick: onClear
  })) : null), /*#__PURE__*/React.createElement("div", {
    className: style.optionsContainer
  }, _map(({
    icon,
    label,
    onClick,
    type,
    selected
  }) => {
    function handleClick() {
      onClick(type);
    }
    return /*#__PURE__*/React.createElement(Chip, {
      leftIcon: icon,
      text: label,
      key: label,
      selected: selected,
      onClick: handleClick
    });
  }, options)));
};
FilterChip.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
FilterChip.contextTypes = {
  translate: Provider.childContextTypes.translate
};
export default FilterChip;
//# sourceMappingURL=index.js.map