import{$t as e,J as t,Q as n,Z as r,d as i,dn as a,in as o,j as s,ln as c,lt as l,nt as u,pt as d,t as f}from"./icon-K_9KhGme.js";import{$ as p,B as m,C as h,Dt as g,K as _,L as v,Ot as y,Q as b,Tt as x,U as S,_ as C,bt as w,d as T,g as E,h as D,k as O,l as k,ot as A,pt as j,r as M,s as N,t as P,v as F,w as I,wt as L,y as R}from"./vue.esm-bundler-DcNPjsgv.js";import{n as z}from"./use-global-config-C-SS2Yu-.js";import{a as B,r as V}from"./icon-DARh_Gl7.js";var H=[`primary`,`success`,`info`,`warning`,`error`],U=r({customClass:{type:String,default:``},dangerouslyUseHTMLString:Boolean,duration:{type:Number,default:4500},icon:{type:B},id:{type:String,default:``},message:{type:n([String,Object,Function]),default:``},offset:{type:Number,default:0},onClick:{type:n(Function),default:()=>void 0},onClose:{type:n(Function),required:!0},position:{type:String,values:[`top-right`,`top-left`,`bottom-right`,`bottom-left`],default:`top-right`},showClose:{type:Boolean,default:!0},title:{type:String,default:``},type:{type:String,values:[...H,``],default:``},zIndex:Number,closeIcon:{type:B,default:i}}),W={destroy:()=>!0},G=[`id`],K=[`textContent`],q={key:0},J=[`innerHTML`],Y=I({name:`ElNotification`,__name:`notification`,props:U,emits:W,setup(t,{expose:n}){let r=t,{ns:i,zIndex:o}=z(`notification`),{nextZIndex:s,currentZIndex:l}=o,d=A(!1),h,w=D(()=>{let e=r.type;return e&&V[r.type]?i.m(e):``}),O=D(()=>r.type&&V[r.type]||r.icon),M=D(()=>r.position.endsWith(`right`)?`right`:`left`),I=D(()=>r.position.startsWith(`top`)?`top`:`bottom`),L=D(()=>({[I.value]:`${r.offset}px`,zIndex:r.zIndex??l.value}));function B(){r.duration>0&&({stop:h}=c(()=>{d.value&&U()},r.duration))}function H(){h?.()}function U(){d.value=!1}function W(e){switch(u(e)){case a.delete:case a.backspace:H();break;case a.esc:d.value&&U();break;default:B();break}}return v(()=>{B(),s(),d.value=!0}),e(document,`keydown`,W),n({visible:d,close:U}),(e,n)=>(m(),C(P,{name:j(i).b(`fade`),onBeforeLeave:t.onClose,onAfterLeave:n[1]||=t=>e.$emit(`destroy`),persisted:``},{default:b(()=>[p(E(`div`,{id:t.id,class:x([j(i).b(),t.customClass,M.value]),style:g(L.value),role:`alert`,onMouseenter:H,onMouseleave:B,onClick:n[0]||=(...e)=>t.onClick&&t.onClick(...e)},[O.value?(m(),C(j(f),{key:0,class:x([j(i).e(`icon`),w.value])},{default:b(()=>[(m(),C(_(O.value)))]),_:1},8,[`class`])):F(`v-if`,!0),E(`div`,{class:x(j(i).e(`group`))},[E(`h2`,{class:x(j(i).e(`title`)),textContent:y(t.title)},null,10,K),p(E(`div`,{class:x(j(i).e(`content`)),style:g(t.title?void 0:{margin:0})},[S(e.$slots,`default`,{},()=>[t.dangerouslyUseHTMLString?(m(),R(T,{key:1},[F(` Caution here, message could've been compromised, never use user's input as message `),E(`p`,{innerHTML:t.message},null,8,J)],2112)):(m(),R(`p`,q,y(t.message),1))])],6),[[N,t.message]]),t.showClose?(m(),C(j(f),{key:0,class:x(j(i).e(`closeBtn`)),onClick:k(U,[`stop`])},{default:b(()=>[(m(),C(_(t.closeIcon)))]),_:1},8,[`class`])):F(`v-if`,!0)],2)],46,G),[[N,d.value]])]),_:3},8,[`name`,`onBeforeLeave`]))}}),X={"top-left":[],"top-right":[],"bottom-left":[],"bottom-right":[]},Z=16,Q=1,$=function(e={},n){if(!o)return{close:()=>void 0};(L(e)||O(e))&&(e={message:e});let r=e.position||`top-right`,i=e.offset||0;X[r].forEach(({vm:e})=>{i+=(e.el?.offsetHeight||0)+Z}),i+=Z;let a=`notification_${Q++}`,s=e.onClose,c={...e,offset:i,id:a,onClose:()=>{ee(a,r,s)}},u=document.body;l(e.appendTo)?u=e.appendTo:L(e.appendTo)&&(u=document.querySelector(e.appendTo)),l(u)||(t(`ElNotification`,`the appendTo option is not an HTMLElement. Falling back to document.body.`),u=document.body);let f=document.createElement(`div`),p=h(Y,c,w(c.message)?c.message:O(c.message)?()=>c.message:null);return p.appContext=d(n)?$._context:n,p.props.onDestroy=()=>{M(null,f)},M(p,f),X[r].push({vm:p}),u.appendChild(f.firstElementChild),{close:()=>{p.component.exposed.visible.value=!1}}};H.forEach(e=>{$[e]=(t={},n)=>((L(t)||O(t))&&(t={message:t}),$({...t,type:e},n))});function ee(e,t,n){let r=X[t],i=r.findIndex(({vm:t})=>t.component?.props.id===e);if(i===-1)return;let{vm:a}=r[i];if(!a)return;n?.(a);let o=a.el.offsetHeight,s=t.split(`-`)[0];r.splice(i,1);let c=r.length;if(!(c<1))for(let e=i;e<c;e++){let{el:t,component:n}=r[e].vm,i=Number.parseInt(t.style[s],10)-o-Z;n.props.offset=i}}function te(){for(let e of Object.values(X))e.forEach(({vm:e})=>{e.component.exposed.visible.value=!1})}function ne(e=`top-right`){let t=X[e][0]?.vm.component?.props?.offset||0;for(let{vm:n}of X[e])n.component.props.offset=t,t+=(n.el?.offsetHeight||0)+Z}$.closeAll=te,$.updateOffsets=ne,$._context=null;var re=s($,`$notify`);export{re as t};