function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import { TouchableOpacity } from 'react-native';
import { Typography } from '../../../core/components/Typography/Typography';
import { useStyles } from './styles';
import { SvgXml } from 'react-native-svg';
export let BUTTON_SIZE = /*#__PURE__*/function (BUTTON_SIZE) {
  BUTTON_SIZE["SMALL"] = "small";
  BUTTON_SIZE["LARGE"] = "large";
  return BUTTON_SIZE;
}({});
export const Button = ({
  icon,
  children,
  style,
  iconProps,
  size = BUTTON_SIZE.LARGE,
  type = 'primary',
  textStyle,
  disabled,
  ...props
}) => {
  const {
    styles,
    theme
  } = useStyles();
  const buttonStyles = type === 'inline' ? [styles[`button${capitalize(type)}`], disabled && styles[`button${capitalize(type)}Disabled`], style] : [styles.button, styles[`button${capitalize(type)}`], styles[`button${capitalize(size)}`], icon && children ? styles[`${size}WithIcon`] : null, icon && !children ? styles[`${size}OnlyIcon`] : null, disabled && styles[`button${capitalize(type)}Disabled`], style];
  const textStyles = [styles[`text${capitalize(type)}`], textStyle];
  const iconColor = {
    primary: theme.colors.background,
    secondary: theme.colors.secondary
  };
  const renderChildren = () => {
    if (!children) return null;
    if (typeof children !== 'string') return children;
    if (type === 'inline') return /*#__PURE__*/React.createElement(Typography.Body, {
      style: buttonStyles
    }, children);
    if (size === 'small') {
      return /*#__PURE__*/React.createElement(Typography.CaptionBold, {
        numberOfLines: 1,
        style: textStyles
      }, children);
    }
    return /*#__PURE__*/React.createElement(Typography.BodyBold, {
      numberOfLines: 1,
      style: textStyles
    }, children);
  };
  return /*#__PURE__*/React.createElement(TouchableOpacity, _extends({}, props, {
    disabled: disabled,
    style: buttonStyles,
    activeOpacity: 0.7,
    accessibilityRole: "button"
  }), icon && /*#__PURE__*/React.createElement(SvgXml, _extends({
    xml: icon,
    width: 20,
    height: 20,
    color: iconColor[type]
  }, iconProps)), renderChildren());
};
const capitalize = str => {
  return str.charAt(0).toUpperCase() + str.slice(1);
};
export default Button;
//# sourceMappingURL=Button.js.map