import{defineComponent as $,computed as k,onMounted as A,onUnmounted as I,watch as K,createVNode as a,Teleport as O}from"vue";import P from"../_util/classNames.mjs";const g=$({name:"Notice",inheritAttrs:!1,props:["prefixCls","duration","updateMark","noticeKey","closeIcon","closable","props","onClick","onClose","holder","visible"],setup(o,{attrs:d,slots:p}){let c,b=!1;const f=k(()=>o.duration===void 0?4.5:o.duration),m=()=>{f.value&&!b&&(c=setTimeout(()=>{h()},f.value*1e3))},i=()=>{c&&(clearTimeout(c),c=null)},h=t=>{t&&t.stopPropagation(),i();const{onClose:e,noticeKey:s}=o;e&&e(s)},M=()=>{i(),m()};return A(()=>{m()}),I(()=>{b=!0,i()}),K([f,()=>o.updateMark,()=>o.visible],([t,e,s],[C,r,u])=>{(t!==C||e!==r||s!==u&&u)&&M()},{flush:"post"}),()=>{const{prefixCls:t,closable:e,closeIcon:s=p.closeIcon?.(),onClick:C,holder:r}=o,{class:u,style:x}=d,n=`${t}-notice`,N=Object.keys(d).reduce((T,l)=>((l.startsWith("data-")||l.startsWith("aria-")||l==="role")&&(T[l]=d[l]),T),{}),v=a("div",{class:P(n,u,{[`${n}-closable`]:e}),style:x,onMouseenter:i,onMouseleave:m,onClick:C,...N},[a("div",{class:`${n}-content`},[p.default?.()]),e?a("a",{tabindex:0,onClick:h,class:`${n}-close`},[s||a("span",{class:`${n}-close-x`},null)]):null]);return r?a(O,{to:r},{default:()=>v}):v}}});export{g as default};
