"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _typography = require("../typography");
var _flex = _interopRequireDefault(require("../templates/flex"));
var _icon = _interopRequireDefault(require("./icon"));
var _colors = require("./mixins/colors");
var _styled = require("./styled");
var _excluded = ["children", "background", "color", "data-testid", "flavour", "hollow", "icon", "iconSize", "normal", "reverse", "size", "textSize", "tiny", "textProps", "semi", "ref"];
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
var textComponents = {
  "default": _typography.Text,
  large: _typography.TextBig,
  normal: _typography.Text,
  small: _typography.TextSmall,
  tiny: _typography.TextNano
};
var Pill = function Pill(_ref) {
  var children = _ref.children,
    background = _ref.background,
    color = _ref.color,
    _ref$dataTestid = _ref["data-testid"],
    testId = _ref$dataTestid === void 0 ? "pill" : _ref$dataTestid,
    flavour = _ref.flavour,
    hollow = _ref.hollow,
    icon = _ref.icon,
    iconSize = _ref.iconSize,
    _ref$normal = _ref.normal,
    normal = _ref$normal === void 0 ? true : _ref$normal,
    reverse = _ref.reverse,
    size = _ref.size,
    textSize = _ref.textSize,
    tiny = _ref.tiny,
    textProps = _ref.textProps,
    semi = _ref.semi,
    ref = _ref.ref,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var iconProps = {
    color: color,
    flavour: flavour,
    hollow: hollow,
    icon: icon,
    size: iconSize
  };
  var TextComponent = tiny ? textComponents.tiny : textSize ? textComponents[textSize] : textComponents[size] || textComponents["default"];
  return /*#__PURE__*/_react["default"].createElement(_styled.PillContainer, _extends({
    background: background,
    "data-testid": testId,
    flavour: flavour,
    gap: 1,
    hollow: hollow,
    ref: ref,
    size: size,
    tiny: tiny,
    semi: semi
  }, rest), !reverse && /*#__PURE__*/_react["default"].createElement(_icon["default"], _extends({
    "data-testid": testId + "-icon-left"
  }, iconProps)), children && /*#__PURE__*/_react["default"].createElement(_flex["default"], _extends({
    as: TextComponent,
    color: color || (hollow ? (0, _colors.getPillColor)("color", flavour) : "bright"),
    "data-testid": testId + "-text",
    strong: !normal,
    whiteSpace: "nowrap"
  }, textProps), children), reverse && /*#__PURE__*/_react["default"].createElement(_icon["default"], _extends({
    "data-testid": testId + "-icon-right"
  }, iconProps)));
};
var _default = exports["default"] = Pill;