import{x as E,y as d,z as L,W as z,d as b,O as u,X as B,Q as k,Y as f,I as D,Z as j,$ as C,a0 as N,i as a,a1 as R,a2 as U,a3 as P,S as _,J as F,K as J}from"./index.afa1b71c.js";const[K,o]=E("image"),O={src:String,alt:String,fit:String,position:String,round:Boolean,width:d,height:d,radius:d,lazyLoad:Boolean,iconSize:d,showError:L,errorIcon:z("photo-fail"),iconPrefix:String,showLoading:L,loadingIcon:z("photo")};var Q=b({name:K,props:O,emits:["load","error"],setup(e,{emit:g,slots:s}){const n=u(!1),i=u(!0),l=u(),{$Lazyload:t}=B().proxy,S=k(()=>{const r={width:f(e.width),height:f(e.height)};return D(e.radius)&&(r.overflow="hidden",r.borderRadius=f(e.radius)),r});j(()=>e.src,()=>{n.value=!1,i.value=!0});const v=r=>{i.value=!1,g("load",r)},h=r=>{n.value=!0,i.value=!1,g("error",r)},m=(r,c,I)=>I?I():a(F,{name:r,size:e.iconSize,class:c,classPrefix:e.iconPrefix},null),x=()=>{if(i.value&&e.showLoading)return a("div",{class:o("loading")},[m(e.loadingIcon,o("loading-icon"),s.loading)]);if(n.value&&e.showError)return a("div",{class:o("error")},[m(e.errorIcon,o("error-icon"),s.error)])},$=()=>{if(n.value||!e.src)return;const r={alt:e.alt,class:o("img"),style:{objectFit:e.fit,objectPosition:e.position}};return e.lazyLoad?R(a("img",P({ref:l},r),null),[[U("lazy"),e.src]]):a("img",P({src:e.src,onLoad:v,onError:h},r),null)},w=({el:r})=>{const c=()=>{r===l.value&&i.value&&v()};l.value?c():_(c)},y=({el:r})=>{r===l.value&&!n.value&&h()};return t&&C&&(t.$on("loaded",w),t.$on("error",y),N(()=>{t.$off("loaded",w),t.$off("error",y)})),()=>{var r;return a("div",{class:o({round:e.round}),style:S.value},[$(),x(),(r=s.default)==null?void 0:r.call(s)])}}});const V=J(Q);export{V as I};
