"use strict";
const jsxRuntime = require("react/jsx-runtime");
const assert = require("assert");
const styles_lib_components_Box_Box_cjs = require("../Box/Box.cjs");
const styles_lib_components_Accordion_AccordionItem_cjs = require("../Accordion/AccordionItem.cjs");
const styles_lib_components_ButtonIcon_ButtonIcon_cjs = require("../ButtonIcon/ButtonIcon.cjs");
const styles_lib_components_Accordion_Accordion_cjs = require("../Accordion/Accordion.cjs");
const styles_lib_components_Tag_Tag_css_cjs = require("./Tag.css.cjs");
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
const assert__default = /* @__PURE__ */ _interopDefaultCompat(assert);
const Tag = ({
  onClear,
  clearLabel = "Clear",
  data,
  id,
  icon,
  children,
  ...restProps
}) => {
  assert__default.default(
    typeof children === "undefined" || typeof children === "string",
    "Tag may only contain a string"
  );
  assert__default.default(
    !icon || icon.props.size === void 0 || icon.props.tone === void 0,
    "Icons cannot set the 'size' or 'tone' prop when passed to a Tag component"
  );
  return /* @__PURE__ */ jsxRuntime.jsx(
    styles_lib_components_Box_Box_cjs.Box,
    {
      id,
      display: "flex",
      ...styles_lib_components_Accordion_Accordion_cjs.buildDataAttributes({ data, validateRestProps: restProps }),
      children: /* @__PURE__ */ jsxRuntime.jsxs(
        styles_lib_components_Box_Box_cjs.Box,
        {
          display: "flex",
          minWidth: 0,
          alignItems: "center",
          background: "neutralLight",
          paddingY: onClear ? void 0 : "xxsmall",
          paddingLeft: icon ? "xsmall" : "small",
          paddingRight: onClear ? void 0 : "small",
          borderRadius: "full",
          children: [
            /* @__PURE__ */ jsxRuntime.jsx(styles_lib_components_Box_Box_cjs.Box, { minWidth: 0, title: children, children: /* @__PURE__ */ jsxRuntime.jsx(styles_lib_components_Accordion_AccordionItem_cjs.Text, { baseline: false, maxLines: 1, icon, children }) }),
            onClear ? /* @__PURE__ */ jsxRuntime.jsx(styles_lib_components_Box_Box_cjs.Box, { flexShrink: 0, display: "flex", className: styles_lib_components_Tag_Tag_css_cjs.clearGutter, children: /* @__PURE__ */ jsxRuntime.jsx(
              styles_lib_components_ButtonIcon_ButtonIcon_cjs.ButtonIcon,
              {
                id: id ? `${id}-clear` : void 0,
                icon: /* @__PURE__ */ jsxRuntime.jsx(styles_lib_components_Accordion_AccordionItem_cjs.IconClear, {}),
                label: clearLabel,
                tone: "secondary",
                variant: "transparent",
                bleed: false,
                onClick: onClear
              }
            ) }) : null
          ]
        }
      )
    }
  );
};
exports.Tag = Tag;
