import{defineComponent as M,computed as d,ref as E,watch as F,createVNode as r,TransitionGroup as G}from"vue";import K from"../_util/Portal.mjs";import O from"../_util/classNames.mjs";import{getTransitionGroupProps as S}from"../_util/transition.mjs";import T from"./Notice.mjs";let C=0;const _=Date.now();function q(){const t=C;return C+=1,`rcNotification_${_}_${t}`}const z=M({name:"HookNotification",inheritAttrs:!1,props:["prefixCls","transitionName","animation","maxCount","closeIcon","hashId","remove","notices","getStyles","getClassName","onAllRemoved","getContainer"],setup(t,{attrs:f,slots:N}){const h=new Map,y=d(()=>t.notices),P=d(()=>{let e=t.transitionName;if(!e&&t.animation)switch(typeof t.animation){case"string":e=t.animation;break;case"function":e=t.animation().name;break;case"object":e=t.animation.name;break;default:e=`${t.prefixCls}-fade`;break}return S(e)}),x=e=>t.remove(e),c=E({});F(y,()=>{const e={};Object.keys(c.value).forEach(n=>{e[n]=[]}),t.notices.forEach(n=>{const{placement:a="topRight"}=n.notice;a&&(e[a]=e[a]||[],e[a].push(n))}),c.value=e});const I=d(()=>Object.keys(c.value));return()=>{const{prefixCls:e,closeIcon:n=N.closeIcon?.({prefixCls:e})}=t,a=I.value.map(s=>{const v=c.value[s],k=t.getClassName?.(s),b=t.getStyles?.(s),$=v.map(({notice:o,holderCallback:g},R)=>{const j=R===y.value.length-1?o.updateMark:void 0,{key:i,userPassKey:L}=o,{content:u}=o,m={prefixCls:e,closeIcon:typeof n=="function"?n({prefixCls:e}):n,...o,...o.props,key:i,noticeKey:L||i,updateMark:j,onClose:l=>{x(l),o.onClose?.()},onClick:o.onClick};return g?r("div",{key:i,class:`${e}-hook-holder`,ref:l=>{typeof i>"u"||(l?(h.set(i,l),g(l,m)):h.delete(i))}},null):r(T,{...m,class:O(m.class,t.hashId)},{default:()=>[typeof u=="function"?u({prefixCls:e}):u]})}),w={[e]:1,[`${e}-${s}`]:1,[f.class]:!!f.class,[t.hashId]:!0,[k]:!!k};function A(){v.length>0||(Reflect.deleteProperty(c.value,s),t.onAllRemoved?.())}return r("div",{key:s,class:w,style:f.style||b||{top:"65px",left:"50%"}},[r(G,{tag:"div",...P.value,onAfterLeave:A},{default:()=>[$]})])});return r(K,{getContainer:t.getContainer},{default:()=>[a]})}}});export{z as default,q as getUuid};
