"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.Controls = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _Button = _interopRequireDefault(require("@material-ui/core/Button"));

var _styles = require("@material-ui/core/styles");

var _Switch = _interopRequireDefault(require("@material-ui/core/Switch"));

var _FormControlLabel = _interopRequireDefault(require("@material-ui/core/FormControlLabel"));

var _renderUi = require("../../render-ui");

var _classnames = _interopRequireDefault(require("classnames"));

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

var Controls = /*#__PURE__*/function (_React$Component) {
  (0, _inherits2["default"])(Controls, _React$Component);

  var _super = _createSuper(Controls);

  function Controls() {
    (0, _classCallCheck2["default"])(this, Controls);
    return _super.apply(this, arguments);
  }

  (0, _createClass2["default"])(Controls, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          classes = _this$props.classes,
          onClear = _this$props.onClear,
          onWords = _this$props.onWords,
          onSentences = _this$props.onSentences,
          onParagraphs = _this$props.onParagraphs,
          setCorrectMode = _this$props.setCorrectMode,
          onToggleCorrectMode = _this$props.onToggleCorrectMode;
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: classes.controls
      }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
        onClick: onWords,
        className: classes.button,
        size: "small",
        color: "primary",
        disabled: setCorrectMode
      }, "Words"), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
        onClick: onSentences,
        className: classes.button,
        size: "small",
        color: "primary",
        disabled: setCorrectMode
      }, "Sentences"), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
        onClick: onParagraphs,
        className: classes.button,
        size: "small",
        color: "primary",
        disabled: setCorrectMode
      }, "Paragraphs"), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
        className: classes.button,
        size: "small",
        color: "secondary",
        onClick: onClear,
        disabled: setCorrectMode
      }, "Clear")), /*#__PURE__*/_react["default"].createElement(_FormControlLabel["default"], {
        control: /*#__PURE__*/_react["default"].createElement(_Switch["default"], {
          classes: {
            checked: classes.checkedThumb,
            bar: (0, _classnames["default"])((0, _defineProperty2["default"])({}, classes.checkedBar, setCorrectMode))
          },
          checked: setCorrectMode,
          onChange: onToggleCorrectMode
        }),
        label: "Set correct answers"
      }));
    }
  }]);
  return Controls;
}(_react["default"].Component);

exports.Controls = Controls;
(0, _defineProperty2["default"])(Controls, "propTypes", {
  classes: _propTypes["default"].object.isRequired,
  onClear: _propTypes["default"].func.isRequired,
  onWords: _propTypes["default"].func.isRequired,
  onSentences: _propTypes["default"].func.isRequired,
  onParagraphs: _propTypes["default"].func.isRequired,
  setCorrectMode: _propTypes["default"].bool.isRequired,
  onToggleCorrectMode: _propTypes["default"].func.isRequired
});
(0, _defineProperty2["default"])(Controls, "defaultProps", {});

var _default = (0, _styles.withStyles)(function (theme) {
  return {
    button: {
      marginRight: theme.spacing.unit
    },
    controls: {
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'space-between'
    },
    checkedThumb: {
      color: "".concat(_renderUi.color.tertiary(), " !important")
    },
    checkedBar: {
      backgroundColor: "".concat(_renderUi.color.tertiaryLight(), " !important")
    }
  };
})(Controls);

exports["default"] = _default;
//# sourceMappingURL=controls.js.map