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