!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=Vt()-1&&i<0)&&(e=bt.x+i*y.mainScrollEndFriction)}bt.x=e,it(e,B)}function p(e,t){var n=It[e]-Ve[e];return We[e]+Ye[e]+n-t/$*n}function g(e,t){e.x=t.x,e.y=t.y,t.id&&(e.id=t.id)}function w(e){e.x=Math.round(e.x),e.y=Math.round(e.y)}function b(e,t){var n=Jt(h.currItem,Ge,e);return t&&(Pe=n),n}function I(e){return(e=e||h.currItem).initialZoomLevel}function C(e){return 0<(e=e||h.currItem).w?y.maxSpreadZoom:1}function D(e,t,n,i){return i===h.currItem.initialZoomLevel?(n[e]=h.currItem.initialPosition[e],!0):(n[e]=p(e,i),n[e]>t.min[e]?(n[e]=t.min[e],!0):n[e]Pe.min[e]||rPe.min[e]&&(n=y.panEndFriction,Pe.min[e],i=Pe.min[e]-We[e]),(i<=0||u<0)&&1ht.x&&(a=ht.x)):Pe.min.x!==Pe.max.x&&(o=r)):(rh.currItem.fitRatio&&(Be[e]+=t[e]*n)}function z(e){if(!("mousedown"===e.type&&0h.currItem.fitRatio&&Pt(we):Lt())}}var U,H,Y,W,B,G,X,V,K,q,$,j,J,Q,ee,te,ne,ie,oe,ae,re,le,se,ue,ce,de,pe,me,fe,he,ye,xe,ve,ge,we,be,Ie,Ce,De,Te,Me,Se,Ae,Ee,Oe,ke,Re,Pe,Ze,Fe,Le,ze,_e,Ne,Ue,He,Ye=n(),We=n(),Be=n(),Ge={},Xe=0,Ve={},Ke=n(),qe=0,$e=!0,je=[],Je={},Qe=!1,et={},tt=function(e){Ze&&(e&&(q>h.currItem.fitRatio?Qe||(Qt(h.currItem,!1,!0),Qe=!0):Qe&&(Qt(h.currItem),Qe=!1)),r(Ze,Be.x,Be.y,q))},nt=function(e){e.container&&r(e.container.style,e.initialPosition.x,e.initialPosition.y,e.initialZoomLevel,e)},it=function(e,t){t[le]=j+e+"px, 0px"+J},ot=null,at=function(){ot&&(f.unbind(document,"mousemove",at),f.addClass(m,"pswp--has_mouse"),y.mouseUsed=!0,x("mouseUsed")),ot=setTimeout(function(){ot=null},100)},rt={},lt=0,st={shout:x,listen:a,viewportSize:Ge,options:y,isMainScrollAnimating:function(){return Fe},getZoomLevel:function(){return q},getCurrentIndex:function(){return W},isDragging:function(){return De},isZooming:function(){return ke},setScrollOffset:function(e,t){Ve.x=e,he=Ve.y=t,x("updateScrollOffset",Ve)},applyZoomPan:function(e,t,n,i){Be.x=t,Be.y=n,q=e,tt(i)},init:function(){if(!U&&!H){var e;h.framework=f,h.template=m,h.bg=f.getChildByClass(m,"pswp__bg"),pe=m.className,U=!0,ye=f.detectFeatures(),ce=ye.raf,de=ye.caf,le=ye.transform,fe=ye.oldIE,h.scrollWrap=f.getChildByClass(m,"pswp__scroll-wrap"),h.container=f.getChildByClass(h.scrollWrap,"pswp__container"),B=h.container.style,h.itemHolders=te=[{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}],te[0].el.style.display=te[2].el.style.display="none",function(){if(le){var e=ye.perspective&&!ue;return j="translate"+(e?"3d(":"("),J=ye.perspective?", 0px)":")"}le="left",f.addClass(m,"pswp--ie"),it=function(e,t){t.left=e+"px"},nt=function(e){var t=1=Vt())&&(W=0),h.currItem=Xt(W),(ye.isOldIOSPhone||ye.isOldAndroid)&&($e=!1),m.setAttribute("aria-hidden","false"),y.modal&&($e?m.style.position="fixed":(m.style.position="absolute",m.style.top=f.getScrollY()+"px")),void 0===he&&(x("initialLayout"),he=me=f.getScrollY());var n="pswp--open ";for(y.mainClass&&(n+=y.mainClass+" "),y.showHideOpacity&&(n+="pswp--animate_opacity "),n+=ue?"pswp--touch":"pswp--notouch",n+=ye.animationName?" pswp--css_animation":"",n+=ye.svg?" pswp--svg":"",f.addClass(m,n),h.updateSize(),G=-1,qe=null,e=0;e<3;e++)it((e+G)*Ke.x,te[e].el.style);fe||f.bind(h.scrollWrap,V,h),a("initialZoomInEnd",function(){h.setContent(te[0],W-1),h.setContent(te[2],W+1),te[0].el.style.display=te[2].el.style.display="block",y.focus&&m.focus(),f.bind(document,"keydown",h),ye.transform&&f.bind(h.scrollWrap,"click",h),y.mouseUsed||f.bind(document,"mousemove",at),f.bind(window,"resize scroll orientationchange",h),x("bindEvents")}),h.setContent(te[1],W),h.updateCurrItem(),x("afterInit"),$e||(Q=setInterval(function(){lt||De||ke||q!==h.currItem.initialZoomLevel||h.updateSize()},1e3)),f.addClass(m,"pswp--visible")}},close:function(){U&&(H=!(U=!1),x("close"),f.unbind(window,"resize scroll orientationchange",h),f.unbind(window,"scroll",K.scroll),f.unbind(document,"keydown",h),f.unbind(document,"mousemove",at),ye.transform&&f.unbind(h.scrollWrap,"click",h),De&&f.unbind(window,X,h),clearTimeout(xe),x("unbindEvents"),Kt(h.currItem,null,!0,h.destroy))},destroy:function(){x("destroy"),Yt&&clearTimeout(Yt),m.setAttribute("aria-hidden","true"),m.className=pe,Q&&clearInterval(Q),f.unbind(h.scrollWrap,V,h),f.unbind(window,"scroll",h),Dt(),A(),et=null},panTo:function(e,t,n){n||(e>Pe.min.x?e=Pe.min.x:ePe.min.y?t=Pe.min.y:th.currItem.initialZoomLevel+h.currItem.initialZoomLevel/15&&(Ue=!0);var a=1,r=I(),l=C();if(oPe.min[t]?i.backAnimDestination[t]=Pe.min[t]:Be[t]=Vt()&&(W=y.loop?0:Vt()-1,o=!0),o&&!y.loop||(qe+=i,Xe-=i,n=!0));var l,s=Ke.x*Xe,u=Math.abs(s-bt.x);return l=n||s>bt.x==0The image could not be loaded.',forceProgressiveLoading:!1,preload:[1,1],getNumItemsFn:function(){return Wt.length}},Jt=function(e,t,n){if(!e.src||e.loadError)return e.w=e.h=0,e.initialZoomLevel=e.fitRatio=1,e.bounds=zt(),e.initialPosition=e.bounds.center,e.bounds;var i,o,a,r,l=!n;if(l&&(e.vGap||(e.vGap={top:0,bottom:0}),x("parseVerticalMargin",e)),qt.x=t.x,qt.y=t.y-e.vGap.top-e.vGap.bottom,l){var s=qt.x/e.w,u=qt.y/e.h;e.fitRatio=sqt.x?Math.round(qt.x-o):r.center.x,r.max.y=a>qt.y?Math.round(qt.y-a)+i.vGap.top:r.center.y,r.min.x=o>qt.x?0:r.center.x,r.min.y=a>qt.y?i.vGap.top:r.center.y,l&&n===e.initialZoomLevel&&(e.initialPosition=e.bounds.center),e.bounds):void 0},Qt=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"}};o("Controller",{publicMethods:{lazyLoadItem:function(e){e=s(e);var t=Xt(e);t&&(!t.loaded&&!t.loading||ee)&&(x("gettingData",e,t),t.src&&Nt(t))},initController:function(){f.extend(y,jt,!0),h.items=Wt=e,Xt=h.getItemAt,Vt=y.getNumItemsFn,y.loop,Vt()<3&&(y.loop=!1),a("beforeChange",function(e){var t,n=y.preload,i=null===e||0<=e,o=Math.min(n[0],Vt()),a=Math.min(n[1],Vt());for(t=1;t<=(i?a:o);t++)h.lazyLoadItem(W+t);for(t=1;t<=(i?o:a);t++)h.lazyLoadItem(W-t)}),a("initialLayout",function(){h.currItem.initialLayout=y.getThumbBoundsFn&&y.getThumbBoundsFn(W)}),a("mainScrollAnimComplete",Ht),a("initialZoomInEnd",Ht),a("destroy",function(){for(var e,t=0;t=Pe.max.x&&n<=Pe.min.y&&n>=Pe.max.y)&&e.preventDefault(),h.panTo(t,n)},toggleDesktopZoom:function(e){e=e||{x:Ge.x/2+Ve.x,y:Ge.y/2+Ve.y};var t=y.getDoubleTapZoom(!0,h.currItem),n=q===t;h.mouseZoomedIn=!n,h.zoomTo(n?h.currItem.initialZoomLevel:t,e,333),f[(n?"remove":"add")+"Class"](m,"pswp--zoomed-in")}}});function an(){return vn.hash.substring(1)}function rn(){sn&&clearTimeout(sn),cn&&clearTimeout(cn)}function ln(){var e=an(),t={};if(e.length<5)return t;var n,i=e.split("&");for(n=0;nx.fitControlsWidth){var n=x.barsSize;if(x.captionEl&&"auto"===n.bottom)if(h||((h=s.createEl("pswp__caption pswp__caption--fake")).appendChild(s.createEl("pswp__caption__center")),m.insertBefore(h,f),s.addClass(m,"pswp__ui--fit")),x.addCaptionHTMLFn(e,h,!0)){var o=h.clientHeight;t.bottom=parseInt(o,10)||44}else t.bottom=n.top;else t.bottom="auto"===n.bottom?0:n.bottom;t.top=n.top}else t.top=t.bottom=0}function p(){function e(e){if(e)for(var t=e.length,n=0;n