function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React from 'react';
import PropTypes from 'prop-types';
import isEmpty from 'lodash/fp/isEmpty';
import map from 'lodash/fp/map';
import Provider, { GetTranslateFromContext } from '../../atom/provider';
import ToolTip from '../../atom/tooltip';
import InputSwitch from '../../atom/input-switch';
import style from './style.css';
const Settings = (props, legacyContext) => {
  const translate = GetTranslateFromContext(legacyContext);
  const {
    label,
    description,
    moreInfoAriaLabel,
    ...settings
  } = props;
  return /*#__PURE__*/React.createElement("div", {
    className: style.settings
  }, /*#__PURE__*/React.createElement(InputSwitch, _extends({}, settings, {
    'aria-label': label
  })), /*#__PURE__*/React.createElement("span", {
    className: style.label,
    tabIndex: 0
  }, label), isEmpty(description) ? null : /*#__PURE__*/React.createElement(ToolTip, {
    TooltipContent: description,
    closeToolTipInformationTextAriaLabel: translate('close_tooltip_information'),
    "data-testid": "user-preferences-tooltip",
    "aria-label": moreInfoAriaLabel,
    iconContainerClassName: style.infoIconTooltip,
    fontSize: 12
  }));
};
Settings.propTypes = process.env.NODE_ENV !== "production" ? {
  ...InputSwitch.propTypes,
  label: PropTypes.string.isRequired,
  description: PropTypes.string
} : {};
Settings.contextTypes = {
  translate: Provider.childContextTypes.translate
};
const UserPreferences = props => {
  const {
    preferences,
    moreInfoAriaLabel,
    groupAriaLabel
  } = props;
  return /*#__PURE__*/React.createElement("form", null, /*#__PURE__*/React.createElement("div", {
    className: style.preferences,
    role: "group",
    "aria-label": groupAriaLabel,
    tabIndex: 0
  }, map(settings => /*#__PURE__*/React.createElement(Settings, _extends({}, settings, {
    key: settings.label,
    moreInfoAriaLabel: moreInfoAriaLabel
  })), preferences)));
};
UserPreferences.propTypes = process.env.NODE_ENV !== "production" ? {
  preferences: PropTypes.arrayOf(PropTypes.shape(Settings.propTypes)),
  moreInfoAriaLabel: PropTypes.string,
  groupAriaLabel: PropTypes.string
} : {};
export default UserPreferences;
//# sourceMappingURL=index.js.map