const e=require("../_util/classNames.js"),t=require("../_util/transition.js"),n=require("./Notice.js"),r=require("../config-provider/index.js");let i=require("vue");var a=0,o=Date.now();function s(){let e=a;return a+=1,`rcNotification_${o}_${e}`}var c=(0,i.defineComponent)({name:`Notification`,inheritAttrs:!1,props:[`prefixCls`,`transitionName`,`animation`,`maxCount`,`closeIcon`,`hashId`],setup(r,{attrs:a,expose:o,slots:c}){let l=new Map,u=(0,i.ref)([]),d=(0,i.computed)(()=>{let{prefixCls:e,animation:n=`fade`}=r,i=r.transitionName;return!i&&n&&(i=`${e}-${n}`),t.getTransitionGroupProps(i)}),f=(e,t)=>{let n=e.key||s(),i={...e,key:n},{maxCount:a}=r,o=u.value.map(e=>e.notice.key).indexOf(n),c=u.value.concat();o===-1?(a&&u.value.length>=a&&(i.key=c[0].notice.key,i.updateMark=s(),i.userPassKey=n,c.shift()),c.push({notice:i,holderCallback:t})):c.splice(o,1,{notice:i,holderCallback:t}),u.value=c},p=e=>{u.value=(0,i.toRaw)(u.value).filter(({notice:{key:t,userPassKey:n}})=>(n||t)!==e)};return o({add:f,remove:p,notices:u}),()=>{let{prefixCls:t,closeIcon:o=c.closeIcon?.({prefixCls:t})}=r,s=u.value.map(({notice:a,holderCallback:s},c)=>{let d=c===u.value.length-1?a.updateMark:void 0,{key:f,userPassKey:m}=a,{content:h}=a,g={prefixCls:t,closeIcon:typeof o==`function`?o({prefixCls:t}):o,...a,...a.props,key:f,noticeKey:m||f,updateMark:d,onClose:e=>{p(e),a.onClose?.()},onClick:a.onClick};return s?(0,i.createVNode)(`div`,{key:f,class:`${t}-hook-holder`,ref:e=>{f!==void 0&&(e?(l.set(f,e),s(e,g)):l.delete(f))}},null):(0,i.createVNode)(n.default,{...g,class:e.default(g.class,r.hashId)},{default:()=>[typeof h==`function`?h({prefixCls:t}):h]})});return(0,i.createVNode)(`div`,{class:{[t]:1,[a.class]:!!a.class,[r.hashId]:!0},style:a.style||{top:`65px`,left:`50%`}},[(0,i.createVNode)(i.TransitionGroup,{tag:`div`,...d.value},{default:()=>[s]})])}}});c.newInstance=function(e,t){let{name:n=`notification`,getContainer:a,appContext:o,prefixCls:s,rootPrefixCls:l,transitionName:u,hasTransitionName:d,useStyle:f,...p}=e||{},m=document.createElement(`div`);a?a().appendChild(m):document.body.appendChild(m);let h=(0,i.createVNode)((0,i.defineComponent)({compatConfig:{MODE:3},name:`NotificationWrapper`,setup(e,{attrs:a}){let o=(0,i.shallowRef)(),p=(0,i.computed)(()=>r.globalConfigForApi.getPrefixCls(n,s)),[,h]=f(p);return(0,i.onMounted)(()=>{t({notice(e){o.value?.add(e)},removeNotice(e){o.value?.remove(e)},destroy(){(0,i.render)(null,m),m.parentNode&&m.parentNode.removeChild(m)},component:o})}),()=>{let e=r.globalConfigForApi,t=e.getRootPrefixCls(l,p.value),n=d?u:`${p.value}-${u}`;return(0,i.createVNode)(r.default,{...e,prefixCls:t},{default:()=>[(0,i.createVNode)(c,{ref:o,...a,prefixCls:p.value,transitionName:n,hashId:h.value},null)]})}}}),p);h.appContext=o||h.appContext,(0,i.render)(h,m)},exports.default=c;