text: !function(e,t){var i='<div id="{{id}}" class="mui-slider mui-preview-image mui-fullscreen"><div class="mui-preview-header">{{header}}</div><div class="mui-slider-group"></div><div class="mui-preview-footer mui-hidden">{{footer}}</div><div class="mui-preview-loading"><span class="mui-spinner mui-spinner-white"></span></div></div>',s='<div class="mui-slider-item mui-zoom-wrapper {{className}}"><div class="mui-zoom-scroller"><img src="{{src}}" data-preview-lazyload="{{lazyload}}" style="{{style}}" class="mui-zoom"></div></div>',r="__DEFAULT",a=document.createElement("div"),n=function(t){this.options=e.extend(!0,{id:"__MUI_PREVIEWIMAGE",zoom:!0,header:'<span class="mui-preview-indicator"></span>',footer:""},t||{}),this.init(),this.initEvent()},o=n.prototype;o.init=function(){var t=this.options,s=document.getElementById(this.options.id);s||(a.innerHTML=i.replace(/\{\{id\}\}/g,this.options.id).replace("{{header}}",t.header).replace("{{footer}}",t.footer),document.body.appendChild(a.firstElementChild),s=document.getElementById(this.options.id)),this.element=s,this.scroller=this.element.querySelector(e.classSelector(".slider-group")),this.indicator=this.element.querySelector(e.classSelector(".preview-indicator")),this.loader=this.element.querySelector(e.classSelector(".preview-loading")),t.footer&&this.element.querySelector(e.classSelector(".preview-footer")).classList.remove(e.className("hidden")),this.addImages()},o.initEvent=function(){var t=this;e(document.body).on("tap","img[data-preview-src]",function(){return t.open(this),!1});var i=null,s=function(){!i&&(i=e.later(function(){t.loader.removeEventListener("tap",s),t.scroller.removeEventListener("tap",s),t.close()},300))};this.scroller.addEventListener("doubletap",function(){i&&(i.cancel(),i=null)}),this.element.addEventListener("webkitAnimationEnd",function(){t.element.classList.contains(e.className("preview-out"))?(t.element.style.display="none",t.element.classList.remove(e.className("preview-out")),t.element.classList.remove(e.className("preview-in")),i=null):(t.loader.addEventListener("tap",s),t.scroller.addEventListener("tap",s))}),this.element.addEventListener("slide",function(i){if(t.options.zoom){var s=t.element.querySelector(".mui-zoom-wrapper:nth-child("+(t.lastIndex+1)+")");s&&e(s).zoom().setZoom(1)}var r=i.detail.slideNumber;t.lastIndex=r,t.indicator&&(t.indicator.innerText=r+1+"/"+t.currentGroup.length),t._loadItem(r)})},o.addImages=function(e,t){this.groups={};var i=[];if(i=e?e===r?document.querySelectorAll("img[data-preview-src]:not([data-preview-group])"):document.querySelectorAll("img[data-preview-src][data-preview-group='"+e+"']"):document.querySelectorAll("img[data-preview-src]"),i.length)for(var s=0,a=i.length;s<a;s++)this.addImage(i[s])},o.addImage=function(e){var t=e.getAttribute("data-preview-group");t=t||r,this.groups[t]||(this.groups[t]=[]);var i=e.getAttribute("src");if(e.__mui_img_data&&e.__mui_img_data.src===i)this.groups[t].push(e.__mui_img_data);else{var s=e.getAttribute("data-preview-src");s||(s=i);var a={src:i,lazyload:i===s?"":s,loaded:i===s,sWidth:0,sHeight:0,sTop:0,sLeft:0,sScale:1,el:e};this.groups[t].push(a),e.__mui_img_data=a}},o.empty=function(){this.scroller.innerHTML=""},o._initImgData=function(i,s){if(!i.sWidth){var r=i.el;i.sWidth=r.offsetWidth,i.sHeight=r.offsetHeight;var a=e.offset(r);i.sTop=a.top,i.sLeft=a.left,i.sScale=Math.max(i.sWidth/t.innerWidth,i.sHeight/t.innerHeight)}s.style.webkitTransform="translate3d(0,0,0) scale("+i.sScale+")"},o._getScale=function(e,t){var i=e.width/t.width,s=e.height/t.height,r=1;return r=i<=s?e.height/(t.height*i):e.width/(t.width*s)},o._imgTransitionEnd=function(t){var i=t.target;i.classList.remove(e.className("transitioning")),i.removeEventListener("webkitTransitionEnd",this._imgTransitionEnd.bind(this))},o._loadItem=function(t,i){var s=this.scroller.querySelector(e.classSelector(".slider-item:nth-child("+(t+1)+")")),r=this.currentGroup[t],a=s.querySelector("img");if(this._initImgData(r,a),i){var n=this._getPosition(r);a.style.webkitTransitionDuration="0ms",a.style.webkitTransform="translate3d("+n.x+"px,"+n.y+"px,0) scale("+r.sScale+")",a.offsetHeight}if(!r.loaded&&a.getAttribute("data-preview-lazyload")){var o=this;o.loader.classList.add(e.className("active")),a.style.webkitTransitionDuration="0.5s",a.addEventListener("webkitTransitionEnd",o._imgTransitionEnd.bind(o)),a.style.webkitTransform="translate3d(0,0,0) scale("+r.sScale+")",this.loadImage(a,function(){r.loaded=!0,a.src=r.lazyload,o._initZoom(s,this.width,this.height),a.classList.add(e.className("transitioning")),a.addEventListener("webkitTransitionEnd",o._imgTransitionEnd.bind(o)),a.setAttribute("style",""),a.offsetHeight,o.loader.classList.remove(e.className("active"))})}else r.lazyload&&(a.src=r.lazyload),this._initZoom(s,a.width,a.height),a.classList.add(e.className("transitioning")),a.addEventListener("webkitTransitionEnd",this._imgTransitionEnd.bind(this)),a.setAttribute("style",""),a.offsetHeight;this._preloadItem(t+1),this._preloadItem(t-1)},o._preloadItem=function(t){var i=this.scroller.querySelector(e.classSelector(".slider-item:nth-child("+(t+1)+")"));if(i){var s=this.currentGroup[t];if(!s.sWidth){var r=i.querySelector("img");this._initImgData(s,r)}}},o._initZoom=function(t,i,s){if(this.options.zoom&&!t.getAttribute("data-zoomer")){var r=t.querySelector(e.classSelector(".zoom"));if("IMG"===r.tagName){var a=this,n=a._getScale({width:t.offsetWidth,height:t.offsetHeight},{width:i,height:s});e(t).zoom({maxZoom:Math.max(n,1)})}else e(t).zoom()}},o.loadImage=function(e,t){var i=function(){t&&t.call(this)},s=new Image;s.onload=i,s.onerror=i,s.src=e.getAttribute("data-preview-lazyload")},o.getRangeByIndex=function(e,t){return{from:0,to:t-1}},o._getPosition=function(e){var i=e.sLeft-t.pageXOffset,s=e.sTop-t.pageYOffset,r=(t.innerWidth-e.sWidth)/2,a=(t.innerHeight-e.sHeight)/2;return{left:i,top:s,x:i-r,y:s-a}},o.refresh=function(i,r){this.currentGroup=r;for(var a=r.length,n=[],o=this.getRangeByIndex(i,a),l=o.from,d=o.to+1,c=i,h="",m="",u=(t.innerWidth,t.innerHeight,0);l<d;l++,u++){var p=r[l],g="";p.sWidth&&(g="-webkit-transform:translate3d(0,0,0) scale("+p.sScale+");transform:translate3d(0,0,0) scale("+p.sScale+")"),m=s.replace("{{src}}",p.src).replace("{{lazyload}}",p.lazyload).replace("{{style}}",g),l===i?(c=u,h=e.className("active")):h="",n.push(m.replace("{{className}}",h))}this.scroller.innerHTML=n.join(""),this.element.style.display="block",this.element.classList.add(e.className("preview-in")),this.lastIndex=c,this.element.offsetHeight,e(this.element).slider().gotoItem(c,0),this.indicator&&(this.indicator.innerText=c+1+"/"+this.currentGroup.length),this._loadItem(c,!0)},o.openByGroup=function(e,t){e=Math.min(Math.max(0,e),this.groups[t].length-1),this.refresh(e,this.groups[t])},o.open=function(e,t){this.isShown()||("number"==typeof e?(t=t||r,this.addImages(t,e),this.openByGroup(e,t)):(t=e.getAttribute("data-preview-group"),t=t||r,this.addImages(t,e),this.openByGroup(this.groups[t].indexOf(e.__mui_img_data),t)))},o.close=function(i,s){if(this.isShown()){this.element.classList.remove(e.className("preview-in")),this.element.classList.add(e.className("preview-out"));var r=this.scroller.querySelector(e.classSelector(".slider-item:nth-child("+(this.lastIndex+1)+")")),a=r.querySelector("img");if(a){a.classList.add(e.className("transitioning"));var n=this.currentGroup[this.lastIndex],o=this._getPosition(n),l=o.left,d=o.top;d>t.innerHeight||l>t.innerWidth||d<0||l<0?(a.style.opacity=0,a.style.webkitTransitionDuration="0.5s",a.style.webkitTransform="scale("+n.sScale+")"):(this.options.zoom&&e(a.parentNode.parentNode).zoom().toggleZoom(0),a.style.webkitTransitionDuration="0.5s",a.style.webkitTransform="translate3d("+o.x+"px,"+o.y+"px,0) scale("+n.sScale+")")}for(var c=this.element.querySelectorAll(e.classSelector(".zoom-wrapper")),h=0,m=c.length;h<m;h++)e(c[h]).zoom().destroy();e(this.element).slider().destroy()}},o.isShown=function(){return this.element.classList.contains(e.className("preview-in"))};var l=null;e.previewImage=function(e){return l||(l=new n(e)),l},e.getPreviewImage=function(){return l}}(mui,window);