import{eventType as e}from"../_util/type.mjs";import t from"../_util/classNames.mjs";import n from"../config-provider/hooks/useConfigInject.mjs";import r from"../_util/vue-types/index.mjs";import{isPresetColor as i,isPresetStatusColor as a}from"../_util/colors.mjs";import o from"../_util/wave/index.mjs";import s from"./style/index.mjs";import c from"./CheckableTag.mjs";import{Fragment as l,computed as u,createVNode as d,defineComponent as f,shallowRef as p,watchEffect as m}from"vue";import{CloseOutlined as h}from"@antsoo-lib/icons";var g=()=>({prefixCls:String,color:{type:String},closable:{type:Boolean,default:!1},closeIcon:r.any,visible:{type:Boolean,default:void 0},onClose:{type:Function},onClick:e(),"onUpdate:visible":Function,icon:r.any,bordered:{type:Boolean,default:!0}}),_=f({compatConfig:{MODE:3},name:`ATag`,inheritAttrs:!1,props:g(),slots:Object,setup(e,{slots:r,emit:c,attrs:f}){let{prefixCls:g,direction:_}=n(`tag`,e),[v,y]=s(g),b=p(!0);m(()=>{e.visible!==void 0&&(b.value=e.visible)});let x=t=>{t.stopPropagation(),c(`update:visible`,!1),c(`close`,t),!t.defaultPrevented&&e.visible===void 0&&(b.value=!1)},S=u(()=>i(e.color)||a(e.color)),C=u(()=>t(g.value,y.value,{[`${g.value}-${e.color}`]:S.value,[`${g.value}-has-color`]:e.color&&!S.value,[`${g.value}-hidden`]:!b.value,[`${g.value}-rtl`]:_.value===`rtl`,[`${g.value}-borderless`]:!e.bordered})),w=e=>{c(`click`,e)};return()=>{let{icon:t=r.icon?.(),color:n,closeIcon:i=r.closeIcon?.(),closable:a=!1}=e,s=()=>a?i?d(`span`,{class:`${g.value}-close-icon`,onClick:x},[i]):d(h,{class:`${g.value}-close-icon`,onClick:x},null):null,c={backgroundColor:n&&!S.value?n:void 0},u=t||null,p=r.default?.(),m=u?d(l,null,[u,d(`span`,null,[p])]):p,_=e.onClick!==void 0,y=d(`span`,{...f,onClick:w,class:[C.value,f.class],style:[c,f.style]},[m,s()]);return v(_?d(o,null,{default:()=>[y]}):y)}}});_.CheckableTag=c,_.install=function(e){return e.component(_.name,_),e.component(c.name,c),e};export{c as CheckableTag,_ as default,g as tagProps};