"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Tag_exports = {};
__export(Tag_exports, {
  default: () => Tag
});
module.exports = __toCommonJS(Tag_exports);
var import_react = __toESM(require("react"));
var import_styled_system = require("styled-system");
var import_Text = __toESM(require("../asorted/Text"));
var import_styled = __toESM(require("../styled"));
function getColor({ type, active, disabled }) {
  switch (type) {
    case "plain":
      if (disabled)
        return active ? "neutral.c00" : "neutral.c70";
      return active ? "neutral.c00" : "primary.c90";
    default:
      return disabled ? "neutral.c70" : "primary.c90";
  }
}
function getBgColor({ type, active, disabled }) {
  switch (type) {
    case "plain":
      return active ? disabled ? "neutral.c70" : "primary.c90" : void 0;
    case "opacity":
      return active ? disabled ? "neutral.c30" : "primary.c20" : void 0;
    default:
      return;
  }
}
function getBorderColor({ type, active, disabled }) {
  if (!active)
    return;
  switch (type) {
    case "outlined":
      return disabled ? "neutral.c70" : "primary.c90";
    case "outlinedOpacity":
      return disabled ? "neutral.c40" : "primary.c40";
  }
}
function getPadding({ size }) {
  switch (size) {
    case "tiny":
      return "1px 3px";
    case "small":
      return "2px 4px";
    case "medium":
      return "5px 7px";
    case "large":
    default:
      return "8px 9px 9px";
  }
}
function getTextProps({ size }) {
  switch (size) {
    case "tiny":
    case "small":
    case "medium":
      return {
        variant: "tiny",
        fontWeight: "semiBold",
        lineHeight: "normal"
      };
    case "large":
    default:
      return {
        variant: "extraSmall",
        fontWeight: "semiBold"
      };
  }
}
const TagContainer = import_styled.default.div.attrs((props) => ({
  backgroundColor: props.bg || props.backgroundColor || getBgColor(props),
  color: props.color || getColor(props),
  borderColor: getBorderColor(props)
}))`
  display: inline-flex;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: ${(p) => `${p.theme.radii[1]}px`};
  padding: ${(p) => getPadding(p)};
  ${import_styled_system.border}
`;
function Tag({
  children,
  textProps,
  size = "large",
  ...props
}) {
  const textColor = getColor(props);
  const baseTextProps = getTextProps({ size, ...props });
  return /* @__PURE__ */ import_react.default.createElement(TagContainer, { size, ...props }, /* @__PURE__ */ import_react.default.createElement(import_Text.default, { ...baseTextProps, color: textColor, ...textProps ? textProps : {} }, children));
}
//# sourceMappingURL=index.js.map
