"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CompoundAccountBadge = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _ = require("..");
var _2 = require("../../../..");
var _utils = require("../../../../common/utils");
var _AccountBadge = require("./AccountBadge.constants");
var _AccountBadgeStack = require("../AccountBadgeStack");
var _excluded = ["children", "badgeSize", "badgeColor"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var StyledTypography = (0, _styledComponents.default)(_2.Typography).withConfig({
  displayName: "AccountBadge__StyledTypography",
  componentId: "sc-1qc7p61-0"
})(["font-weight:800;"]);
var AccountBadgeContent = function AccountBadgeContent(_ref) {
  var children = _ref.children,
    typographyType = _ref.typographyType;
  if (typeof children === 'undefined') return null;
  if ((0, _utils.isFunction)(children)) return children();
  if ((0, _utils.isElement)(children)) return children;
  return _react.default.createElement(StyledTypography, {
    type: typographyType,
    color: function color(t) {
      return t.color.badgeTextColor;
    }
  }, children);
};
var AccountBadge = _react.default.forwardRef(function (_ref2, ref) {
  var children = _ref2.children,
    _ref2$badgeSize = _ref2.badgeSize,
    badgeSize = _ref2$badgeSize === void 0 ? 'm' : _ref2$badgeSize,
    _ref2$badgeColor = _ref2.badgeColor,
    badgeColor = _ref2$badgeColor === void 0 ? function (t) {
      return t.color.accountBadgeBackground;
    } : _ref2$badgeColor,
    htmlProps = _objectWithoutProperties(_ref2, _excluded);
  var baseBadgeSize = typeof badgeSize === 'number' ? badgeSize : _AccountBadge.AccountBadgeSize[badgeSize];
  var typographyType = baseBadgeSize === _AccountBadge.AccountBadgeSize.l ? 'tertiary' : 'caption';
  return _react.default.createElement(_.BaseBadge, _extends({}, htmlProps, {
    ref: ref,
    badgeColor: badgeColor,
    badgeSize: baseBadgeSize,
    symmetricShape: true
  }), _react.default.createElement(AccountBadgeContent, {
    typographyType: typographyType
  }, children));
});
var CompoundAccountBadge = exports.CompoundAccountBadge = Object.assign({}, AccountBadge, {
  Stack: _AccountBadgeStack.AccountBadgeStack
});