"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Badge = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _react = _interopRequireWildcard(require("react"));

var _Box = require("../Box");

var _useVariantColorWarning = require("../hooks/useVariantColorWarning");

var _styles = _interopRequireDefault(require("./styles"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var __jsx = _react["default"].createElement;

/**
 * The Badge component is used for state, general text, and number labels.
 */
var Badge = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
  var _ref$variantColor = _ref.variantColor,
      variantColor = _ref$variantColor === void 0 ? 'gray' : _ref$variantColor,
      _ref$variant = _ref.variant,
      variant = _ref$variant === void 0 ? 'subtle' : _ref$variant,
      size = _ref.size,
      children = _ref.children,
      props = (0, _objectWithoutProperties2["default"])(_ref, ["variantColor", "variant", "size", "children"]);
  // Wrong usage of `variantColor` prop is quite common
  // Let's add a warning hook that validates the passed variantColor
  (0, _useVariantColorWarning.useVariantColorWarning)('Badge', variantColor);
  var badgeStyleProps = (0, _styles["default"])({
    color: variantColor,
    variant: variant,
    size: size
  });
  var child = children; // Hexagonal Badge

  if (variant === 'hexagon') {
    child = __jsx(_react["default"].Fragment, null, __jsx("svg", {
      viewBox: "0 0 100 100",
      version: "1.1",
      xmlns: "http://www.w3.org/2000/svg",
      width: Number(size)
    }, __jsx("defs", null), __jsx("polygon", {
      points: "50 1 95 25 95 75 50 99 5 75 5 25"
    })), __jsx(_Box.Box, {
      position: "absolute"
    }, children));
  }

  return __jsx(_Box.Box, (0, _extends2["default"])({
    ref: ref,
    textTransform: "uppercase",
    size: size
  }, badgeStyleProps, props), child);
});
exports.Badge = Badge;
//# sourceMappingURL=Badge.js.map