'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _class, _temp2;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _reactRedux = require('react-redux');

var _reactBootstrap = require('react-bootstrap');

var _lodash = require('lodash');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const { config } = window;

function _ref(state, props) {
  return {
    value: (0, _lodash.get)(state.config, props.configName, props.defaultVal),
    configName: props.configName,
    undecided: props.undecided,
    label: props.label
  };
}

const CheckboxLabelConfig = (0, _reactRedux.connect)(() => {
  return _ref;
})((_temp2 = _class = class checkboxLabelConfig extends _react.Component {
  constructor(...args) {
    var _temp;

    return _temp = super(...args), this.handleChange = () => {
      config.set(this.props.configName, !this.props.value);
    }, _temp;
  }

  render() {
    return _react2.default.createElement(
      'div',
      { className: this.props.undecided ? 'undecided-checkbox-inside' : '' },
      _react2.default.createElement(
        _reactBootstrap.Checkbox,
        {
          disabled: this.props.undecided,
          checked: this.props.undecided ? false : this.props.value,
          onChange: this.props.undecided ? null : this.handleChange },
        this.props.label
      )
    );
  }
}, _class.propTypes = {
  label: _propTypes2.default.string,
  configName: _propTypes2.default.string,
  value: _propTypes2.default.bool,
  undecided: _propTypes2.default.bool
}, _temp2));

exports.default = CheckboxLabelConfig;
module.exports = exports['default'];