import * as t from "react";
import H from "../../../@ant-design/icons/es/icons/CheckCircleFilled.mjs";
import R from "../../../@ant-design/icons/es/icons/CloseCircleFilled.mjs";
import z from "../../../@ant-design/icons/es/icons/CloseOutlined.mjs";
import U from "../../../@ant-design/icons/es/icons/ExclamationCircleFilled.mjs";
import W from "../../../@ant-design/icons/es/icons/InfoCircleFilled.mjs";
import p from "../../../classnames/index.mjs";
import q from "../../../rc-motion/es/CSSMotion.mjs";
import "../../../rc-motion/es/CSSMotionList.mjs";
import B from "../../../rc-util/es/pickAttrs.mjs";
import { replaceElement as G } from "../_util/reactNode.mjs";
import { devUseWarning as J } from "../_util/warning.mjs";
import "../config-provider/index.mjs";
import K from "./style/index.mjs";
import { ConfigContext as Q } from "../config-provider/context.mjs";
var X = globalThis && globalThis.__rest || function(e, n) {
  var r = {};
  for (var o in e)
    Object.prototype.hasOwnProperty.call(e, o) && n.indexOf(o) < 0 && (r[o] = e[o]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var l = 0, o = Object.getOwnPropertySymbols(e); l < o.length; l++)
      n.indexOf(o[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[l]) && (r[o[l]] = e[o[l]]);
  return r;
};
const Y = {
  success: H,
  info: W,
  error: R,
  warning: U
}, Z = (e) => {
  const {
    icon: n,
    prefixCls: r,
    type: o
  } = e, l = Y[o] || null;
  return n ? G(n, /* @__PURE__ */ t.createElement("span", {
    className: `${r}-icon`
  }, n), () => ({
    className: p(`${r}-icon`, {
      [n.props.className]: n.props.className
    })
  })) : /* @__PURE__ */ t.createElement(l, {
    className: `${r}-icon`
  });
}, ee = (e) => {
  const {
    isClosable: n,
    prefixCls: r,
    closeIcon: o,
    handleClose: l
  } = e, u = o === !0 || o === void 0 ? /* @__PURE__ */ t.createElement(z, null) : o;
  return n ? /* @__PURE__ */ t.createElement("button", {
    type: "button",
    onClick: l,
    className: `${r}-close-icon`,
    tabIndex: 0
  }, u) : null;
}, E = (e) => {
  const {
    description: n,
    prefixCls: r,
    message: o,
    banner: l,
    className: u,
    rootClassName: g,
    style: x,
    onMouseEnter: h,
    onMouseLeave: I,
    onClick: O,
    afterClose: $,
    showIcon: C,
    closable: d,
    closeText: f,
    closeIcon: i,
    action: b
  } = e, w = X(e, ["description", "prefixCls", "message", "banner", "className", "rootClassName", "style", "onMouseEnter", "onMouseLeave", "onClick", "afterClose", "showIcon", "closable", "closeText", "closeIcon", "action"]), [y, S] = t.useState(!1);
  process.env.NODE_ENV !== "production" && J("Alert").deprecated(!f, "closeText", "closeIcon");
  const M = t.useRef(null), {
    getPrefixCls: j,
    direction: P,
    alert: a
  } = t.useContext(Q), s = j("alert", r), [_, k, A] = K(s), T = (c) => {
    var m;
    S(!0), (m = e.onClose) === null || m === void 0 || m.call(e, c);
  }, N = t.useMemo(() => e.type !== void 0 ? e.type : l ? "warning" : "info", [e.type, l]), F = t.useMemo(() => f ? !0 : typeof d == "boolean" ? d : i !== !1 && i !== null && i !== void 0, [f, i, d]), v = l && C === void 0 ? !0 : C, L = p(s, `${s}-${N}`, {
    [`${s}-with-description`]: !!n,
    [`${s}-no-icon`]: !v,
    [`${s}-banner`]: !!l,
    [`${s}-rtl`]: P === "rtl"
  }, a == null ? void 0 : a.className, u, g, A, k), V = B(w, {
    aria: !0,
    data: !0
  });
  return _(/* @__PURE__ */ t.createElement(q, {
    visible: !y,
    motionName: `${s}-motion`,
    motionAppear: !1,
    motionEnter: !1,
    onLeaveStart: (c) => ({
      maxHeight: c.offsetHeight
    }),
    onLeaveEnd: $
  }, (c) => {
    let {
      className: m,
      style: D
    } = c;
    return /* @__PURE__ */ t.createElement("div", Object.assign({
      ref: M,
      "data-show": !y,
      className: p(L, m),
      style: Object.assign(Object.assign(Object.assign({}, a == null ? void 0 : a.style), x), D),
      onMouseEnter: h,
      onMouseLeave: I,
      onClick: O,
      role: "alert"
    }, V), v ? /* @__PURE__ */ t.createElement(Z, {
      description: n,
      icon: e.icon,
      prefixCls: s,
      type: N
    }) : null, /* @__PURE__ */ t.createElement("div", {
      className: `${s}-content`
    }, o ? /* @__PURE__ */ t.createElement("div", {
      className: `${s}-message`
    }, o) : null, n ? /* @__PURE__ */ t.createElement("div", {
      className: `${s}-description`
    }, n) : null), b ? /* @__PURE__ */ t.createElement("div", {
      className: `${s}-action`
    }, b) : null, /* @__PURE__ */ t.createElement(ee, {
      isClosable: F,
      prefixCls: s,
      closeIcon: f || i,
      handleClose: T
    }));
  }));
};
process.env.NODE_ENV !== "production" && (E.displayName = "Alert");
const Ce = E;
export {
  Ce as default
};
