import{a as G,aa as J,r as _,U as H,f as U,aD as K,D as Q,ao as Y,V as W,ac as I,al as Z,b9 as $,J as l,j as c,_ as B,aT as aa,T as y,aR as ta,aB as ea,cX as ra}from"./index.bde7963b.js";import{u as na,b as ia}from"./index.3289c967.js";import{e as oa}from"./index.18602d99.js";var la=function(){return{prefixCls:String,shape:{type:String,default:"circle"},size:{type:[Number,String,Object],default:function(){return"default"}},src:String,srcset:String,icon:J.any,alt:String,gap:Number,draggable:{type:Boolean,default:void 0},crossOrigin:String,loadError:{type:Function}}},sa=G({name:"AAvatar",inheritAttrs:!1,props:la(),slots:["icon"],setup:function(a,b){var S=b.slots,i=b.attrs,d=_(!0),m=_(!1),x=_(1),o=_(null),h=_(null),T=H("avatar",a),p=T.prefixCls,A=na(),n=U(function(){return a.size==="default"?A.value:a.size}),w=K(),u=oa(function(){if(Q(a.size)==="object"){var t=Y.find(function(r){return w.value[r]}),e=a.size[t];return e}}),E=function(e){return u.value?{width:"".concat(u.value,"px"),height:"".concat(u.value,"px"),lineHeight:"".concat(u.value,"px"),fontSize:"".concat(e?u.value/2:18,"px")}:{}},v=function(){if(!(!o.value||!h.value)){var e=o.value.offsetWidth,r=h.value.offsetWidth;if(e!==0&&r!==0){var s=a.gap,P=s===void 0?4:s;P*2<r&&(x.value=r-P*2<e?(r-P*2)/e:1)}}},z=function(){var e=a.loadError,r=e==null?void 0:e();r!==!1&&(d.value=!1)};return W(function(){return a.src},function(){I(function(){d.value=!0,x.value=1})}),W(function(){return a.gap},function(){I(function(){v()})}),Z(function(){I(function(){v(),m.value=!0})}),function(){var t,e,r=a.shape,s=a.src,P=a.alt,D=a.srcset,F=a.draggable,L=a.crossOrigin,C=$(S,a,"icon"),f=p.value,M=(t={},l(t,"".concat(i.class),!!i.class),l(t,f,!0),l(t,"".concat(f,"-lg"),n.value==="large"),l(t,"".concat(f,"-sm"),n.value==="small"),l(t,"".concat(f,"-").concat(r),r),l(t,"".concat(f,"-image"),s&&d.value),l(t,"".concat(f,"-icon"),C),t),V=typeof n.value=="number"?{width:"".concat(n.value,"px"),height:"".concat(n.value,"px"),lineHeight:"".concat(n.value,"px"),fontSize:C?"".concat(n.value/2,"px"):"18px"}:{},R=(e=S.default)===null||e===void 0?void 0:e.call(S),k;if(s&&d.value)k=c("img",{draggable:F,src:s,srcset:D,onError:z,alt:P,crossorigin:L},null);else if(C)k=C;else if(m.value||x.value!==1){var O="scale(".concat(x.value,") translateX(-50%)"),X={msTransform:O,WebkitTransform:O,transform:O},q=typeof n.value=="number"?{lineHeight:"".concat(n.value,"px")}:{};k=c(aa,{onResize:v},{default:function(){return[c("span",{class:"".concat(f,"-string"),ref:o,style:B(B({},q),X)},[R])]}})}else k=c("span",{class:"".concat(f,"-string"),ref:o,style:{opacity:0}},[R]);return c("span",y(y({},i),{},{ref:h,class:M,style:[V,E(!!C),i.style]}),[k])}}}),j=sa,ca=function(){return{prefixCls:String,maxCount:Number,maxStyle:{type:Object,default:void 0},maxPopoverPlacement:{type:String,default:"top"},maxPopoverTrigger:String,size:{type:[Number,String,Object],default:"default"}}},ua=G({name:"AAvatarGroup",inheritAttrs:!1,props:ca(),setup:function(a,b){var S=b.slots,i=b.attrs,d=H("avatar-group",a),m=d.prefixCls,x=d.direction;return ia(a),function(){var o,h=a.maxPopoverPlacement,T=h===void 0?"top":h,p=a.maxCount,A=a.maxStyle,n=a.maxPopoverTrigger,w=n===void 0?"hover":n,u=(o={},l(o,m.value,!0),l(o,"".concat(m.value,"-rtl"),x.value==="rtl"),l(o,"".concat(i.class),!!i.class),o),E=$(S,a),v=ta(E).map(function(r,s){return ea(r,{key:"avatar-key-".concat(s)})}),z=v.length;if(p&&p<z){var t=v.slice(0,p),e=v.slice(p,z);return t.push(c(ra,{key:"avatar-popover-key",content:e,trigger:w,placement:T,overlayClassName:"".concat(m.value,"-popover")},{default:function(){return[c(j,{style:A},{default:function(){return["+".concat(z-p)]}})]}})),c("div",y(y({},i),{},{class:u,style:i.style}),[t])}return c("div",y(y({},i),{},{class:u,style:i.style}),[v])}}}),N=ua;j.Group=N;j.install=function(g){return g.component(j.name,j),g.component(N.name,N),g};export{j as A};
