import{e as U,a$ as z,cW as V,bO as X,d as N,aZ as ee,f as ae,bM as le,dt as se,r as c,ad as u,c6 as p,w as te,b as ie,o as n,c as d,j as E,C as T,D as oe,a,n as g,F as _,m as ne,h as y,g as re,B as ce,du as ue,aB as de,_ as ve,aF as fe,dv as pe,bP as ye,dw as me,bm as A,dx as ge,dy as we,q as he}from"./index-CHTXMeh8.js";const be=U({hideOnClickModal:Boolean,src:{type:String,default:""},fit:{type:String,values:["","contain","cover","fill","none","scale-down"],default:""},loading:{type:String,values:["eager","lazy"]},lazy:Boolean,scrollContainer:{type:z([String,Object])},previewSrcList:{type:z(Array),default:()=>V([])},previewTeleported:Boolean,zIndex:{type:Number},initialIndex:{type:Number,default:0},infinite:{type:Boolean,default:!0},closeOnPressEscape:{type:Boolean,default:!0},zoomRate:{type:Number,default:1.2},minScale:{type:Number,default:.2},maxScale:{type:Number,default:7},crossorigin:{type:z(String)}}),Se={load:i=>i instanceof Event,error:i=>i instanceof Event,switch:i=>X(i),close:()=>!0,show:()=>!0},xe=["src","loading","crossorigin"],ke={key:0},ze=N({name:"ElImage",inheritAttrs:!1}),Ee=he(ve(N({...ze,props:be,emits:Se,setup(i,{emit:v}){const l=i;let B="";const{t:F}=ee(),o=ae("image"),j=le(),D=se(),w=c(),f=c(!1),r=c(!0),h=c(!1),m=c(),t=c(),P=p&&"loading"in HTMLImageElement.prototype;let b,S;const R=u(()=>[o.e("inner"),x.value&&o.e("preview"),r.value&&o.is("loading")]),q=u(()=>j.style),Y=u(()=>{const{fit:e}=l;return p&&e?{objectFit:e}:{}}),x=u(()=>{const{previewSrcList:e}=l;return Array.isArray(e)&&e.length>0}),H=u(()=>{const{previewSrcList:e,initialIndex:s}=l;let M=s;return s>e.length-1&&(M=0),M}),C=u(()=>l.loading!=="eager"&&(!P&&l.loading==="lazy"||l.lazy)),k=()=>{p&&(r.value=!0,f.value=!1,w.value=l.src)};function K(e){r.value=!1,f.value=!1,v("load",e)}function W(e){r.value=!1,f.value=!0,v("error",e)}function I(){ge(m.value,t.value)&&(k(),$())}const L=we(I,200,!0);async function O(){var e;if(!p)return;await fe();const{scrollContainer:s}=l;pe(s)?t.value=s:ye(s)&&s!==""?t.value=(e=document.querySelector(s))!=null?e:void 0:m.value&&(t.value=me(m.value)),t.value&&(b=A(t,"scroll",L),setTimeout(()=>I(),100))}function $(){p&&t.value&&L&&(b==null||b(),t.value=void 0)}function Z(e){if(e.ctrlKey)return e.deltaY<0||e.deltaY>0?(e.preventDefault(),!1):void 0}function G(){x.value&&(S=A("wheel",Z,{passive:!1}),B=document.body.style.overflow,document.body.style.overflow="hidden",h.value=!0,v("show"))}function J(){S==null||S(),document.body.style.overflow=B,h.value=!1,v("close")}function Q(e){v("switch",e)}return te(()=>l.src,()=>{C.value?(r.value=!0,f.value=!1,$(),O()):k()}),ie(()=>{C.value?O():k()}),(e,s)=>(n(),d("div",{ref_key:"container",ref:m,class:g([a(o).b(),e.$attrs.class]),style:de(a(q))},[f.value?E(e.$slots,"error",{key:0},()=>[T("div",{class:g(a(o).e("error"))},oe(a(F)("el.image.error")),3)]):(n(),d(_,{key:1},[w.value!==void 0?(n(),d("img",ne({key:0},a(D),{src:w.value,loading:e.loading,style:a(Y),class:a(R),crossorigin:e.crossorigin,onClick:G,onLoad:K,onError:W}),null,16,xe)):y("v-if",!0),r.value?(n(),d("div",{key:1,class:g(a(o).e("wrapper"))},[E(e.$slots,"placeholder",{},()=>[T("div",{class:g(a(o).e("placeholder"))},null,2)])],2)):y("v-if",!0)],64)),a(x)?(n(),d(_,{key:2},[h.value?(n(),re(a(ue),{key:0,"z-index":e.zIndex,"initial-index":a(H),infinite:e.infinite,"zoom-rate":e.zoomRate,"min-scale":e.minScale,"max-scale":e.maxScale,"url-list":e.previewSrcList,"hide-on-click-modal":e.hideOnClickModal,teleported:e.previewTeleported,"close-on-press-escape":e.closeOnPressEscape,onClose:J,onSwitch:Q},{default:ce(()=>[e.$slots.viewer?(n(),d("div",ke,[E(e.$slots,"viewer")])):y("v-if",!0)]),_:3},8,["z-index","initial-index","infinite","zoom-rate","min-scale","max-scale","url-list","hide-on-click-modal","teleported","close-on-press-escape"])):y("v-if",!0)],64)):y("v-if",!0)],6))}}),[["__file","image.vue"]]));export{Ee as E};
|