import{defineComponent as k,shallowRef as f,computed as D,createVNode as n,Transition as L,withDirectives as M,vShow as V}from"vue";import{ExclamationCircleOutlined as R,CloseCircleOutlined as j,InfoCircleOutlined as q,CheckCircleOutlined as z,ExclamationCircleFilled as G,CloseCircleFilled as J,InfoCircleFilled as K,CheckCircleFilled as Q,CloseOutlined as U}from"@antsoo-lib/icons";import W from"../_util/classNames.mjs";import{isValidElement as X}from"../_util/props-util/index.mjs";import{getTransitionProps as Y}from"../_util/transition.mjs";import{withInstall as Z,tuple as _}from"../_util/type.mjs";import{cloneElement as ee}from"../_util/vnode.mjs";import i from"../_util/vue-types/index.mjs";import ne from"../config-provider/hooks/useConfigInject.mjs";import oe from"./style/index.mjs";const te={success:Q,info:K,error:J,warning:G},le={success:z,info:q,error:j,warning:R},se=_("success","info","warning","error"),ie=()=>({type:i.oneOf(se),closable:{type:Boolean,default:void 0},closeText:i.any,message:i.any,description:i.any,afterClose:Function,showIcon:{type:Boolean,default:void 0},prefixCls:String,banner:{type:Boolean,default:void 0},icon:i.any,closeIcon:i.any,onClose:Function}),ce=k({compatConfig:{MODE:3},name:"AAlert",inheritAttrs:!1,props:ie(),setup(o,{slots:s,emit:I,attrs:m,expose:b}){const{prefixCls:v,direction:T}=ne("alert",o),[O,F]=oe(v),c=f(!1),g=f(!1),h=f(),A=t=>{t.preventDefault();const l=h.value;l.style.height=`${l.offsetHeight}px`,l.style.height=`${l.offsetHeight}px`,c.value=!0,I("close",t)},y=()=>{c.value=!1,g.value=!0,o.afterClose?.()},$=D(()=>{const{type:t}=o;return t!==void 0?t:o.banner?"warning":"info"});b({animationEnd:y});const E=f({});return()=>{const{banner:t,closeIcon:l=s.closeIcon?.()}=o;let{closable:p,showIcon:a}=o;const C=o.closeText??s.closeText?.(),r=o.description??s.description?.(),x=o.message??s.message?.(),u=o.icon??s.icon?.(),w=s.action?.();a=t&&a===void 0?!0:a;const S=(r?le:te)[$.value]||null;C&&(p=!0);const e=v.value,H=W(e,{[`${e}-${$.value}`]:!0,[`${e}-closing`]:c.value,[`${e}-with-description`]:!!r,[`${e}-no-icon`]:!a,[`${e}-banner`]:!!t,[`${e}-closable`]:p,[`${e}-rtl`]:T.value==="rtl",[F.value]:!0}),B=p?n("button",{type:"button",onClick:A,class:`${e}-close-icon`,tabindex:0},[C?n("span",{class:`${e}-close-text`},[C]):l===void 0?n(U,null,null):l]):null,N=u&&(X(u)?ee(u,{class:`${e}-icon`}):n("span",{class:`${e}-icon`},[u]))||n(S,{class:`${e}-icon`},null),P=Y(`${e}-motion`,{appear:!1,css:!0,onAfterLeave:y,onBeforeLeave:d=>{d.style.maxHeight=`${d.offsetHeight}px`},onLeave:d=>{d.style.maxHeight="0px"}});return O(g.value?null:n(L,P,{default:()=>[M(n("div",{role:"alert",...m,style:[m.style,E.value],class:[m.class,H],"data-show":!c.value,ref:h},[a?N:null,n("div",{class:`${e}-content`},[x?n("div",{class:`${e}-message`},[x]):null,r?n("div",{class:`${e}-description`},[r]):null]),w?n("div",{class:`${e}-action`},[w]):null,B]),[[V,!c.value]])]}))}}}),he=Z(ce);export{ie as alertProps,he as default};
