photoswipe.min_wev8.js 30.4 KB
!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.PhotoSwipe=t()}(this,function(){"use strict";return function(m,i,e,t){var f={features:null,bind:function(e,t,n,i){var o=(i?"remove":"add")+"EventListener";t=t.split(" ");for(var a=0;a<t.length;a++)t[a]&&e[o](t[a],n,!1)},isArray:function(e){return e instanceof Array},createEl:function(e,t){var n=document.createElement(t||"div");return e&&(n.className=e),n},getScrollY:function(){var e=window.pageYOffset;return void 0!==e?e:document.documentElement.scrollTop},unbind:function(e,t,n){f.bind(e,t,n,!0)},removeClass:function(e,t){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ").replace(/^\s\s*/,"").replace(/\s\s*$/,"")},addClass:function(e,t){f.hasClass(e,t)||(e.className+=(e.className?" ":"")+t)},hasClass:function(e,t){return e.className&&new RegExp("(^|\\s)"+t+"(\\s|$)").test(e.className)},getChildByClass:function(e,t){for(var n=e.firstChild;n;){if(f.hasClass(n,t))return n;n=n.nextSibling}},arraySearch:function(e,t,n){for(var i=e.length;i--;)if(e[i][n]===t)return i;return-1},extend:function(e,t,n){for(var i in t)if(t.hasOwnProperty(i)){if(n&&e.hasOwnProperty(i))continue;e[i]=t[i]}},easing:{sine:{out:function(e){return Math.sin(e*(Math.PI/2))},inOut:function(e){return-(Math.cos(Math.PI*e)-1)/2}},cubic:{out:function(e){return--e*e*e+1}}},detectFeatures:function(){if(f.features)return f.features;var e=f.createEl().style,t="",n={};if(n.oldIE=document.all&&!document.addEventListener,n.touch="ontouchstart"in window,window.requestAnimationFrame&&(n.raf=window.requestAnimationFrame,n.caf=window.cancelAnimationFrame),n.pointerEvent=navigator.pointerEnabled||navigator.msPointerEnabled,!n.pointerEvent){var i=navigator.userAgent;if(/iP(hone|od)/.test(navigator.platform)){var o=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);o&&0<o.length&&1<=(o=parseInt(o[1],10))&&o<8&&(n.isOldIOSPhone=!0)}var a=i.match(/Android\s([0-9\.]*)/),r=a?a[1]:0;1<=(r=parseFloat(r))&&(r<4.4&&(n.isOldAndroid=!0),n.androidVersion=r),n.isMobileOpera=/opera mini|opera mobi/i.test(i)}for(var l,s,u=["transform","perspective","animationName"],c=["","webkit","Moz","ms","O"],d=0;d<4;d++){t=c[d];for(var p=0;p<3;p++)l=u[p],s=t+(t?l.charAt(0).toUpperCase()+l.slice(1):l),!n[l]&&s in e&&(n[l]=s);t&&!n.raf&&(t=t.toLowerCase(),n.raf=window[t+"RequestAnimationFrame"],n.raf&&(n.caf=window[t+"CancelAnimationFrame"]||window[t+"CancelRequestAnimationFrame"]))}if(!n.raf){var m=0;n.raf=function(e){var t=(new Date).getTime(),n=Math.max(0,16-(t-m)),i=window.setTimeout(function(){e(t+n)},n);return m=t+n,i},n.caf=function(e){clearTimeout(e)}}return n.svg=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,f.features=n}};f.detectFeatures(),f.features.oldIE&&(f.bind=function(e,t,n,i){t=t.split(" ");for(var o,a=(i?"detach":"attach")+"Event",r=function(){n.handleEvent.call(n)},l=0;l<t.length;l++)if(o=t[l])if("object"==typeof n&&n.handleEvent){if(i){if(!n["oldIE"+o])return!1}else n["oldIE"+o]=r;e[a]("on"+o,n["oldIE"+o])}else e[a]("on"+o,n)});var h=this,y={allowPanToNext:!0,spacing:.12,bgOpacity:1,mouseUsed:!1,loop:!0,pinchToClose:!0,closeOnScroll:!0,closeOnVerticalDrag:!0,verticalDragRange:.75,hideAnimationDuration:333,showAnimationDuration:333,showHideOpacity:!1,focus:!0,escKey:!0,arrowKeys:!0,mainScrollEndFriction:.35,panEndFriction:.35,isClickableElement:function(e){return"A"===e.tagName},getDoubleTapZoom:function(e,t){return e?1:t.initialZoomLevel<.7?1:1.33},maxSpreadZoom:1.33,modal:!0,scaleMode:"fit",alwaysFadeIn:!1};f.extend(y,t);var s,o,a,x,r,l,u,c,d,v,p,g,w,b,I,C,D,M,T,S,A,E,O,k,R,Z,P,F,L,_,z,N,U,H,Y,B,W,G,X,V,n,K,q,$,j,J,Q,ee,te,ne,ie,oe,ae,re,le={x:0,y:0},se={x:0,y:0},ue={x:0,y:0},ce={},de=0,pe={},me={x:0,y:0},fe=0,he=!0,ye=[],xe={},ve=!1,ge=function(e,t){f.extend(h,t.publicMethods),ye.push(e)},we=function(e){var t=Nt();return t-1<e?e-t:e<0?t+e:e},be={},Ie=function(e,t){return be[e]||(be[e]=[]),be[e].push(t)},Ce=function(e){var t=be[e];if(t){var n=Array.prototype.slice.call(arguments);n.shift();for(var i=0;i<t.length;i++)t[i].apply(h,n)}},De=function(){return(new Date).getTime()},Me=function(e){oe=e,h.bg.style.opacity=e*y.bgOpacity},Te=function(e,t,n,i,o){(!ve||o&&o!==h.currItem)&&(i/=o?o.fitRatio:h.currItem.fitRatio),e[E]=g+t+"px, "+n+"px"+w+" scale("+i+")"},Se=function(e){Q&&(e&&(v>h.currItem.fitRatio?ve||(Kt(h.currItem,!1,!0),ve=!0):ve&&(Kt(h.currItem),ve=!1)),Te(Q,ue.x,ue.y,v))},Ae=function(e){e.container&&Te(e.container.style,e.initialPosition.x,e.initialPosition.y,e.initialZoomLevel,e)},Ee=function(e,t){t[E]=g+e+"px, 0px"+w},Oe=function(e,t){if(!y.loop&&t){var n=x+(me.x*de-e)/me.x,i=Math.round(e-st.x);(n<0&&0<i||n>=Nt()-1&&i<0)&&(e=st.x+i*y.mainScrollEndFriction)}st.x=e,Ee(e,r)},ke=function(e,t){var n=ut[e]-pe[e];return se[e]+le[e]+n-n*(t/p)},Re=function(e,t){e.x=t.x,e.y=t.y,t.id&&(e.id=t.id)},Ze=function(e){e.x=Math.round(e.x),e.y=Math.round(e.y)},Pe=null,Fe=function(){Pe&&(f.unbind(document,"mousemove",Fe),f.addClass(m,"pswp--has_mouse"),y.mouseUsed=!0,Ce("mouseUsed")),Pe=setTimeout(function(){Pe=null},100)},Le=function(e,t){var n=Wt(h.currItem,ce,e);return t&&(J=n),n},_e=function(e){return e||(e=h.currItem),e.initialZoomLevel},ze=function(e){return e||(e=h.currItem),0<e.w?y.maxSpreadZoom:1},Ne=function(e,t,n,i){return i===h.currItem.initialZoomLevel?(n[e]=h.currItem.initialPosition[e],!0):(n[e]=ke(e,i),n[e]>t.min[e]?(n[e]=t.min[e],!0):n[e]<t.max[e]&&(n[e]=t.max[e],!0))},Ue=function(e){var t="";y.escKey&&27===e.keyCode?t="close":y.arrowKeys&&(37===e.keyCode?t="prev":39===e.keyCode&&(t="next")),t&&(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey||(e.preventDefault?e.preventDefault():e.returnValue=!1,h[t]()))},He=function(e){e&&(V||X||ee||Y)&&(e.preventDefault(),e.stopPropagation())},Ye=function(){h.setScrollOffset(0,f.getScrollY())},Be={},We=0,Ge=function(e){Be[e]&&(Be[e].raf&&Z(Be[e].raf),We--,delete Be[e])},Xe=function(e){Be[e]&&Ge(e),Be[e]||(We++,Be[e]={})},Ve=function(){for(var e in Be)Be.hasOwnProperty(e)&&Ge(e)},Ke=function(e,t,n,i,o,a,r){var l,s=De();Xe(e);var u=function(){if(Be[e]){if(l=De()-s,i<=l)return Ge(e),a(n),void(r&&r());a((n-t)*o(l/i)+t),Be[e].raf=R(u)}};u()},qe={shout:Ce,listen:Ie,viewportSize:ce,options:y,isMainScrollAnimating:function(){return ee},getZoomLevel:function(){return v},getCurrentIndex:function(){return x},isDragging:function(){return W},isZooming:function(){return $},setScrollOffset:function(e,t){pe.x=e,_=pe.y=t,Ce("updateScrollOffset",pe)},applyZoomPan:function(e,t,n,i){ue.x=t,ue.y=n,v=e,Se(i)},init:function(){if(!s&&!o){var e;h.framework=f,h.template=m,h.bg=f.getChildByClass(m,"pswp__bg"),P=m.className,s=!0,z=f.detectFeatures(),R=z.raf,Z=z.caf,E=z.transform,L=z.oldIE,h.scrollWrap=f.getChildByClass(m,"pswp__scroll-wrap"),h.container=f.getChildByClass(h.scrollWrap,"pswp__container"),r=h.container.style,h.itemHolders=C=[{el:h.container.children[0],wrap:0,index:-1},{el:h.container.children[1],wrap:0,index:-1},{el:h.container.children[2],wrap:0,index:-1}],C[0].el.style.display=C[2].el.style.display="none",function(){if(E){var e=z.perspective&&!k;return g="translate"+(e?"3d(":"("),w=z.perspective?", 0px)":")"}E="left",f.addClass(m,"pswp--ie"),Ee=function(e,t){t.left=e+"px"},Ae=function(e){var t=1<e.fitRatio?1:e.fitRatio,n=e.container.style,i=t*e.w,o=t*e.h;n.width=i+"px",n.height=o+"px",n.left=e.initialPosition.x+"px",n.top=e.initialPosition.y+"px"},Se=function(){if(Q){var e=Q,t=h.currItem,n=1<t.fitRatio?1:t.fitRatio,i=n*t.w,o=n*t.h;e.width=i+"px",e.height=o+"px",e.left=ue.x+"px",e.top=ue.y+"px"}}}(),d={resize:h.updateSize,scroll:Ye,keydown:Ue,click:He};var t=z.isOldIOSPhone||z.isOldAndroid||z.isMobileOpera;for(z.animationName&&z.transform&&!t||(y.showAnimationDuration=y.hideAnimationDuration=0),e=0;e<ye.length;e++)h["init"+ye[e]]();i&&(h.ui=new i(h,f)).init(),Ce("firstUpdate"),x=x||y.index||0,(isNaN(x)||x<0||x>=Nt())&&(x=0),h.currItem=zt(x),(z.isOldIOSPhone||z.isOldAndroid)&&(he=!1),m.setAttribute("aria-hidden","false"),y.modal&&(he?m.style.position="fixed":(m.style.position="absolute",m.style.top=f.getScrollY()+"px")),void 0===_&&(Ce("initialLayout"),_=F=f.getScrollY());var n="pswp--open ";for(y.mainClass&&(n+=y.mainClass+" "),y.showHideOpacity&&(n+="pswp--animate_opacity "),n+=k?"pswp--touch":"pswp--notouch",n+=z.animationName?" pswp--css_animation":"",n+=z.svg?" pswp--svg":"",f.addClass(m,n),h.updateSize(),l=-1,fe=null,e=0;e<3;e++)Ee((e+l)*me.x,C[e].el.style);L||f.bind(h.scrollWrap,c,h),Ie("initialZoomInEnd",function(){h.setContent(C[0],x-1),h.setContent(C[2],x+1),C[0].el.style.display=C[2].el.style.display="block",y.focus&&m.focus(),f.bind(document,"keydown",h),z.transform&&f.bind(h.scrollWrap,"click",h),y.mouseUsed||f.bind(document,"mousemove",Fe),f.bind(window,"resize scroll",h),Ce("bindEvents")}),h.setContent(C[1],x),h.updateCurrItem(),Ce("afterInit"),he||(b=setInterval(function(){We||W||$||v!==h.currItem.initialZoomLevel||h.updateSize()},1e3)),f.addClass(m,"pswp--visible")}},close:function(){"function"==typeof y.onClose?y.onClose():s&&(o=!(s=!1),Ce("close"),f.unbind(window,"resize",h),f.unbind(window,"scroll",d.scroll),f.unbind(document,"keydown",h),f.unbind(document,"mousemove",Fe),z.transform&&f.unbind(h.scrollWrap,"click",h),W&&f.unbind(window,u,h),Ce("unbindEvents"),Ut(h.currItem,null,!0,h.destroy))},destroy:function(){Ce("destroy"),Pt&&clearTimeout(Pt),m.setAttribute("aria-hidden","true"),m.className=P,b&&clearInterval(b),f.unbind(h.scrollWrap,c,h),f.unbind(window,"scroll",h),pt(),Ve(),be=null},panTo:function(e,t,n){n||(e>J.min.x?e=J.min.x:e<J.max.x&&(e=J.max.x),t>J.min.y?t=J.min.y:t<J.max.y&&(t=J.max.y)),ue.x=e,ue.y=t,Se()},handleEvent:function(e){e=e||window.event,d[e.type]&&d[e.type](e)},goTo:function(e){var t=(e=we(e))-x;fe=t,x=e,h.currItem=zt(x),de-=t,Oe(me.x*de),Ve(),ee=!1,h.updateCurrItem()},next:function(){h.goTo(x+1)},prev:function(){h.goTo(x-1)},updateCurrZoomItem:function(e){if(e&&Ce("beforeChange",0),C[1].el.children.length){var t=C[1].el.children[0];Q=f.hasClass(t,"pswp__zoom-wrap")?t.style:null}else Q=null;J=h.currItem.bounds,p=v=h.currItem.initialZoomLevel,ue.x=J.center.x,ue.y=J.center.y,e&&Ce("afterChange")},invalidateCurrItems:function(){I=!0;for(var e=0;e<3;e++)C[e].item&&(C[e].item.needsUpdate=!0)},updateCurrItem:function(e){if(0!==fe){var t,n=Math.abs(fe);if(!(e&&n<2)){h.currItem=zt(x),ve=!1,Ce("beforeChange",fe),3<=n&&(l+=fe+(0<fe?-3:3),n=3);for(var i=0;i<n;i++)0<fe?(t=C.shift(),C[2]=t,Ee((++l+2)*me.x,t.el.style),h.setContent(t,x-n+i+1+1)):(t=C.pop(),C.unshift(t),Ee(--l*me.x,t.el.style),h.setContent(t,x+n-i-1-1));if(Q&&1===Math.abs(fe)){var o=zt(D);o.initialZoomLevel!==v&&(Wt(o,ce),Kt(o),Ae(o))}fe=0,h.updateCurrZoomItem(),D=x,Ce("afterChange")}}},updateSize:function(e){if(!he&&y.modal){var t=f.getScrollY();if(_!==t&&(m.style.top=t+"px",_=t),!e&&xe.x===window.innerWidth&&xe.y===window.innerHeight)return;xe.x=window.innerWidth,xe.y=window.innerHeight,m.style.height=xe.y+"px"}if(ce.x=h.scrollWrap.clientWidth,ce.y=h.scrollWrap.clientHeight,Ye(),me.x=ce.x+Math.round(ce.x*y.spacing),me.y=ce.y,Oe(me.x*de),Ce("beforeResize"),void 0!==l){for(var n,i,o,a=0;a<3;a++)n=C[a],Ee((a+l)*me.x,n.el.style),o=x+a-1,y.loop&&2<Nt()&&(o=we(o)),(i=zt(o))&&(I||i.needsUpdate||!i.bounds)?(h.cleanSlide(i),h.setContent(n,o),1===a&&(h.currItem=i,h.updateCurrZoomItem(!0)),i.needsUpdate=!1):-1===n.index&&0<=o&&h.setContent(n,o),i&&i.container&&(Wt(i,ce),Kt(i),Ae(i));I=!1}p=v=h.currItem.initialZoomLevel,(J=h.currItem.bounds)&&(ue.x=J.center.x,ue.y=J.center.y,Se(!0)),Ce("resize")},zoomTo:function(t,e,n,i,o){e&&(p=v,ut.x=Math.abs(e.x)-ue.x,ut.y=Math.abs(e.y)-ue.y,Re(se,ue));var a=Le(t,!1),r={};Ne("x",a,r,t),Ne("y",a,r,t);var l=v,s=ue.x,u=ue.y;Ze(r);var c=function(e){ue.y=1===e?(v=t,ue.x=r.x,r.y):(v=(t-l)*e+l,ue.x=(r.x-s)*e+s,(r.y-u)*e+u),o&&o(e),Se(1===e)};n?Ke("customZoomTo",0,1,n,i||f.easing.sine.inOut,c):c(1)}},$e={},je={},Je={},Qe={},et={},tt=[],nt={},it=[],ot={},at=0,rt={x:0,y:0},lt=0,st={x:0,y:0},ut={x:0,y:0},ct={x:0,y:0},dt=function(e,t){return ot.x=Math.abs(e.x-t.x),ot.y=Math.abs(e.y-t.y),Math.sqrt(ot.x*ot.x+ot.y*ot.y)},pt=function(){n&&(Z(n),n=null)},mt=function(){W&&(n=R(mt),St())},ft=function(e,t){return!!e&&!(e.className&&-1<e.className.indexOf("pswp__scroll-wrap"))&&(t(e)?e:ft(e.parentNode,t))},ht={},yt=function(e,t){return ht.prevent=!ft(e.target,y.isClickableElement),Ce("preventDragEvent",e,t,ht),ht.prevent},xt=function(e,t){return t.x=e.pageX,t.y=e.pageY,t.id=e.identifier,t},vt=function(e,t,n){n.x=.5*(e.x+t.x),n.y=.5*(e.y+t.y)},gt=function(){var e=ue.y-h.currItem.initialPosition.y;return 1-Math.abs(e/(ce.y/2))},wt={},bt={},It=[],Ct=function(e){for(;0<It.length;)It.pop();return O?(re=0,tt.forEach(function(e){0===re?It[0]=e:1===re&&(It[1]=e),re++})):-1<e.type.indexOf("touch")?e.touches&&0<e.touches.length&&(It[0]=xt(e.touches[0],wt),1<e.touches.length&&(It[1]=xt(e.touches[1],bt))):(wt.x=e.pageX,wt.y=e.pageY,wt.id="",It[0]=wt),It},Dt=function(e,t){var n,i,o,a,r=ue[e]+t[e],l=0<t[e],s=st.x+t.x,u=st.x-nt.x;return n=r>J.min[e]||r<J.max[e]?y.panEndFriction:1,r=ue[e]+t[e]*n,!y.allowPanToNext&&v!==h.currItem.initialZoomLevel||(Q?"h"!==te||"x"!==e||X||(l?(r>J.min[e]&&(n=y.panEndFriction,J.min[e],i=J.min[e]-se[e]),(i<=0||u<0)&&1<Nt()?(a=s,u<0&&s>nt.x&&(a=nt.x)):J.min.x!==J.max.x&&(o=r)):(r<J.max[e]&&(n=y.panEndFriction,J.max[e],i=se[e]-J.max[e]),(i<=0||0<u)&&1<Nt()?(a=s,0<u&&s<nt.x&&(a=nt.x)):J.min.x!==J.max.x&&(o=r))):a=s,"x"!==e)?void(ee||K||v>h.currItem.fitRatio&&(ue[e]+=t[e]*n)):(void 0!==a&&(Oe(a,!0),K=a!==nt.x),J.min.x!==J.max.x&&(void 0!==o?ue.x=o:K||(ue.x+=t.x*n)),void 0!==a)},Mt=function(e){if(!("mousedown"===e.type&&0<e.button)){if(_t)return void e.preventDefault();if(!B||"mousedown"!==e.type){if(yt(e,!0)&&e.preventDefault(),Ce("pointerDown"),O){var t=f.arraySearch(tt,e.pointerId,"id");t<0&&(t=tt.length),tt[t]={x:e.pageX,y:e.pageY,id:e.pointerId}}var n=Ct(e),i=n.length;q=null,Ve(),W&&1!==i||(W=ne=!0,f.bind(window,u,h),ae=ie=Y=K=V=G=X=!1,te=null,Ce("firstTouchStart",n),Re(se,ue),le.x=le.y=0,Re(Qe,n[0]),Re(et,Qe),nt.x=me.x*de,it=[{x:Qe.x,y:Qe.y}],U=N=De(),Le(v,!0),pt(),mt()),!$&&1<i&&!ee&&!K&&(p=v,$=G=!(X=!1),le.y=le.x=0,Re(se,ue),Re($e,n[0]),Re(je,n[1]),vt($e,je,ct),ut.x=Math.abs(ct.x)-ue.x,ut.y=Math.abs(ct.y)-ue.y,j=dt($e,je))}}},Tt=function(e){if(e.preventDefault(),O){var t=f.arraySearch(tt,e.pointerId,"id");if(-1<t){var n=tt[t];n.x=e.pageX,n.y=e.pageY}}if(W){var i=Ct(e);if(te||V||$)q=i;else if(st.x!==me.x*de)te="h";else{var o=Math.abs(i[0].x-Qe.x)-Math.abs(i[0].y-Qe.y);10<=Math.abs(o)&&(te=0<o?"h":"v",q=i)}}},St=function(){if(q){var e=q.length;if(0!==e)if(Re($e,q[0]),Je.x=$e.x-Qe.x,Je.y=$e.y-Qe.y,$&&1<e){if(Qe.x=$e.x,Qe.y=$e.y,!Je.x&&!Je.y&&(s=q[1],u=je,s.x===u.x&&s.y===u.y))return;Re(je,q[1]),X||(X=!0,Ce("zoomGestureStarted"));var t=dt($e,je),n=Rt(t);n>h.currItem.initialZoomLevel+h.currItem.initialZoomLevel/15&&(ae=!0);var i=1,o=_e(),a=ze();if(n<o)if(y.pinchToClose&&!ae&&p<=h.currItem.initialZoomLevel){var r=1-(o-n)/(o/1.2);Me(r),Ce("onPinchClose",r),ie=!0}else 1<(i=(o-n)/o)&&(i=1),n=o-i*(o/3);else a<n&&(1<(i=(n-a)/(6*o))&&(i=1),n=a+i*o);i<0&&(i=0),vt($e,je,rt),le.x+=rt.x-ct.x,le.y+=rt.y-ct.y,Re(ct,rt),ue.x=ke("x",n),ue.y=ke("y",n),v=n,Se()}else{if(!te)return;if(ne&&(ne=!1,10<=Math.abs(Je.x)&&(Je.x-=q[0].x-et.x),10<=Math.abs(Je.y)&&(Je.y-=q[0].y-et.y)),Qe.x=$e.x,Qe.y=$e.y,0===Je.x&&0===Je.y)return;if("v"===te&&y.closeOnVerticalDrag&&"fit"===y.scaleMode&&v===h.currItem.initialZoomLevel){le.y+=Je.y,ue.y+=Je.y;var l=gt();return Y=!0,Ce("onVerticalDrag",l),Me(l),void Se()}(function(e,t,n){if(50<e-U){var i=2<it.length?it.shift():{};i.x=t,i.y=n,it.push(i),U=e}})(De(),$e.x,$e.y),V=!0,J=h.currItem.bounds,Dt("x",Je)||(Dt("y",Je),Ze(ue),Se())}}var s,u},At=function(e){if(z.isOldAndroid){if(B&&"mouseup"===e.type)return;-1<e.type.indexOf("touch")&&(clearTimeout(B),B=setTimeout(function(){B=0},600))}var t;if(Ce("pointerUp"),yt(e,!1)&&e.preventDefault(),O){var n=f.arraySearch(tt,e.pointerId,"id");-1<n&&(t=tt.splice(n,1)[0],navigator.pointerEnabled?t.type=e.pointerType||"mouse":(t.type={4:"mouse",2:"touch",3:"pen"}[e.pointerType],t.type||(t.type=e.pointerType||"mouse")))}var i,o=Ct(e),a=o.length;if("mouseup"===e.type&&(a=0),2===a)return!(q=null);1===a&&Re(et,o[0]),0!==a||te||ee||(t||("mouseup"===e.type?t={x:e.pageX,y:e.pageY,type:"mouse"}:e.changedTouches&&e.changedTouches[0]&&(t={x:e.changedTouches[0].pageX,y:e.changedTouches[0].pageY,type:"touch"})),Ce("touchRelease",e,t));var r=-1;if(0===a&&(W=!1,f.unbind(window,u,h),pt(),$?r=0:-1!==lt&&(r=De()-lt)),lt=1===a?De():-1,i=-1!==r&&r<150?"zoom":"swipe",$&&a<2&&($=!1,1===a&&(i="zoomPointerUp"),Ce("zoomGestureEnded")),q=null,V||X||ee||Y)if(Ve(),H||(H=Et()),H.calculateSwipeSpeed("x"),Y){gt();var l=ue.y,s=oe;Ke("verticalDrag",0,1,300,f.easing.cubic.out,function(e){ue.y=(h.currItem.initialPosition.y-l)*e+l,Me((1-s)*e+s),Se()}),Ce("onVerticalDrag",1)}else{if((K||ee)&&0===a){if(kt(i,H))return;i="zoomPointerUp"}if(!ee)return"swipe"!==i?void Zt():void(!K&&v>h.currItem.fitRatio&&Ot(H))}},Et=function(){var t,n,i={lastFlickOffset:{},lastFlickDist:{},lastFlickSpeed:{},slowDownRatio:{},slowDownRatioReverse:{},speedDecelerationRatio:{},speedDecelerationRatioAbs:{},distanceOffset:{},backAnimDestination:{},backAnimStarted:{},calculateSwipeSpeed:function(e){n=1<it.length?(t=De()-U+50,it[it.length-2][e]):(t=De()-N,et[e]),i.lastFlickOffset[e]=Qe[e]-n,i.lastFlickDist[e]=Math.abs(i.lastFlickOffset[e]),20<i.lastFlickDist[e]?i.lastFlickSpeed[e]=i.lastFlickOffset[e]/t:i.lastFlickSpeed[e]=0,Math.abs(i.lastFlickSpeed[e])<.1&&(i.lastFlickSpeed[e]=0),i.slowDownRatio[e]=.95,i.slowDownRatioReverse[e]=1-i.slowDownRatio[e],i.speedDecelerationRatio[e]=1},calculateOverBoundsAnimOffset:function(t,e){i.backAnimStarted[t]||(ue[t]>J.min[t]?i.backAnimDestination[t]=J.min[t]:ue[t]<J.max[t]&&(i.backAnimDestination[t]=J.max[t]),void 0!==i.backAnimDestination[t]&&(i.slowDownRatio[t]=.7,i.slowDownRatioReverse[t]=1-i.slowDownRatio[t],i.speedDecelerationRatioAbs[t]<.05&&(i.lastFlickSpeed[t]=0,i.backAnimStarted[t]=!0,Ke("bounceZoomPan"+t,ue[t],i.backAnimDestination[t],e||300,f.easing.sine.out,function(e){ue[t]=e,Se()}))))},calculateAnimOffset:function(e){i.backAnimStarted[e]||(i.speedDecelerationRatio[e]=i.speedDecelerationRatio[e]*(i.slowDownRatio[e]+i.slowDownRatioReverse[e]-i.slowDownRatioReverse[e]*i.timeDiff/10),i.speedDecelerationRatioAbs[e]=Math.abs(i.lastFlickSpeed[e]*i.speedDecelerationRatio[e]),i.distanceOffset[e]=i.lastFlickSpeed[e]*i.speedDecelerationRatio[e]*i.timeDiff,ue[e]+=i.distanceOffset[e])},panAnimLoop:function(){return Be.zoomPan&&(Be.zoomPan.raf=R(i.panAnimLoop),i.now=De(),i.timeDiff=i.now-i.lastNow,i.lastNow=i.now,i.calculateAnimOffset("x"),i.calculateAnimOffset("y"),Se(),i.calculateOverBoundsAnimOffset("x"),i.calculateOverBoundsAnimOffset("y"),i.speedDecelerationRatioAbs.x<.05&&i.speedDecelerationRatioAbs.y<.05)?(ue.x=Math.round(ue.x),ue.y=Math.round(ue.y),Se(),void Ge("zoomPan")):void 0}};return i},Ot=function(e){return e.calculateSwipeSpeed("y"),J=h.currItem.bounds,e.backAnimDestination={},e.backAnimStarted={},Math.abs(e.lastFlickSpeed.x)<=.05&&Math.abs(e.lastFlickSpeed.y)<=.05?(e.speedDecelerationRatioAbs.x=e.speedDecelerationRatioAbs.y=0,e.calculateOverBoundsAnimOffset("x"),e.calculateOverBoundsAnimOffset("y"),!0):(Xe("zoomPan"),e.lastNow=De(),void e.panAnimLoop())},kt=function(e,t){var n,i,o;if(ee||(at=x),"swipe"===e){var a=Qe.x-et.x,r=t.lastFlickDist.x<10;30<a&&(r||20<t.lastFlickOffset.x)?i=-1:a<-30&&(r||t.lastFlickOffset.x<-20)&&(i=1)}i&&((x+=i)<0?(x=y.loop?Nt()-1:0,o=!0):x>=Nt()&&(x=y.loop?0:Nt()-1,o=!0),(!o||y.loop)&&(fe+=i,de-=i,n=!0));var l,s=me.x*de,u=Math.abs(s-st.x);return l=n||s>st.x==0<t.lastFlickSpeed.x?(l=0<Math.abs(t.lastFlickSpeed.x)?u/Math.abs(t.lastFlickSpeed.x):333,l=Math.min(l,400),Math.max(l,250)):333,at===x&&(n=!1),ee=!0,Ce("mainScrollAnimStart"),Ke("mainScroll",st.x,s,l,f.easing.cubic.out,Oe,function(){Ve(),ee=!1,at=-1,(n||at!==x)&&h.updateCurrItem(),Ce("mainScrollAnimComplete")}),n&&h.updateCurrItem(!0),n},Rt=function(e){return 1/j*e*p},Zt=function(){var e=v,t=_e(),n=ze();v<t?e=t:n<v&&(e=n);var i,o=oe;return ie&&(i=function(e){Me((1-o)*e+o)}),h.zoomTo(e,0,200,f.easing.cubic.out,i),!0};ge("Gestures",{publicMethods:{initGestures:function(){var e=function(e,t,n,i,o){M=e+t,T=e+n,S=e+i,A=o?e+o:""};(O=z.pointerEvent)&&z.touch&&(z.touch=!1),O?navigator.pointerEnabled?e("pointer","down","move","up","cancel"):e("MSPointer","Down","Move","Up","Cancel"):z.touch?(e("touch","start","move","end","cancel"),k=!0):e("mouse","down","move","up"),u=T+" "+S+" "+A,c=M,O&&!k&&(k=1<navigator.maxTouchPoints||1<navigator.msMaxTouchPoints),h.likelyTouchDevice=k,d[M]=Mt,d[T]=Tt,d[S]=At,A&&(d[A]=d[S]),z.touch&&(c+=" mousedown",u+=" mousemove mouseup",d.mousedown=d[M],d.mousemove=d[T],d.mouseup=d[S]),k||(y.allowPanToNext=!1)}}});var Pt,Ft,Lt,_t,zt,Nt,Ut=function(r,e,l,t){var s;Pt&&clearTimeout(Pt),Lt=_t=!0,r.initialLayout?(s=r.initialLayout,r.initialLayout=null):s=y.getThumbBoundsFn&&y.getThumbBoundsFn(x);var u,c,d=l?y.hideAnimationDuration:y.showAnimationDuration,p=function(){Ge("initialZoom"),l?(h.template.removeAttribute("style"),h.bg.removeAttribute("style")):(Me(1),e&&(e.style.display="block"),f.addClass(m,"pswp--animated-in"),Ce("initialZoom"+(l?"OutEnd":"InEnd"))),t&&t(),_t=!1};if(!d||!s||void 0===s.x)return Ce("initialZoom"+(l?"Out":"In")),v=r.initialZoomLevel,Re(ue,r.initialPosition),Se(),m.style.opacity=l?0:1,Me(1),void p();u=a,c=!h.currItem.src||h.currItem.loadError||y.showHideOpacity,r.miniImg&&(r.miniImg.style.webkitBackfaceVisibility="hidden"),l||(v=s.w/r.w,ue.x=s.x,ue.y=s.y-F,h[c?"template":"bg"].style.opacity=.001,Se()),Xe("initialZoom"),l&&!u&&f.removeClass(m,"pswp--animated-in"),c&&(l?f[(u?"remove":"add")+"Class"](m,"pswp--animate_opacity"):setTimeout(function(){f.addClass(m,"pswp--animate_opacity")},30)),Pt=setTimeout(function(){if(Ce("initialZoom"+(l?"Out":"In")),l){var t=s.w/r.w,n=ue.x,i=ue.y,o=v,a=oe,e=function(e){ue.y=1===e?(v=t,ue.x=s.x,s.y-_):(v=(t-o)*e+o,ue.x=(s.x-n)*e+n,(s.y-_-i)*e+i),Se(),c?m.style.opacity=1-e:Me(a-e*a)};u?Ke("initialZoom",0,1,d,f.easing.cubic.out,e,p):(e(1),Pt=setTimeout(p,d+20))}else v=r.initialZoomLevel,Re(ue,r.initialPosition),Se(),Me(1),c?m.style.opacity=1:Me(1),Pt=setTimeout(p,d+20)},l?25:90)},Ht={},Yt=[],Bt={index:0,errorMsg:'<div class="pswp__error-msg"><a href="%url%" target="_blank">The image</a> could not be loaded.</div>',forceProgressiveLoading:!1,preload:[1,1],getNumItemsFn:function(){return Ft.length}},Wt=function(e,t,n){if(!e.src||e.loadError)return e.w=e.h=0,e.initialZoomLevel=e.fitRatio=1,e.bounds={center:{x:0,y:0},max:{x:0,y:0},min:{x:0,y:0}},e.initialPosition=e.bounds.center,e.bounds;var i,o,a,r,l=!n;if(l&&(e.vGap||(e.vGap={top:0,bottom:0}),Ce("parseVerticalMargin",e)),Ht.x=t.x,Ht.y=t.y-e.vGap.top-e.vGap.bottom,l){var s=Ht.x/e.w,u=Ht.y/e.h;e.fitRatio=s<u?s:u;var c=y.scaleMode;"orig"===c?n=1:"fit"===c&&(n=e.fitRatio),1<n&&(n=1),e.initialZoomLevel=n,e.bounds||(e.bounds={center:{x:0,y:0},max:{x:0,y:0},min:{x:0,y:0}})}return n?(o=(i=e).w*n,a=e.h*n,(r=i.bounds).center.x=Math.round((Ht.x-o)/2),r.center.y=Math.round((Ht.y-a)/2)+i.vGap.top,r.max.x=o>Ht.x?Math.round(Ht.x-o):r.center.x,r.max.y=a>Ht.y?Math.round(Ht.y-a)+i.vGap.top:r.center.y,r.min.x=o>Ht.x?0:r.center.x,r.min.y=a>Ht.y?i.vGap.top:r.center.y,l&&n===e.initialZoomLevel&&(e.initialPosition=e.bounds.center),e.bounds):void 0},Gt=function(e,t,n,i,o,a){t.loadError||i&&(t.imageAppended=!0,Kt(t,i),n.appendChild(i),a&&setTimeout(function(){t&&t.loaded&&t.placeholder&&(t.placeholder.style.display="none",t.placeholder=null)},500))},Xt=function(e){e.loading=!0,e.loaded=!1;var t=e.img=f.createEl("pswp__img","img"),n=function(){e.loading=!1,e.loaded=!0,e.loadComplete?e.loadComplete(e):e.img=null,t.onload=t.onerror=null,t=null};return t.onload=n,t.onerror=function(){e.loadError=!0,n()},t.src=e.src,t},Vt=function(e,t){return e.src&&e.loadError&&e.container?(t&&(e.container.innerHTML=""),e.container.innerHTML=y.errorMsg.replace("%url%",e.src),!0):void 0},Kt=function(e,t,n){if(e.src){t||(t=e.container.lastChild);var i=n?e.w:Math.round(e.w*e.fitRatio),o=n?e.h:Math.round(e.h*e.fitRatio);e.placeholder&&!e.loaded&&(e.placeholder.style.width=i+"px",e.placeholder.style.height=o+"px"),t.style.width=i+"px",t.style.height=o+"px"}},qt=function(){if(Yt.length){for(var e,t=0;t<Yt.length;t++)(e=Yt[t]).holder.index===e.index&&Gt(e.index,e.item,e.baseDiv,e.img,0,e.clearPlaceholder);Yt=[]}};ge("Controller",{publicMethods:{lazyLoadItem:function(e){e=we(e);var t=zt(e);!t||t.loaded||t.loading||(Ce("gettingData",e,t),t.src&&Xt(t))},initController:function(){f.extend(y,Bt,!0),h.items=Ft=e,zt=h.getItemAt,Nt=y.getNumItemsFn,y.loop,Nt()<3&&(y.loop=!1),Ie("beforeChange",function(e){var t,n=y.preload,i=null===e||0<e,o=Math.min(n[0],Nt()),a=Math.min(n[1],Nt());for(t=1;t<=(i?a:o);t++)h.lazyLoadItem(x+t);for(t=1;t<=(i?o:a);t++)h.lazyLoadItem(x-t)}),Ie("initialLayout",function(){h.currItem.initialLayout=y.getThumbBoundsFn&&y.getThumbBoundsFn(x)}),Ie("mainScrollAnimComplete",qt),Ie("initialZoomInEnd",qt),Ie("destroy",function(){for(var e,t=0;t<Ft.length;t++)(e=Ft[t]).container&&(e.container=null),e.placeholder&&(e.placeholder=null),e.img&&(e.img=null),e.preloader&&(e.preloader=null),e.loadError&&(e.loaded=e.loadError=!1);Yt=null})},getItemAt:function(e){return 0<=e&&void 0!==Ft[e]&&Ft[e]},allowProgressiveImg:function(){return y.forceProgressiveLoading||!k||y.mouseUsed||1200<screen.width},setContent:function(t,n){y.loop&&(n=we(n));var e=h.getItemAt(t.index);e&&(e.container=null);var i,o=h.getItemAt(n);if(o){Ce("gettingData",n,o),t.index=n;var a=(t.item=o).container=f.createEl("pswp__zoom-wrap");if(!o.src&&o.html&&(o.html.tagName?a.appendChild(o.html):a.innerHTML=o.html),Vt(o),Wt(o,ce),!o.src||o.loadError||o.loaded)o.src&&!o.loadError&&((i=f.createEl("pswp__img","img")).style.opacity=1,i.src=o.src,Kt(o,i),Gt(0,o,a,i));else{if(o.loadComplete=function(e){if(s){if(t&&t.index===n){if(Vt(e,!0))return e.loadComplete=e.img=null,Wt(e,ce),Ae(e),void(t.index===x&&h.updateCurrZoomItem());e.imageAppended?!_t&&e.placeholder&&(e.placeholder.style.display="none",e.placeholder=null):z.transform&&(ee||_t)?Yt.push({item:e,baseDiv:a,img:e.img,index:n,holder:t,clearPlaceholder:!0}):Gt(0,e,a,e.img,0,!0)}e.loadComplete=null,e.img=null,Ce("imageLoadComplete",n,e)}},f.features.transform){var r="pswp__img pswp__img--placeholder";r+=o.msrc?"":" pswp__img--placeholder--blank";var l=f.createEl(r,o.msrc?"img":"");o.msrc&&(l.src=o.msrc),Kt(o,l),a.appendChild(l),o.placeholder=l}o.loading||Xt(o),h.allowProgressiveImg()&&(!Lt&&z.transform?Yt.push({item:o,baseDiv:a,img:o.img,index:n,holder:t}):Gt(0,o,a,o.img,0,!0))}Lt||n!==x?Ae(o):(Q=a.style,Ut(o,i||o.img)),t.el.innerHTML="",t.el.appendChild(a)}else t.el.innerHTML=""},cleanSlide:function(e){e.img&&(e.img.onload=e.img.onerror=null),e.loaded=e.loading=e.img=e.imageAppended=!1}}});var $t,jt,Jt={},Qt=function(e,t,n){var i=document.createEvent("CustomEvent"),o={origEvent:e,target:e.target,releasePoint:t,pointerType:n||"touch"};i.initCustomEvent("pswpTap",!0,!0,o),e.target.dispatchEvent(i)};ge("Tap",{publicMethods:{initTap:function(){Ie("firstTouchStart",h.onTapStart),Ie("touchRelease",h.onTapRelease),Ie("destroy",function(){Jt={},$t=null})},onTapStart:function(e){1<e.length&&(clearTimeout($t),$t=null)},onTapRelease:function(e,t){if(t&&!V&&!G&&!We){var n=t;if($t&&(clearTimeout($t),$t=null,i=n,o=Jt,Math.abs(i.x-o.x)<25&&Math.abs(i.y-o.y)<25))return void Ce("doubleTap",n);if("mouse"===t.type)return void Qt(e,t,"mouse");if("BUTTON"===e.target.tagName.toUpperCase()||f.hasClass(e.target,"pswp__single-tap"))return void Qt(e,t);Re(Jt,n),$t=setTimeout(function(){Qt(e,t),$t=null},300)}var i,o}}}),ge("DesktopZoom",{publicMethods:{initDesktopZoom:function(){L||(k?Ie("mouseUsed",function(){h.setupDesktopZoom()}):h.setupDesktopZoom(!0))},setupDesktopZoom:function(e){jt={};var t="wheel mousewheel DOMMouseScroll";Ie("bindEvents",function(){f.bind(m,t,h.handleMouseWheel)}),Ie("unbindEvents",function(){jt&&f.unbind(m,t,h.handleMouseWheel)}),h.mouseZoomedIn=!1;var n,i=function(){h.mouseZoomedIn&&(f.removeClass(m,"pswp--zoomed-in"),h.mouseZoomedIn=!1),v<1?f.addClass(m,"pswp--zoom-allowed"):f.removeClass(m,"pswp--zoom-allowed"),o()},o=function(){n&&(f.removeClass(m,"pswp--dragging"),n=!1)};Ie("resize",i),Ie("afterChange",i),Ie("pointerDown",function(){h.mouseZoomedIn&&(n=!0,f.addClass(m,"pswp--dragging"))}),Ie("pointerUp",o),e||i()},handleMouseWheel:function(e){if(v<=h.currItem.fitRatio)return y.modal&&(!y.closeOnScroll||We||W?e.preventDefault():E&&2<Math.abs(e.deltaY)&&(a=!0,h.close())),!0;if(e.stopPropagation(),jt.x=0,"deltaX"in e)1===e.deltaMode?(jt.x=18*e.deltaX,jt.y=18*e.deltaY):(jt.x=e.deltaX,jt.y=e.deltaY);else if("wheelDelta"in e)e.wheelDeltaX&&(jt.x=-.16*e.wheelDeltaX),e.wheelDeltaY?jt.y=-.16*e.wheelDeltaY:jt.y=-.16*e.wheelDelta;else{if(!("detail"in e))return;jt.y=e.detail}Le(v,!0);var t=ue.x-jt.x,n=ue.y-jt.y;(y.modal||t<=J.min.x&&t>=J.max.x&&n<=J.min.y&&n>=J.max.y)&&e.preventDefault(),h.panTo(t,n)},toggleDesktopZoom:function(e){e=e||{x:ce.x/2+pe.x,y:ce.y/2+pe.y};var t=y.getDoubleTapZoom(!0,h.currItem),n=v===t;h.mouseZoomedIn=!n,h.zoomTo(n?h.currItem.initialZoomLevel:t,e,333),f[(n?"remove":"add")+"Class"](m,"pswp--zoomed-in")}}});var en,tn,nn,on,an,rn,ln,sn,un,cn,dn,pn,mn={history:!0,galleryUID:1},fn=function(){return dn.hash.substring(1)},hn=function(){en&&clearTimeout(en),nn&&clearTimeout(nn)},yn=function(){var e=fn(),t={};if(e.length<5)return t;var n,i=e.split("&");for(n=0;n<i.length;n++)if(i[n]){var o=i[n].split("=");o.length<2||(t[o[0]]=o[1])}if(y.galleryPIDs){var a=t.pid;for(n=t.pid=0;n<Ft.length;n++)if(Ft[n].pid===a){t.pid=n;break}}else t.pid=parseInt(t.pid,10)-1;return t.pid<0&&(t.pid=0),t},xn=function(){if(nn&&clearTimeout(nn),We||W)nn=setTimeout(xn,500);else{on?clearTimeout(tn):on=!0;var e=x+1,t=zt(x);t.hasOwnProperty("pid")&&(e=t.pid);var n=ln+"&gid="+y.galleryUID+"&pid="+e;sn||-1===dn.hash.indexOf(n)&&(cn=!0);var i=dn.href.split("#")[0]+"#"+n;pn?"#"+n!==window.location.hash&&history[sn?"replaceState":"pushState"]("",document.title,i):sn?dn.replace(i):dn.hash=n,sn=!0,tn=setTimeout(function(){on=!1},60)}};ge("History",{publicMethods:{initHistory:function(){if(f.extend(y,mn,!0),y.history){dn=window.location,sn=un=cn=!1,ln=fn(),pn="pushState"in history,-1<ln.indexOf("gid=")&&(ln=(ln=ln.split("&gid=")[0]).split("?gid=")[0]),Ie("afterChange",h.updateURL),Ie("unbindEvents",function(){f.unbind(window,"hashchange",h.onHashChange)});var e=function(){rn=!0,un||(cn?history.back():ln?dn.hash=ln:pn?history.pushState("",document.title,dn.pathname+dn.search):dn.hash=""),hn()};Ie("unbindEvents",function(){a&&e()}),Ie("destroy",function(){rn||e()}),Ie("firstUpdate",function(){x=yn().pid});var t=ln.indexOf("pid=");-1<t&&"&"===(ln=ln.substring(0,t)).slice(-1)&&(ln=ln.slice(0,-1)),setTimeout(function(){s&&f.bind(window,"hashchange",h.onHashChange)},40)}},onHashChange:function(){return fn()===ln?(un=!0,void h.close()):void(on||(an=!0,h.goTo(yn().pid),an=!1))},updateURL:function(){hn(),an||(sn?en=setTimeout(xn,800):xn())}}}),f.extend(h,qe)}});