"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _proptypes = require("../../util/proptypes");
var _checkbox = _interopRequireDefault(require("../../atom/checkbox"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const TitledCheckbox = props => {
  const {
    choice,
    background,
    onToggle
  } = props;
  const label = choice.name;
  const handleChange = (0, _react.useMemo)(() => () => onToggle(choice), [onToggle, choice]);
  return /*#__PURE__*/_react.default.createElement("label", {
    className: _style.default.defaultStyle
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.box,
    style: {
      background: background || '#3d3d3d'
    }
  }, choice.selected ? /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyCheck, {
    className: _style.default.icon
  }) : null, /*#__PURE__*/_react.default.createElement(_checkbox.default, {
    className: _style.default.input,
    checked: choice.selected,
    onChange: handleChange,
    "data-name": label
  })), /*#__PURE__*/_react.default.createElement("span", {
    title: label,
    className: _style.default.label
  }, label));
};
TitledCheckbox.propTypes = process.env.NODE_ENV !== "production" ? {
  choice: _propTypes.default.shape({
    selected: _propTypes.default.bool.isRequired,
    name: _propTypes.default.string.isRequired,
    value: _propTypes.default.string
  }).isRequired,
  background: _proptypes.ColorPropType,
  onToggle: _propTypes.default.func.isRequired
} : {};
var _default = exports.default = TitledCheckbox;
//# sourceMappingURL=index.js.map