text: "use strict";
  
  exports.__esModule = true;
  exports.default = void 0;
  
  var _propTypes = _interopRequireDefault(require("prop-types"));
  
  var _react = _interopRequireDefault(require("react"));
  
  var _v = _interopRequireDefault(require("uuid/v4"));
  
  var _airbnbPropTypes = require("airbnb-prop-types");
  
  var _BaseRadioButton = _interopRequireDefault(require("../private/BaseRadioButton"));
  
  var _FormField = _interopRequireWildcard(require("../FormField"));
  
  var _Text = _interopRequireDefault(require("../Text"));
  
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function _extends() { _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; }; return _extends.apply(this, arguments); }
  
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  const stateProp = (0, _airbnbPropTypes.mutuallyExclusiveTrueProps)('checked', 'indeterminate');
  
  /** A controlled radio button field. */
  class RadioButton extends _react.default.Component {
    constructor() {
      super(...arguments);
  
      _defineProperty(this, "state", {
        // Support for RadioButtonController
        id: this.props.id || (0, _v.default)()
      });
    }
  
    render() {
      const {
        children,
        fieldProps,
        inputProps
      } = (0, _FormField.partitionFieldProps)(this.props);
  
      const {
        topAlign
      } = inputProps,
            restProps = _objectWithoutPropertiesLoose(inputProps, ["topAlign"]);
  
      const {
        id
      } = this.state;
      const {
        hideLabel
      } = fieldProps;
      return _react.default.createElement(_FormField.default, _extends({}, fieldProps, {
        inline: true,
        renderBeforeLabel: true,
        renderLargeLabel: true,
        stretchLabel: true,
        id: id,
        hideLabel: fieldProps.hideLabel || inputProps.button,
        renderFullWidth: inputProps.button,
        topAlign: topAlign
      }), _react.default.createElement(_BaseRadioButton.default, _extends({}, restProps, {
        id: id,
        hideLabel: hideLabel
      }), children || _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_Text.default, {
        bold: true
      }, fieldProps.label), fieldProps.labelDescription && _react.default.createElement(_Text.default, null, fieldProps.labelDescription))));
    }
  
  }
  
  exports.default = RadioButton;
  
  _defineProperty(RadioButton, "defaultProps", {
    button: false,
    checked: false,
    children: null,
    indeterminate: false,
    topAlign: false
  });
  
  _defineProperty(RadioButton, "propTypes", {
    value: _propTypes.default.string.isRequired,
    topAlign: _propTypes.default.bool,
    checked: stateProp,
    indeterminate: stateProp
  });