import{j as u,n as P,o as I,f as m,t as j,r as v,v as D,y as F,w as M,x as N}from"./index-60657852.js";import{c as z}from"./Grow-a21bdd26.js";const U=z(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"}),"Person");function E(a){return P("MuiAvatar",a)}const K=I("MuiAvatar",["root","colorDefault","circular","rounded","square","img","fallback"]),T=a=>{const{classes:t,variant:e,colorDefault:r}=a;return N({root:["root",e,r&&"colorDefault"],img:["img"],fallback:["fallback"]},E,t)},q=m("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=m("img",{name:"MuiAvatar",slot:"Img",overridesResolver:(a,t)=>t.img})({width:"100%",height:"100%",textAlign:"center",objectFit:"cover",color:"transparent",textIndent:1e4}),B=m(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[n,s]=v.useState(!1);return v.useEffect(()=>{if(!e&&!r)return;s(!1);let i=!0;const o=new Image;return o.onload=()=>{i&&s("loaded")},o.onerror=()=>{i&&s("error")},o.crossOrigin=a,o.referrerPolicy=t,o.src=e,r&&(o.srcset=r),()=>{i=!1}},[a,t,e,r]),n}const $=v.forwardRef(function(t,e){const r=D({props:t,name:"MuiAvatar"}),{alt:n,children:s,className:i,component:o="div",slots:A={},slotProps:d={},imgProps:y,sizes:h,src:p,srcSet:f,variant:k="circular",...w}=r;let c=null;const l={...r,component:o,variant:k},R=H({...y,...typeof d.img=="function"?d.img(l):d.img,src:p,srcSet:f}),b=p||f,x=b&&R!=="error";l.colorDefault=!x,delete l.ownerState;const g=T(l),[S,C]=F("img",{className:g.img,elementType:L,externalForwardedProps:{slots:A,slotProps:{img:{...y,...d.img}}},additionalProps:{alt:n,src:p,srcSet:f,sizes:h},ownerState:l});return x?c=u.jsx(S,{...C}):s||s===0?c=s:b&&n?c=n[0]:c=u.jsx(B,{ownerState:l,className:g.fallback}),u.jsx(q,{as:o,className:M(g.root,i),ref:e,...w,ownerState:l,children:c})}),O=$;export{O as A,K as a};
