import{defineComponent as q,computed as l,ref as N,watch as F,createVNode as a,Transition as G,withDirectives as J,vShow as K}from"vue";import L from"../_util/classNames.mjs";import{isPresetColor as Q}from"../_util/colors.mjs";import U from"../_util/isNumeric.mjs";import{getPropsSlot as W,flattenChildren as X}from"../_util/props-util/index.mjs";import{getTransitionProps as Y}from"../_util/transition.mjs";import{cloneElement as _}from"../_util/vnode.mjs";import B from"../_util/vue-types/index.mjs";import ee from"../config-provider/hooks/useConfigInject.mjs";import te from"./Ribbon.mjs";import le from"./ScrollNumber.mjs";import oe from"./style/index.mjs";function ue(){return{count:B.any.def(null),showZero:{type:Boolean,default:void 0},overflowCount:{type:Number,default:99},dot:{type:Boolean,default:void 0},prefixCls:String,scrollNumberPrefixCls:String,status:{type:String},size:{type:String,default:"default"},color:String,text:B.any,offset:Array,numberStyle:{type:Object,default:void 0},title:String}}const be=q({compatConfig:{MODE:3},name:"ABadge",Ribbon:te,inheritAttrs:!1,props:ue(),slots:Object,setup(e,{slots:c,attrs:v}){const{prefixCls:t,direction:w}=ee("badge",e),[P,E]=oe(t),C=l(()=>e.count>e.overflowCount?`${e.overflowCount}+`:e.count),$=l(()=>C.value==="0"||C.value===0),Z=l(()=>e.count===null||$.value&&!e.showZero),S=l(()=>(e.status!==null&&e.status!==void 0||e.color!==null&&e.color!==void 0)&&Z.value),i=l(()=>e.dot&&!$.value),s=l(()=>i.value?"":C.value),T=l(()=>(s.value===null||s.value===void 0||s.value===""||$.value&&!e.showZero)&&!i.value),D=N(e.count),d=N(s.value),m=N(i.value);F([()=>e.count,s,i],()=>{T.value||(D.value=e.count,d.value=s.value,m.value=i.value)},{immediate:!0});const y=l(()=>Q(e.color,!1)),k=l(()=>({[`${t.value}-status-dot`]:S.value,[`${t.value}-status-${e.status}`]:!!e.status,[`${t.value}-color-${e.color}`]:y.value})),z=l(()=>e.color&&!y.value?{background:e.color,color:e.color}:{}),O=l(()=>({[`${t.value}-dot`]:m.value,[`${t.value}-count`]:!m.value,[`${t.value}-count-sm`]:e.size==="small",[`${t.value}-multiple-words`]:!m.value&&d.value&&d.value.toString().length>1,[`${t.value}-status-${e.status}`]:!!e.status,[`${t.value}-color-${e.color}`]:y.value}));return()=>{const{offset:o,title:R,color:I}=e,j=v.style,h=W(c,e,"text"),u=t.value,r=D.value;let n=X(c.default?.());n=n.length?n:null;const x=!!(!T.value||c.count),g=(()=>{if(!o)return{...j};const f={marginTop:U(o[1])?`${o[1]}px`:o[1]};return w.value==="rtl"?f.left=`${Number.parseInt(o[0],10)}px`:f.right=`${-Number.parseInt(o[0],10)}px`,{...f,...j}})(),H=R??(typeof r=="string"||typeof r=="number"?r:void 0),M=x||!h?null:a("span",{class:`${u}-status-text`},[h]),V=typeof r=="object"||r===void 0&&c.count?_(r??c.count?.(),{style:g},!1):null,A=L(u,{[`${u}-status`]:S.value,[`${u}-not-a-wrapper`]:!n,[`${u}-rtl`]:w.value==="rtl"},v.class,E.value);if(!n&&S.value){const f=g.color;return P(a("span",{...v,class:A,style:g},[a("span",{class:k.value,style:z.value},null),a("span",{style:{color:f},class:`${u}-status-text`},[h])]))}const p=Y(n?`${u}-zoom`:"",{appear:!1});let b={...g,...e.numberStyle};return I&&!y.value&&(b=b||{},b.background=I),P(a("span",{...v,class:A},[n,a(G,p,{default:()=>[J(a(le,{prefixCls:e.scrollNumberPrefixCls,show:x,class:O.value,count:d.value,title:H,style:b,key:"scrollNumber"},{default:()=>[V]}),[[K,x]])]}),M]))}}});export{ue as badgeProps,be as default};
