import { jsxs, jsx } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import { S as SvgClose } from './close-DZj38AEh.js';
import { S as SvgInfo } from './info-CYpG6tcI.js';
import { S as SvgWarning } from './warning-c4Wj1rI4.js';
import { S as SvgError } from './error-DR_wWdYY.js';
import { S as SvgCheckCircle } from './check_circle-CM0ukqXv.js';
import { I as Icon } from './Icon-Bcil6aBo.js';
import { B as Button } from './Button-DrNDkO2f.js';
import { c as cx } from './index-SvGbrGuT.js';
import { u as useLayoutPropsUtil } from './useLayoutPropsUtil-loxbyklF.js';
import { useTrackingId } from './useTrackingId.js';

import './Alert.css';const alert = "_alert_16him_2";
const content = "_content_16him_34";
const top = "_top_16him_42";
const success = "_success_16him_60";
const warning = "_warning_16him_66";
const danger = "_danger_16him_72";
const styles = {
	alert: alert,
	"close-container": "_close-container_16him_27",
	content: content,
	top: top,
	"title-container": "_title-container_16him_48",
	"status-icon": "_status-icon_16him_56",
	success: success,
	warning: warning,
	danger: danger,
	"close-button": "_close-button_16him_80"
};

const statusIconMap = {
  info: SvgInfo,
  success: SvgCheckCircle,
  warning: SvgWarning,
  danger: SvgError
};
const Alert = forwardRef(
  (props, ref) => {
    const { layoutStyles, componentProps } = useLayoutPropsUtil(props);
    const {
      children,
      className,
      title,
      status = "info",
      style,
      onClose,
      ...rest
    } = componentProps;
    const data = {
      title,
      status
    };
    const trackingId = useTrackingId({
      name: "Alert",
      data,
      hasOverride: !!props["data-tracking-id"]
    });
    const alertCx = cx(styles["alert"], className, {
      [styles["success"]]: status === "success",
      [styles["warning"]]: status === "warning",
      [styles["danger"]]: status === "danger"
    });
    const styleCombined = {
      ...style,
      ...layoutStyles
    };
    return /* @__PURE__ */ jsxs(
      "div",
      {
        "data-tracking-id": trackingId,
        "data-anv": "alert",
        role: "status",
        className: alertCx,
        style: styleCombined,
        ...rest,
        ref,
        children: [
          /* @__PURE__ */ jsxs("div", { className: styles["top"], children: [
            /* @__PURE__ */ jsxs("span", { className: styles["title-container"], children: [
              /* @__PURE__ */ jsx(
                Icon,
                {
                  size: "large",
                  className: styles["status-icon"],
                  svg: statusIconMap[status ?? "info"]
                }
              ),
              title
            ] }),
            !!onClose && /* @__PURE__ */ jsx("span", { className: styles["close-container"], children: /* @__PURE__ */ jsx(
              Button,
              {
                icon: SvgClose,
                size: "small",
                appearance: "ghost",
                className: styles["close-button"],
                onClick: (e) => onClose(e),
                "aria-label": `Dismiss ${status} alert`
              }
            ) })
          ] }),
          children && /* @__PURE__ */ jsx("div", { className: styles["content"], children })
        ]
      }
    );
  }
);
Alert.displayName = "Alert";

export { Alert as A };
//# sourceMappingURL=Alert-D9mBPs6z.js.map
