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