!function(t,e){"use strict";"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():t.baguetteBox=e()}(this,(function(){"use strict";function t(t){if(A.hasOwnProperty(t)){var e=A[t].galleries;[].forEach.call(e,(function(t){[].forEach.call(t,(function(t){f(t.imageElement,"click",t.eventHandler)})),C===t&&(C=[])})),delete A[t]}}function e(t){switch(t.keyCode){case 37:l();break;case 39:r();break;case 27:i()}}function n(t){k.noScrollbars&&(document.documentElement.style.overflowY="hidden",document.body.style.overflowY="scroll"),"block"!==p.style.display&&(d(document,"keydown",e),B={count:0,startX:null,startY:null},a(E=t,(function(){s(E),c(E)})),u(),p.style.display="block",k.fullScreen&&(p.requestFullscreen?p.requestFullscreen():p.webkitRequestFullscreen?p.webkitRequestFullscreen():p.mozRequestFullScreen&&p.mozRequestFullScreen()),setTimeout((function(){p.className="visible",k.afterShow&&k.afterShow()}),50),k.onChange&&k.onChange(E,S.length),P=document.activeElement,o())}function o(){k.buttons?h.focus():y.focus()}function i(){k.noScrollbars&&(document.documentElement.style.overflowY="auto",document.body.style.overflowY="auto"),"none"!==p.style.display&&(f(document,"keydown",e),p.className="",setTimeout((function(){p.style.display="none",document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen(),k.afterHide&&k.afterHide()}),500),P.focus())}function a(t,e){var n=S[t];if(void 0!==n){if(n.getElementsByTagName("img")[0])return void(e&&e());var o=C[t].imageElement,i=o.getElementsByTagName("img")[0],a="function"==typeof k.captions?k.captions.call(C,o):o.getAttribute("data-caption")||o.title,r=function(t){var e=t.href;if(t.dataset){var n=[];for(var o in t.dataset)"at-"!==o.substring(0,3)||isNaN(o.substring(3))||(n[o.replace("at-","")]=t.dataset[o]);for(var i=Object.keys(n).sort((function(t,e){return parseInt(t,10)<parseInt(e,10)?-1:1})),a=window.innerWidth*window.devicePixelRatio,r=0;r<i.length-1&&i[r]<a;)r++;e=n[i[r]]||e}return e}(o),l=m("figure");if(l.id="baguetteBox-figure-"+t,l.innerHTML='<div class="baguetteBox-spinner"><div class="baguetteBox-double-bounce1"></div><div class="baguetteBox-double-bounce2"></div></div>',k.captions&&a){var u=m("figcaption");u.id="baguetteBox-figcaption-"+t,u.innerHTML=a,l.appendChild(u)}n.appendChild(l);var s=m("img");s.onload=function(){var n=document.querySelector("#baguette-img-"+t+" .baguetteBox-spinner");l.removeChild(n),!k.async&&e&&e()},s.setAttribute("src",r),s.alt=i&&i.alt||"",k.titleTag&&a&&(s.title=a),l.appendChild(s),k.async&&e&&e()}}function r(){var t;return E<=S.length-2?(E++,u(),s(E),t=!0):k.animation&&(b.className="bounce-from-right",setTimeout((function(){b.className=""}),400),t=!1),k.onChange&&k.onChange(E,S.length),t}function l(){var t;return E>=1?(E--,u(),c(E),t=!0):k.animation&&(b.className="bounce-from-left",setTimeout((function(){b.className=""}),400),t=!1),k.onChange&&k.onChange(E,S.length),t}function u(){var t=100*-E+"%";"fadeIn"===k.animation?(b.style.opacity=0,setTimeout((function(){x.transforms?b.style.transform=b.style.webkitTransform="translate3d("+t+",0,0)":b.style.left=t,b.style.opacity=1}),400)):x.transforms?b.style.transform=b.style.webkitTransform="translate3d("+t+",0,0)":b.style.left=t}function s(t){t-E>=k.preload||a(t+1,(function(){s(t+1)}))}function c(t){E-t>=k.preload||a(t-1,(function(){c(t-1)}))}function d(t,e,n,o){t.addEventListener?t.addEventListener(e,n,o):t.attachEvent("on"+e,n)}function f(t,e,n,o){t.removeEventListener?t.removeEventListener(e,n,o):t.detachEvent("on"+e,n)}function g(t){return document.getElementById(t)}function m(t){return document.createElement(t)}var p,b,h,v,y,k={},w={captions:!0,fullScreen:!1,noScrollbars:!1,titleTag:!1,buttons:"auto",async:!1,preload:2,animation:"slideIn",afterShow:null,afterHide:null,onChange:null,overlayBackgroundColor:"rgba(0,0,0,.8)"},x={},C=[],E=0,B={},T=!1,N=/.+\.(gif|jpe?g|png|webp)/i,A={},S=[],P=null,F=function(t){-1!==t.target.id.indexOf("baguette-img")&&i()},H=function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,l()},L=function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,r()},I=function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,i()},Y=function(t){B.count++,B.count>1&&(B.multitouch=!0),B.startX=t.changedTouches[0].pageX,B.startY=t.changedTouches[0].pageY},q=function(t){if(!T&&!B.multitouch){t.preventDefault?t.preventDefault():t.returnValue=!1;var e=t.touches[0]||t.changedTouches[0];e.pageX-B.startX>40?(T=!0,l()):e.pageX-B.startX<-40?(T=!0,r()):B.startY-e.pageY>100&&i()}},j=function(){B.count--,B.count<=0&&(B.multitouch=!1),T=!1},X=function(t){"block"!==p.style.display||p.contains(t.target)||(t.stopPropagation(),o())};return[].forEach||(Array.prototype.forEach=function(t,e){for(var n=0;n<this.length;n++)t.call(e,this[n],n,this)}),[].filter||(Array.prototype.filter=function(t,e,n,o,i){for(n=this,o=[],i=0;i<n.length;i++)t.call(e,n[i],i,n)&&o.push(n[i]);return o}),{run:function(e,o){x.transforms=function(){var t=m("div");return void 0!==t.style.perspective||void 0!==t.style.webkitPerspective}(),x.svg=function(){var t=m("div");return t.innerHTML="<svg/>","http://www.w3.org/2000/svg"===(t.firstChild&&t.firstChild.namespaceURI)}(),(p=g("baguetteBox-overlay"))?(b=g("baguetteBox-slider"),h=g("previous-button"),v=g("next-button"),y=g("close-button")):((p=m("div")).setAttribute("role","dialog"),p.id="baguetteBox-overlay",document.getElementsByTagName("body")[0].appendChild(p),(b=m("div")).id="baguetteBox-slider",p.appendChild(b),(h=m("button")).setAttribute("type","button"),h.id="previous-button",h.setAttribute("aria-label","Previous"),h.innerHTML=x.svg?'<svg width="44" height="60"><polyline points="30 10 10 30 30 50" stroke="rgba(255,255,255,0.5)" stroke-width="4"stroke-linecap="butt" fill="none" stroke-linejoin="round"/></svg>':"&lt;",p.appendChild(h),(v=m("button")).setAttribute("type","button"),v.id="next-button",v.setAttribute("aria-label","Next"),v.innerHTML=x.svg?'<svg width="44" height="60"><polyline points="14 10 34 30 14 50" stroke="rgba(255,255,255,0.5)" stroke-width="4"stroke-linecap="butt" fill="none" stroke-linejoin="round"/></svg>':"&gt;",p.appendChild(v),(y=m("button")).setAttribute("type","button"),y.id="close-button",y.setAttribute("aria-label","Close"),y.innerHTML=x.svg?'<svg width="30" height="30"><g stroke="rgb(160,160,160)" stroke-width="4"><line x1="5" y1="5" x2="25" y2="25"/><line x1="5" y1="25" x2="25" y2="5"/></g></svg>':"&times;",p.appendChild(y),h.className=v.className=y.className="baguetteBox-button",d(p,"click",F),d(h,"click",H),d(v,"click",L),d(y,"click",I),d(p,"touchstart",Y),d(p,"touchmove",q),d(p,"touchend",j),d(document,"focus",X,!0)),t(e),function(t,e){var o=document.querySelectorAll(t),i={galleries:[],nodeList:o};A[t]=i,[].forEach.call(o,(function(t){e&&e.filter&&(N=e.filter);var o=[];if(o="A"===t.tagName?[t]:t.getElementsByTagName("a"),o=[].filter.call(o,(function(t){return N.test(t.href)})),0!==o.length){var a=[];[].forEach.call(o,(function(t,o){var i=function(t){t.preventDefault?t.preventDefault():t.returnValue=!1,function(t,e){if(C!==t){for(C=t,function(t){for(var e in t||(t={}),w)k[e]=w[e],void 0!==t[e]&&(k[e]=t[e]);b.style.transition=b.style.webkitTransition="fadeIn"===k.animation?"opacity .4s ease":"slideIn"===k.animation?"":"none","auto"===k.buttons&&("ontouchstart"in window||1===C.length)&&(k.buttons=!1),h.style.display=v.style.display=k.buttons?"":"none";try{p.style.backgroundColor=k.overlayBackgroundColor}catch(t){}}(e);b.firstChild;)b.removeChild(b.firstChild);S.length=0;for(var n,o=[],i=[],a=0;a<t.length;a++)(n=m("div")).className="full-image",n.id="baguette-img-"+a,S.push(n),o.push("baguetteBox-figure-"+a),i.push("baguetteBox-figcaption-"+a),b.appendChild(S[a]);p.setAttribute("aria-labelledby",o.join(" ")),p.setAttribute("aria-describedby",i.join(" "))}}(a,e),n(o)},r={eventHandler:i,imageElement:t};d(t,"click",i),a.push(r)})),i.galleries.push(a)}}))}(e,o)},destroy:function(){f(p,"click",F),f(h,"click",H),f(v,"click",L),f(y,"click",I),f(p,"touchstart",Y),f(p,"touchmove",q),f(p,"touchend",j),f(document,"focus",X,!0),function(){for(var e in A)A.hasOwnProperty(e)&&t(e)}(),f(document,"keydown",e),document.getElementsByTagName("body")[0].removeChild(document.getElementById("baguetteBox-overlay")),A={},C=[],E=0},showNext:r,showPrevious:l}}));