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