import{createVNode as s}from"vue";import{LoadingOutlined as w,ExclamationCircleFilled as T,CloseCircleFilled as b,CheckCircleFilled as j,InfoCircleFilled as F}from"@antsoo-lib/icons";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 m=3,d,t,L=1,C="",p="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&&(m=e.duration),e.prefixCls!==void 0&&(C=e.prefixCls),e.getContainer!==void 0&&(v=e.getContainer,t=null),e.transitionName!==void 0&&(p=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,n){if(t){n(t);return}O.newInstance({appContext:e.appContext,prefixCls:e.prefixCls||C,rootPrefixCls:e.rootPrefixCls,transitionName:p,hasTransitionName:y,style:{top:d},getContainer:v||e.getPopupContainer,maxCount:x,name:"message",useStyle:$},o=>{if(t){n(t);return}t=o,n(o)})}const h={info:F,success:j,error:b,warning:T,loading:w},V=Object.keys(h);function g(e){const n=e.duration!==void 0?e.duration:m,o=e.key||S(),i=new Promise(r=>{const f=()=>(typeof e.onClose=="function"&&e.onClose(),r(!0));K(e,I=>{I.notice({key:o,duration:n,style:e.style||{},class:e.class,content:({prefixCls:u})=>{const a=h[e.type],P=a?s(a,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(o)};return l.then=(r,f)=>i.then(r,f),l.promise=i,l}function q(e){return Object.prototype.toString.call(e)==="[object Object]"&&!!e.content}const c={open:g,config:D,destroy(e){if(t)if(e){const{removeNotice:n}=t;n(e)}else{const{destroy:n}=t;n(),t=null}}};function z(e,n){e[n]=(o,i,l)=>q(o)?e.open({...o,type:n}):(typeof i=="function"&&(l=i,i=void 0),e.open({content:o,duration:i,type:n,onClose:l}))}V.forEach(e=>z(c,e));c.warn=c.warning;c.useMessage=E;export{z as attachTypeApi,c as default,S as getKeyThenIncreaseKey,V as typeList};
