'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
require('react');
var formik = require('formik');
var ramda = require('ramda');
var Radio = require('../Radio.js');
var jsxRuntime = require('react/jsx-runtime');
require('classnames');
require('../Label.js');
require('@bigbinary/neeto-icons/Help');
require('../Button.js');
require('react-router-dom');
require('../Spinner.js');
require('../Tooltip.js');
require('@tippyjs/react');
require('tippy.js');
require('@bigbinary/neeto-hotkeys');
require('../overlayManager.js');
require('@babel/runtime/helpers/classCallCheck');
require('@babel/runtime/helpers/createClass');
require('@bigbinary/neeto-cist');
require('qs');
require('../index-BgzkP01c.js');
require('@babel/runtime/helpers/toConsumableArray');
require('dayjs');
require('dayjs/plugin/localeData');
require('dayjs/plugin/utc');
require('dayjs/plugin/weekday');
require('dayjs/plugin/weekOfYear');
require('i18next');
require('../usePrefersReducedMotion-D2Ck84HM.js');
require('../Popover.js');
require('../Typography.js');
require('../useId-DXHUzdxd.js');
require('../index-CNZKW5X0.js');
require('../en-B1i-pQJm.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
var _slicedToArray__default = /*#__PURE__*/_interopDefault(_slicedToArray);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);

var _excluded = ["label", "name", "className"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var RadioGroup = function RadioGroup(_ref) {
  var label = _ref.label,
    name = _ref.name,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? "" : _ref$className,
    props = _objectWithoutProperties__default.default(_ref, _excluded);
  var _useFormikContext = formik.useFormikContext(),
    setFieldValue = _useFormikContext.setFieldValue,
    _useFormikContext$sta = _useFormikContext.status,
    status = _useFormikContext$sta === void 0 ? {} : _useFormikContext$sta,
    setStatus = _useFormikContext.setStatus;
  var _useField = formik.useField({
      name: name
    }),
    _useField2 = _slicedToArray__default.default(_useField, 2),
    field = _useField2[0],
    meta = _useField2[1];
  var fieldStatus = formik.getIn(status, name);
  var fieldProps = _objectSpread(_objectSpread({}, field), {}, {
    onChange: function onChange(event) {
      setStatus(ramda.dissoc(name, status));
      setFieldValue(name, event.target.value);
    }
  });
  return /*#__PURE__*/jsxRuntime.jsx(Radio, _objectSpread({
    error: meta.touched ? meta.error || fieldStatus : ""
  }, _objectSpread(_objectSpread({
    className: className,
    label: label
  }, fieldProps), props)));
};
RadioGroup.Item = Radio.Item;

module.exports = RadioGroup;
//# sourceMappingURL=Radio.js.map
