(function(t, e) { "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalthis ? globalthis : t || self, t.viewer = e()) } )(this, function() { "use strict"; function t(e) { return t = "function" == typeof symbol && "symbol" == typeof symbol.iterator ? function(t) { return typeof t } : function(t) { return t && "function" == typeof symbol && t.constructor === symbol && t !== symbol.prototype ? "symbol" : typeof t } , t(e) } function e(t, e) { if (!(t instanceof e)) throw new typeerror("cannot call a class as a function") } function i(t, e) { for (var i = 0; i < e.length; i++) { var n = e[i]; n.enumerable = n.enumerable || !1, n.configurable = !0, "value"in n && (n.writable = !0), object.defineproperty(t, n.key, n) } } function n(t, e, n) { return e && i(t.prototype, e), n && i(t, n), t } function s(t, e, i) { return e in t ? object.defineproperty(t, e, { value: i, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = i, t } function o(t, e) { var i = object.keys(t); if (object.getownpropertysymbols) { var n = object.getownpropertysymbols(t); e && (n = n.filter(function(e) { return object.getownpropertydescriptor(t, e).enumerable })), i.push.apply(i, n) } return i } function a(t) { for (var e = 1; e < arguments.length; e++) { var i = null != arguments[e] ? arguments[e] : {}; e % 2 ? o(object(i), !0).foreach(function(e) { s(t, e, i[e]) }) : object.getownpropertydescriptors ? object.defineproperties(t, object.getownpropertydescriptors(i)) : o(object(i)).foreach(function(e) { object.defineproperty(t, e, object.getownpropertydescriptor(i, e)) }) } return t } function r(t) { return "string" == typeof t } function h(t) { return "number" == typeof t && !pt(t) } function l(t) { return void 0 === t } function c(e) { return "object" === t(e) && null !== e } function u(t) { if (!c(t)) return !1; try { var e = t.constructor , i = e.prototype; return e && i && qt.call(i, "isprototypeof") } catch (t) { return !1 } } function d(t) { return "function" == typeof t } function m(t, e) { if (t && d(e)) if (array.isarray(t) || h(t.length)) { var i, n = t.length; for (i = 0; i < n && !1 !== e.call(t, t[i], i, t); i += 1) ; } else c(t) && object.keys(t).foreach(function(i) { e.call(t, t[i], i, t) }); return t } function f(t, e) { var i = t.style; m(e, function(t, e) { yt.test(e) && h(t) && (t += "px"), i[e] = t }) } function g(t) { return r(t) ? t.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g, "&").replace(/"/g, """).replace(/'/g, "'").replace(//g, ">") : t } function v(t, e) { return !(!t || !e) && (t.classlist ? t.classlist.contains(e) : t.classname.indexof(e) > -1) } function p(t, e) { if (t && e) if (h(t.length)) m(t, function(t) { p(t, e) }); else if (t.classlist) t.classlist.add(e); else { var i = t.classname.trim(); i ? i.indexof(e) < 0 && (t.classname = "".concat(i, " ").concat(e)) : t.classname = e } } function w(t, e) { t && e && (h(t.length) ? m(t, function(t) { w(t, e) }) : t.classlist ? t.classlist.remove(e) : t.classname.indexof(e) >= 0 && (t.classname = t.classname.replace(e, ""))) } function b(t, e, i) { e && (h(t.length) ? m(t, function(t) { b(t, e, i) }) : i ? p(t, e) : w(t, e)) } function y(t) { return t.replace(xt, "$1-$2").tolowercase() } function x(t, e) { return c(t[e]) ? t[e] : t.dataset ? t.dataset[e] : t.getattribute("data-".concat(y(e))) } function k(t, e, i) { c(i) ? t[e] = i : t.dataset ? t.dataset[e] = i : t.setattribute("data-".concat(y(e)), i) } function z(t, e, i) { var n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {} , s = i; e.trim().split(nt).foreach(function(e) { if (!ft) { var o = t.listeners; o && o[e] && o[e][i] && (s = o[e][i], delete o[e][i], 0 === object.keys(o[e]).length && delete o[e], 0 === object.keys(o).length && delete t.listeners) } t.removeeventlistener(e, s, n) }) } function d(t, e, i) { var n = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : {} , s = i; e.trim().split(nt).foreach(function(e) { if (n.once && !ft) { var o = t.listeners , a = void 0 === o ? {} : o; s = function() { delete a[e][i], t.removeeventlistener(e, s, n); for (var o = arguments.length, r = new array(o), h = 0; h < o; h++) r[h] = arguments[h]; i.apply(t, r) } , a[e] || (a[e] = {}), a[e][i] && t.removeeventlistener(e, a[e][i], n), a[e][i] = s, t.listeners = a } t.addeventlistener(e, s, n) }) } function t(t, e, i, n) { var s; return d(event) && d(customevent) ? s = new customevent(e,a({ bubbles: !0, cancelable: !0, detail: i }, n)) : (s = document.createevent("customevent"), s.initcustomevent(e, !0, !0, i)), t.dispatchevent(s) } function i(t) { var e = t.getboundingclientrect(); return { left: e.left + (window.pagexoffset - document.documentelement.clientleft), top: e.top + (window.pageyoffset - document.documentelement.clienttop) } } function e(t) { var e = t.rotate , i = t.scalex , n = t.scaley , s = t.translatex , o = t.translatey , a = []; h(s) && 0 !== s && a.push("translatex(".concat(s, "px)")), h(o) && 0 !== o && a.push("translatey(".concat(o, "px)")), h(e) && 0 !== e && a.push("rotate(".concat(e, "deg)")), h(i) && 1 !== i && a.push("scalex(".concat(i, ")")), h(n) && 1 !== n && a.push("scaley(".concat(n, ")")); var r = a.length ? a.join(" ") : "none"; return { webkittransform: r, mstransform: r, transform: r } } function o(t) { return r(t) ? decodeuricomponent(t.replace(/^.*\//, "").replace(/[?&#].*$/, "")) : "" } function c(t, e, i) { var n = document.createelement("img"); if (t.naturalwidth && !wt) return i(t.naturalwidth, t.naturalheight), n; var s = document.body || document.documentelement; return n.onload = function() { i(n.width, n.height), wt || s.removechild(n) } , m(e.inheritedattributes, function(e) { var i = t.getattribute(e); null !== i && n.setattribute(e, i) }), n.src = t.src, wt || (n.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;", s.appendchild(n)), n } function s(t) { switch (t) { case 2: return tt; case 3: return j; case 4: return g; default: return "" } } function l(t) { var e = a({}, t) , i = []; return m(t, function(t, n) { delete e[n], m(e, function(e) { var n = math.abs(t.startx - e.startx) , s = math.abs(t.starty - e.starty) , o = math.abs(t.endx - e.endx) , a = math.abs(t.endy - e.endy) , r = math.sqrt(n * n + s * s) , h = math.sqrt(o * o + a * a) , l = (h - r) / r; i.push(l) }) }), i.sort(function(t, e) { return math.abs(t) < math.abs(e) }), i[0] } function r(t, e) { var i = t.pagex , n = t.pagey , s = { endx: i, endy: n }; return e ? s : a({ timestamp: date.now(), startx: i, starty: n }, s) } function a(t) { var e = 0 , i = 0 , n = 0; return m(t, function(t) { var s = t.startx , o = t.starty; e += s, i += o, n += 1 }), e /= n, i /= n, { pagex: e, pagey: i } } var n = { 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"], initialviewindex: 0, inline: !1, interval: 5e3, keyboard: !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, zoom: null, zoomed: null, play: null, stop: null } , m = '
' , p = "undefined" != typeof window && void 0 !== window.document , q = p ? window : {} , j = !(!p || !q.document.documentelement) && "ontouchstart"in q.document.documentelement , y = !!p && "pointerevent"in q , x = "viewer" , f = "move" , w = "switch" , h = "zoom" , b = "".concat(x, "-active") , v = "".concat(x, "-close") , u = "".concat(x, "-fade") , k = "".concat(x, "-fixed") , z = "".concat(x, "-fullscreen") , _ = "".concat(x, "-fullscreen-exit") , q = "".concat(x, "-hide") , g = "".concat(x, "-hide-md-down") , j = "".concat(x, "-hide-sm-down") , tt = "".concat(x, "-hide-xs-down") , et = "".concat(x, "-in") , it = "".concat(x, "-invisible") , nt = "".concat(x, "-loading") , st = "".concat(x, "-move") , ot = "".concat(x, "-open") , at = "".concat(x, "-show") , rt = "".concat(x, "-transition") , ht = "click" , lt = "dblclick" , ct = "dragstart" , ut = "hidden" , dt = "hide" , mt = "keydown" , ft = "load" , gt = j ? "touchstart" : "mousedown" , vt = j ? "touchmove" : "mousemove" , pt = j ? "touchend touchcancel" : "mouseup" , wt = y ? "pointerdown" : gt , bt = y ? "pointermove" : vt , yt = y ? "pointerup pointercancel" : pt , xt = "ready" , kt = "resize" , zt = "show" , dt = "shown" , tt = "transitionend" , it = "view" , et = "viewed" , ot = "wheel" , ct = "zoom" , st = "zoomed" , lt = "play" , rt = "stop" , at = "".concat(x, "action") , nt = /\s\s*/ , mt = ["zoom-in", "zoom-out", "one-to-one", "reset", "prev", "play", "next", "rotate-left", "rotate-right", "flip-horizontal", "flip-vertical"] , pt = number.isnan || q.isnan , qt = object.prototype.hasownproperty , jt = object.assign || function(t) { for (var e = arguments.length, i = new array(e > 1 ? e - 1 : 0), n = 1; n < e; n++) i[n - 1] = arguments[n]; return c(t) && i.length > 0 && i.foreach(function(e) { c(e) && object.keys(e).foreach(function(i) { t[i] = e[i] }) }), t } , yt = /^(?:width|height|left|top|marginleft|margintop)$/ , xt = /([a-z\d])([a-z])/g , ft = function() { var t = !1; if (p) { var e = !1 , i = function() {} , n = object.defineproperty({}, "once", { get: function() { return t = !0, e }, set: function(t) { e = t } }); q.addeventlistener("test", i, n), q.removeeventlistener("test", i, n) } return t }() , wt = q.navigator && /(macintosh|iphone|ipod|ipad).*applewebkit/i.test(q.navigator.useragent) , ht = { render: function() { this.initcontainer(), this.initviewer(), this.initlist(), this.renderviewer() }, initbody: function() { var t = this.element.ownerdocument , e = t.body || t.documentelement; this.body = e, this.scrollbarwidth = window.innerwidth - t.documentelement.clientwidth, this.initialbodypaddingright = e.style.paddingright, this.initialbodycomputedpaddingright = window.getcomputedstyle(e).paddingright }, initcontainer: function() { this.containerdata = { width: window.innerwidth, height: window.innerheight } }, initviewer: function() { var t, e = this.options, i = this.parent; e.inline && (t = { width: math.max(i.offsetwidth, e.minwidth), height: math.max(i.offsetheight, e.minheight) }, this.parentdata = t), !this.fulled && t || (t = this.containerdata), this.viewerdata = jt({}, t) }, renderviewer: function() { this.options.inline && !this.fulled && f(this.viewer, this.viewerdata) }, initlist: function() { var t = this , e = this.element , i = this.options , n = this.list , s = []; n.innerhtml = "", m(this.images, function(e, o) { var a = e.src , r = e.alt || o(a) , h = t.getimageurl(e); if (a || h) { var l = document.createelement("li") , c = document.createelement("img"); m(i.inheritedattributes, function(t) { var i = e.getattribute(t); null !== i && c.setattribute(t, i) }), c.src = a || h, c.alt = r, c.setattribute("data-index", o), c.setattribute("data-original-url", h || a), c.setattribute("data-viewer-action", "view"), c.setattribute("role", "button"), l.appendchild(c), n.appendchild(l), s.push(l) } }), this.items = s, m(s, function(e) { var n = e.firstelementchild; k(n, "filled", !0), i.loading && p(e, nt), d(n, ft, function(n) { i.loading && w(e, nt), t.loadimage(n) }, { once: !0 }) }), i.transition && d(e, et, function() { p(n, rt) }, { once: !0 }) }, renderlist: function(t) { var e = t || this.index , i = this.items[e].offsetwidth || 30 , n = i + 1; f(this.list, jt({ width: n * this.length }, e({ translatex: (this.viewerdata.width - i) / 2 - n * e }))) }, resetlist: function() { var t = this.list; t.innerhtml = "", w(t, rt), f(t, e({ translatex: 0 })) }, initimage: function(t) { var e, i = this, n = this.options, s = this.image, o = this.viewerdata, a = this.footer.offsetheight, r = o.width, h = math.max(o.height - a, a), l = this.imagedata || {}; this.imageinitializing = { abort: function() { e.onload = null } }, e = c(s, n, function(e, s) { var o = e / s , a = r , c = h; i.imageinitializing = !1, h * o > r ? c = r / o : a = h * o, a = math.min(.9 * a, e), c = math.min(.9 * c, s); var u = { naturalwidth: e, naturalheight: s, aspectratio: o, ratio: a / e, width: a, height: c, left: (r - a) / 2, top: (h - c) / 2 } , d = jt({}, u); n.rotatable && (u.rotate = l.rotate || 0, d.rotate = 0), n.scalable && (u.scalex = l.scalex || 1, u.scaley = l.scaley || 1, d.scalex = 1, d.scaley = 1), i.imagedata = u, i.initialimagedata = d, t && t() }) }, renderimage: function(t) { var e = this , i = this.image , n = this.imagedata; if (f(i, jt({ width: n.width, height: n.height, marginleft: n.left, margintop: n.top }, e(n))), t) if ((this.viewing || this.zooming) && this.options.transition) { var s = function() { e.imagerendering = !1, t() }; this.imagerendering = { abort: function() { z(i, tt, s) } }, d(i, tt, s, { once: !0 }) } else t() }, resetimage: function() { if (this.viewing || this.viewed) { var t = this.image; this.viewing && this.viewing.abort(), t.parentnode.removechild(t), this.image = null } } } , bt = { bind: function() { var t = this.options , e = this.viewer , i = this.canvas , n = this.element.ownerdocument; d(e, ht, this.onclick = this.click.bind(this)), d(e, ct, this.ondragstart = this.dragstart.bind(this)), d(i, wt, this.onpointerdown = this.pointerdown.bind(this)), d(n, bt, this.onpointermove = this.pointermove.bind(this)), d(n, yt, this.onpointerup = this.pointerup.bind(this)), d(n, mt, this.onkeydown = this.keydown.bind(this)), d(window, kt, this.onresize = this.resize.bind(this)), t.zoomable && t.zoomonwheel && d(e, ot, this.onwheel = this.wheel.bind(this), { passive: !1, capture: !0 }), t.toggleondblclick && d(i, lt, this.ondblclick = this.dblclick.bind(this)) }, unbind: function() { var t = this.options , e = this.viewer , i = this.canvas , n = this.element.ownerdocument; z(e, ht, this.onclick), z(e, ct, this.ondragstart), z(i, wt, this.onpointerdown), z(n, bt, this.onpointermove), z(n, yt, this.onpointerup), z(n, mt, this.onkeydown), z(window, kt, this.onresize), t.zoomable && t.zoomonwheel && z(e, ot, this.onwheel, { passive: !1, capture: !0 }), t.toggleondblclick && z(i, lt, this.ondblclick) } } , vt = { click: function(t) { var e = t.target , i = this.options , n = this.imagedata , s = x(e, at); switch (j && t.istrusted && e === this.canvas && cleartimeout(this.clickcanvastimeout), s) { case "mix": this.played ? this.stop() : i.inline ? this.fulled ? this.exit() : this.full() : this.hide(); break; case "hide": this.hide(); break; case "view": this.view(x(e, "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(i.loop); break; case "play": this.play(i.fullscreen); break; case "next": this.next(i.loop); break; case "rotate-left": this.rotate(-90); break; case "rotate-right": this.rotate(90); break; case "flip-horizontal": this.scalex(-n.scalex || -1); break; case "flip-vertical": this.scaley(-n.scaley || -1); break; default: this.played && this.stop() } }, dblclick: function(t) { t.preventdefault(), this.viewed && t.target === this.image && (j && t.istrusted && cleartimeout(this.doubleclickimagetimeout), this.toggle()) }, load: function() { var t = this; this.timeout && (cleartimeout(this.timeout), this.timeout = !1); var e = this.element , i = this.options , n = this.image , s = this.index , o = this.viewerdata; w(n, it), i.loading && w(this.canvas, nt), n.style.csstext = "height:0;" + "margin-left:".concat(o.width / 2, "px;") + "margin-top:".concat(o.height / 2, "px;") + "max-width:none!important;position:absolute;width:0;", this.initimage(function() { b(n, st, i.movable), b(n, rt, i.transition), t.renderimage(function() { t.viewed = !0, t.viewing = !1, d(i.viewed) && d(e, et, i.viewed, { once: !0 }), t(e, et, { originalimage: t.images[s], index: s, image: n }, { cancelable: !1 }) }) }) }, loadimage: function(t) { var e = t.target , i = e.parentnode , n = i.offsetwidth || 30 , s = i.offsetheight || 50 , o = !!x(e, "filled"); c(e, this.options, function(t, i) { var a = t / i , r = n , h = s; s * a > n ? o ? r = s * a : h = n / a : o ? h = n / a : r = s * a, f(e, jt({ width: r, height: h }, e({ translatex: (n - r) / 2, translatey: (s - h) / 2 }))) }) }, keydown: function(t) { var e = this.options; if (this.fulled && e.keyboard) switch (t.keycode || t.which || t.charcode) { case 27: this.played ? this.stop() : e.inline ? this.fulled && this.exit() : this.hide(); break; case 32: this.played && this.stop(); break; case 37: this.prev(e.loop); break; case 38: t.preventdefault(), this.zoom(e.zoomratio, !0); break; case 39: this.next(e.loop); break; case 40: t.preventdefault(), this.zoom(-e.zoomratio, !0); break; case 48: case 49: t.ctrlkey && (t.preventdefault(), this.toggle()) } }, dragstart: function(t) { "img" === t.target.tagname.tolowercase() && t.preventdefault() }, pointerdown: function(t) { var e = this.options , i = this.pointers , n = t.buttons , s = t.button; if (!(!this.viewed || this.showing || this.viewing || this.hiding || ("mousedown" === t.type || "pointerdown" === t.type && "mouse" === t.pointertype) && (h(n) && 1 !== n || h(s) && 0 !== s || t.ctrlkey))) { t.preventdefault(), t.changedtouches ? m(t.changedtouches, function(t) { i[t.identifier] = r(t) }) : i[t.pointerid || 0] = r(t); var o = !!e.movable && f; e.zoomontouch && e.zoomable && object.keys(i).length > 1 ? o = h : e.slideontouch && ("touch" === t.pointertype || "touchstart" === t.type) && this.isswitchable() && (o = w), !e.transition || o !== f && o !== h || w(this.image, rt), this.action = o } }, pointermove: function(t) { var e = this.pointers , i = this.action; this.viewed && i && (t.preventdefault(), t.changedtouches ? m(t.changedtouches, function(t) { jt(e[t.identifier] || {}, r(t, !0)) }) : jt(e[t.pointerid || 0] || {}, r(t, !0)), this.change(t)) }, pointerup: function(t) { var e, i = this, n = this.options, s = this.action, o = this.pointers; t.changedtouches ? m(t.changedtouches, function(t) { e = o[t.identifier], delete o[t.identifier] }) : (e = o[t.pointerid || 0], delete o[t.pointerid || 0]), s && (t.preventdefault(), !n.transition || s !== f && s !== h || p(this.image, rt), this.action = !1, j && s !== h && e && date.now() - e.timestamp < 500 && (cleartimeout(this.clickcanvastimeout), cleartimeout(this.doubleclickimagetimeout), n.toggleondblclick && this.viewed && t.target === this.image ? this.imageclicked ? (this.imageclicked = !1, this.doubleclickimagetimeout = settimeout(function() { t(i.image, lt) }, 50)) : (this.imageclicked = !0, this.doubleclickimagetimeout = settimeout(function() { i.imageclicked = !1 }, 500)) : (this.imageclicked = !1, n.backdrop && "static" !== n.backdrop && t.target === this.canvas && (this.clickcanvastimeout = settimeout(function() { t(i.canvas, ht) }, 50))))) }, resize: function() { var t = 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() { t.renderimage() }), this.played)) { if (this.options.fullscreen && this.fulled && !(document.fullscreenelement || document.webkitfullscreenelement || document.mozfullscreenelement || document.msfullscreenelement)) return void this.stop(); m(this.player.getelementsbytagname("img"), function(e) { d(e, ft, t.loadimage.bind(t), { once: !0 }), t(e, ft) }) } }, wheel: function(t) { var e = this; if (this.viewed && (t.preventdefault(), !this.wheeling)) { this.wheeling = !0, settimeout(function() { e.wheeling = !1 }, 50); var i = number(this.options.zoomratio) || .1 , n = 1; t.deltay ? n = t.deltay > 0 ? 1 : -1 : t.wheeldelta ? n = -t.wheeldelta / 120 : t.detail && (n = t.detail > 0 ? 1 : -1), this.zoom(-n * i, !0, t) } } } , ut = { show: function() { var t = arguments.length > 0 && void 0 !== arguments[0] && arguments[0] , e = this.element , i = this.options; if (i.inline || this.showing || this.isshown || this.showing) return this; if (!this.ready) return this.build(), this.ready && this.show(t), this; if (d(i.show) && d(e, zt, i.show, { once: !0 }), !1 === t(e, zt) || !this.ready) return this; this.hiding && this.transitioning.abort(), this.showing = !0, this.open(); var n = this.viewer; if (w(n, q), i.transition && !t) { var s = this.shown.bind(this); this.transitioning = { abort: function() { z(n, tt, s), w(n, et) } }, p(n, rt), n.initialoffsetwidth = n.offsetwidth, d(n, tt, s, { once: !0 }), p(n, et) } else p(n, et), this.shown(); return this }, hide: function() { var t = this , e = arguments.length > 0 && void 0 !== arguments[0] && arguments[0] , i = this.element , n = this.options; if (n.inline || this.hiding || !this.isshown && !this.showing) return this; if (d(n.hide) && d(i, dt, n.hide, { once: !0 }), !1 === t(i, dt)) return this; this.showing && this.transitioning.abort(), this.hiding = !0, this.played ? this.stop() : this.viewing && this.viewing.abort(); var s = this.viewer , o = this.image , a = function() { w(s, et), t.hidden() }; if (n.transition && !e) { var r = function e(i) { i && i.target === s && (z(s, tt, e), t.hidden()) } , h = function() { v(s, rt) ? (d(s, tt, r), w(s, et)) : a() }; this.transitioning = { abort: function() { t.viewed && v(o, rt) ? z(o, tt, h) : v(s, rt) && z(s, tt, r) } }, this.viewed && v(o, rt) ? (d(o, tt, h, { once: !0 }), this.zoomto(0, !1, !1, !0)) : h() } else a(); return this }, view: function() { var t = this , e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : this.options.initialviewindex; if (e = number(e) || 0, this.hiding || this.played || e < 0 || e >= this.length || this.viewed && e === this.index) return this; if (!this.isshown) return this.index = e, this.show(); this.viewing && this.viewing.abort(); var i = this.element , n = this.options , s = this.title , o = this.canvas , a = this.items[e] , r = a.queryselector("img") , h = x(r, "originalurl") , l = r.getattribute("alt") , c = document.createelement("img"); if (m(n.inheritedattributes, function(t) { var e = r.getattribute(t); null !== e && c.setattribute(t, e) }), c.src = h, c.alt = l, d(n.view) && d(i, it, n.view, { once: !0 }), !1 === t(i, it, { originalimage: this.images[e], index: e, image: c }) || !this.isshown || this.hiding || this.played) return this; this.image = c, w(this.items[this.index], b), p(a, b), this.viewed = !1, this.index = e, this.imagedata = {}, p(c, it), n.loading && p(o, nt), o.innerhtml = "", o.appendchild(c), this.renderlist(), s.innerhtml = ""; var u, f = function() { var e = t.imagedata , i = array.isarray(n.title) ? n.title[1] : n.title; s.innerhtml = g(d(i) ? i.call(t, c, e) : "".concat(l, " (").concat(e.naturalwidth, " x ").concat(e.naturalheight, ")")) }; return d(i, et, f, { once: !0 }), this.viewing = { abort: function() { z(i, et, f), c.complete ? t.imagerendering ? t.imagerendering.abort() : t.imageinitializing && t.imageinitializing.abort() : (c.src = "", z(c, ft, u), t.timeout && cleartimeout(t.timeout)) } }, c.complete ? this.load() : (d(c, ft, u = this.load.bind(this), { once: !0 }), this.timeout && cleartimeout(this.timeout), this.timeout = settimeout(function() { w(c, it), t.timeout = !1 }, 1e3)), this }, prev: function() { var t = arguments.length > 0 && void 0 !== arguments[0] && arguments[0] , e = this.index - 1; return e < 0 && (e = t ? this.length - 1 : 0), this.view(e), this }, next: function() { var t = arguments.length > 0 && void 0 !== arguments[0] && arguments[0] , e = this.length - 1 , i = this.index + 1; return i > e && (i = t ? 0 : e), this.view(i), this }, move: function(t, e) { var i = this.imagedata; return this.moveto(l(t) ? t : i.left + number(t), l(e) ? e : i.top + number(e)), this }, moveto: function(t) { var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : t , i = this.imagedata; if (t = number(t), e = number(e), this.viewed && !this.played && this.options.movable) { var n = !1; h(t) && (i.left = t, n = !0), h(e) && (i.top = e, n = !0), n && this.renderimage() } return this }, zoom: function(t) { var e = arguments.length > 1 && void 0 !== arguments[1] && arguments[1] , i = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : null , n = this.imagedata; return t = number(t), t = t < 0 ? 1 / (1 - t) : 1 + t, this.zoomto(n.width * t / n.naturalwidth, e, i), this }, zoomto: function(t) { var e = this , i = arguments.length > 1 && void 0 !== arguments[1] && arguments[1] , n = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : null , s = arguments.length > 3 && void 0 !== arguments[3] && arguments[3] , o = this.element , a = this.options , r = this.pointers , l = this.imagedata , c = l.width , u = l.height , m = l.left , f = l.top , g = l.naturalwidth , v = l.naturalheight; if (t = math.max(0, t), h(t) && this.viewed && !this.played && (s || a.zoomable)) { if (!s) { var p = math.max(.01, a.minzoomratio) , w = math.min(100, a.maxzoomratio); t = math.min(math.max(t, p), w) } n && a.zoomratio >= .055 && t > .95 && t < 1.05 && (t = 1); var b = g * t , y = v * t , x = b - c , k = y - u , z = c / g; if (d(a.zoom) && d(o, ct, a.zoom, { once: !0 }), !1 === t(o, ct, { ratio: t, oldratio: z, originalevent: n })) return this; if (this.zooming = !0, n) { var e = i(this.viewer) , o = r && object.keys(r).length ? a(r) : { pagex: n.pagex, pagey: n.pagey }; l.left -= x * ((o.pagex - e.left - m) / c), l.top -= k * ((o.pagey - e.top - f) / u) } else l.left -= x / 2, l.top -= k / 2; l.width = b, l.height = y, l.ratio = t, this.renderimage(function() { e.zooming = !1, d(a.zoomed) && d(o, st, a.zoomed, { once: !0 }), t(o, st, { ratio: t, oldratio: z, originalevent: n }, { cancelable: !1 }) }), i && this.tooltip() } return this }, rotate: function(t) { return this.rotateto((this.imagedata.rotate || 0) + number(t)), this }, rotateto: function(t) { var e = this.imagedata; return t = number(t), h(t) && this.viewed && !this.played && this.options.rotatable && (e.rotate = t, this.renderimage()), this }, scalex: function(t) { return this.scale(t, this.imagedata.scaley), this }, scaley: function(t) { return this.scale(this.imagedata.scalex, t), this }, scale: function(t) { var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : t , i = this.imagedata; if (t = number(t), e = number(e), this.viewed && !this.played && this.options.scalable) { var n = !1; h(t) && (i.scalex = t, n = !0), h(e) && (i.scaley = e, n = !0), n && this.renderimage() } return this }, play: function() { var t = this , e = arguments.length > 0 && void 0 !== arguments[0] && arguments[0]; if (!this.isshown || this.played) return this; var i = this.element , n = this.options; if (d(n.play) && d(i, lt, n.play, { once: !0 }), !1 === t(i, lt)) return this; var s = this.player , o = this.loadimage.bind(this) , a = [] , r = 0 , l = 0; if (this.played = !0, this.onloadwhenplay = o, e && this.requestfullscreen(), p(s, at), m(this.items, function(t, e) { var i = t.queryselector("img") , h = document.createelement("img"); h.src = x(i, "originalurl"), h.alt = i.getattribute("alt"), h.referrerpolicy = i.referrerpolicy, r += 1, p(h, u), b(h, rt, n.transition), v(t, b) && (p(h, et), l = e), a.push(h), d(h, ft, o, { once: !0 }), s.appendchild(h) }), h(n.interval) && n.interval > 0) { var c = function e() { t.playing = settimeout(function() { w(a[l], et), l += 1, l = l < r ? l : 0, p(a[l], et), e() }, n.interval) }; r > 1 && c() } return this }, stop: function() { var t = this; if (!this.played) return this; var e = this.element , i = this.options; if (d(i.stop) && d(e, rt, i.stop, { once: !0 }), !1 === t(e, rt)) return this; var n = this.player; return this.played = !1, cleartimeout(this.playing), m(n.getelementsbytagname("img"), function(e) { z(e, ft, t.onloadwhenplay) }), w(n, at), n.innerhtml = "", this.exitfullscreen(), this }, full: function() { var t = this , e = this.options , i = this.viewer , n = this.image , s = this.list; return !this.isshown || this.played || this.fulled || !e.inline ? this : (this.fulled = !0, this.open(), p(this.button, _), e.transition && (w(s, rt), this.viewed && w(n, rt)), p(i, k), i.setattribute("style", ""), f(i, { zindex: e.zindex }), this.initcontainer(), this.viewerdata = jt({}, this.containerdata), this.renderlist(), this.viewed && this.initimage(function() { t.renderimage(function() { e.transition && settimeout(function() { p(n, rt), p(s, rt) }, 0) }) }), this) }, exit: function() { var t = this , e = this.options , i = this.viewer , n = this.image , s = this.list; return this.isshown && !this.played && this.fulled && e.inline ? (this.fulled = !1, this.close(), w(this.button, _), e.transition && (w(s, rt), this.viewed && w(n, rt)), w(i, k), f(i, { zindex: e.zindexinline }), this.viewerdata = jt({}, this.parentdata), this.renderviewer(), this.renderlist(), this.viewed && this.initimage(function() { t.renderimage(function() { e.transition && settimeout(function() { p(n, rt), p(s, rt) }, 0) }) }), this) : this }, tooltip: function() { var t = this , e = this.options , i = this.tooltipbox , n = this.imagedata; return this.viewed && !this.played && e.tooltip ? (i.textcontent = "".concat(math.round(100 * n.ratio), "%"), this.tooltipping ? cleartimeout(this.tooltipping) : e.transition ? (this.fading && t(i, tt), p(i, at), p(i, u), p(i, rt), i.initialoffsetwidth = i.offsetwidth, p(i, et)) : p(i, at), this.tooltipping = settimeout(function() { e.transition ? (d(i, tt, function() { w(i, at), w(i, u), w(i, rt), t.fading = !1 }, { once: !0 }), w(i, et), t.fading = !0) : w(i, at), t.tooltipping = !1 }, 1e3), this) : this }, toggle: function() { return 1 === this.imagedata.ratio ? this.zoomto(this.initialimagedata.ratio, !0) : this.zoomto(1, !0), this }, reset: function() { return this.viewed && !this.played && (this.imagedata = jt({}, this.initialimagedata), this.renderimage()), this }, update: function() { var t = this , e = this.element , i = this.options , n = this.isimg; if (n && !e.parentnode) return this.destroy(); var s = []; if (m(n ? [e] : e.queryselectorall("img"), function(e) { d(i.filter) ? i.filter.call(t, e) && s.push(e) : t.getimageurl(e) && s.push(e) }), !s.length) return this; if (this.images = s, this.length = s.length, this.ready) { var o = []; if (m(this.items, function(t, e) { var i = t.queryselector("img") , n = s[e]; n && i && n.src === i.src && n.alt === i.alt || o.push(e) }), f(this.list, { width: "auto" }), this.initlist(), this.isshown) if (this.length) { if (this.viewed) { var a = o.indexof(this.index); a >= 0 ? (this.viewed = !1, this.view(math.max(math.min(this.index - a, this.length - 1), 0))) : p(this.items[this.index], b) } } 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() { var t = this.element , e = this.options; return t[x] ? (this.destroyed = !0, this.ready ? (this.played && this.stop(), e.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)) : e.inline && (this.delaying ? this.delaying.abort() : this.initializing && this.initializing.abort()), e.inline || z(t, ht, this.onstart), t[x] = void 0, this) : this } } , $t = { getimageurl: function(t) { var e = this.options.url; return e = r(e) ? t.getattribute(e) : d(e) ? e.call(this, t) : "", e }, open: function() { var t = this.body; p(t, ot), t.style.paddingright = "".concat(this.scrollbarwidth + (parsefloat(this.initialbodycomputedpaddingright) || 0), "px"), $("html").addclass("viewer-open") }, close: function() { var t = this.body; w(t, ot), t.style.paddingright = this.initialbodypaddingright, $("html").removeclass("viewer-open") }, shown: function() { var t = this.element , e = this.options; this.fulled = !0, this.isshown = !0, this.render(), this.bind(), this.showing = !1, d(e.shown) && d(t, dt, e.shown, { once: !0 }), !1 !== t(t, dt) && this.ready && this.isshown && !this.hiding && this.view(this.index) }, hidden: function() { var t = this.element , e = this.options; this.fulled = !1, this.viewed = !1, this.isshown = !1, this.close(), this.unbind(), p(this.viewer, q), this.resetlist(), this.resetimage(), this.hiding = !1, this.destroyed || (d(e.hidden) && d(t, ut, e.hidden, { once: !0 }), t(t, ut, null, { cancelable: !1 })) }, requestfullscreen: function() { var t = this.element.ownerdocument; if (this.fulled && !(t.fullscreenelement || t.webkitfullscreenelement || t.mozfullscreenelement || t.msfullscreenelement)) { var e = t.documentelement; e.requestfullscreen ? e.requestfullscreen() : e.webkitrequestfullscreen ? e.webkitrequestfullscreen(element.allow_keyboard_input) : e.mozrequestfullscreen ? e.mozrequestfullscreen() : e.msrequestfullscreen && e.msrequestfullscreen() } }, exitfullscreen: function() { var t = this.element.ownerdocument; this.fulled && (t.fullscreenelement || t.webkitfullscreenelement || t.mozfullscreenelement || t.msfullscreenelement) && (t.exitfullscreen ? t.exitfullscreen() : t.webkitexitfullscreen ? t.webkitexitfullscreen() : t.mozcancelfullscreen ? t.mozcancelfullscreen() : t.msexitfullscreen && t.msexitfullscreen()) }, change: function(t) { var e = this.options , i = this.pointers , n = i[object.keys(i)[0]] , s = n.endx - n.startx , o = n.endy - n.starty; switch (this.action) { case f: this.move(s, o); break; case h: this.zoom(l(i), !1, t); break; case w: this.action = "switched"; var a = math.abs(s); a > 1 && a > math.abs(o) && (this.pointers = {}, s > 1 ? this.prev(e.loop) : s < -1 && this.next(e.loop)) } m(i, function(t) { t.startx = t.endx, t.starty = t.endy }) }, isswitchable: function() { var t = this.imagedata , e = this.viewerdata; return this.length > 1 && t.left >= 0 && t.top >= 0 && t.width <= e.width && t.height <= e.height } } , kt = q.viewer , zt = function() { function t(i) { var n = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; if (e(this, t), !i || 1 !== i.nodetype) throw new error("the first argument is required and must be an element."); this.element = i, this.options = jt({}, n, u(n) && n), 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.played = !1, this.playing = !1, this.pointers = {}, this.ready = !1, this.showing = !1, this.timeout = !1, this.tooltipping = !1, this.viewed = !1, this.viewing = !1, this.wheeling = !1, this.zooming = !1, this.init() } return n(t, [{ key: "init", value: function() { var t = this , e = this.element , i = this.options; if (!e[x]) { e[x] = this; var n = "img" === e.tagname.tolowercase() , s = []; if (m(n ? [e] : $(e).find("img:not('.viewer-not')"), function(e) { d(i.filter) ? i.filter.call(t, e) && s.push(e) : t.getimageurl(e) && s.push(e) }), this.isimg = n, this.length = s.length, this.images = s, this.initbody(), l(document.createelement(x).style.transition) && (i.transition = !1), i.inline) { var o = 0 , a = function() { var e; (o += 1, o === t.length) && (t.initializing = !1, t.delaying = { abort: function() { cleartimeout(e) } }, e = settimeout(function() { t.delaying = !1, t.build() }, 0)) }; this.initializing = { abort: function() { m(s, function(t) { t.complete || z(t, ft, a) }) } }, m(s, function(t) { t.complete ? a() : d(t, ft, a, { once: !0 }) }) } else d(e, ht, this.onstart = function(e) { var n = e.target; "img" !== n.tagname.tolowercase() || d(i.filter) && !i.filter.call(t, n) || t.view(t.images.indexof(n)) } ) } } }, { key: "build", value: function() { if (!this.ready) { var t = this.element , e = this.options , i = t.parentnode , n = document.createelement("div"); n.innerhtml = m; var s = n.queryselector(".".concat(x, "-container")) , o = s.queryselector(".".concat(x, "-title")) , a = s.queryselector(".".concat(x, "-toolbar")) , c = s.queryselector(".".concat(x, "-navbar")) , g = s.queryselector(".".concat(x, "-button")) , v = s.queryselector(".".concat(x, "-canvas")); if (this.parent = i, this.viewer = s, this.title = o, this.toolbar = a, this.navbar = c, this.button = g, this.canvas = v, this.footer = s.queryselector(".".concat(x, "-footer")), this.tooltipbox = s.queryselector(".".concat(x, "-tooltip")), this.player = s.queryselector(".".concat(x, "-player")), this.list = s.queryselector(".".concat(x, "-list")), p(o, e.title ? s(array.isarray(e.title) ? e.title[0] : e.title) : q), p(c, e.navbar ? s(e.navbar) : q), b(g, q, !e.button), e.backdrop && (p(s, "".concat(x, "-backdrop")), e.inline || "static" === e.backdrop || k(v, at, "hide")), r(e.classname) && e.classname && e.classname.split(nt).foreach(function(t) { p(s, t) }), e.toolbar) { var w = document.createelement("ul") , x = u(e.toolbar) , z = mt.slice(0, 3) , i = mt.slice(7, 9) , e = mt.slice(9); x || p(a, s(e.toolbar)), m(x ? e.toolbar : mt, function(t, i) { var n = x && u(t) , s = x ? y(i) : t , o = n && !l(t.show) ? t.show : t; if (o && (e.zoomable || -1 === z.indexof(s)) && (e.rotatable || -1 === i.indexof(s)) && (e.scalable || -1 === e.indexof(s))) { var a = n && !l(t.size) ? t.size : t , r = n && !l(t.click) ? t.click : t , c = document.createelement("li"); c.setattribute("role", "button"), p(c, "".concat(x, "-").concat(s)), d(r) || k(c, at, s), h(o) && p(c, s(o)), -1 !== ["small", "large"].indexof(a) ? p(c, "".concat(x, "-").concat(a)) : "play" === s && p(c, "".concat(x, "-large")), d(r) && d(c, ht, r), w.appendchild(c) } }), a.appendchild(w) } else p(a, q); if (!e.rotatable) { var o = a.queryselectorall('li[class*="rotate"]'); p(o, it), m(o, function(t) { a.appendchild(t) }) } if (e.inline) p(g, z), f(s, { zindex: e.zindexinline }), "static" === window.getcomputedstyle(i).position && f(i, { position: "relative" }), i.insertbefore(s, t.nextsibling); else { p(g, v), p(s, k), p(s, u), p(s, q), f(s, { zindex: e.zindex }); var c = e.container; r(c) && (c = t.ownerdocument.queryselector(c)), c || (c = this.body), c.appendchild(s) } e.inline && (this.render(), this.bind(), this.isshown = !0), this.ready = !0, d(e.ready) && d(t, xt, e.ready, { once: !0 }), !1 !== t(t, xt) ? this.ready && e.inline && this.view(this.index) : this.ready = !1 } } }], [{ key: "noconflict", value: function() { return window.viewer = kt, t } }, { key: "setdefaults", value: function(t) { jt(n, u(t) && t) } }]), t }(); return jt(zt.prototype, ht, bt, vt, ut, $t), zt }), function(t, e) { "object" == typeof exports && "undefined" != typeof module ? e(require("jquery"), require("viewerjs")) : "function" == typeof define && define.amd ? define(["jquery", "viewerjs"], e) : (t = t || self, e(t.jquery, t.viewer)) }(this, function(t, e) { "use strict"; if (t = t && t.hasownproperty("default") ? t.default : t, e = e && e.hasownproperty("default") ? e.default : e, t && t.fn && e) { var i = t.fn.viewer , n = "viewer"; t.fn.viewer = function(i) { for (var s = arguments.length, o = new array(s > 1 ? s - 1 : 0), a = 1; a < s; a++) o[a - 1] = arguments[a]; var r; return this.each(function(s, a) { var h = t(a) , l = "destroy" === i , c = h.data(n); if (!c) { if (l) return; var u = t.extend({}, h.data(), t.isplainobject(i) && i); c = new e(a,u), h.data(n, c) } if ("string" == typeof i) { var d = c[i]; t.isfunction(d) && (r = d.apply(c, o), r === c && (r = void 0), l && h.removedata(n)) } }), void 0 !== r ? r : this } , t.fn.viewer.constructor = e, t.fn.viewer.setdefaults = e.setdefaults, t.fn.viewer.noconflict = function() { return t.fn.viewer = i, this } } });