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