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); }

import React, { memo, forwardRef } from 'react';
import Box from '../Box';
import { useFormControlContext } from '../../composites/FormControl';
import { useRadioGroupState } from '@react-stately/radio';
import { useRadioGroup } from '@react-native-aria/radio';
import { useHasResponsiveProps } from '../../../hooks/useHasResponsiveProps';
export const RadioContext = /*#__PURE__*/React.createContext({});

const RadioGroup = ({
  size,
  colorScheme,
  ...props
}, ref) => {
  const formControlContext = useFormControlContext();
  const state = useRadioGroupState(props);
  const {
    radioGroupProps
  } = useRadioGroup({ ...formControlContext,
    ...props,
    'aria-label': props.accessibilityLabel
  }, state); //TODO: refactor for responsive prop

  if (useHasResponsiveProps({ ...props,
    size,
    colorScheme
  })) {
    return null;
  }

  return /*#__PURE__*/React.createElement(Box, {
    ref: ref
  }, /*#__PURE__*/React.createElement(RadioContext.Provider, {
    value: { ...formControlContext,
      size,
      colorScheme,
      state
    }
  }, /*#__PURE__*/React.createElement(Box, _extends({
    alignItems: "flex-start"
  }, radioGroupProps, props), props.children)));
};

export default /*#__PURE__*/memo( /*#__PURE__*/forwardRef(RadioGroup));
//# sourceMappingURL=RadioGroup.js.map