"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Icon = exports.Loading = exports.TextButton = exports.ButtonWrapper = exports.Touchable = void 0;
const tslib_1 = require("tslib");
const native_1 = tslib_1.__importDefault(require("styled-components/native"));
const theme_toolkit_1 = require("@platformbuilders/theme-toolkit");
const Icon_1 = tslib_1.__importDefault(require("../Icon"));
const LoadingIndicator_1 = tslib_1.__importDefault(require("../LoadingIndicator"));
const Touchable_1 = tslib_1.__importDefault(require("../Touchable"));
const Typography_1 = tslib_1.__importDefault(require("../Typography"));
const borderWidthSmall = (0, theme_toolkit_1.getTheme)('borderWidth.sm');
const backgroundElevation = (0, theme_toolkit_1.getTheme)('background.z1');
const textMain = (0, theme_toolkit_1.getTheme)('text.main');
const brandPrimary = (0, theme_toolkit_1.getTheme)('brand.primary.main');
const brandPrimaryContrast = (0, theme_toolkit_1.getTheme)('brand.primary.contrast');
const brandSecondary = (0, theme_toolkit_1.getTheme)('brand.secondary.main');
const brandSecondaryContrast = (0, theme_toolkit_1.getTheme)('brand.secondary.contrast');
const brandTertiary = (0, theme_toolkit_1.getTheme)('brand.tertiary.main');
const brandTertiaryContrast = (0, theme_toolkit_1.getTheme)('brand.tertiary.contrast');
const brandAccent = (0, theme_toolkit_1.getTheme)('brand.accent.light');
const brandAccentContrast = (0, theme_toolkit_1.getTheme)('brand.accent.contrast');
const infoMain = (0, theme_toolkit_1.getTheme)('info.main');
const infoContrast = (0, theme_toolkit_1.getTheme)('info.contrast');
const dangerMain = (0, theme_toolkit_1.getTheme)('danger.main');
const dangerContrast = (0, theme_toolkit_1.getTheme)('danger.contrast');
const warningMain = (0, theme_toolkit_1.getTheme)('warning.main');
const warningContrast = (0, theme_toolkit_1.getTheme)('warning.contrast');
const spacingSm = (0, theme_toolkit_1.getTheme)('spacing.sm');
const spacingMd = (0, theme_toolkit_1.getTheme)('spacing.md');
const isLeftIcon = (0, theme_toolkit_1.ifStyle)('leftIcon');
const isRightIcon = (0, theme_toolkit_1.ifStyle)('rightIcon');
const hasBorder = (0, theme_toolkit_1.ifStyle)('hasBorder');
const isFlat = (0, theme_toolkit_1.ifStyle)('flat');
const buttonSize = 40;
const getBackgroundColor = (props) => {
    if (props.disabled) {
        return `${brandPrimary(props)}70`;
    }
    switch (props.buttonVariant) {
        case 'primary':
            return `${backgroundElevation(props)}`;
        case 'secondary':
            return `${brandSecondary(props)}`;
        case 'tertiary':
            return `${brandTertiary(props)}`;
        case 'accent':
            return `${brandAccent(props)}`;
        case 'info':
            return `${infoMain(props)}`;
        case 'warning':
            return `${warningMain(props)}`;
        case 'danger':
            return `${dangerMain(props)}`;
        case 'invert':
            return `${brandPrimaryContrast(props)}`;
        case 'flat':
            return `${'transparent'}`;
        default:
            return `${backgroundElevation(props)}`;
    }
};
const getTextColor = (props) => {
    if (props?.disabled) {
        return `${brandPrimaryContrast(props)}`;
    }
    switch (props.buttonVariant) {
        case 'primary':
            return `${textMain(props)}`;
        case 'secondary':
            return `${brandSecondaryContrast(props)}`;
        case 'tertiary':
            return `${brandTertiaryContrast(props)}`;
        case 'accent':
            return `${brandAccentContrast(props)}`;
        case 'danger':
            return `${dangerContrast(props)}`;
        case 'info':
            return `${infoContrast(props)}`;
        case 'warning':
            return `${warningContrast(props)}`;
        case 'invert':
            return `${brandPrimary(props)}`;
        case 'flat':
            return `${brandPrimary(props)}`;
        default:
            return `${textMain(props)}`;
    }
};
exports.Touchable = (0, native_1.default)(Touchable_1.default) `
  border-radius: ${buttonSize / 2}px;
`;
exports.ButtonWrapper = native_1.default.View `
  align-self: center; // AUTO WIDTH DE ACORDO COM TEXTO
  height: ${buttonSize}px;
  flex-direction: row;
  align-items: center;
  overflow: hidden;
  padding-vertical: ${spacingSm}px;
  padding-horizontal: ${spacingMd}px;
  border-radius: ${buttonSize}px;
  justify-content: center;
  background-color: ${isFlat('transparent', getBackgroundColor)};
  border-color: ${getBackgroundColor};
  border-width: ${hasBorder(borderWidthSmall, '0')}px;
`;
exports.TextButton = (0, native_1.default)(Typography_1.default) `
  letter-spacing: -0.41px;
  color: ${isFlat(getBackgroundColor, getTextColor)};
  font-weight: bold;
`;
exports.Loading = (0, native_1.default)(LoadingIndicator_1.default).attrs({
    variant: 'button',
}) `
  align-self: center;
  width: 55px;
`;
exports.Icon = (0, native_1.default)(Icon_1.default).attrs((props) => ({
    color: getTextColor(props),
})) `
  margin-right: ${isLeftIcon(spacingSm, 0)}px;
  margin-left: ${isRightIcon(spacingSm, 0)}px;
`;
//# sourceMappingURL=styles.js.map