import{s as e}from"./rolldown-runtime-C5c2KzVm.js";import{$P as t}from"./lucide-C4oWPzu4.js";import{p as n,t as r}from"./utils-Bs-0X7qI.js";import{r as i}from"./bundle-mjs-C4g7ASB5.js";import{n as a}from"./dist-CImBN8k_.js";import{i as o,t as s}from"./dist-dVVC74St.js";import{t as c}from"./dist-BP7JCesB.js";import{t as l}from"./shim-J2g4uRG1.js";var u=e(l(),1);function d(){return(0,u.useSyncExternalStore)(f,()=>!0,()=>!1)}function f(){return()=>{}}var p=e(t(),1),m=i(),h=`Avatar`,[g,_]=o(h),[v,y]=g(h),b=p.forwardRef((e,t)=>{let{__scopeAvatar:n,...r}=e,[i,o]=p.useState(`idle`);return(0,m.jsx)(v,{scope:n,imageLoadingStatus:i,onImageLoadingStatusChange:o,children:(0,m.jsx)(a.span,{...r,ref:t})})});b.displayName=h;var x=`AvatarImage`,S=p.forwardRef((e,t)=>{let{__scopeAvatar:n,src:r,onLoadingStatusChange:i=()=>{},...o}=e,l=y(x,n),u=E(r,o),d=c(e=>{i(e),l.onImageLoadingStatusChange(e)});return s(()=>{u!==`idle`&&d(u)},[u,d]),u===`loaded`?(0,m.jsx)(a.img,{...o,ref:t,src:r}):null});S.displayName=x;var C=`AvatarFallback`,w=p.forwardRef((e,t)=>{let{__scopeAvatar:n,delayMs:r,...i}=e,o=y(C,n),[s,c]=p.useState(r===void 0);return p.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>c(!0),r);return()=>window.clearTimeout(e)}},[r]),s&&o.imageLoadingStatus!==`loaded`?(0,m.jsx)(a.span,{...i,ref:t}):null});w.displayName=C;function T(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?`loaded`:`loading`):`error`:`idle`}function E(e,{referrerPolicy:t,crossOrigin:n}){let r=d(),i=p.useRef(null),a=r?(i.current||=new window.Image,i.current):null,[o,c]=p.useState(()=>T(a,e));return s(()=>{c(T(a,e))},[a,e]),s(()=>{let e=e=>()=>{c(e)};if(!a)return;let r=e(`loaded`),i=e(`error`);return a.addEventListener(`load`,r),a.addEventListener(`error`,i),t&&(a.referrerPolicy=t),typeof n==`string`&&(a.crossOrigin=n),()=>{a.removeEventListener(`load`,r),a.removeEventListener(`error`,i)}},[a,n,t]),o}var D=b,O=S,k=w,A=n();function j(e){let t=(0,A.c)(10),n,i,a;t[0]===e?(n=t[1],i=t[2],a=t[3]):({className:n,size:a,...i}=e,t[0]=e,t[1]=n,t[2]=i,t[3]=a);let o=a===void 0?`default`:a,s;t[4]===n?s=t[5]:(s=r(`after:border-border group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,n),t[4]=n,t[5]=s);let c;return t[6]!==i||t[7]!==o||t[8]!==s?(c=(0,m.jsx)(D,{"data-slot":`avatar`,"data-size":o,className:s,...i}),t[6]=i,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function M(e){let t=(0,A.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`aspect-square rounded-full object-cover`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,m.jsx)(O,{"data-slot":`avatar-image`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function N(e){let t=(0,A.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`bg-muted text-muted-foreground flex size-full items-center justify-center rounded-full text-sm group-data-[size=sm]/avatar:text-xs`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,m.jsx)(k,{"data-slot":`avatar-fallback`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function P(e){let t=(0,A.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`*:data-[slot=avatar]:ring-background group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,m.jsx)(`div`,{"data-slot":`avatar-group`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}function F(e){let t=(0,A.c)(8),n,i;t[0]===e?(n=t[1],i=t[2]):({className:n,...i}=e,t[0]=e,t[1]=n,t[2]=i);let a;t[3]===n?a=t[4]:(a=r(`bg-muted text-muted-foreground ring-background relative flex size-8 shrink-0 items-center justify-center rounded-full text-sm ring-2 group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3`,n),t[3]=n,t[4]=a);let o;return t[5]!==i||t[6]!==a?(o=(0,m.jsx)(`div`,{"data-slot":`avatar-group-count`,className:a,...i}),t[5]=i,t[6]=a,t[7]=o):o=t[7],o}export{M as a,F as i,N as n,P as r,j as t};