File: /www/wwwroot/www.scdc-marine.com/wp-content/themes/heku-cms/TempParts/assets/js/viewer.min.js
/*!
* Viewer.js v1.11.1
* https://fengyuanchen.github.io/viewerjs
*
* Copyright 2015-present Chen Fengyuan
* Released under the MIT license
*
* Date: 2022-11-06T05:18:19.939Z
*/
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):(global="undefined"!=typeof globalThis?globalThis:global||self).Viewer=factory()}(this,(function(){"use strict";function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter((function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable}))),keys.push.apply(keys,symbols)}return keys}function _objectSpread2(target){for(var i=1;i<arguments.length;i++){var source=null!=arguments[i]?arguments[i]:{};i%2?ownKeys(Object(source),!0).forEach((function(key){_defineProperty(target,key,source[key])})):Object.getOwnPropertyDescriptors?Object.defineProperties(target,Object.getOwnPropertyDescriptors(source)):ownKeys(Object(source)).forEach((function(key){Object.defineProperty(target,key,Object.getOwnPropertyDescriptor(source,key))}))}return target}function _typeof(obj){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj})(obj)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}function _createClass(Constructor,protoProps,staticProps){return protoProps&&_defineProperties(Constructor.prototype,protoProps),staticProps&&_defineProperties(Constructor,staticProps),Object.defineProperty(Constructor,"prototype",{writable:!1}),Constructor}function _defineProperty(obj,key,value){return key in obj?Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}):obj[key]=value,obj}var DEFAULTS={backdrop:!0,button:!0,navbar:!0,title:!0,toolbar:!0,className:"",container:"body",filter:null,fullscreen:!0,inheritedAttributes:["crossOrigin","decoding","isMap","loading","referrerPolicy","sizes","srcset","useMap"],initialCoverage:.9,initialViewIndex:0,inline:!1,interval:5e3,keyboard:!0,focus:!0,loading:!0,loop:!0,minWidth:200,minHeight:100,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,slideOnTouch:!0,toggleOnDblclick:!0,tooltip:!0,transition:!0,zIndex:2015,zIndexInline:0,zoomRatio:.1,minZoomRatio:.01,maxZoomRatio:100,url:"src",ready:null,show:null,shown:null,hide:null,hidden:null,view:null,viewed:null,move:null,moved:null,rotate:null,rotated:null,scale:null,scaled:null,zoom:null,zoomed:null,play:null,stop:null},TEMPLATE='<div class="viewer-container" tabindex="-1" touch-action="none"><div class="viewer-canvas"></div><div class="viewer-footer"><div class="viewer-title"></div><div class="viewer-toolbar"></div><div class="viewer-navbar"><ul class="viewer-list" role="navigation"></ul></div></div><div class="viewer-tooltip" role="alert" aria-hidden="true"></div><div class="viewer-button" data-viewer-action="mix" role="button"></div><div class="viewer-player"></div></div>',IS_BROWSER="undefined"!=typeof window&&void 0!==window.document,WINDOW=IS_BROWSER?window:{},IS_TOUCH_DEVICE=!(!IS_BROWSER||!WINDOW.document.documentElement)&&"ontouchstart"in WINDOW.document.documentElement,HAS_POINTER_EVENT=!!IS_BROWSER&&"PointerEvent"in WINDOW,NAMESPACE="viewer",ACTION_MOVE="move",ACTION_SWITCH="switch",ACTION_ZOOM="zoom",CLASS_ACTIVE="".concat("viewer","-active"),CLASS_CLOSE="".concat("viewer","-close"),CLASS_FADE="".concat("viewer","-fade"),CLASS_FIXED="".concat("viewer","-fixed"),CLASS_FULLSCREEN="".concat("viewer","-fullscreen"),CLASS_FULLSCREEN_EXIT="".concat("viewer","-fullscreen-exit"),CLASS_HIDE="".concat("viewer","-hide"),CLASS_HIDE_MD_DOWN="".concat("viewer","-hide-md-down"),CLASS_HIDE_SM_DOWN="".concat("viewer","-hide-sm-down"),CLASS_HIDE_XS_DOWN="".concat("viewer","-hide-xs-down"),CLASS_IN="".concat("viewer","-in"),CLASS_INVISIBLE="".concat("viewer","-invisible"),CLASS_LOADING="".concat("viewer","-loading"),CLASS_MOVE="".concat("viewer","-move"),CLASS_OPEN="".concat("viewer","-open"),CLASS_SHOW="".concat("viewer","-show"),CLASS_TRANSITION="".concat("viewer","-transition"),EVENT_CLICK="click",EVENT_DBLCLICK="dblclick",EVENT_DRAG_START="dragstart",EVENT_FOCUSIN="focusin",EVENT_KEY_DOWN="keydown",EVENT_LOAD="load",EVENT_ERROR="error",EVENT_TOUCH_END,EVENT_TOUCH_MOVE,EVENT_TOUCH_START,EVENT_POINTER_DOWN=HAS_POINTER_EVENT?"pointerdown":IS_TOUCH_DEVICE?"touchstart":"mousedown",EVENT_POINTER_MOVE=HAS_POINTER_EVENT?"pointermove":IS_TOUCH_DEVICE?"touchmove":"mousemove",EVENT_POINTER_UP=HAS_POINTER_EVENT?"pointerup pointercancel":IS_TOUCH_DEVICE?"touchend touchcancel":"mouseup",EVENT_RESIZE="resize",EVENT_TRANSITION_END="transitionend",EVENT_WHEEL="wheel",EVENT_READY="ready",EVENT_SHOW="show",EVENT_SHOWN="shown",EVENT_HIDE="hide",EVENT_HIDDEN="hidden",EVENT_VIEW="view",EVENT_VIEWED="viewed",EVENT_MOVE="move",EVENT_MOVED="moved",EVENT_ROTATE="rotate",EVENT_ROTATED="rotated",EVENT_SCALE="scale",EVENT_SCALED="scaled",EVENT_ZOOM="zoom",EVENT_ZOOMED="zoomed",EVENT_PLAY="play",EVENT_STOP="stop",DATA_ACTION="".concat("viewer","Action"),REGEXP_SPACES=/\s\s*/,BUTTONS=["zoom-in","zoom-out","one-to-one","reset","prev","play","next","rotate-left","rotate-right","flip-horizontal","flip-vertical"];function isString(value){return"string"==typeof value}var isNaN=Number.isNaN||WINDOW.isNaN;function isNumber(value){return"number"==typeof value&&!isNaN(value)}function isUndefined(value){return void 0===value}function isObject(value){return"object"===_typeof(value)&&null!==value}var hasOwnProperty=Object.prototype.hasOwnProperty;function isPlainObject(value){if(!isObject(value))return!1;try{var _constructor=value.constructor,prototype=_constructor.prototype;return _constructor&&prototype&&hasOwnProperty.call(prototype,"isPrototypeOf")}catch(error){return!1}}function isFunction(value){return"function"==typeof value}function forEach(data,callback){if(data&&isFunction(callback))if(Array.isArray(data)||isNumber(data.length)){var length=data.length,i;for(i=0;i<length&&!1!==callback.call(data,data[i],i,data);i+=1);}else isObject(data)&&Object.keys(data).forEach((function(key){callback.call(data,data[key],key,data)}));return data}var assign=Object.assign||function assign(obj){for(var _len=arguments.length,args=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];return isObject(obj)&&args.length>0&&args.forEach((function(arg){isObject(arg)&&Object.keys(arg).forEach((function(key){obj[key]=arg[key]}))})),obj},REGEXP_SUFFIX=/^(?:width|height|left|top|marginLeft|marginTop)$/;function setStyle(element,styles){var style=element.style;forEach(styles,(function(value,property){REGEXP_SUFFIX.test(property)&&isNumber(value)&&(value+="px"),style[property]=value}))}function escapeHTMLEntities(value){return isString(value)?value.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"):value}function hasClass(element,value){return!(!element||!value)&&(element.classList?element.classList.contains(value):element.className.indexOf(value)>-1)}function addClass(element,value){if(element&&value)if(isNumber(element.length))forEach(element,(function(elem){addClass(elem,value)}));else if(element.classList)element.classList.add(value);else{var className=element.className.trim();className?className.indexOf(value)<0&&(element.className="".concat(className," ").concat(value)):element.className=value}}function removeClass(element,value){element&&value&&(isNumber(element.length)?forEach(element,(function(elem){removeClass(elem,value)})):element.classList?element.classList.remove(value):element.className.indexOf(value)>=0&&(element.className=element.className.replace(value,"")))}function toggleClass(element,value,added){value&&(isNumber(element.length)?forEach(element,(function(elem){toggleClass(elem,value,added)})):added?addClass(element,value):removeClass(element,value))}var REGEXP_HYPHENATE=/([a-z\d])([A-Z])/g;function hyphenate(value){return value.replace(REGEXP_HYPHENATE,"$1-$2").toLowerCase()}function getData(element,name){return isObject(element[name])?element[name]:element.dataset?element.dataset[name]:element.getAttribute("data-".concat(hyphenate(name)))}function setData(element,name,data){isObject(data)?element[name]=data:element.dataset?element.dataset[name]=data:element.setAttribute("data-".concat(hyphenate(name)),data)}var onceSupported=function(){var supported=!1;if(IS_BROWSER){var once=!1,listener=function listener(){},options=Object.defineProperty({},"once",{get:function get(){return supported=!0,once},set:function set(value){once=value}});WINDOW.addEventListener("test",listener,options),WINDOW.removeEventListener("test",listener,options)}return supported}();function removeListener(element,type,listener){var options=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},handler=listener;type.trim().split(REGEXP_SPACES).forEach((function(event){if(!onceSupported){var listeners=element.listeners;listeners&&listeners[event]&&listeners[event][listener]&&(handler=listeners[event][listener],delete listeners[event][listener],0===Object.keys(listeners[event]).length&&delete listeners[event],0===Object.keys(listeners).length&&delete element.listeners)}element.removeEventListener(event,handler,options)}))}function addListener(element,type,listener){var options=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},_handler=listener;type.trim().split(REGEXP_SPACES).forEach((function(event){if(options.once&&!onceSupported){var _element$listeners=element.listeners,listeners=void 0===_element$listeners?{}:_element$listeners;_handler=function handler(){delete listeners[event][listener],element.removeEventListener(event,_handler,options);for(var _len2=arguments.length,args=new Array(_len2),_key2=0;_key2<_len2;_key2++)args[_key2]=arguments[_key2];listener.apply(element,args)},listeners[event]||(listeners[event]={}),listeners[event][listener]&&element.removeEventListener(event,listeners[event][listener],options),listeners[event][listener]=_handler,element.listeners=listeners}element.addEventListener(event,_handler,options)}))}function dispatchEvent(element,type,data,options){var event;return isFunction(Event)&&isFunction(CustomEvent)?event=new CustomEvent(type,_objectSpread2({bubbles:!0,cancelable:!0,detail:data},options)):(event=document.createEvent("CustomEvent")).initCustomEvent(type,!0,!0,data),element.dispatchEvent(event)}function getOffset(element){var box=element.getBoundingClientRect();return{left:box.left+(window.pageXOffset-document.documentElement.clientLeft),top:box.top+(window.pageYOffset-document.documentElement.clientTop)}}function getTransforms(_ref){var rotate=_ref.rotate,scaleX=_ref.scaleX,scaleY=_ref.scaleY,translateX=_ref.translateX,translateY=_ref.translateY,values=[];isNumber(translateX)&&0!==translateX&&values.push("translateX(".concat(translateX,"px)")),isNumber(translateY)&&0!==translateY&&values.push("translateY(".concat(translateY,"px)")),isNumber(rotate)&&0!==rotate&&values.push("rotate(".concat(rotate,"deg)")),isNumber(scaleX)&&1!==scaleX&&values.push("scaleX(".concat(scaleX,")")),isNumber(scaleY)&&1!==scaleY&&values.push("scaleY(".concat(scaleY,")"));var transform=values.length?values.join(" "):"none";return{WebkitTransform:transform,msTransform:transform,transform:transform}}function getImageNameFromURL(url){return isString(url)?decodeURIComponent(url.replace(/^.*\//,"").replace(/[?&#].*$/,"")):""}var IS_SAFARI=WINDOW.navigator&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(WINDOW.navigator.userAgent);function getImageNaturalSizes(image,options,callback){var newImage=document.createElement("img");if(image.naturalWidth&&!IS_SAFARI)return callback(image.naturalWidth,image.naturalHeight),newImage;var body=document.body||document.documentElement;return newImage.onload=function(){callback(newImage.width,newImage.height),IS_SAFARI||body.removeChild(newImage)},forEach(options.inheritedAttributes,(function(name){var value=image.getAttribute(name);null!==value&&newImage.setAttribute(name,value)})),newImage.src=image.src,IS_SAFARI||(newImage.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",body.appendChild(newImage)),newImage}function getResponsiveClass(type){switch(type){case 2:return CLASS_HIDE_XS_DOWN;case 3:return CLASS_HIDE_SM_DOWN;case 4:return CLASS_HIDE_MD_DOWN;default:return""}}function getMaxZoomRatio(pointers){var pointers2=_objectSpread2({},pointers),ratios=[];return forEach(pointers,(function(pointer,pointerId){delete pointers2[pointerId],forEach(pointers2,(function(pointer2){var x1=Math.abs(pointer.startX-pointer2.startX),y1=Math.abs(pointer.startY-pointer2.startY),x2=Math.abs(pointer.endX-pointer2.endX),y2=Math.abs(pointer.endY-pointer2.endY),z1=Math.sqrt(x1*x1+y1*y1),z2,ratio=(Math.sqrt(x2*x2+y2*y2)-z1)/z1;ratios.push(ratio)}))})),ratios.sort((function(a,b){return Math.abs(a)<Math.abs(b)})),ratios[0]}function getPointer(_ref2,endOnly){var pageX=_ref2.pageX,pageY=_ref2.pageY,end={endX:pageX,endY:pageY};return endOnly?end:_objectSpread2({timeStamp:Date.now(),startX:pageX,startY:pageY},end)}function getPointersCenter(pointers){var pageX=0,pageY=0,count=0;return forEach(pointers,(function(_ref3){var startX=_ref3.startX,startY=_ref3.startY;pageX+=startX,pageY+=startY,count+=1})),{pageX:pageX/=count,pageY:pageY/=count}}var render={render:function render(){this.initContainer(),this.initViewer(),this.initList(),this.renderViewer()},initBody:function initBody(){var ownerDocument=this.element.ownerDocument,body=ownerDocument.body||ownerDocument.documentElement;this.body=body,this.scrollbarWidth=window.innerWidth-ownerDocument.documentElement.clientWidth,this.initialBodyPaddingRight=body.style.paddingRight,this.initialBodyComputedPaddingRight=window.getComputedStyle(body).paddingRight},initContainer:function initContainer(){this.containerData={width:window.innerWidth,height:window.innerHeight}},initViewer:function initViewer(){var options=this.options,parent=this.parent,viewerData;options.inline&&(viewerData={width:Math.max(parent.offsetWidth,options.minWidth),height:Math.max(parent.offsetHeight,options.minHeight)},this.parentData=viewerData),!this.fulled&&viewerData||(viewerData=this.containerData),this.viewerData=assign({},viewerData)},renderViewer:function renderViewer(){this.options.inline&&!this.fulled&&setStyle(this.viewer,this.viewerData)},initList:function initList(){var _this=this,element=this.element,options=this.options,list=this.list,items=[];list.innerHTML="",forEach(this.images,(function(image,index){var src=image.src,alt=image.alt||getImageNameFromURL(src),url=_this.getImageURL(image);if(src||url){var item=document.createElement("li"),img=document.createElement("img");forEach(options.inheritedAttributes,(function(name){var value=image.getAttribute(name);null!==value&&img.setAttribute(name,value)})),options.navbar&&(img.src=src||url),img.alt=alt,img.setAttribute("data-original-url",url||src),item.setAttribute("data-index",index),item.setAttribute("data-viewer-action","view"),item.setAttribute("role","button"),options.keyboard&&item.setAttribute("tabindex",0),item.appendChild(img),list.appendChild(item),items.push(item)}})),this.items=items,forEach(items,(function(item){var image=item.firstElementChild,onLoad,onError;setData(image,"filled",!0),options.loading&&addClass(item,CLASS_LOADING),addListener(image,"load",onLoad=function onLoad(event){removeListener(image,"error",onError),options.loading&&removeClass(item,CLASS_LOADING),_this.loadImage(event)},{once:!0}),addListener(image,"error",onError=function onError(){removeListener(image,"load",onLoad),options.loading&&removeClass(item,CLASS_LOADING)},{once:!0})})),options.transition&&addListener(element,"viewed",(function(){addClass(list,CLASS_TRANSITION)}),{once:!0})},renderList:function renderList(){var index=this.index,item=this.items[index];if(item){var next=item.nextElementSibling,gutter=parseInt(window.getComputedStyle(next||item).marginLeft,10),offsetWidth=item.offsetWidth,outerWidth=offsetWidth+gutter;setStyle(this.list,assign({width:outerWidth*this.length-gutter},getTransforms({translateX:(this.viewerData.width-offsetWidth)/2-outerWidth*index})))}},resetList:function resetList(){var list=this.list;list.innerHTML="",removeClass(list,CLASS_TRANSITION),setStyle(list,getTransforms({translateX:0}))},initImage:function initImage(done){var _this2=this,options=this.options,image=this.image,viewerData=this.viewerData,footerHeight=this.footer.offsetHeight,viewerWidth=viewerData.width,viewerHeight=Math.max(viewerData.height-footerHeight,footerHeight),oldImageData=this.imageData||{},sizingImage;this.imageInitializing={abort:function abort(){sizingImage.onload=null}},sizingImage=getImageNaturalSizes(image,options,(function(naturalWidth,naturalHeight){var aspectRatio=naturalWidth/naturalHeight,initialCoverage=Math.max(0,Math.min(1,options.initialCoverage)),width=viewerWidth,height=viewerHeight;_this2.imageInitializing=!1,viewerHeight*aspectRatio>viewerWidth?height=viewerWidth/aspectRatio:width=viewerHeight*aspectRatio,initialCoverage=isNumber(initialCoverage)?initialCoverage:.9,width=Math.min(width*initialCoverage,naturalWidth),height=Math.min(height*initialCoverage,naturalHeight);var left=(viewerWidth-width)/2,top=(viewerHeight-height)/2,imageData={left:left,top:top,x:left,y:top,width:width,height:height,oldRatio:1,ratio:width/naturalWidth,aspectRatio:aspectRatio,naturalWidth:naturalWidth,naturalHeight:naturalHeight},initialImageData=assign({},imageData);options.rotatable&&(imageData.rotate=oldImageData.rotate||0,initialImageData.rotate=0),options.scalable&&(imageData.scaleX=oldImageData.scaleX||1,imageData.scaleY=oldImageData.scaleY||1,initialImageData.scaleX=1,initialImageData.scaleY=1),_this2.imageData=imageData,_this2.initialImageData=initialImageData,done&&done()}))},renderImage:function renderImage(done){var _this3=this,image=this.image,imageData=this.imageData;if(setStyle(image,assign({width:imageData.width,height:imageData.height,marginLeft:imageData.x,marginTop:imageData.y},getTransforms(imageData))),done)if((this.viewing||this.moving||this.rotating||this.scaling||this.zooming)&&this.options.transition&&hasClass(image,CLASS_TRANSITION)){var onTransitionEnd=function onTransitionEnd(){_this3.imageRendering=!1,done()};this.imageRendering={abort:function abort(){removeListener(image,"transitionend",onTransitionEnd)}},addListener(image,"transitionend",onTransitionEnd,{once:!0})}else done()},resetImage:function resetImage(){if(this.viewing||this.viewed){var image=this.image;this.viewing&&this.viewing.abort(),image.parentNode.removeChild(image),this.image=null}}},events={bind:function bind(){var options=this.options,viewer=this.viewer,canvas=this.canvas,document=this.element.ownerDocument;addListener(viewer,"click",this.onClick=this.click.bind(this)),addListener(viewer,"dragstart",this.onDragStart=this.dragstart.bind(this)),addListener(canvas,EVENT_POINTER_DOWN,this.onPointerDown=this.pointerdown.bind(this)),addListener(document,EVENT_POINTER_MOVE,this.onPointerMove=this.pointermove.bind(this)),addListener(document,EVENT_POINTER_UP,this.onPointerUp=this.pointerup.bind(this)),addListener(document,"keydown",this.onKeyDown=this.keydown.bind(this)),addListener(window,"resize",this.onResize=this.resize.bind(this)),options.zoomable&&options.zoomOnWheel&&addListener(viewer,"wheel",this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),options.toggleOnDblclick&&addListener(canvas,"dblclick",this.onDblclick=this.dblclick.bind(this))},unbind:function unbind(){var options=this.options,viewer=this.viewer,canvas=this.canvas,document=this.element.ownerDocument;removeListener(viewer,"click",this.onClick),removeListener(viewer,"dragstart",this.onDragStart),removeListener(canvas,EVENT_POINTER_DOWN,this.onPointerDown),removeListener(document,EVENT_POINTER_MOVE,this.onPointerMove),removeListener(document,EVENT_POINTER_UP,this.onPointerUp),removeListener(document,"keydown",this.onKeyDown),removeListener(window,"resize",this.onResize),options.zoomable&&options.zoomOnWheel&&removeListener(viewer,"wheel",this.onWheel,{passive:!1,capture:!0}),options.toggleOnDblclick&&removeListener(canvas,"dblclick",this.onDblclick)}},handlers={click:function click(event){var options=this.options,imageData=this.imageData,target=event.target,action=getData(target,DATA_ACTION);switch(action||"img"!==target.localName||"li"!==target.parentElement.localName||(action=getData(target=target.parentElement,DATA_ACTION)),IS_TOUCH_DEVICE&&event.isTrusted&&target===this.canvas&&clearTimeout(this.clickCanvasTimeout),action){case"mix":this.played?this.stop():options.inline?this.fulled?this.exit():this.full():this.hide();break;case"hide":this.hide();break;case"view":this.view(getData(target,"index"));break;case"zoom-in":this.zoom(.1,!0);break;case"zoom-out":this.zoom(-.1,!0);break;case"one-to-one":this.toggle();break;case"reset":this.reset();break;case"prev":this.prev(options.loop);break;case"play":this.play(options.fullscreen);break;case"next":this.next(options.loop);break;case"rotate-left":this.rotate(-90);break;case"rotate-right":this.rotate(90);break;case"flip-horizontal":this.scaleX(-imageData.scaleX||-1);break;case"flip-vertical":this.scaleY(-imageData.scaleY||-1);break;default:this.played&&this.stop()}},dblclick:function dblclick(event){event.preventDefault(),this.viewed&&event.target===this.image&&(IS_TOUCH_DEVICE&&event.isTrusted&&clearTimeout(this.doubleClickImageTimeout),this.toggle(event.isTrusted?event:event.detail&&event.detail.originalEvent))},load:function load(){var _this=this;this.timeout&&(clearTimeout(this.timeout),this.timeout=!1);var element=this.element,options=this.options,image=this.image,index=this.index,viewerData=this.viewerData;removeClass(image,CLASS_INVISIBLE),options.loading&&removeClass(this.canvas,CLASS_LOADING),image.style.cssText="height:0;"+"margin-left:".concat(viewerData.width/2,"px;")+"margin-top:".concat(viewerData.height/2,"px;")+"max-width:none!important;position:relative;width:0;",this.initImage((function(){toggleClass(image,CLASS_MOVE,options.movable),toggleClass(image,CLASS_TRANSITION,options.transition),_this.renderImage((function(){_this.viewed=!0,_this.viewing=!1,isFunction(options.viewed)&&addListener(element,"viewed",options.viewed,{once:!0}),dispatchEvent(element,"viewed",{originalImage:_this.images[index],index:index,image:image},{cancelable:!1})}))}))},loadImage:function loadImage(event){var image=event.target,parent=image.parentNode,parentWidth=parent.offsetWidth||30,parentHeight=parent.offsetHeight||50,filled=!!getData(image,"filled");getImageNaturalSizes(image,this.options,(function(naturalWidth,naturalHeight){var aspectRatio=naturalWidth/naturalHeight,width=parentWidth,height=parentHeight;parentHeight*aspectRatio>parentWidth?filled?width=parentHeight*aspectRatio:height=parentWidth/aspectRatio:filled?height=parentWidth/aspectRatio:width=parentHeight*aspectRatio,setStyle(image,assign({width:width,height:height},getTransforms({translateX:(parentWidth-width)/2,translateY:(parentHeight-height)/2})))}))},keydown:function keydown(event){var options=this.options;if(options.keyboard){var keyCode=event.keyCode||event.which||event.charCode;switch(keyCode){case 13:this.viewer.contains(event.target)&&this.click(event)}if(this.fulled)switch(keyCode){case 27:this.played?this.stop():options.inline?this.fulled&&this.exit():this.hide();break;case 32:this.played&&this.stop();break;case 37:this.played&&this.playing?this.playing.prev():this.prev(options.loop);break;case 38:event.preventDefault(),this.zoom(options.zoomRatio,!0);break;case 39:this.played&&this.playing?this.playing.next():this.next(options.loop);break;case 40:event.preventDefault(),this.zoom(-options.zoomRatio,!0);break;case 48:case 49:event.ctrlKey&&(event.preventDefault(),this.toggle())}}},dragstart:function dragstart(event){"img"===event.target.localName&&event.preventDefault()},pointerdown:function pointerdown(event){var options=this.options,pointers=this.pointers,buttons=event.buttons,button=event.button;if(!(!this.viewed||this.showing||this.viewing||this.hiding||("mousedown"===event.type||"pointerdown"===event.type&&"mouse"===event.pointerType)&&(isNumber(buttons)&&1!==buttons||isNumber(button)&&0!==button||event.ctrlKey))){event.preventDefault(),event.changedTouches?forEach(event.changedTouches,(function(touch){pointers[touch.identifier]=getPointer(touch)})):pointers[event.pointerId||0]=getPointer(event);var action=!!options.movable&&"move";options.zoomOnTouch&&options.zoomable&&Object.keys(pointers).length>1?action="zoom":options.slideOnTouch&&("touch"===event.pointerType||"touchstart"===event.type)&&this.isSwitchable()&&(action="switch"),!options.transition||"move"!==action&&"zoom"!==action||removeClass(this.image,CLASS_TRANSITION),this.action=action}},pointermove:function pointermove(event){var pointers=this.pointers,action=this.action;this.viewed&&action&&(event.preventDefault(),event.changedTouches?forEach(event.changedTouches,(function(touch){assign(pointers[touch.identifier]||{},getPointer(touch,!0))})):assign(pointers[event.pointerId||0]||{},getPointer(event,!0)),this.change(event))},pointerup:function pointerup(event){var _this2=this,options=this.options,action=this.action,pointers=this.pointers,pointer;event.changedTouches?forEach(event.changedTouches,(function(touch){pointer=pointers[touch.identifier],delete pointers[touch.identifier]})):(pointer=pointers[event.pointerId||0],delete pointers[event.pointerId||0]),action&&(event.preventDefault(),!options.transition||"move"!==action&&"zoom"!==action||addClass(this.image,CLASS_TRANSITION),this.action=!1,IS_TOUCH_DEVICE&&"zoom"!==action&&pointer&&Date.now()-pointer.timeStamp<500&&(clearTimeout(this.clickCanvasTimeout),clearTimeout(this.doubleClickImageTimeout),options.toggleOnDblclick&&this.viewed&&event.target===this.image?this.imageClicked?(this.imageClicked=!1,this.doubleClickImageTimeout=setTimeout((function(){dispatchEvent(_this2.image,"dblclick",{originalEvent:event})}),50)):(this.imageClicked=!0,this.doubleClickImageTimeout=setTimeout((function(){_this2.imageClicked=!1}),500)):(this.imageClicked=!1,options.backdrop&&"static"!==options.backdrop&&event.target===this.canvas&&(this.clickCanvasTimeout=setTimeout((function(){dispatchEvent(_this2.canvas,"click",{originalEvent:event})}),50)))))},resize:function resize(){var _this3=this;if(this.isShown&&!this.hiding&&(this.fulled&&(this.close(),this.initBody(),this.open()),this.initContainer(),this.initViewer(),this.renderViewer(),this.renderList(),this.viewed&&this.initImage((function(){_this3.renderImage()})),this.played)){if(this.options.fullscreen&&this.fulled&&!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement))return void this.stop();forEach(this.player.getElementsByTagName("img"),(function(image){addListener(image,"load",_this3.loadImage.bind(_this3),{once:!0}),dispatchEvent(image,"load")}))}},wheel:function wheel(event){var _this4=this;if(this.viewed&&(event.preventDefault(),!this.wheeling)){this.wheeling=!0,setTimeout((function(){_this4.wheeling=!1}),50);var ratio=Number(this.options.zoomRatio)||.1,delta=1;event.deltaY?delta=event.deltaY>0?1:-1:event.wheelDelta?delta=-event.wheelDelta/120:event.detail&&(delta=event.detail>0?1:-1),this.zoom(-delta*ratio,!0,null,event)}}},methods={show:function show(){var immediate=arguments.length>0&&void 0!==arguments[0]&&arguments[0],element=this.element,options=this.options;if(options.inline||this.showing||this.isShown||this.showing)return this;if(!this.ready)return this.build(),this.ready&&this.show(immediate),this;if(isFunction(options.show)&&addListener(element,"show",options.show,{once:!0}),!1===dispatchEvent(element,"show")||!this.ready)return this;this.hiding&&this.transitioning.abort(),this.showing=!0,this.open();var viewer=this.viewer;if(removeClass(viewer,CLASS_HIDE),viewer.setAttribute("role","dialog"),viewer.setAttribute("aria-labelledby",this.title.id),viewer.setAttribute("aria-modal",!0),viewer.removeAttribute("aria-hidden"),options.transition&&!immediate){var shown=this.shown.bind(this);this.transitioning={abort:function abort(){removeListener(viewer,"transitionend",shown),removeClass(viewer,CLASS_IN)}},addClass(viewer,CLASS_TRANSITION),viewer.initialOffsetWidth=viewer.offsetWidth,addListener(viewer,"transitionend",shown,{once:!0}),addClass(viewer,CLASS_IN)}else addClass(viewer,CLASS_IN),this.shown();return this},hide:function hide(){var _this=this,immediate=arguments.length>0&&void 0!==arguments[0]&&arguments[0],element=this.element,options=this.options;if(options.inline||this.hiding||!this.isShown&&!this.showing)return this;if(isFunction(options.hide)&&addListener(element,"hide",options.hide,{once:!0}),!1===dispatchEvent(element,"hide"))return this;this.showing&&this.transitioning.abort(),this.hiding=!0,this.played?this.stop():this.viewing&&this.viewing.abort();var viewer=this.viewer,image=this.image,hideImmediately=function hideImmediately(){removeClass(viewer,CLASS_IN),_this.hidden()};if(options.transition&&!immediate){var onViewerTransitionEnd=function onViewerTransitionEnd(event){event&&event.target===viewer&&(removeListener(viewer,"transitionend",onViewerTransitionEnd),_this.hidden())},onImageTransitionEnd=function onImageTransitionEnd(){hasClass(viewer,CLASS_TRANSITION)?(addListener(viewer,"transitionend",onViewerTransitionEnd),removeClass(viewer,CLASS_IN)):hideImmediately()};this.transitioning={abort:function abort(){_this.viewed&&hasClass(image,CLASS_TRANSITION)?removeListener(image,"transitionend",onImageTransitionEnd):hasClass(viewer,CLASS_TRANSITION)&&removeListener(viewer,"transitionend",onViewerTransitionEnd)}},this.viewed&&hasClass(image,CLASS_TRANSITION)?(addListener(image,"transitionend",onImageTransitionEnd,{once:!0}),this.zoomTo(0,!1,null,null,!0)):onImageTransitionEnd()}else hideImmediately();return this},view:function view(){var _this2=this,index=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.initialViewIndex;if(index=Number(index)||0,this.hiding||this.played||index<0||index>=this.length||this.viewed&&index===this.index)return this;if(!this.isShown)return this.index=index,this.show();this.viewing&&this.viewing.abort();var element=this.element,options=this.options,title=this.title,canvas=this.canvas,item=this.items[index],img=item.querySelector("img"),url=getData(img,"originalUrl"),alt=img.getAttribute("alt"),image=document.createElement("img");if(forEach(options.inheritedAttributes,(function(name){var value=img.getAttribute(name);null!==value&&image.setAttribute(name,value)})),image.src=url,image.alt=alt,isFunction(options.view)&&addListener(element,"view",options.view,{once:!0}),!1===dispatchEvent(element,"view",{originalImage:this.images[index],index:index,image:image})||!this.isShown||this.hiding||this.played)return this;var activeItem=this.items[this.index];activeItem&&(removeClass(activeItem,CLASS_ACTIVE),activeItem.removeAttribute("aria-selected")),addClass(item,CLASS_ACTIVE),item.setAttribute("aria-selected",!0),options.focus&&item.focus(),this.image=image,this.viewed=!1,this.index=index,this.imageData={},addClass(image,CLASS_INVISIBLE),options.loading&&addClass(canvas,CLASS_LOADING),canvas.innerHTML="",canvas.appendChild(image),this.renderList(),title.innerHTML="";var onViewed=function onViewed(){var imageData=_this2.imageData,render=Array.isArray(options.title)?options.title[1]:options.title;title.innerHTML=escapeHTMLEntities(isFunction(render)?render.call(_this2,image,imageData):"".concat(alt," (").concat(imageData.naturalWidth," × ").concat(imageData.naturalHeight,")"))},onLoad,onError;return addListener(element,"viewed",onViewed,{once:!0}),this.viewing={abort:function abort(){removeListener(element,"viewed",onViewed),image.complete?_this2.imageRendering?_this2.imageRendering.abort():_this2.imageInitializing&&_this2.imageInitializing.abort():(image.src="",removeListener(image,"load",onLoad),_this2.timeout&&clearTimeout(_this2.timeout))}},image.complete?this.load():(addListener(image,"load",onLoad=function onLoad(){removeListener(image,"error",onError),_this2.load()},{once:!0}),addListener(image,"error",onError=function onError(){removeListener(image,"load",onLoad),_this2.timeout&&(clearTimeout(_this2.timeout),_this2.timeout=!1),removeClass(image,CLASS_INVISIBLE),options.loading&&removeClass(_this2.canvas,CLASS_LOADING)},{once:!0}),this.timeout&&clearTimeout(this.timeout),this.timeout=setTimeout((function(){removeClass(image,CLASS_INVISIBLE),_this2.timeout=!1}),1e3)),this},prev:function prev(){var loop=arguments.length>0&&void 0!==arguments[0]&&arguments[0],index=this.index-1;return index<0&&(index=loop?this.length-1:0),this.view(index),this},next:function next(){var loop=arguments.length>0&&void 0!==arguments[0]&&arguments[0],maxIndex=this.length-1,index=this.index+1;return index>maxIndex&&(index=loop?0:maxIndex),this.view(index),this},move:function move(x){var y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:x,imageData=this.imageData;return this.moveTo(isUndefined(x)?x:imageData.x+Number(x),isUndefined(y)?y:imageData.y+Number(y)),this},moveTo:function moveTo(x){var _this3=this,y=arguments.length>1&&void 0!==arguments[1]?arguments[1]:x,_originalEvent=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,element=this.element,options=this.options,imageData=this.imageData;if(x=Number(x),y=Number(y),this.viewed&&!this.played&&options.movable){var oldX=imageData.x,oldY=imageData.y,changed=!1;if(isNumber(x)?changed=!0:x=oldX,isNumber(y)?changed=!0:y=oldY,changed){if(isFunction(options.move)&&addListener(element,"move",options.move,{once:!0}),!1===dispatchEvent(element,"move",{x:x,y:y,oldX:oldX,oldY:oldY,originalEvent:_originalEvent}))return this;imageData.x=x,imageData.y=y,imageData.left=x,imageData.top=y,this.moving=!0,this.renderImage((function(){_this3.moving=!1,isFunction(options.moved)&&addListener(element,"moved",options.moved,{once:!0}),dispatchEvent(element,"moved",{x:x,y:y,oldX:oldX,oldY:oldY,originalEvent:_originalEvent},{cancelable:!1})}))}}return this},rotate:function rotate(degree){return this.rotateTo((this.imageData.rotate||0)+Number(degree)),this},rotateTo:function rotateTo(degree){var _this4=this,element=this.element,options=this.options,imageData=this.imageData;if(isNumber(degree=Number(degree))&&this.viewed&&!this.played&&options.rotatable){var oldDegree=imageData.rotate;if(isFunction(options.rotate)&&addListener(element,"rotate",options.rotate,{once:!0}),!1===dispatchEvent(element,"rotate",{degree:degree,oldDegree:oldDegree}))return this;imageData.rotate=degree,this.rotating=!0,this.renderImage((function(){_this4.rotating=!1,isFunction(options.rotated)&&addListener(element,"rotated",options.rotated,{once:!0}),dispatchEvent(element,"rotated",{degree:degree,oldDegree:oldDegree},{cancelable:!1})}))}return this},scaleX:function scaleX(_scaleX){return this.scale(_scaleX,this.imageData.scaleY),this},scaleY:function scaleY(_scaleY){return this.scale(this.imageData.scaleX,_scaleY),this},scale:function scale(scaleX){var _this5=this,scaleY=arguments.length>1&&void 0!==arguments[1]?arguments[1]:scaleX,element=this.element,options=this.options,imageData=this.imageData;if(scaleX=Number(scaleX),scaleY=Number(scaleY),this.viewed&&!this.played&&options.scalable){var oldScaleX=imageData.scaleX,oldScaleY=imageData.scaleY,changed=!1;if(isNumber(scaleX)?changed=!0:scaleX=oldScaleX,isNumber(scaleY)?changed=!0:scaleY=oldScaleY,changed){if(isFunction(options.scale)&&addListener(element,"scale",options.scale,{once:!0}),!1===dispatchEvent(element,"scale",{scaleX:scaleX,scaleY:scaleY,oldScaleX:oldScaleX,oldScaleY:oldScaleY}))return this;imageData.scaleX=scaleX,imageData.scaleY=scaleY,this.scaling=!0,this.renderImage((function(){_this5.scaling=!1,isFunction(options.scaled)&&addListener(element,"scaled",options.scaled,{once:!0}),dispatchEvent(element,"scaled",{scaleX:scaleX,scaleY:scaleY,oldScaleX:oldScaleX,oldScaleY:oldScaleY},{cancelable:!1})}))}}return this},zoom:function zoom(ratio){var showTooltip=arguments.length>1&&void 0!==arguments[1]&&arguments[1],pivot=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,_originalEvent=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,imageData=this.imageData;return ratio=(ratio=Number(ratio))<0?1/(1-ratio):1+ratio,this.zoomTo(imageData.width*ratio/imageData.naturalWidth,showTooltip,pivot,_originalEvent),this},zoomTo:function zoomTo(ratio){var _this6=this,showTooltip=arguments.length>1&&void 0!==arguments[1]&&arguments[1],pivot=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,_originalEvent=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,_zoomable=arguments.length>4&&void 0!==arguments[4]&&arguments[4],element=this.element,options=this.options,pointers=this.pointers,imageData=this.imageData,x=imageData.x,y=imageData.y,width=imageData.width,height=imageData.height,naturalWidth=imageData.naturalWidth,naturalHeight=imageData.naturalHeight;if(isNumber(ratio=Math.max(0,ratio))&&this.viewed&&!this.played&&(_zoomable||options.zoomable)){if(!_zoomable){var minZoomRatio=Math.max(.01,options.minZoomRatio),maxZoomRatio=Math.min(100,options.maxZoomRatio);ratio=Math.min(Math.max(ratio,minZoomRatio),maxZoomRatio)}if(_originalEvent)switch(_originalEvent.type){case"wheel":options.zoomRatio>=.055&&ratio>.95&&ratio<1.05&&(ratio=1);break;case"pointermove":case"touchmove":case"mousemove":ratio>.99&&ratio<1.01&&(ratio=1)}var newWidth=naturalWidth*ratio,newHeight=naturalHeight*ratio,offsetWidth=newWidth-width,offsetHeight=newHeight-height,oldRatio=imageData.ratio;if(isFunction(options.zoom)&&addListener(element,"zoom",options.zoom,{once:!0}),!1===dispatchEvent(element,"zoom",{ratio:ratio,oldRatio:oldRatio,originalEvent:_originalEvent}))return this;if(this.zooming=!0,_originalEvent){var offset=getOffset(this.viewer),center=pointers&&Object.keys(pointers).length>0?getPointersCenter(pointers):{pageX:_originalEvent.pageX,pageY:_originalEvent.pageY};imageData.x-=offsetWidth*((center.pageX-offset.left-x)/width),imageData.y-=offsetHeight*((center.pageY-offset.top-y)/height)}else isPlainObject(pivot)&&isNumber(pivot.x)&&isNumber(pivot.y)?(imageData.x-=offsetWidth*((pivot.x-x)/width),imageData.y-=offsetHeight*((pivot.y-y)/height)):(imageData.x-=offsetWidth/2,imageData.y-=offsetHeight/2);imageData.left=imageData.x,imageData.top=imageData.y,imageData.width=newWidth,imageData.height=newHeight,imageData.oldRatio=oldRatio,imageData.ratio=ratio,this.renderImage((function(){_this6.zooming=!1,isFunction(options.zoomed)&&addListener(element,"zoomed",options.zoomed,{once:!0}),dispatchEvent(element,"zoomed",{ratio:ratio,oldRatio:oldRatio,originalEvent:_originalEvent},{cancelable:!1})})),showTooltip&&this.tooltip()}return this},play:function play(){var _this7=this,fullscreen=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.isShown||this.played)return this;var element=this.element,options=this.options;if(isFunction(options.play)&&addListener(element,"play",options.play,{once:!0}),!1===dispatchEvent(element,"play"))return this;var player=this.player,onLoad=this.loadImage.bind(this),list=[],total=0,index=0;if(this.played=!0,this.onLoadWhenPlay=onLoad,fullscreen&&this.requestFullscreen(fullscreen),addClass(player,CLASS_SHOW),forEach(this.items,(function(item,i){var img=item.querySelector("img"),image=document.createElement("img");image.src=getData(img,"originalUrl"),image.alt=img.getAttribute("alt"),image.referrerPolicy=img.referrerPolicy,total+=1,addClass(image,CLASS_FADE),toggleClass(image,CLASS_TRANSITION,options.transition),hasClass(item,CLASS_ACTIVE)&&(addClass(image,CLASS_IN),index=i),list.push(image),addListener(image,"load",onLoad,{once:!0}),player.appendChild(image)})),isNumber(options.interval)&&options.interval>0){var prev=function prev(){clearTimeout(_this7.playing.timeout),removeClass(list[index],CLASS_IN),addClass(list[index=(index-=1)>=0?index:total-1],CLASS_IN),_this7.playing.timeout=setTimeout(prev,options.interval)},next=function next(){clearTimeout(_this7.playing.timeout),removeClass(list[index],CLASS_IN),addClass(list[index=(index+=1)<total?index:0],CLASS_IN),_this7.playing.timeout=setTimeout(next,options.interval)};total>1&&(this.playing={prev:prev,next:next,timeout:setTimeout(next,options.interval)})}return this},stop:function stop(){var _this8=this;if(!this.played)return this;var element=this.element,options=this.options;if(isFunction(options.stop)&&addListener(element,"stop",options.stop,{once:!0}),!1===dispatchEvent(element,"stop"))return this;var player=this.player;return clearTimeout(this.playing.timeout),this.playing=!1,this.played=!1,forEach(player.getElementsByTagName("img"),(function(image){removeListener(image,"load",_this8.onLoadWhenPlay)})),removeClass(player,CLASS_SHOW),player.innerHTML="",this.exitFullscreen(),this},full:function full(){var _this9=this,options=this.options,viewer=this.viewer,image=this.image,list=this.list;return!this.isShown||this.played||this.fulled||!options.inline?this:(this.fulled=!0,this.open(),addClass(this.button,CLASS_FULLSCREEN_EXIT),options.transition&&(removeClass(list,CLASS_TRANSITION),this.viewed&&removeClass(image,CLASS_TRANSITION)),addClass(viewer,CLASS_FIXED),viewer.setAttribute("role","dialog"),viewer.setAttribute("aria-labelledby",this.title.id),viewer.setAttribute("aria-modal",!0),viewer.removeAttribute("style"),setStyle(viewer,{zIndex:options.zIndex}),options.focus&&this.enforceFocus(),this.initContainer(),this.viewerData=assign({},this.containerData),this.renderList(),this.viewed&&this.initImage((function(){_this9.renderImage((function(){options.transition&&setTimeout((function(){addClass(image,CLASS_TRANSITION),addClass(list,CLASS_TRANSITION)}),0)}))})),this)},exit:function exit(){var _this10=this,options=this.options,viewer=this.viewer,image=this.image,list=this.list;return this.isShown&&!this.played&&this.fulled&&options.inline?(this.fulled=!1,this.close(),removeClass(this.button,CLASS_FULLSCREEN_EXIT),options.transition&&(removeClass(list,CLASS_TRANSITION),this.viewed&&removeClass(image,CLASS_TRANSITION)),options.focus&&this.clearEnforceFocus(),viewer.removeAttribute("role"),viewer.removeAttribute("aria-labelledby"),viewer.removeAttribute("aria-modal"),removeClass(viewer,CLASS_FIXED),setStyle(viewer,{zIndex:options.zIndexInline}),this.viewerData=assign({},this.parentData),this.renderViewer(),this.renderList(),this.viewed&&this.initImage((function(){_this10.renderImage((function(){options.transition&&setTimeout((function(){addClass(image,CLASS_TRANSITION),addClass(list,CLASS_TRANSITION)}),0)}))})),this):this},tooltip:function tooltip(){var _this11=this,options=this.options,tooltipBox=this.tooltipBox,imageData=this.imageData;return this.viewed&&!this.played&&options.tooltip?(tooltipBox.textContent="".concat(Math.round(100*imageData.ratio),"%"),this.tooltipping?clearTimeout(this.tooltipping):options.transition?(this.fading&&dispatchEvent(tooltipBox,"transitionend"),addClass(tooltipBox,CLASS_SHOW),addClass(tooltipBox,CLASS_FADE),addClass(tooltipBox,CLASS_TRANSITION),tooltipBox.removeAttribute("aria-hidden"),tooltipBox.initialOffsetWidth=tooltipBox.offsetWidth,addClass(tooltipBox,CLASS_IN)):(addClass(tooltipBox,CLASS_SHOW),tooltipBox.removeAttribute("aria-hidden")),this.tooltipping=setTimeout((function(){options.transition?(addListener(tooltipBox,"transitionend",(function(){removeClass(tooltipBox,CLASS_SHOW),removeClass(tooltipBox,CLASS_FADE),removeClass(tooltipBox,CLASS_TRANSITION),tooltipBox.setAttribute("aria-hidden",!0),_this11.fading=!1}),{once:!0}),removeClass(tooltipBox,CLASS_IN),_this11.fading=!0):(removeClass(tooltipBox,CLASS_SHOW),tooltipBox.setAttribute("aria-hidden",!0)),_this11.tooltipping=!1}),1e3),this):this},toggle:function toggle(){var _originalEvent=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return 1===this.imageData.ratio?this.zoomTo(this.imageData.oldRatio,!0,null,_originalEvent):this.zoomTo(1,!0,null,_originalEvent),this},reset:function reset(){return this.viewed&&!this.played&&(this.imageData=assign({},this.initialImageData),this.renderImage()),this},update:function update(){var _this12=this,element=this.element,options=this.options,isImg=this.isImg;if(isImg&&!element.parentNode)return this.destroy();var images=[];if(forEach(isImg?[element]:element.querySelectorAll("img"),(function(image){isFunction(options.filter)?options.filter.call(_this12,image)&&images.push(image):_this12.getImageURL(image)&&images.push(image)})),!images.length)return this;if(this.images=images,this.length=images.length,this.ready){var changedIndexes=[];if(forEach(this.items,(function(item,i){var img=item.querySelector("img"),image=images[i];image&&img&&image.src===img.src&&image.alt===img.alt||changedIndexes.push(i)})),setStyle(this.list,{width:"auto"}),this.initList(),this.isShown)if(this.length){if(this.viewed){var changedIndex=changedIndexes.indexOf(this.index);if(changedIndex>=0)this.viewed=!1,this.view(Math.max(Math.min(this.index-changedIndex,this.length-1),0));else{var activeItem=this.items[this.index];addClass(activeItem,CLASS_ACTIVE),activeItem.setAttribute("aria-selected",!0)}}}else this.image=null,this.viewed=!1,this.index=0,this.imageData={},this.canvas.innerHTML="",this.title.innerHTML=""}else this.build();return this},destroy:function destroy(){var element=this.element,options=this.options;return element.viewer?(this.destroyed=!0,this.ready?(this.played&&this.stop(),options.inline?(this.fulled&&this.exit(),this.unbind()):this.isShown?(this.viewing&&(this.imageRendering?this.imageRendering.abort():this.imageInitializing&&this.imageInitializing.abort()),this.hiding&&this.transitioning.abort(),this.hidden()):this.showing&&(this.transitioning.abort(),this.hidden()),this.ready=!1,this.viewer.parentNode.removeChild(this.viewer)):options.inline&&(this.delaying?this.delaying.abort():this.initializing&&this.initializing.abort()),options.inline||removeListener(element,"click",this.onStart),element.viewer=void 0,this):this}},others={getImageURL:function getImageURL(image){var url=this.options.url;return url=isString(url)?image.getAttribute(url):isFunction(url)?url.call(this,image):""},enforceFocus:function enforceFocus(){var _this=this;this.clearEnforceFocus(),addListener(document,"focusin",this.onFocusin=function(event){var viewer=_this.viewer,target=event.target;if(target!==document&&target!==viewer&&!viewer.contains(target)){for(;target;){if(null!==target.getAttribute("tabindex")||"true"===target.getAttribute("aria-modal"))return;target=target.parentElement}viewer.focus()}})},clearEnforceFocus:function clearEnforceFocus(){this.onFocusin&&(removeListener(document,"focusin",this.onFocusin),this.onFocusin=null)},open:function open(){var body=this.body;addClass(body,CLASS_OPEN),this.scrollbarWidth>0&&(body.style.paddingRight="".concat(this.scrollbarWidth+(parseFloat(this.initialBodyComputedPaddingRight)||0),"px"))},close:function close(){var body=this.body;removeClass(body,CLASS_OPEN),this.scrollbarWidth>0&&(body.style.paddingRight=this.initialBodyPaddingRight)},shown:function shown(){var element=this.element,options=this.options,viewer=this.viewer;this.fulled=!0,this.isShown=!0,this.render(),this.bind(),this.showing=!1,options.focus&&(viewer.focus(),this.enforceFocus()),isFunction(options.shown)&&addListener(element,"shown",options.shown,{once:!0}),!1!==dispatchEvent(element,"shown")&&this.ready&&this.isShown&&!this.hiding&&this.view(this.index)},hidden:function hidden(){var element=this.element,options=this.options,viewer=this.viewer;options.fucus&&this.clearEnforceFocus(),this.fulled=!1,this.viewed=!1,this.isShown=!1,this.close(),this.unbind(),addClass(viewer,CLASS_HIDE),viewer.removeAttribute("role"),viewer.removeAttribute("aria-labelledby"),viewer.removeAttribute("aria-modal"),viewer.setAttribute("aria-hidden",!0),this.resetList(),this.resetImage(),this.hiding=!1,this.destroyed||(isFunction(options.hidden)&&addListener(element,"hidden",options.hidden,{once:!0}),dispatchEvent(element,"hidden",null,{cancelable:!1}))},requestFullscreen:function requestFullscreen(options){var document=this.element.ownerDocument;if(this.fulled&&!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)){var documentElement=document.documentElement;documentElement.requestFullscreen?isPlainObject(options)?documentElement.requestFullscreen(options):documentElement.requestFullscreen():documentElement.webkitRequestFullscreen?documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):documentElement.mozRequestFullScreen?documentElement.mozRequestFullScreen():documentElement.msRequestFullscreen&&documentElement.msRequestFullscreen()}},exitFullscreen:function exitFullscreen(){var document=this.element.ownerDocument;this.fulled&&(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)&&(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen())},change:function change(event){var options=this.options,pointers=this.pointers,pointer=pointers[Object.keys(pointers)[0]];if(pointer){var offsetX=pointer.endX-pointer.startX,offsetY=pointer.endY-pointer.startY;switch(this.action){case"move":this.move(offsetX,offsetY,event);break;case"zoom":this.zoom(getMaxZoomRatio(pointers),!1,null,event);break;case"switch":this.action="switched";var absoluteOffsetX=Math.abs(offsetX);absoluteOffsetX>1&&absoluteOffsetX>Math.abs(offsetY)&&(this.pointers={},offsetX>1?this.prev(options.loop):offsetX<-1&&this.next(options.loop))}forEach(pointers,(function(p){p.startX=p.endX,p.startY=p.endY}))}},isSwitchable:function isSwitchable(){var imageData=this.imageData,viewerData=this.viewerData;return this.length>1&&imageData.x>=0&&imageData.y>=0&&imageData.width<=viewerData.width&&imageData.height<=viewerData.height}},AnotherViewer=WINDOW.Viewer,getUniqueID=(id=-1,function(){return id+=1}),id,Viewer=function(){function Viewer(element){var options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(_classCallCheck(this,Viewer),!element||1!==element.nodeType)throw new Error("The first argument is required and must be an element.");this.element=element,this.options=assign({},DEFAULTS,isPlainObject(options)&&options),this.action=!1,this.fading=!1,this.fulled=!1,this.hiding=!1,this.imageClicked=!1,this.imageData={},this.index=this.options.initialViewIndex,this.isImg=!1,this.isShown=!1,this.length=0,this.moving=!1,this.played=!1,this.playing=!1,this.pointers={},this.ready=!1,this.rotating=!1,this.scaling=!1,this.showing=!1,this.timeout=!1,this.tooltipping=!1,this.viewed=!1,this.viewing=!1,this.wheeling=!1,this.zooming=!1,this.id=getUniqueID(),this.init()}return _createClass(Viewer,[{key:"init",value:function init(){var _this=this,element=this.element,options=this.options;if(!element.viewer){element.viewer=this,options.focus&&!options.keyboard&&(options.focus=!1);var isImg="img"===element.localName,images=[];if(forEach(isImg?[element]:element.querySelectorAll("img"),(function(image){isFunction(options.filter)?options.filter.call(_this,image)&&images.push(image):_this.getImageURL(image)&&images.push(image)})),this.isImg=isImg,this.length=images.length,this.images=images,this.initBody(),isUndefined(document.createElement("viewer").style.transition)&&(options.transition=!1),options.inline){var count=0,progress=function progress(){var timeout;(count+=1)===_this.length&&(_this.initializing=!1,_this.delaying={abort:function abort(){clearTimeout(timeout)}},timeout=setTimeout((function(){_this.delaying=!1,_this.build()}),0))};this.initializing={abort:function abort(){forEach(images,(function(image){image.complete||(removeListener(image,"load",progress),removeListener(image,"error",progress))}))}},forEach(images,(function(image){var onLoad,onError;image.complete?progress():(addListener(image,"load",onLoad=function onLoad(){removeListener(image,"error",onError),progress()},{once:!0}),addListener(image,"error",onError=function onError(){removeListener(image,"load",onLoad),progress()},{once:!0}))}))}else addListener(element,"click",this.onStart=function(_ref){var target=_ref.target;"img"!==target.localName||isFunction(options.filter)&&!options.filter.call(_this,target)||_this.view(_this.images.indexOf(target))})}}},{key:"build",value:function build(){if(!this.ready){var element=this.element,options=this.options,parent=element.parentNode,template=document.createElement("div");template.innerHTML=TEMPLATE;var viewer=template.querySelector(".".concat("viewer","-container")),title=viewer.querySelector(".".concat("viewer","-title")),toolbar=viewer.querySelector(".".concat("viewer","-toolbar")),navbar=viewer.querySelector(".".concat("viewer","-navbar")),button=viewer.querySelector(".".concat("viewer","-button")),canvas=viewer.querySelector(".".concat("viewer","-canvas"));if(this.parent=parent,this.viewer=viewer,this.title=title,this.toolbar=toolbar,this.navbar=navbar,this.button=button,this.canvas=canvas,this.footer=viewer.querySelector(".".concat("viewer","-footer")),this.tooltipBox=viewer.querySelector(".".concat("viewer","-tooltip")),this.player=viewer.querySelector(".".concat("viewer","-player")),this.list=viewer.querySelector(".".concat("viewer","-list")),viewer.id="".concat("viewer").concat(this.id),title.id="".concat("viewer","Title").concat(this.id),addClass(title,options.title?getResponsiveClass(Array.isArray(options.title)?options.title[0]:options.title):CLASS_HIDE),addClass(navbar,options.navbar?getResponsiveClass(options.navbar):CLASS_HIDE),toggleClass(button,CLASS_HIDE,!options.button),options.keyboard&&button.setAttribute("tabindex",0),options.backdrop&&(addClass(viewer,"".concat("viewer","-backdrop")),options.inline||"static"===options.backdrop||setData(canvas,DATA_ACTION,"hide")),isString(options.className)&&options.className&&options.className.split(REGEXP_SPACES).forEach((function(className){addClass(viewer,className)})),options.toolbar){var list=document.createElement("ul"),custom=isPlainObject(options.toolbar),zoomButtons=BUTTONS.slice(0,3),rotateButtons=BUTTONS.slice(7,9),scaleButtons=BUTTONS.slice(9);custom||addClass(toolbar,getResponsiveClass(options.toolbar)),forEach(custom?options.toolbar:BUTTONS,(function(value,index){var deep=custom&&isPlainObject(value),name=custom?hyphenate(index):value,show=deep&&!isUndefined(value.show)?value.show:value;if(show&&(options.zoomable||-1===zoomButtons.indexOf(name))&&(options.rotatable||-1===rotateButtons.indexOf(name))&&(options.scalable||-1===scaleButtons.indexOf(name))){var size=deep&&!isUndefined(value.size)?value.size:value,click=deep&&!isUndefined(value.click)?value.click:value,item=document.createElement("li");options.keyboard&&item.setAttribute("tabindex",0),item.setAttribute("role","button"),addClass(item,"".concat("viewer","-").concat(name)),isFunction(click)||setData(item,DATA_ACTION,name),isNumber(show)&&addClass(item,getResponsiveClass(show)),-1!==["small","large"].indexOf(size)?addClass(item,"".concat("viewer","-").concat(size)):"play"===name&&addClass(item,"".concat("viewer","-large")),isFunction(click)&&addListener(item,"click",click),list.appendChild(item)}})),toolbar.appendChild(list)}else addClass(toolbar,CLASS_HIDE);if(!options.rotatable){var rotates=toolbar.querySelectorAll('li[class*="rotate"]');addClass(rotates,CLASS_INVISIBLE),forEach(rotates,(function(rotate){toolbar.appendChild(rotate)}))}if(options.inline)addClass(button,CLASS_FULLSCREEN),setStyle(viewer,{zIndex:options.zIndexInline}),"static"===window.getComputedStyle(parent).position&&setStyle(parent,{position:"relative"}),parent.insertBefore(viewer,element.nextSibling);else{addClass(button,CLASS_CLOSE),addClass(viewer,CLASS_FIXED),addClass(viewer,CLASS_FADE),addClass(viewer,CLASS_HIDE),setStyle(viewer,{zIndex:options.zIndex});var container=options.container;isString(container)&&(container=element.ownerDocument.querySelector(container)),container||(container=this.body),container.appendChild(viewer)}options.inline&&(this.render(),this.bind(),this.isShown=!0),this.ready=!0,isFunction(options.ready)&&addListener(element,"ready",options.ready,{once:!0}),!1!==dispatchEvent(element,"ready")?this.ready&&options.inline&&this.view(this.index):this.ready=!1}}}],[{key:"noConflict",value:function noConflict(){return window.Viewer=AnotherViewer,Viewer}},{key:"setDefaults",value:function setDefaults(options){assign(DEFAULTS,isPlainObject(options)&&options)}}]),Viewer}();return assign(Viewer.prototype,render,events,handlers,methods,others),Viewer}));