"use strict";

import { useContext } from 'react';
import { TouchableOpacity, View } from 'react-native';
import { ApplicationContext } from "../Context/index.js";
import { Colors } from "../Consts/index.js";
import { Icon } from "../Icon/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 CheckBox = ({
  value,
  disabled = false,
  onChange,
  style,
  label,
  indeterminate
}) => {
  const {
    theme
  } = useContext(ApplicationContext);
  const haveValue = value || indeterminate;
  const iconSource = indeterminate ? 'minus' : 'check';
  let borderColor = theme.colors.text.default;
  let backgroundColor = theme.colors.background.surface;
  if (haveValue) {
    borderColor = theme.colors.primary.default;
    backgroundColor = theme.colors.primary.default;
  }
  if (disabled) {
    borderColor = theme.colors.background.disable;
    backgroundColor = theme.colors.background.surface;
    if (haveValue) {
      borderColor = theme.colors.primary.light;
      backgroundColor = theme.colors.primary.light;
    }
  }
  return /*#__PURE__*/_jsxs(TouchableOpacity, {
    activeOpacity: 0.8,
    onPress: () => {
      onChange?.(!value);
    },
    disabled: disabled,
    style: [styles.container, style],
    children: [/*#__PURE__*/_jsx(View, {
      style: [{
        borderColor,
        backgroundColor
      }, styles.checkbox],
      children: haveValue && /*#__PURE__*/_jsx(Icon, {
        color: Colors.white,
        size: 16,
        name: iconSource
      })
    }), !!label && /*#__PURE__*/_jsx(Text, {
      typography: 'footnote',
      children: label
    })]
  });
};
export { CheckBox };
//# sourceMappingURL=index.js.map