import {
  Icon
} from "./chunk-TKIP5Q5H.js";
import {
  TextOrHTML
} from "./chunk-KTJCAQT4.js";

// src/components/Alert/Alert.tsx
import { circleInfo, circleTick, error, warning } from "@simplybusiness/icons";
import classNames from "classnames/dedupe";
import "@simplybusiness/mobius/src/components/Alert/Alert.css";
import { jsx, jsxs } from "react/jsx-runtime";
function isAlertVariant(value) {
  return value === "info" || value === "success" || value === "warning" || value === "error";
}
var Alert = ({ ref, ...props }) => {
  const {
    elementType: Element = "div",
    variant: variantProp,
    show = true,
    header,
    children,
    ...otherProps
  } = props;
  if (!show) return null;
  const variant = variantProp && isAlertVariant(variantProp) ? variantProp : "info";
  const colorValue = variant === "success" ? `var(--color-valid)` : `var(--color-${variant})`;
  const classes = classNames(
    "mobius",
    "mobius-alert",
    {
      "--info": variant === "info",
      "--success": variant === "success",
      "--warning": variant === "warning",
      "--error": variant === "error",
      "--has-header": header
    },
    otherProps.className
  );
  const icon = {
    info: circleInfo,
    success: circleTick,
    warning,
    error
  };
  const headerClasses = classNames("mobius", "mobius-alert__header");
  const iconClasses = classNames("mobius", "mobius-alert__icon");
  const contentClasses = classNames("mobius", "mobius-alert__content");
  return /* @__PURE__ */ jsxs(Element, { ref, role: "alert", ...otherProps, className: classes, children: [
    /* @__PURE__ */ jsx("span", { className: iconClasses, children: /* @__PURE__ */ jsx(Icon, { icon: icon[variant], color: colorValue }) }),
    /* @__PURE__ */ jsxs("div", { children: [
      header && /* @__PURE__ */ jsx(
        TextOrHTML,
        {
          autoDetect: true,
          htmlElementType: "span",
          className: headerClasses,
          htmlClassName: headerClasses,
          text: header
        }
      ),
      /* @__PURE__ */ jsx("div", { className: contentClasses, children })
    ] })
  ] });
};
Alert.displayName = "Alert";

export {
  Alert
};
//# sourceMappingURL=chunk-HGNWNZ5E.js.map
