import{createVNode as s}from"vue";import w from"@ant-design/icons-vue/CheckCircleFilled";import T from"@ant-design/icons-vue/CloseCircleFilled";import b from"@ant-design/icons-vue/ExclamationCircleFilled";import j from"@ant-design/icons-vue/InfoCircleFilled";import F from"@ant-design/icons-vue/LoadingOutlined";import M from"../_util/classNames.mjs";import O from"../vc-notification/Notification.mjs";import"../_util/Portal.mjs";import $ from"./style/index.mjs";import E from"./useMessage.mjs";let a=3,d,t,L=1,p="",C="move-up",y=!1,v=()=>document.body,x,N=!1;function S(){return L++}function D(e){e.top!==void 0&&(d=e.top,t=null),e.duration!==void 0&&(a=e.duration),e.prefixCls!==void 0&&(p=e.prefixCls),e.getContainer!==void 0&&(v=e.getContainer,t=null),e.transitionName!==void 0&&(C=e.transitionName,t=null,y=!0),e.maxCount!==void 0&&(x=e.maxCount,t=null),e.rtl!==void 0&&(N=e.rtl)}function K(e,o){if(t){o(t);return}O.newInstance({appContext:e.appContext,prefixCls:e.prefixCls||p,rootPrefixCls:e.rootPrefixCls,transitionName:C,hasTransitionName:y,style:{top:d},getContainer:v||e.getPopupContainer,maxCount:x,name:"message",useStyle:$},n=>{if(t){o(t);return}t=n,o(n)})}const h={info:j,success:w,error:T,warning:b,loading:F},V=Object.keys(h);function g(e){const o=e.duration!==void 0?e.duration:a,n=e.key||S(),i=new Promise(c=>{const f=()=>(typeof e.onClose=="function"&&e.onClose(),c(!0));K(e,I=>{I.notice({key:n,duration:o,style:e.style||{},class:e.class,content:({prefixCls:u})=>{const m=h[e.type],P=m?s(m,null,null):"",k=M(`${u}-custom-content`,{[`${u}-${e.type}`]:e.type,[`${u}-rtl`]:N===!0});return s("div",{class:k},[typeof e.icon=="function"?e.icon():e.icon||P,s("span",null,[typeof e.content=="function"?e.content():e.content])])},onClose:f,onClick:e.onClick})})}),l=()=>{t&&t.removeNotice(n)};return l.then=(c,f)=>i.then(c,f),l.promise=i,l}function q(e){return Object.prototype.toString.call(e)==="[object Object]"&&!!e.content}const r={open:g,config:D,destroy(e){if(t)if(e){const{removeNotice:o}=t;o(e)}else{const{destroy:o}=t;o(),t=null}}};function z(e,o){e[o]=(n,i,l)=>q(n)?e.open({...n,type:o}):(typeof i=="function"&&(l=i,i=void 0),e.open({content:n,duration:i,type:o,onClose:l}))}V.forEach(e=>z(r,e));r.warn=r.warning;r.useMessage=E;export{z as attachTypeApi,r as default,S as getKeyThenIncreaseKey,V as typeList};
