import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React from 'react';
import PropTypes from 'prop-types';
import Checkbox from 'react-bootstrap/lib/Checkbox';
import { isIndeterminate } from './FormControl';
export var PureCheckbox =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(PureCheckbox, _React$Component);

  function PureCheckbox() {
    var _this;

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;

    _defineProperty(_assertThisInitialized(_this), "input", {});

    return _this;
  }

  var _proto = PureCheckbox.prototype;

  _proto.render = function render() {
    var _this2 = this;

    var _this$props = this.props,
        hiddenLabel = _this$props.hiddenLabel,
        children = _this$props.children,
        label = _this$props.label,
        inputRef = _this$props.inputRef,
        props = _objectWithoutPropertiesLoose(_this$props, ["hiddenLabel", "children", "label", "inputRef"]);

    if (!inputRef) {
      inputRef = function inputRef(ref) {
        return _this2.input = ref;
      };
    }

    this.input.indeterminate = isIndeterminate(props.checked);
    return React.createElement("div", {
      "data-test-automation-id": "checkbox"
    }, React.createElement(Checkbox, _extends({}, props, {
      "data-test-automation-id": "input",
      inputRef: inputRef
    }), React.createElement("span", {
      "data-test-automation-id": "label",
      className: !!hiddenLabel ? 'sr-only' : null
    }, children || label)));
  };

  return PureCheckbox;
}(React.Component);

_defineProperty(PureCheckbox, "propTypes", {
  hiddenLabel: PropTypes.bool,
  children: PropTypes.node,
  inputRef: PropTypes.func,
  label: PropTypes.string
});

_defineProperty(PureCheckbox, "defaultProps", {
  hiddenLabel: false,
  children: '',
  inputRef: null,
  label: ''
});