"use strict";

import { useContext } from 'react';
import { TouchableOpacity, View } from 'react-native';
import { ApplicationContext } from "../Context/index.js";
import { Spacing, Styles } from "../Consts/index.js";
import { Text } from "../Text/index.js";
import styles from "./styles.js";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const Radio = ({
  value,
  groupValue,
  disabled,
  onChange,
  label,
  style
}) => {
  const {
    theme
  } = useContext(ApplicationContext);
  const selected = value === groupValue;
  let disabledStyle = {};
  let checkBoxStyle = {
    borderWidth: 2,
    borderColor: theme.colors.text.default
  };
  if (selected) {
    checkBoxStyle = {
      borderWidth: 6,
      borderColor: theme.colors.primary.default
    };
  }
  if (disabled) {
    disabledStyle = {
      borderColor: selected ? theme.colors.primary.container : theme.colors.text.disable
    };
  }
  return /*#__PURE__*/_jsxs(TouchableOpacity, {
    onPress: () => {
      onChange?.(value);
    },
    disabled: disabled,
    style: [style, Styles.rowCenter],
    children: [/*#__PURE__*/_jsx(View, {
      style: [styles.radio, checkBoxStyle, disabledStyle, label && {
        marginRight: Spacing.XS
      }]
    }), !!label && /*#__PURE__*/_jsx(Text, {
      typography: 'footnote',
      children: label
    })]
  });
};
export { Radio };
//# sourceMappingURL=index.js.map