import{r as e,j as t}from"./vendor-react-AXa6hZO5.js";import{g as a}from"./c6eedc03a-C8LSdtro.js";const s=e.createContext(null);const r=a("inline-flex shrink-0 select-none items-center justify-center overflow-hidden rounded-full font-sans font-medium leading-none",{variants:{size:{sm:"size-avatar-sm text-[9px]",md:"size-avatar-md text-footnote",lg:"size-avatar-lg text-body"},variant:{default:"bg-fill-control text-primary",pro:"bg-fill-pro text-on-pro"}},defaultVariants:{size:"md",variant:"default"}});const n=e.forwardRef(({src:a,name:n,size:o,variant:i,className:l,...c},d)=>{const m=e.useContext(s);m&&(o=m.size);const[f,u]=e.useState(!1);e.useEffect(()=>{u(!1)},[a]);const v=e.useMemo(()=>function(e){const t=e.trim().split(/\s+/);return((t[0]?.[0]??"")+(t.length>1?t[t.length-1]?.[0]??"":"")).toLocaleUpperCase()||"?"}(n),[n]),p=Boolean(a)&&!f;return t.jsx("span",{ref:d,"data-cds":"Avatar",...c,className:`${r({size:o,variant:i})} ${l??""}`,role:p?void 0:"img","aria-label":p?void 0:n,children:p?t.jsx("img",{src:a,alt:n,className:"size-full object-cover",draggable:!1,onError:()=>u(!0)}):v})});n.displayName="Avatar";export{n as A};
