'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _styledComponents = require('styled-components');

var _styledComponents2 = _interopRequireDefault(_styledComponents);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var Wrapper = _styledComponents2.default.div.withConfig({
  displayName: 'RadioButtonInput__Wrapper'
})(['display:flex;flex-direction:row;justify-content:flex-start;align-items:center;width:100%;']);

var BaseRadioButtonInput = _styledComponents2.default.input.attrs({
  type: 'radio'
}).withConfig({
  displayName: 'RadioButtonInput__BaseRadioButtonInput'
})(['opacity:0;width:0px;height:0px;position:absolute;&:checked{& + label{&:before{background:', ';}}}&:disabled{& + label{&:before{cursor:not-allowed;border:1px solid ', ';}}}'], function (props) {
  return props.theme['brand-secondary'];
}, function (props) {
  return props.theme['gray-2'];
});
var Label = _styledComponents2.default.label.withConfig({
  displayName: 'RadioButtonInput__Label'
})(['display:flex;cursor:pointer;align-items:center;&:before{content:\'\';width:12px;height:12px;margin-right:5px;background:white;border-radius:2px;transition:background .2s;border:1px solid ', ';}'], function (props) {
  return props.theme['brand-secondary'];
});

var RadioButtonInput = function RadioButtonInput(props) {
  var name = props.name,
      children = props.children,
      checked = props.checked,
      disabled = props.disabled,
      rest = _objectWithoutProperties(props, ['name', 'children', 'checked', 'disabled']);

  var id = props.props.id;


  return _react2.default.createElement(
    Wrapper,
    null,
    _react2.default.createElement(BaseRadioButtonInput, _extends({ id: id, name: name, checked: checked, disabled: disabled }, rest)),
    _react2.default.createElement(
      Label,
      { htmlFor: id },
      children
    )
  );
};

RadioButtonInput.propTypes = {
  name: _propTypes2.default.string.isRequired,
  props: _propTypes2.default.object.isRequired,
  children: _propTypes2.default.node.isRequired,
  checked: _propTypes2.default.bool,
  disabled: _propTypes2.default.string
};

exports.default = RadioButtonInput;