"use strict";
const React = require("react");
const assert = require("assert");
const clsx = require("clsx");
const styles_lib_components_Accordion_AccordionItem_cjs = require("../../components/Accordion/AccordionItem.cjs");
const styles_lib_components_Heading_Heading_cjs = require("../../components/Heading/Heading.cjs");
const styles_lib_css_lineHeightContainer_css_cjs = require("../../css/lineHeightContainer.css.cjs");
const styles_lib_components_Accordion_Accordion_cjs = require("../../components/Accordion/Accordion.cjs");
const styles_lib_components_icons_IconRenderer_cjs = require("../../components/icons/IconRenderer.cjs");
const styles_lib_css_atoms_atoms_cjs = require("../../css/atoms/atoms.cjs");
const styles_lib_css_typography_css_cjs = require("../../css/typography.css.cjs");
const styles_lib_hooks_useIcon_icon_css_cjs = require("./icon.css.cjs");
const _interopDefaultCompat = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
const assert__default = /* @__PURE__ */ _interopDefaultCompat(assert);
const clsx__default = /* @__PURE__ */ _interopDefaultCompat(clsx);
const iconSize = ({
  size = "standard",
  crop = false
} = {}) => clsx__default.default(styles_lib_hooks_useIcon_icon_css_cjs.size, styles_lib_css_typography_css_cjs.textSizeUntrimmed[size], {
  [styles_lib_hooks_useIcon_icon_css_cjs.cropToTextSize]: crop
});
const iconContainerSize = (size = "standard") => clsx__default.default(styles_lib_hooks_useIcon_icon_css_cjs.blockWidths[size], styles_lib_css_lineHeightContainer_css_cjs.lineHeightContainer[size]);
const defaultVerticalCorrection = {
  uppercase: "none",
  lowercase: "none"
};
const useIcon = ({ size, tone, alignY, data, title, titleId, ...restProps }, { verticalCorrection = defaultVerticalCorrection } = {}) => {
  const textContext = React.useContext(styles_lib_components_Accordion_AccordionItem_cjs.TextContext);
  const headingContext = React.useContext(styles_lib_components_Heading_Heading_cjs.HeadingContext);
  const resolvedTone = styles_lib_css_typography_css_cjs.tone[tone || (textContext == null ? void 0 : textContext.tone) || "neutral"];
  const toneClass = tone || !headingContext && !(textContext == null ? void 0 : textContext.tone) ? resolvedTone : void 0;
  const isInline = Boolean(textContext || headingContext);
  const a11yProps = title ? { title, titleId, role: "img" } : { "aria-hidden": true };
  assert__default.default(
    !(size && isInline),
    `Specifying a custom \`size\` for an \`Icon\` inside the context of a \`<${textContext ? "Text" : "Heading"}>\` component is invalid. See the documentation for correct usage: https://seek-oss.github.io/braid-design-system/components/${textContext ? "Text" : "Heading"}`
  );
  assert__default.default(
    !(alignY && !isInline),
    `Specifying \`alignY\` for an \`Icon\` outside of a text component is invalid.`
  );
  if (size === "fill") {
    return {
      width: "full",
      height: "full",
      display: "block",
      className: toneClass,
      ...styles_lib_components_Accordion_Accordion_cjs.buildDataAttributes({ data, validateRestProps: restProps }),
      ...a11yProps
    };
  }
  return {
    className: [
      toneClass,
      isInline ? [
        styles_lib_components_icons_IconRenderer_cjs.iconInlineSize({
          alignY: alignY || "uppercase",
          verticalCorrection: verticalCorrection[alignY || "uppercase"]
        })
      ] : [
        styles_lib_css_atoms_atoms_cjs.atoms({
          display: "block"
        }),
        iconContainerSize(size)
      ]
    ],
    ...styles_lib_components_Accordion_Accordion_cjs.buildDataAttributes({ data, validateRestProps: restProps }),
    ...a11yProps
  };
};
exports.iconContainerSize = iconContainerSize;
exports.iconSize = iconSize;
exports.useIcon = useIcon;
