import{h as f,ac as A,af as C,E as c,v,o as p,w as _,x as m,g as o,ae as S,k as L,bm as w,H as q,Z as E,W as R,b0 as I,m as $,$ as x,bn as B,y as P,N as k,ad as b}from"./BzhixHsn.js";const[z,O]=A("AvatarRoot");var M=f({__name:"AvatarRoot",props:{asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"span"}},setup(t){return C(),O({imageLoadingStatus:c("idle")}),(e,r)=>(p(),v(o(S),{"as-child":e.asChild,as:e.as},{default:_(()=>[m(e.$slots,"default")]),_:3},8,["as-child","as"]))}}),W=M;function y(t,e){return t?e?(t.src!==e&&(t.src=e),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function j(t,{referrerPolicy:e,crossOrigin:r}={}){const s=c(!1),l=c(null),u=L(()=>s.value?(!l.value&&w&&(l.value=new window.Image),l.value):null),i=c(y(u.value,t.value)),d=n=>()=>{s.value&&(i.value=n)};return q(()=>{s.value=!0,E(n=>{const a=u.value;if(!a)return;i.value=y(a,t.value);const g=d("loaded"),h=d("error");a.addEventListener("load",g),a.addEventListener("error",h),e?.value&&(a.referrerPolicy=e.value),typeof r?.value=="string"&&(a.crossOrigin=r.value),n(()=>{a.removeEventListener("load",g),a.removeEventListener("error",h)})})}),R(()=>{s.value=!1}),i}var D=f({__name:"AvatarImage",props:{src:{type:String,required:!0},referrerPolicy:{type:null,required:!1},crossOrigin:{type:null,required:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1,default:"img"}},emits:["loadingStatusChange"],setup(t,{emit:e}){const r=t,s=e,{src:l,referrerPolicy:u,crossOrigin:i}=I(r);C();const d=z(),n=j(l,{referrerPolicy:u,crossOrigin:i});return $(n,a=>{s("loadingStatusChange",a),a!=="idle"&&(d.imageLoadingStatus.value=a)},{immediate:!0}),(a,g)=>x((p(),v(o(S),{role:"img","as-child":a.asChild,as:a.as,src:o(l),"referrer-policy":o(u)},{default:_(()=>[m(a.$slots,"default")]),_:3},8,["as-child","as","src","referrer-policy"])),[[B,o(n)==="loaded"]])}}),F=D;const N=f({__name:"Avatar",props:{class:{}},setup(t){const e=t;return(r,s)=>(p(),v(o(W),{"data-slot":"avatar",class:P(o(k)("relative flex size-8 shrink-0 overflow-hidden rounded-full",e.class))},{default:_(()=>[m(r.$slots,"default")]),_:3},8,["class"]))}}),U=f({__name:"AvatarImage",props:{src:{},referrerPolicy:{},crossOrigin:{},asChild:{type:Boolean},as:{}},setup(t){const e=t;return(r,s)=>(p(),v(o(F),b({"data-slot":"avatar-image"},e,{class:"aspect-square size-full"}),{default:_(()=>[m(r.$slots,"default")]),_:3},16))}});export{N as _,U as a,z as i};
