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