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