import { render as s, cloneVNode as h, createVNode as p, mergeProps as m } from "vue";
import { globalConfigForApi as b } from "@aplus-frontend/antdv/es/config-provider";
import P from "@aplus-frontend/antdv/es/modal/ConfirmDialog";
import { getConfirmLocale as w } from "@aplus-frontend/antdv/es/modal/locale";
import { omit as v } from "lodash-unified";
import "../../config-provider/index.mjs";
import c from "./destroyFns.mjs";
import { getModalGlobalAppContext as A } from "./util.mjs";
import { globalConfigCached as D, ConfigProvider as F } from "../../config-provider/config-provider.mjs";
const G = (e) => {
  const f = document.createDocumentFragment();
  let n = {
    ...v(e, ["parentContext", "appContext"]),
    close: l,
    open: !0,
    centered: !0
  }, i = null;
  function x(...o) {
    i && (s(null, f), i = null);
    const r = o.some((t) => t && t.triggerCancel);
    e.onCancel && r && e.onCancel(() => {
    }, ...o.slice(1));
    for (let t = 0; t < c.length; t++)
      if (c[t] === l) {
        c.splice(t, 1);
        break;
      }
  }
  function l(...o) {
    n = {
      ...n,
      open: !1,
      afterClose: () => {
        typeof e.afterClose == "function" && e.afterClose(), x.apply(this, o);
      }
    }, n.visible && delete n.visible, a(n);
  }
  function a(o) {
    typeof o == "function" ? n = o(n) : n = {
      ...n,
      ...o
    }, i && s(h(i, {
      ...n
    }), f);
  }
  const d = (o) => {
    const r = {
      ...b,
      ...D.value
    }, t = r.prefixCls, u = o.prefixCls || `${t}-modal`, y = r.iconPrefixCls, C = w();
    return p(F, m(r, {
      prefixCls: t
    }), {
      default: () => [p(P, m(o, {
        rootPrefixCls: t,
        prefixCls: u,
        iconPrefixCls: y,
        locale: C,
        cancelText: o.cancelText || C.cancelText
      }), null)]
    });
  };
  function g(o) {
    const r = A(), t = p(d, {
      ...o
    });
    return t.appContext = e.appContext || r || t.appContext, s(t, f), t;
  }
  return i = g(n), c.push(l), {
    destroy: l,
    update: a
  };
};
function M(e) {
  return {
    ...e,
    type: "warning"
  };
}
function S(e) {
  return {
    ...e,
    type: "info"
  };
}
function j(e) {
  return {
    ...e,
    type: "success"
  };
}
function q(e) {
  return {
    ...e,
    type: "error"
  };
}
function z(e) {
  return {
    ...e,
    type: "confirm"
  };
}
export {
  G as default,
  z as withConfirm,
  q as withError,
  S as withInfo,
  j as withSuccess,
  M as withWarn
};
