import{j as d,m as P,n as I,f as g,q as j,r as v,t as D,x as F,v as M,w as N}from"./index-c121b02d.js";import{c as z}from"./Grow-9a484472.js";const U=z(d.jsx("path",{d:"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"}),"Person");function q(a){return P("MuiAvatar",a)}const K=I("MuiAvatar",["root","colorDefault","circular","rounded","square","img","fallback"]),E=a=>{const{classes:t,variant:e,colorDefault:r}=a;return N({root:["root",e,r&&"colorDefault"],img:["img"],fallback:["fallback"]},q,t)},T=g("div",{name:"MuiAvatar",slot:"Root",overridesResolver:(a,t)=>{const{ownerState:e}=a;return[t.root,t[e.variant],e.colorDefault&&t.colorDefault]}})(j(({theme:a})=>({position:"relative",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:40,height:40,fontFamily:a.typography.fontFamily,fontSize:a.typography.pxToRem(20),lineHeight:1,borderRadius:"50%",overflow:"hidden",userSelect:"none",variants:[{props:{variant:"rounded"},style:{borderRadius:(a.vars||a).shape.borderRadius}},{props:{variant:"square"},style:{borderRadius:0}},{props:{colorDefault:!0},style:{color:(a.vars||a).palette.background.default,...a.vars?{backgroundColor:a.vars.palette.Avatar.defaultBg}:{backgroundColor:a.palette.grey[400],...a.applyStyles("dark",{backgroundColor:a.palette.grey[600]})}}}]}))),L=g("img",{name:"MuiAvatar",slot:"Img",overridesResolver:(a,t)=>t.img})({width:"100%",height:"100%",textAlign:"center",objectFit:"cover",color:"transparent",textIndent:1e4}),B=g(U,{name:"MuiAvatar",slot:"Fallback",overridesResolver:(a,t)=>t.fallback})({width:"75%",height:"75%"});function H({crossOrigin:a,referrerPolicy:t,src:e,srcSet:r}){const[l,s]=v.useState(!1);return v.useEffect(()=>{if(!e&&!r)return;s(!1);let n=!0;const o=new Image;return o.onload=()=>{n&&s("loaded")},o.onerror=()=>{n&&s("error")},o.crossOrigin=a,o.referrerPolicy=t,o.src=e,r&&(o.srcset=r),()=>{n=!1}},[a,t,e,r]),l}const $=v.forwardRef(function(t,e){const r=D({props:t,name:"MuiAvatar"}),{alt:l,children:s,className:n,component:o="div",slots:x={},slotProps:A={},imgProps:m,sizes:h,src:u,srcSet:p,variant:k="circular",...w}=r;let i=null;const R=H({...m,src:u,srcSet:p}),y=u||p,b=y&&R!=="error",c={...r,colorDefault:!b,component:o,variant:k};delete c.ownerState;const f=E(c),[S,C]=F("img",{className:f.img,elementType:L,externalForwardedProps:{slots:x,slotProps:{img:{...m,...A.img}}},additionalProps:{alt:l,src:u,srcSet:p,sizes:h},ownerState:c});return b?i=d.jsx(S,{...C}):s||s===0?i=s:y&&l?i=l[0]:i=d.jsx(B,{ownerState:c,className:f.fallback}),d.jsx(T,{as:o,className:M(f.root,n),ref:e,...w,ownerState:c,children:i})}),O=$;export{O as A,K as a};
