import '@das-fed/upf-ui/packages/components/message/style.css';
import { ElMessage as m } from "element-plus";
import { DasIconTongguo as y } from "@das-fed/upf-ui/packages/icons/tongguo/index";
import { DasIconJinggao as g } from "@das-fed/upf-ui/packages/icons/jinggao/index";
import { DasIconTongzhi as x } from "@das-fed/upf-ui/packages/icons/tongzhi/index";
import { h as o } from "vue";
import "element-plus/es/components/message/style/css";
import { setI18nRule as w, t as M } from "@das-fed/upf-web/packages/i18n/index";
const p = (e = 24) => {
  C("das-ui-message-container", [
    {
      styleName: "transform",
      style: `translateY(${e}px)`
    }
  ]);
}, C = (e, s) => {
  const a = document.getElementById(e);
  if (!a) {
    const r = document.createElement("div");
    r.style.transform = "translateY(24px)", r.id = e, r.style.position = "fixed", r.style.top = "0", r.style.left = "0", r.style.width = "100%", r.style.zIndex = "999999", document.body.appendChild(r);
    return;
  }
  for (const r of s)
    a.style[r.styleName] = r.style;
}, n = (e, s) => getComputedStyle(document.documentElement).getPropertyValue(e).trim() || s, S = (e) => {
  let s = "";
  return e == "success" && (s = o(y, {
    iconColor: n("--upf-message-success-text", n("--upf-color-success", "#1BA854")),
    customSize: "16"
  })), e == "warning" && (s = o(g, {
    iconColor: n("--upf-message-warning-text", n("--upf-color-warning", "#FF991C")),
    customSize: "16"
  })), e == "info" && (s = o(x, {
    iconColor: n("--upf-message-info-text", n("--upf-color-info", "#0E5FD8")),
    customSize: "16"
  })), e == "error" && (s = o(g, {
    iconColor: n("--upf-message-error-text", n("--upf-color-error", "#FB2323")),
    customSize: "16"
  })), s;
}, h = (e) => {
  let s = "";
  return e == "success" && (s = " el-message--success"), e == "warning" && (s = " el-message--warning"), e == "info" && (s = " el-message--info"), e == "error" && (s = " el-message--error"), s;
};
p();
let i = {
  close() {
  }
};
const P = {
  offset: 16,
  // 默认3s
  duration: 3e3
}, t = (e) => {
  var s, a;
  return t.proxyStatus ? (s = t.proxyMessage) == null ? void 0 : s.call(t, e) : (typeof e == "string" && (e = { message: e }), e = { ...P, ...e }, e.customClass = ((a = e.customClass) == null ? void 0 : a.concat(" das-ui-message")) || "das-ui-message", e.appendTo || (e.appendTo = "#das-ui-message-container"), e.icon || (e.icon = S(e.type), e.customClass = e.customClass.concat(h(e.type))), i = m(e), i);
};
t.error = (e) => (typeof e == "string" && (e = { message: e }), e.type = "error", t(e));
t.success = (e) => (typeof e == "string" && (e = { message: e }), e.type = "success", t(e));
t.info = (e) => (typeof e == "string" && (e = { message: e }), e.type = "info", t(e));
t.warning = (e) => (typeof e == "string" && (e = { message: e }), e.type = "warning", t(e));
t.closeAll = (e) => m.closeAll(e);
window.addEventListener("message", (e) => {
  const { type: s, data: a } = e.data, r = { setProxyMessageStatus: "setProxyMessageStatus", showProxyMessage: "showProxyMessage" };
  if (Object.values(r).includes(s)) {
    if (s === r.setProxyMessageStatus) {
      const { visible: u, parentHref: f } = a;
      t.proxyStatus = u ?? !0, t.proxyMessage = (l) => {
        var c;
        const { origin: d } = new URL(f);
        (c = window.top) == null || c.postMessage({ type: "showProxyMessage", data: l }, d);
      };
    }
    s === r.showProxyMessage && t(a);
  }
});
const z = { 消息提示: { "zh-CN": "消息提示", en: "Message Prompt", "zh-MO": "消息提示", _appCode: "framework" } };
w(z);
const I = t;
window.DasMessage = I;
const B = { name: `Message ${M("消息提示")}` };
export {
  I as DasMessage,
  B as default
};
