"use strict";

import { useContext } from 'react';
import { View } from 'react-native';
import { ApplicationContext } from "../Context/index.js";
import { Colors, Radius, Shadow, Spacing } 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 Tag = ({
  label = 'Label',
  icon,
  color,
  type = 'default',
  size = 'small',
  style
}) => {
  const {
    theme
  } = useContext(ApplicationContext);

  /**
   * get style for button by type
   */
  const getTypeStyle = () => {
    switch (type) {
      case 'rating':
        return {
          backgroundColor: color ?? theme.colors.primary.default,
          borderTopRightRadius: 0,
          borderRadius: Radius.S,
          borderBottomLeftRadius: Radius.S,
          borderTopLeftRadius: Radius.S,
          borderBottomRightRadius: Radius.S
        };
      default:
        if (color) {
          return {
            backgroundColor: Colors.lighten(color, 40),
            borderRadius: Radius.S
          };
        }
        return {
          backgroundColor: theme.colors.background.surface,
          borderRadius: Radius.S
        };
    }
  };

  /**
   * get size style
   */
  const getSizeStyle = () => {
    switch (size) {
      case 'large':
        return {
          height: 28,
          paddingHorizontal: Spacing.M
        };
      case 'medium':
        return {
          height: 24,
          paddingHorizontal: Spacing.M
        };
      default:
        return {
          paddingHorizontal: Spacing.S,
          height: 20
        };
    }
  };

  /**
   * get color for button by type
   */
  const getColor = () => {
    switch (type) {
      case 'rating':
        return Colors.white;
      default:
        return color;
    }
  };

  /**
   * get text
   */
  const getText = () => {
    switch (size) {
      case 'large':
        return 'footnote';
      case 'medium':
        return 'caption1';
      default:
        return 'caption2';
    }
  };
  const getIconSize = () => {
    switch (size) {
      case 'large':
        return 20;
      case 'medium':
        return 18;
      default:
        return 16;
    }
  };
  return /*#__PURE__*/_jsxs(View, {
    style: [styles.container, Shadow.dark, getSizeStyle(), getTypeStyle(), style],
    children: [!!icon && /*#__PURE__*/_jsx(Icon, {
      style: styles.icon,
      size: getIconSize(),
      name: icon,
      color: getColor()
    }), /*#__PURE__*/_jsx(Text, {
      color: getColor(),
      typography: getText(),
      fontWeight: 'bold',
      children: label
    })]
  });
};
export { Tag };
//# sourceMappingURL=index.js.map