import * as l from "react";
import N from "../../../classnames/index.mjs";
import _ from "../../../rc-notification/es/hooks/useNotification.mjs";
import S from "../../../rc-notification/es/NotificationProvider.mjs";
import { devUseWarning as k } from "../_util/warning.mjs";
import "../config-provider/index.mjs";
import { getCloseIcon as E, PureContent as T } from "./PurePanel.mjs";
import A from "./style/index.mjs";
import { getPlacementStyle as R, getMotion as D } from "./util.mjs";
import "../../../@ant-design/cssinjs/es/extractStyle.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useCacheToken.mjs";
import "../../../@ant-design/cssinjs/es/StyleContext.mjs";
import "../../../@ant-design/cssinjs/es/theme/createTheme.mjs";
import "../../../rc-util/es/warning.mjs";
import "../../../@ant-design/cssinjs/es/theme/ThemeCache.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.mjs";
import "../../../@ant-design/cssinjs/es/hooks/useHMR.mjs";
import "../../../@ant-design/cssinjs/es/transformers/legacyLogicalProperties.mjs";
import F from "../theme/useToken.mjs";
import U from "../config-provider/hooks/useCSSVarCls.mjs";
import { ConfigContext as $ } from "../config-provider/context.mjs";
var L = globalThis && globalThis.__rest || function(e, n) {
  var r = {};
  for (var t in e)
    Object.prototype.hasOwnProperty.call(e, t) && n.indexOf(t) < 0 && (r[t] = e[t]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var s = 0, t = Object.getOwnPropertySymbols(e); s < t.length; s++)
      n.indexOf(t[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[s]) && (r[t[s]] = e[t[s]]);
  return r;
};
const j = 24, M = 4.5, V = "topRight", H = (e) => {
  let {
    children: n,
    prefixCls: r
  } = e;
  const t = U(r), [s, p, f] = A(r, t);
  return s(/* @__PURE__ */ l.createElement(S, {
    classNames: {
      list: N(p, f, t)
    }
  }, n));
}, W = (e, n) => {
  let {
    prefixCls: r,
    key: t
  } = n;
  return /* @__PURE__ */ l.createElement(H, {
    prefixCls: r,
    key: t
  }, e);
}, G = /* @__PURE__ */ l.forwardRef((e, n) => {
  const {
    top: r,
    bottom: t,
    prefixCls: s,
    getContainer: p,
    maxCount: f,
    rtl: h,
    onAllRemoved: i,
    stack: o
  } = e, {
    getPrefixCls: a,
    getPopupContainer: u,
    notification: c
  } = l.useContext($), [, d] = F(), m = s || a("notification"), v = (O) => R(O, r ?? j, t ?? j), b = () => N({
    [`${m}-rtl`]: h
  }), g = () => D(m), [y, C] = _({
    prefixCls: m,
    style: v,
    className: b,
    motion: g,
    closable: !0,
    closeIcon: E(m),
    duration: M,
    getContainer: () => (p == null ? void 0 : p()) || (u == null ? void 0 : u()) || document.body,
    maxCount: f,
    onAllRemoved: i,
    renderNotifications: W,
    stack: o === !1 ? !1 : {
      threshold: typeof o == "object" ? o == null ? void 0 : o.threshold : void 0,
      offset: 8,
      gap: d.margin
    }
  });
  return l.useImperativeHandle(n, () => Object.assign(Object.assign({}, y), {
    prefixCls: m,
    notification: c
  })), C;
});
function Y(e) {
  const n = l.useRef(null), r = k("Notification");
  return [l.useMemo(() => {
    const s = (i) => {
      var o;
      if (!n.current) {
        process.env.NODE_ENV !== "production" && r(!1, "usage", "You are calling notice in render which will break in React 18 concurrent mode. Please trigger in effect instead.");
        return;
      }
      const {
        open: a,
        prefixCls: u,
        notification: c
      } = n.current, d = `${u}-notice`, {
        message: m,
        description: v,
        icon: b,
        type: g,
        btn: y,
        className: C,
        style: O,
        role: P = "alert",
        closeIcon: I
      } = i, w = L(i, ["message", "description", "icon", "type", "btn", "className", "style", "role", "closeIcon"]), x = E(d, I);
      return a(Object.assign(Object.assign({
        // use placement from props instead of hard-coding "topRight"
        placement: (o = e == null ? void 0 : e.placement) !== null && o !== void 0 ? o : V
      }, w), {
        content: /* @__PURE__ */ l.createElement(T, {
          prefixCls: d,
          icon: b,
          type: g,
          message: m,
          description: v,
          btn: y,
          role: P
        }),
        className: N(g && `${d}-${g}`, C, c == null ? void 0 : c.className),
        style: Object.assign(Object.assign({}, c == null ? void 0 : c.style), O),
        closeIcon: x,
        closable: !!x
      }));
    }, f = {
      open: s,
      destroy: (i) => {
        var o, a;
        i !== void 0 ? (o = n.current) === null || o === void 0 || o.close(i) : (a = n.current) === null || a === void 0 || a.destroy();
      }
    };
    return ["success", "info", "warning", "error"].forEach((i) => {
      f[i] = (o) => s(Object.assign(Object.assign({}, o), {
        type: i
      }));
    }), f;
  }, []), /* @__PURE__ */ l.createElement(G, Object.assign({
    key: "notification-holder"
  }, e, {
    ref: n
  }))];
}
function ue(e) {
  return Y(e);
}
export {
  ue as default,
  Y as useInternalNotification
};
