You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

910 lines
55 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Viewer.js v1.11.7
  3. * https://fengyuanchen.github.io/viewerjs
  4. *
  5. * Copyright 2015-present Chen Fengyuan
  6. * Released under the MIT license
  7. *
  8. * Date: 2024-11-24T04:32:19.116Z
  9. */
  10. ((t, e) => {
  11. "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).Viewer = e()
  12. })(this, function () {
  13. function n(t, e) {
  14. for (var i = 0; i < e.length; i++) {
  15. var n = e[i];
  16. n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, r(n.key), n)
  17. }
  18. }
  19. function s(e, t) {
  20. var i, n = Object.keys(e);
  21. return Object.getOwnPropertySymbols && (i = Object.getOwnPropertySymbols(e), t && (i = i.filter(function (t) {
  22. return Object.getOwnPropertyDescriptor(e, t).enumerable
  23. })), n.push.apply(n, i)), n
  24. }
  25. function P(n) {
  26. for (var t = 1; t < arguments.length; t++) {
  27. var o = null != arguments[t] ? arguments[t] : {};
  28. t % 2 ? s(Object(o), !0).forEach(function (t) {
  29. var e, i;
  30. e = n, i = o[t = t], (t = r(t)) in e ? Object.defineProperty(e, t, {
  31. value: i,
  32. enumerable: !0,
  33. configurable: !0,
  34. writable: !0
  35. }) : e[t] = i
  36. }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(n, Object.getOwnPropertyDescriptors(o)) : s(Object(o)).forEach(function (t) {
  37. Object.defineProperty(n, t, Object.getOwnPropertyDescriptor(o, t))
  38. })
  39. }
  40. return n
  41. }
  42. function r(t) {
  43. t = ((t, e) => {
  44. if ("object" != typeof t || !t) return t;
  45. var i = t[Symbol.toPrimitive];
  46. if (void 0 === i) return ("string" === e ? String : Number)(t);
  47. if ("object" != typeof (i = i.call(t, e || "default"))) return i;
  48. throw new TypeError("@@toPrimitive must return a primitive value.")
  49. })(t, "string");
  50. return "symbol" == typeof t ? t : t + ""
  51. }
  52. function l(t) {
  53. return (l = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) {
  54. return typeof t
  55. } : function (t) {
  56. return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t
  57. })(t)
  58. }
  59. var W = {
  60. backdrop: !0,
  61. button: !0,
  62. navbar: !0,
  63. title: !0,
  64. toolbar: !0,
  65. className: "",
  66. container: "body",
  67. filter: null,
  68. fullscreen: !0,
  69. inheritedAttributes: ["crossOrigin", "decoding", "isMap", "loading", "referrerPolicy", "sizes", "srcset", "useMap"],
  70. initialCoverage: .9,
  71. initialViewIndex: 0,
  72. inline: !1,
  73. interval: 5e3,
  74. keyboard: !0,
  75. focus: !0,
  76. loading: !0,
  77. loop: !0,
  78. minWidth: 200,
  79. minHeight: 100,
  80. movable: !0,
  81. rotatable: !0,
  82. scalable: !0,
  83. zoomable: !0,
  84. zoomOnTouch: !0,
  85. zoomOnWheel: !0,
  86. slideOnTouch: !0,
  87. toggleOnDblclick: !0,
  88. tooltip: !0,
  89. transition: !0,
  90. zIndex: 2015,
  91. zIndexInline: 0,
  92. zoomRatio: .1,
  93. minZoomRatio: .01,
  94. maxZoomRatio: 100,
  95. url: "src",
  96. ready: null,
  97. show: null,
  98. shown: null,
  99. hide: null,
  100. hidden: null,
  101. view: null,
  102. viewed: null,
  103. move: null,
  104. moved: null,
  105. rotate: null,
  106. rotated: null,
  107. scale: null,
  108. scaled: null,
  109. zoom: null,
  110. zoomed: null,
  111. play: null,
  112. stop: null
  113. }, t = "undefined" != typeof window && void 0 !== window.document, e = t ? window : {},
  114. a = !(!t || !e.document.documentElement) && "ontouchstart" in e.document.documentElement,
  115. i = t && "PointerEvent" in e, g = "viewer", h = "move", j = "switch", c = "zoom", f = "".concat(g, "-active"),
  116. H = "".concat(g, "-close"), B = "".concat(g, "-fade"), V = "".concat(g, "-fixed"),
  117. U = "".concat(g, "-fullscreen"), K = "".concat(g, "-fullscreen-exit"), v = "".concat(g, "-hide"),
  118. Z = "".concat(g, "-hide-md-down"), $ = "".concat(g, "-hide-sm-down"), _ = "".concat(g, "-hide-xs-down"),
  119. u = "".concat(g, "-in"), p = "".concat(g, "-invisible"), b = "".concat(g, "-loading"),
  120. G = "".concat(g, "-move"), J = "".concat(g, "-open"), d = "".concat(g, "-show"),
  121. m = "".concat(g, "-transition"), w = "click", Q = "dblclick", tt = "dragstart", et = "focusin", it = "keydown",
  122. y = "load", x = "error", nt = i ? "pointerdown" : a ? "touchstart" : "mousedown",
  123. ot = i ? "pointermove" : a ? "touchmove" : "mousemove",
  124. st = i ? "pointerup pointercancel" : a ? "touchend touchcancel" : "mouseup", at = "resize", k = "transitionend",
  125. rt = "wheel", z = "viewed", lt = "rotated", ht = "".concat(g, "Action"), ct = /\s\s*/,
  126. ut = ["zoom-in", "zoom-out", "one-to-one", "reset", "prev", "play", "next", "rotate-left", "rotate-right", "flip-horizontal", "flip-vertical"];
  127. function T(t) {
  128. return "string" == typeof t
  129. }
  130. var dt = Number.isNaN || e.isNaN;
  131. function E(t) {
  132. return "number" == typeof t && !dt(t)
  133. }
  134. function D(t) {
  135. return void 0 === t
  136. }
  137. function o(t) {
  138. return "object" === l(t) && null !== t
  139. }
  140. var mt = Object.prototype.hasOwnProperty;
  141. function S(t) {
  142. if (!o(t)) return !1;
  143. try {
  144. var e = t.constructor, i = e.prototype;
  145. return e && i && mt.call(i, "isPrototypeOf")
  146. } catch (t) {
  147. return !1
  148. }
  149. }
  150. function I(t) {
  151. return "function" == typeof t
  152. }
  153. function A(e, i) {
  154. if (e && I(i)) if (Array.isArray(e) || E(e.length)) for (var t = e.length, n = 0; n < t && !1 !== i.call(e, e[n], n, e); n += 1) ; else o(e) && Object.keys(e).forEach(function (t) {
  155. i.call(e, e[t], t, e)
  156. })
  157. }
  158. var O = Object.assign || function (i) {
  159. for (var t = arguments.length, e = new Array(1 < t ? t - 1 : 0), n = 1; n < t; n++) e[n - 1] = arguments[n];
  160. return o(i) && 0 < e.length && e.forEach(function (e) {
  161. o(e) && Object.keys(e).forEach(function (t) {
  162. i[t] = e[t]
  163. })
  164. }), i
  165. }, gt = /^(?:width|height|left|top|marginLeft|marginTop)$/;
  166. function C(t, e) {
  167. var i = t.style;
  168. A(e, function (t, e) {
  169. gt.test(e) && E(t) && (t += "px"), i[e] = t
  170. })
  171. }
  172. function L(t, e) {
  173. return t && e && (t.classList ? t.classList.contains(e) : -1 < t.className.indexOf(e))
  174. }
  175. function R(t, e) {
  176. var i;
  177. t && e && (E(t.length) ? A(t, function (t) {
  178. R(t, e)
  179. }) : t.classList ? t.classList.add(e) : (i = t.className.trim()) ? i.indexOf(e) < 0 && (t.className = "".concat(i, " ").concat(e)) : t.className = e)
  180. }
  181. function M(t, e) {
  182. t && e && (E(t.length) ? A(t, function (t) {
  183. M(t, e)
  184. }) : t.classList ? t.classList.remove(e) : 0 <= t.className.indexOf(e) && (t.className = t.className.replace(e, "")))
  185. }
  186. function F(t, e, i) {
  187. e && (E(t.length) ? A(t, function (t) {
  188. F(t, e, i)
  189. }) : (i ? R : M)(t, e))
  190. }
  191. var ft = /([a-z\d])([A-Z])/g;
  192. function vt(t) {
  193. return t.replace(ft, "$1-$2").toLowerCase()
  194. }
  195. function N(t, e) {
  196. return o(t[e]) ? t[e] : t.dataset ? t.dataset[e] : t.getAttribute("data-".concat(vt(e)))
  197. }
  198. function pt(t, e, i) {
  199. o(i) ? t[e] = i : t.dataset ? t.dataset[e] = i : t.setAttribute("data-".concat(vt(e)), i)
  200. }
  201. wt = !1, t && (bt = !1, i = function () {
  202. }, t = Object.defineProperty({}, "once", {
  203. get: function () {
  204. return wt = !0, bt
  205. }, set: function (t) {
  206. bt = t
  207. }
  208. }), e.addEventListener("test", i, t), e.removeEventListener("test", i, t));
  209. var bt, wt, yt = wt;
  210. function Y(i, t, n, e) {
  211. var o = 3 < arguments.length && void 0 !== e ? e : {}, s = n;
  212. t.trim().split(ct).forEach(function (t) {
  213. var e;
  214. yt || (e = i.listeners) && e[t] && e[t][n] && (s = e[t][n], delete e[t][n], 0 === Object.keys(e[t]).length && delete e[t], 0 === Object.keys(e).length) && delete i.listeners, i.removeEventListener(t, s, o)
  215. })
  216. }
  217. function X(s, t, a, e) {
  218. var r = 3 < arguments.length && void 0 !== e ? e : {}, l = a;
  219. t.trim().split(ct).forEach(function (n) {
  220. var t, o;
  221. r.once && !yt && (t = s.listeners, l = function () {
  222. delete o[n][a], s.removeEventListener(n, l, r);
  223. for (var t = arguments.length, e = new Array(t), i = 0; i < t; i++) e[i] = arguments[i];
  224. a.apply(s, e)
  225. }, (o = void 0 === t ? {} : t)[n] || (o[n] = {}), o[n][a] && s.removeEventListener(n, o[n][a], r), o[n][a] = l, s.listeners = o), s.addEventListener(n, l, r)
  226. })
  227. }
  228. function q(t, e, i, n) {
  229. var o;
  230. return I(Event) && I(CustomEvent) ? o = new CustomEvent(e, P({
  231. bubbles: !0,
  232. cancelable: !0,
  233. detail: i
  234. }, n)) : (o = document.createEvent("CustomEvent")).initCustomEvent(e, !0, !0, i), t.dispatchEvent(o)
  235. }
  236. function xt(t) {
  237. var e = t.rotate, i = t.scaleX, n = t.scaleY, o = t.translateX, t = t.translateY, s = [],
  238. o = (E(o) && 0 !== o && s.push("translateX(".concat(o, "px)")), E(t) && 0 !== t && s.push("translateY(".concat(t, "px)")), E(e) && 0 !== e && s.push("rotate(".concat(e, "deg)")), E(i) && 1 !== i && s.push("scaleX(".concat(i, ")")), E(n) && 1 !== n && s.push("scaleY(".concat(n, ")")), s.length ? s.join(" ") : "none");
  239. return {WebkitTransform: o, msTransform: o, transform: o}
  240. }
  241. var kt = e.navigator && /Version\/\d+(\.\d+)+?\s+Safari/i.test(e.navigator.userAgent);
  242. function zt(i, t, e) {
  243. var n, o = document.createElement("img");
  244. return i.naturalWidth && !kt ? e(i.naturalWidth, i.naturalHeight) : (n = document.body || document.documentElement, o.onload = function () {
  245. e(o.width, o.height), kt || n.removeChild(o)
  246. }, A(t.inheritedAttributes, function (t) {
  247. var e = i.getAttribute(t);
  248. null !== e && o.setAttribute(t, e)
  249. }), o.src = i.src, kt || (o.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;", n.appendChild(o))), o
  250. }
  251. function Tt(t) {
  252. switch (t) {
  253. case 2:
  254. return _;
  255. case 3:
  256. return $;
  257. case 4:
  258. return Z;
  259. default:
  260. return ""
  261. }
  262. }
  263. function Et(t, e) {
  264. var i = t.pageX, t = t.pageY, n = {endX: i, endY: t};
  265. return e ? n : P({timeStamp: Date.now(), startX: i, startY: t}, n)
  266. }
  267. var Dt, i = {
  268. render: function () {
  269. this.initContainer(), this.initViewer(), this.initList(), this.renderViewer()
  270. }, initBody: function () {
  271. var t = this.element.ownerDocument, e = t.body || t.documentElement;
  272. this.body = e, this.scrollbarWidth = window.innerWidth - t.documentElement.clientWidth, this.initialBodyPaddingRight = e.style.paddingRight, this.initialBodyComputedPaddingRight = window.getComputedStyle(e).paddingRight
  273. }, initContainer: function () {
  274. this.containerData = {width: window.innerWidth, height: window.innerHeight}
  275. }, initViewer: function () {
  276. var t, e = this.options, i = this.parent;
  277. e.inline && (t = {
  278. width: Math.max(i.offsetWidth, e.minWidth),
  279. height: Math.max(i.offsetHeight, e.minHeight)
  280. }, this.parentData = t), !this.fulled && t || (t = this.containerData), this.viewerData = O({}, t)
  281. }, renderViewer: function () {
  282. this.options.inline && !this.fulled && C(this.viewer, this.viewerData)
  283. }, initList: function () {
  284. var r = this, t = this.element, l = this.options, h = this.list, c = [];
  285. h.innerHTML = "", A(this.images, function (i, t) {
  286. var e, n, o = i.src,
  287. s = i.alt || (T(s = o) ? decodeURIComponent(s.replace(/^.*\//, "").replace(/[?&#].*$/, "")) : ""),
  288. a = r.getImageURL(i);
  289. (o || a) && (e = document.createElement("li"), n = document.createElement("img"), A(l.inheritedAttributes, function (t) {
  290. var e = i.getAttribute(t);
  291. null !== e && n.setAttribute(t, e)
  292. }), l.navbar && (n.src = o || a), n.alt = s, n.setAttribute("data-original-url", a || o), e.setAttribute("data-index", t), e.setAttribute("data-viewer-action", "view"), e.setAttribute("role", "button"), l.keyboard && e.setAttribute("tabindex", 0), e.appendChild(n), h.appendChild(e), c.push(e))
  293. }), A(this.items = c, function (e) {
  294. var t, i, n = e.firstElementChild;
  295. pt(n, "filled", !0), l.loading && R(e, b), X(n, y, t = function (t) {
  296. Y(n, x, i), l.loading && M(e, b), r.loadImage(t)
  297. }, {once: !0}), X(n, x, i = function () {
  298. Y(n, y, t), l.loading && M(e, b)
  299. }, {once: !0})
  300. }), l.transition && X(t, z, function () {
  301. R(h, m)
  302. }, {once: !0})
  303. }, renderList: function () {
  304. var t, e, i = this.index, n = this.items[i];
  305. n && (t = n.nextElementSibling, t = parseInt(window.getComputedStyle(t || n).marginLeft, 10), n = n.offsetWidth, C(this.list, O({width: (e = n + t) * this.length - t}, xt({translateX: (this.viewerData.width - n) / 2 - e * i}))))
  306. }, resetList: function () {
  307. var t = this.list;
  308. t.innerHTML = "", M(t, m), C(t, xt({translateX: 0}))
  309. }, initImage: function (r) {
  310. var t, l = this, h = this.options, e = this.image, i = this.viewerData, n = this.footer.offsetHeight,
  311. c = i.width, u = Math.max(i.height - n, n), d = this.imageData || {};
  312. this.imageInitializing = {
  313. abort: function () {
  314. t.onload = null
  315. }
  316. }, t = zt(e, h, function (t, e) {
  317. var i = t / e, n = Math.max(0, Math.min(1, h.initialCoverage)), o = c, s = u,
  318. n = (l.imageInitializing = !1, c < u * i ? s = c / i : o = u * i, n = E(n) ? n : .9, o = Math.min(o * n, t), s = Math.min(s * n, e), (c - o) / 2),
  319. a = (u - s) / 2, n = {
  320. left: n,
  321. top: a,
  322. x: n,
  323. y: a,
  324. width: o,
  325. height: s,
  326. oldRatio: 1,
  327. ratio: o / t,
  328. aspectRatio: i,
  329. naturalWidth: t,
  330. naturalHeight: e
  331. }, a = O({}, n);
  332. h.rotatable && (n.rotate = d.rotate || 0, a.rotate = 0), h.scalable && (n.scaleX = d.scaleX || 1, n.scaleY = d.scaleY || 1, a.scaleX = 1, a.scaleY = 1), l.imageData = n, l.initialImageData = a, r && r()
  333. })
  334. }, renderImage: function (t) {
  335. var e, i = this, n = this.image, o = this.imageData;
  336. C(n, O({
  337. width: o.width,
  338. height: o.height,
  339. marginLeft: o.x,
  340. marginTop: o.y
  341. }, xt(o))), t && ((this.viewing || this.moving || this.rotating || this.scaling || this.zooming) && this.options.transition && L(n, m) ? (e = function () {
  342. i.imageRendering = !1, t()
  343. }, this.imageRendering = {
  344. abort: function () {
  345. Y(n, k, e)
  346. }
  347. }, X(n, k, e, {once: !0})) : t())
  348. }, resetImage: function () {
  349. var t = this.image;
  350. t && (this.viewing && this.viewing.abort(), t.parentNode.removeChild(t), this.image = null, this.title.innerHTML = "")
  351. }
  352. }, t = {
  353. bind: function () {
  354. var t = this.options, e = this.viewer, i = this.canvas, n = this.element.ownerDocument;
  355. X(e, w, this.onClick = this.click.bind(this)), X(e, tt, this.onDragStart = this.dragstart.bind(this)), X(i, nt, this.onPointerDown = this.pointerdown.bind(this)), X(n, ot, this.onPointerMove = this.pointermove.bind(this)), X(n, st, this.onPointerUp = this.pointerup.bind(this)), X(n, it, this.onKeyDown = this.keydown.bind(this)), X(window, at, this.onResize = this.resize.bind(this)), t.zoomable && t.zoomOnWheel && X(e, rt, this.onWheel = this.wheel.bind(this), {
  356. passive: !1,
  357. capture: !0
  358. }), t.toggleOnDblclick && X(i, Q, this.onDblclick = this.dblclick.bind(this))
  359. }, unbind: function () {
  360. var t = this.options, e = this.viewer, i = this.canvas, n = this.element.ownerDocument;
  361. Y(e, w, this.onClick), Y(e, tt, this.onDragStart), Y(i, nt, this.onPointerDown), Y(n, ot, this.onPointerMove), Y(n, st, this.onPointerUp), Y(n, it, this.onKeyDown), Y(window, at, this.onResize), t.zoomable && t.zoomOnWheel && Y(e, rt, this.onWheel, {
  362. passive: !1,
  363. capture: !0
  364. }), t.toggleOnDblclick && Y(i, Q, this.onDblclick)
  365. }
  366. }, St = {
  367. click: function (t) {
  368. var e = this.options, i = this.imageData, n = t.target, o = N(n, ht);
  369. switch (o || "img" !== n.localName || "li" !== n.parentElement.localName || (o = N(n = n.parentElement, ht)), a && t.isTrusted && n === this.canvas && clearTimeout(this.clickCanvasTimeout), o) {
  370. case"mix":
  371. this.played ? this.stop() : e.inline ? this.fulled ? this.exit() : this.full() : this.hide();
  372. break;
  373. case"hide":
  374. this.pointerMoved || this.hide();
  375. break;
  376. case"view":
  377. this.view(N(n, "index"));
  378. break;
  379. case"zoom-in":
  380. this.zoom(.1, !0);
  381. break;
  382. case"zoom-out":
  383. this.zoom(-.1, !0);
  384. break;
  385. case"one-to-one":
  386. this.toggle();
  387. break;
  388. case"reset":
  389. this.reset();
  390. break;
  391. case"prev":
  392. this.prev(e.loop);
  393. break;
  394. case"play":
  395. this.play(e.fullscreen);
  396. break;
  397. case"next":
  398. this.next(e.loop);
  399. break;
  400. case"rotate-left":
  401. this.rotate(-90);
  402. break;
  403. case"rotate-right":
  404. this.rotate(90);
  405. break;
  406. case"flip-horizontal":
  407. this.scaleX(-i.scaleX || -1);
  408. break;
  409. case"flip-vertical":
  410. this.scaleY(-i.scaleY || -1);
  411. break;
  412. default:
  413. this.played && this.stop()
  414. }
  415. }, dblclick: function (t) {
  416. t.preventDefault(), this.viewed && t.target === this.image && (a && t.isTrusted && clearTimeout(this.doubleClickImageTimeout), this.toggle(t.isTrusted ? t : t.detail && t.detail.originalEvent))
  417. }, load: function () {
  418. var t = this, e = (this.timeout && (clearTimeout(this.timeout), this.timeout = !1), this.element),
  419. i = this.options, n = this.image, o = this.index, s = this.viewerData;
  420. M(n, p), i.loading && M(this.canvas, b), n.style.cssText = "height:0;" + "margin-left:".concat(s.width / 2, "px;") + "margin-top:".concat(s.height / 2, "px;") + "max-width:none!important;position:relative;width:0;", this.initImage(function () {
  421. F(n, G, i.movable), F(n, m, i.transition), t.renderImage(function () {
  422. t.viewed = !0, t.viewing = !1, I(i.viewed) && X(e, z, i.viewed, {once: !0}), q(e, z, {
  423. originalImage: t.images[o],
  424. index: o,
  425. image: n
  426. }, {cancelable: !1})
  427. })
  428. })
  429. }, loadImage: function (t) {
  430. var n = t.target, t = n.parentNode, o = t.offsetWidth || 30, s = t.offsetHeight || 50, a = !!N(n, "filled");
  431. zt(n, this.options, function (t, e) {
  432. var t = t / e, e = o, i = s;
  433. o < s * t ? a ? e = s * t : i = o / t : a ? i = o / t : e = s * t, C(n, O({
  434. width: e,
  435. height: i
  436. }, xt({translateX: (o - e) / 2, translateY: (s - i) / 2})))
  437. })
  438. }, keydown: function (t) {
  439. var e = this.options;
  440. if (e.keyboard) {
  441. var i = t.keyCode || t.which || t.charCode;
  442. if (13 === i && this.viewer.contains(t.target) && this.click(t), this.fulled) switch (i) {
  443. case 27:
  444. this.played ? this.stop() : e.inline ? this.fulled && this.exit() : this.hide();
  445. break;
  446. case 32:
  447. this.played && this.stop();
  448. break;
  449. case 37:
  450. this.played && this.playing ? this.playing.prev() : this.prev(e.loop);
  451. break;
  452. case 38:
  453. t.preventDefault(), this.zoom(e.zoomRatio, !0);
  454. break;
  455. case 39:
  456. this.played && this.playing ? this.playing.next() : this.next(e.loop);
  457. break;
  458. case 40:
  459. t.preventDefault(), this.zoom(-e.zoomRatio, !0);
  460. break;
  461. case 48:
  462. case 49:
  463. t.ctrlKey && (t.preventDefault(), this.toggle())
  464. }
  465. }
  466. }, dragstart: function (t) {
  467. "img" === t.target.localName && t.preventDefault()
  468. }, pointerdown: function (t) {
  469. var e = this.options, i = this.pointers, n = t.buttons, o = t.button;
  470. this.pointerMoved = !1, !this.viewed || this.showing || this.viewing || this.hiding || ("mousedown" === t.type || "pointerdown" === t.type && "mouse" === t.pointerType) && (E(n) && 1 !== n || E(o) && 0 !== o || t.ctrlKey) || (t.preventDefault(), t.changedTouches ? A(t.changedTouches, function (t) {
  471. i[t.identifier] = Et(t)
  472. }) : i[t.pointerId || 0] = Et(t), n = !!e.movable && h, e.zoomOnTouch && e.zoomable && 1 < Object.keys(i).length ? n = c : e.slideOnTouch && ("touch" === t.pointerType || "touchstart" === t.type) && this.isSwitchable() && (n = j), !e.transition || n !== h && n !== c || M(this.image, m), this.action = n)
  473. }, pointermove: function (t) {
  474. var e = this.pointers, i = this.action;
  475. this.viewed && i && (t.preventDefault(), t.changedTouches ? A(t.changedTouches, function (t) {
  476. O(e[t.identifier] || {}, Et(t, !0))
  477. }) : O(e[t.pointerId || 0] || {}, Et(t, !0)), this.change(t))
  478. }, pointerup: function (t) {
  479. var e, i = this, n = this.options, o = this.action, s = this.pointers;
  480. t.changedTouches ? A(t.changedTouches, function (t) {
  481. e = s[t.identifier], delete s[t.identifier]
  482. }) : (e = s[t.pointerId || 0], delete s[t.pointerId || 0]), o && (t.preventDefault(), !n.transition || o !== h && o !== c || R(this.image, m), this.action = !1, a) && o !== c && 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 () {
  483. q(i.image, Q, {originalEvent: t})
  484. }, 50)) : (this.imageClicked = !0, this.doubleClickImageTimeout = setTimeout(function () {
  485. i.imageClicked = !1
  486. }, 500)) : (this.imageClicked = !1, n.backdrop && "static" !== n.backdrop && t.target === this.canvas && (this.clickCanvasTimeout = setTimeout(function () {
  487. q(i.canvas, w, {originalEvent: t})
  488. }, 50))))
  489. }, resize: function () {
  490. var e = this;
  491. 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 () {
  492. e.renderImage()
  493. }), this.played) && (this.options.fullscreen && this.fulled && !(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) ? this.stop() : A(this.player.getElementsByTagName("img"), function (t) {
  494. X(t, y, e.loadImage.bind(e), {once: !0}), q(t, y)
  495. }))
  496. }, wheel: function (t) {
  497. var e, i, n = this;
  498. this.viewed && (t.preventDefault(), this.wheeling || (this.wheeling = !0, setTimeout(function () {
  499. n.wheeling = !1
  500. }, 50), e = Number(this.options.zoomRatio) || .1, i = 1, t.deltaY ? i = 0 < t.deltaY ? 1 : -1 : t.wheelDelta ? i = -t.wheelDelta / 120 : t.detail && (i = 0 < t.detail ? 1 : -1), this.zoom(-i * e, !0, null, t)))
  501. }
  502. }, It = {
  503. show: function () {
  504. var t, e, i = 0 < arguments.length && void 0 !== arguments[0] && arguments[0], n = this.element,
  505. o = this.options;
  506. return o.inline || this.showing || this.isShown || this.showing || (this.ready ? (I(o.show) && X(n, "show", o.show, {once: !0}), !1 !== q(n, "show") && this.ready && (this.hiding && this.transitioning.abort(), this.showing = !0, this.open(), M(t = this.viewer, v), t.setAttribute("role", "dialog"), t.setAttribute("aria-labelledby", this.title.id), t.setAttribute("aria-modal", !0), t.removeAttribute("aria-hidden"), o.transition && !i ? (e = this.shown.bind(this), this.transitioning = {
  507. abort: function () {
  508. Y(t, k, e), M(t, u)
  509. }
  510. }, R(t, m), t.initialOffsetWidth = t.offsetWidth, X(t, k, e, {once: !0}), R(t, u)) : (R(t, u), this.shown()))) : (this.build(), this.ready && this.show(i))), this
  511. }, hide: function () {
  512. var e, t, i, n, o, s = this, a = 0 < arguments.length && void 0 !== arguments[0] && arguments[0],
  513. r = this.element, l = this.options;
  514. return l.inline || this.hiding || !this.isShown && !this.showing || (I(l.hide) && X(r, "hide", l.hide, {once: !0}), !1 !== q(r, "hide") && (this.showing && this.transitioning.abort(), this.hiding = !0, this.played ? this.stop() : this.viewing && this.viewing.abort(), e = this.viewer, t = this.image, i = function () {
  515. M(e, u), s.hidden()
  516. }, l.transition && !a ? (n = function (t) {
  517. t && t.target === e && (Y(e, k, n), s.hidden())
  518. }, o = function () {
  519. L(e, m) ? (X(e, k, n), M(e, u)) : i()
  520. }, this.transitioning = {
  521. abort: function () {
  522. s.viewed && L(t, m) ? Y(t, k, o) : L(e, m) && Y(e, k, n)
  523. }
  524. }, this.viewed && L(t, m) ? (X(t, k, o, {once: !0}), this.zoomTo(0, !1, null, null, !0)) : o()) : i())), this
  525. }, view: function () {
  526. var i = this,
  527. t = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : this.options.initialViewIndex,
  528. t = Number(t) || 0;
  529. if (!(this.hiding || this.played || t < 0 || t >= this.length || this.viewed && t === this.index)) {
  530. if (!this.isShown) return this.index = t, this.show();
  531. this.viewing && this.viewing.abort();
  532. var e, n, o, s = this.element, a = this.options, r = this.title, l = this.canvas, h = this.items[t],
  533. c = h.querySelector("img"), u = N(c, "originalUrl"), d = c.getAttribute("alt"),
  534. m = document.createElement("img");
  535. A(a.inheritedAttributes, function (t) {
  536. var e = c.getAttribute(t);
  537. null !== e && m.setAttribute(t, e)
  538. }), m.src = u, m.alt = d, I(a.view) && X(s, "view", a.view, {once: !0}), !1 === q(s, "view", {
  539. originalImage: this.images[t],
  540. index: t,
  541. image: m
  542. }) || !this.isShown || this.hiding || this.played || ((u = this.items[this.index]) && (M(u, f), u.removeAttribute("aria-selected")), R(h, f), h.setAttribute("aria-selected", !0), a.focus && h.focus(), this.image = m, this.viewed = !1, this.index = t, this.imageData = {}, R(m, p), a.loading && R(l, b), l.innerHTML = "", l.appendChild(m), this.renderList(), r.innerHTML = "", X(s, z, e = function () {
  543. var t = i.imageData, e = Array.isArray(a.title) ? a.title[1] : a.title;
  544. r.innerHTML = T(e = I(e) ? e.call(i, m, t) : "".concat(d, " (").concat(t.naturalWidth, " × ").concat(t.naturalHeight, ")")) ? e.replace(/&(?!amp;|quot;|#39;|lt;|gt;)/g, "&amp;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/</g, "&lt;").replace(/>/g, "&gt;") : e
  545. }, {once: !0}), this.viewing = {
  546. abort: function () {
  547. Y(s, z, e), m.complete ? i.imageRendering ? i.imageRendering.abort() : i.imageInitializing && i.imageInitializing.abort() : (m.src = "", Y(m, y, n), i.timeout && clearTimeout(i.timeout))
  548. }
  549. }, m.complete ? this.load() : (X(m, y, n = function () {
  550. Y(m, x, o), i.load()
  551. }, {once: !0}), X(m, x, o = function () {
  552. Y(m, y, n), i.timeout && (clearTimeout(i.timeout), i.timeout = !1), M(m, p), a.loading && M(i.canvas, b)
  553. }, {once: !0}), this.timeout && clearTimeout(this.timeout), this.timeout = setTimeout(function () {
  554. M(m, p), i.timeout = !1
  555. }, 1e3)))
  556. }
  557. return this
  558. }, prev: function () {
  559. var t = this.index - 1;
  560. return t < 0 && (t = 0 < arguments.length && void 0 !== arguments[0] && arguments[0] ? this.length - 1 : 0), this.view(t), this
  561. }, next: function () {
  562. var t = this.length - 1, e = this.index + 1;
  563. return this.view(e = t < e ? 0 < arguments.length && void 0 !== arguments[0] && arguments[0] ? 0 : t : e), this
  564. }, move: function (t) {
  565. var e = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : t, i = this.imageData;
  566. return this.moveTo(D(t) ? t : i.x + Number(t), D(e) ? e : i.y + Number(e)), this
  567. }, moveTo: function (t) {
  568. var e = this, i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : t,
  569. n = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : null, o = this.element,
  570. s = this.options, a = this.imageData;
  571. if (t = Number(t), i = Number(i), this.viewed && !this.played && s.movable) {
  572. var r = a.x, l = a.y, h = !1;
  573. if (E(t) ? h = !0 : t = r, E(i) ? h = !0 : i = l, h) {
  574. if (I(s.move) && X(o, "move", s.move, {once: !0}), !1 === q(o, "move", {
  575. x: t,
  576. y: i,
  577. oldX: r,
  578. oldY: l,
  579. originalEvent: n
  580. })) return this;
  581. a.x = t, a.y = i, a.left = t, a.top = i, this.moving = !0, this.renderImage(function () {
  582. e.moving = !1, I(s.moved) && X(o, "moved", s.moved, {once: !0}), q(o, "moved", {
  583. x: t,
  584. y: i,
  585. oldX: r,
  586. oldY: l,
  587. originalEvent: n
  588. }, {cancelable: !1})
  589. })
  590. }
  591. }
  592. return this
  593. }, rotate: function (t) {
  594. return this.rotateTo((this.imageData.rotate || 0) + Number(t)), this
  595. }, rotateTo: function (t) {
  596. var e = this, i = this.element, n = this.options, o = this.imageData;
  597. if (E(t = Number(t)) && this.viewed && !this.played && n.rotatable) {
  598. var s = o.rotate;
  599. if (I(n.rotate) && X(i, "rotate", n.rotate, {once: !0}), !1 === q(i, "rotate", {
  600. degree: t,
  601. oldDegree: s
  602. })) return this;
  603. o.rotate = t, this.rotating = !0, this.renderImage(function () {
  604. e.rotating = !1, I(n.rotated) && X(i, lt, n.rotated, {once: !0}), q(i, lt, {
  605. degree: t,
  606. oldDegree: s
  607. }, {cancelable: !1})
  608. })
  609. }
  610. return this
  611. }, scaleX: function (t) {
  612. return this.scale(t, this.imageData.scaleY), this
  613. }, scaleY: function (t) {
  614. return this.scale(this.imageData.scaleX, t), this
  615. }, scale: function (t) {
  616. var e = this, i = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : t, n = this.element,
  617. o = this.options, s = this.imageData;
  618. if (t = Number(t), i = Number(i), this.viewed && !this.played && o.scalable) {
  619. var a = s.scaleX, r = s.scaleY, l = !1;
  620. if (E(t) ? l = !0 : t = a, E(i) ? l = !0 : i = r, l) {
  621. if (I(o.scale) && X(n, "scale", o.scale, {once: !0}), !1 === q(n, "scale", {
  622. scaleX: t,
  623. scaleY: i,
  624. oldScaleX: a,
  625. oldScaleY: r
  626. })) return this;
  627. s.scaleX = t, s.scaleY = i, this.scaling = !0, this.renderImage(function () {
  628. e.scaling = !1, I(o.scaled) && X(n, "scaled", o.scaled, {once: !0}), q(n, "scaled", {
  629. scaleX: t,
  630. scaleY: i,
  631. oldScaleX: a,
  632. oldScaleY: r
  633. }, {cancelable: !1})
  634. })
  635. }
  636. }
  637. return this
  638. }, zoom: function (t) {
  639. var e = 1 < arguments.length && void 0 !== arguments[1] && arguments[1],
  640. i = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : null,
  641. n = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null, o = this.imageData;
  642. return t = Number(t), this.zoomTo(o.width * (t = t < 0 ? 1 / (1 - t) : 1 + t) / o.naturalWidth, e, i, n), this
  643. }, zoomTo: function (t) {
  644. var i, n, o, e = this, s = 1 < arguments.length && void 0 !== arguments[1] && arguments[1],
  645. a = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : null,
  646. r = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null,
  647. l = 4 < arguments.length && void 0 !== arguments[4] && arguments[4], h = this.element, c = this.options,
  648. u = this.pointers, d = this.imageData, m = d.x, g = d.y, f = d.width, v = d.height, p = d.naturalWidth,
  649. b = d.naturalHeight;
  650. if (E(t = Math.max(0, t)) && this.viewed && !this.played && (l || c.zoomable)) {
  651. if (l || (l = Math.max(.01, c.minZoomRatio), y = Math.min(100, c.maxZoomRatio), t = Math.min(Math.max(t, l), y)), r) switch (r.type) {
  652. case"wheel":
  653. .055 <= c.zoomRatio && .95 < t && t < 1.05 && (t = 1);
  654. break;
  655. case"pointermove":
  656. case"touchmove":
  657. case"mousemove":
  658. .99 < t && t < 1.01 && (t = 1)
  659. }
  660. var w, l = p * t, y = b * t, p = l - f, b = y - v, x = d.ratio;
  661. if (I(c.zoom) && X(h, "zoom", c.zoom, {once: !0}), !1 === q(h, "zoom", {
  662. ratio: t,
  663. oldRatio: x,
  664. originalEvent: r
  665. })) return this;
  666. this.zooming = !0, r ? (w = {
  667. left: (w = (w = this.viewer).getBoundingClientRect()).left + (window.pageXOffset - document.documentElement.clientLeft),
  668. top: w.top + (window.pageYOffset - document.documentElement.clientTop)
  669. }, u = u && 0 < Object.keys(u).length ? (o = n = i = 0, A(u, function (t) {
  670. var e = t.startX;
  671. i += e, n += t.startY, o += 1
  672. }), {pageX: i /= o, pageY: n /= o}) : {
  673. pageX: r.pageX,
  674. pageY: r.pageY
  675. }, d.x -= (u.pageX - w.left - m) / f * p, d.y -= (u.pageY - w.top - g) / v * b) : S(a) && E(a.x) && E(a.y) ? (d.x -= p * ((a.x - m) / f), d.y -= b * ((a.y - g) / v)) : (d.x -= p / 2, d.y -= b / 2), d.left = d.x, d.top = d.y, d.width = l, d.height = y, d.oldRatio = x, d.ratio = t, this.renderImage(function () {
  676. e.zooming = !1, I(c.zoomed) && X(h, "zoomed", c.zoomed, {once: !0}), q(h, "zoomed", {
  677. ratio: t,
  678. oldRatio: x,
  679. originalEvent: r
  680. }, {cancelable: !1})
  681. }), s && this.tooltip()
  682. }
  683. return this
  684. }, play: function () {
  685. var t, o, s, a, r, l, h, e, i, n = this,
  686. c = 0 < arguments.length && void 0 !== arguments[0] && arguments[0];
  687. return this.isShown && !this.played && (t = this.element, I((o = this.options).play) && X(t, "play", o.play, {once: !0}), !1 !== q(t, "play") && (s = this.player, a = this.loadImage.bind(this), r = [], h = l = 0, this.played = !0, this.onLoadWhenPlay = a, c && this.requestFullscreen(c), R(s, d), A(this.items, function (t, e) {
  688. var i = t.querySelector("img"), n = document.createElement("img");
  689. n.src = N(i, "originalUrl"), n.alt = i.getAttribute("alt"), n.referrerPolicy = i.referrerPolicy, l += 1, R(n, B), F(n, m, o.transition), L(t, f) && (R(n, u), h = e), r.push(n), X(n, y, a, {once: !0}), s.appendChild(n)
  690. }), E(o.interval)) && 0 < o.interval && (e = function () {
  691. clearTimeout(n.playing.timeout), M(r[h], u), R(r[h = 0 <= --h ? h : l - 1], u), n.playing.timeout = setTimeout(e, o.interval)
  692. }, i = function () {
  693. clearTimeout(n.playing.timeout), M(r[h], u), R(r[h = (h += 1) < l ? h : 0], u), n.playing.timeout = setTimeout(i, o.interval)
  694. }, 1 < l)) && (this.playing = {prev: e, next: i, timeout: setTimeout(i, o.interval)}), this
  695. }, stop: function () {
  696. var t, e, i = this;
  697. return this.played && (t = this.element, I((e = this.options).stop) && X(t, "stop", e.stop, {once: !0}), !1 !== q(t, "stop")) && (e = this.player, clearTimeout(this.playing.timeout), this.playing = !1, this.played = !1, A(e.getElementsByTagName("img"), function (t) {
  698. Y(t, y, i.onLoadWhenPlay)
  699. }), M(e, d), e.innerHTML = "", this.exitFullscreen()), this
  700. }, full: function () {
  701. var t = this, e = this.options, i = this.viewer, n = this.image, o = this.list;
  702. return this.isShown && !this.played && !this.fulled && e.inline && (this.fulled = !0, this.open(), R(this.button, K), e.transition && (M(o, m), this.viewed) && M(n, m), R(i, V), i.setAttribute("role", "dialog"), i.setAttribute("aria-labelledby", this.title.id), i.setAttribute("aria-modal", !0), i.removeAttribute("style"), C(i, {zIndex: e.zIndex}), e.focus && this.enforceFocus(), this.initContainer(), this.viewerData = O({}, this.containerData), this.renderList(), this.viewed) && this.initImage(function () {
  703. t.renderImage(function () {
  704. e.transition && setTimeout(function () {
  705. R(n, m), R(o, m)
  706. }, 0)
  707. })
  708. }), this
  709. }, exit: function () {
  710. var t = this, e = this.options, i = this.viewer, n = this.image, o = this.list;
  711. return this.isShown && !this.played && this.fulled && e.inline && (this.fulled = !1, this.close(), M(this.button, K), e.transition && (M(o, m), this.viewed) && M(n, m), e.focus && this.clearEnforceFocus(), i.removeAttribute("role"), i.removeAttribute("aria-labelledby"), i.removeAttribute("aria-modal"), M(i, V), C(i, {zIndex: e.zIndexInline}), this.viewerData = O({}, this.parentData), this.renderViewer(), this.renderList(), this.viewed) && this.initImage(function () {
  712. t.renderImage(function () {
  713. e.transition && setTimeout(function () {
  714. R(n, m), R(o, m)
  715. }, 0)
  716. })
  717. }), this
  718. }, tooltip: function () {
  719. var t = this, e = this.options, i = this.tooltipBox, n = this.imageData;
  720. return this.viewed && !this.played && e.tooltip && (i.textContent = "".concat(Math.round(100 * n.ratio), "%"), this.tooltipping ? clearTimeout(this.tooltipping) : e.transition ? (this.fading && q(i, k), R(i, d), R(i, B), R(i, m), i.removeAttribute("aria-hidden"), i.initialOffsetWidth = i.offsetWidth, R(i, u)) : (R(i, d), i.removeAttribute("aria-hidden")), this.tooltipping = setTimeout(function () {
  721. e.transition ? (X(i, k, function () {
  722. M(i, d), M(i, B), M(i, m), i.setAttribute("aria-hidden", !0), t.fading = !1
  723. }, {once: !0}), M(i, u), t.fading = !0) : (M(i, d), i.setAttribute("aria-hidden", !0)), t.tooltipping = !1
  724. }, 1e3)), this
  725. }, toggle: function () {
  726. var t = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : null;
  727. return 1 === this.imageData.ratio ? this.zoomTo(this.imageData.oldRatio, !0, null, t) : this.zoomTo(1, !0, null, t), this
  728. }, reset: function () {
  729. return this.viewed && !this.played && (this.imageData = O({}, this.initialImageData), this.renderImage()), this
  730. }, update: function () {
  731. var n, o, e = this, t = this.element, i = this.options, s = this.isImg;
  732. return s && !t.parentNode ? this.destroy() : (n = [], A(s ? [t] : t.querySelectorAll("img"), function (t) {
  733. I(i.filter) ? i.filter.call(e, t) && n.push(t) : e.getImageURL(t) && n.push(t)
  734. }), n.length && (this.images = n, this.length = n.length, this.ready ? (o = [], A(this.items, function (t, e) {
  735. var t = t.querySelector("img"), i = n[e];
  736. i && t && i.src === t.src && i.alt === t.alt || o.push(e)
  737. }), C(this.list, {width: "auto"}), this.initList(), this.isShown && (this.length ? this.viewed && (0 <= (s = o.indexOf(this.index)) ? (this.viewed = !1, this.view(Math.max(Math.min(this.index - s, this.length - 1), 0))) : (R(t = this.items[this.index], f), t.setAttribute("aria-selected", !0))) : (this.image = null, this.viewed = !1, this.index = 0, this.imageData = {}, this.canvas.innerHTML = "", this.title.innerHTML = ""))) : this.build()), this)
  738. }, destroy: function () {
  739. var t = this.element, e = this.options;
  740. return t[g] && (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 || Y(t, w, this.onStart), t[g] = void 0), this
  741. }
  742. }, At = {
  743. getImageURL: function (t) {
  744. var e = this.options.url;
  745. return e = T(e) ? t.getAttribute(e) : I(e) ? e.call(this, t) : ""
  746. }, enforceFocus: function () {
  747. var n = this;
  748. this.clearEnforceFocus(), X(document, et, this.onFocusin = function (t) {
  749. var e = n.viewer, i = t.target;
  750. if (i !== document && i !== e && !e.contains(i)) {
  751. for (; i;) {
  752. if (null !== i.getAttribute("tabindex") || "true" === i.getAttribute("aria-modal")) return;
  753. i = i.parentElement
  754. }
  755. e.focus()
  756. }
  757. })
  758. }, clearEnforceFocus: function () {
  759. this.onFocusin && (Y(document, et, this.onFocusin), this.onFocusin = null)
  760. }, open: function () {
  761. var t = this.body;
  762. R(t, J), 0 < this.scrollbarWidth && (t.style.paddingRight = "".concat(this.scrollbarWidth + (parseFloat(this.initialBodyComputedPaddingRight) || 0), "px"))
  763. }, close: function () {
  764. var t = this.body;
  765. M(t, J), 0 < this.scrollbarWidth && (t.style.paddingRight = this.initialBodyPaddingRight)
  766. }, shown: function () {
  767. var t = this.element, e = this.options, i = this.viewer;
  768. this.fulled = !0, this.isShown = !0, this.render(), this.bind(), this.showing = !1, e.focus && (i.focus(), this.enforceFocus()), I(e.shown) && X(t, "shown", e.shown, {once: !0}), !1 !== q(t, "shown") && this.ready && this.isShown && !this.hiding && this.view(this.index)
  769. }, hidden: function () {
  770. var t = this.element, e = this.options, i = this.viewer;
  771. e.fucus && this.clearEnforceFocus(), this.close(), this.unbind(), R(i, v), i.removeAttribute("role"), i.removeAttribute("aria-labelledby"), i.removeAttribute("aria-modal"), i.setAttribute("aria-hidden", !0), this.resetList(), this.resetImage(), this.fulled = !1, this.viewed = !1, this.isShown = !1, this.hiding = !1, this.destroyed || (I(e.hidden) && X(t, "hidden", e.hidden, {once: !0}), q(t, "hidden", null, {cancelable: !1}))
  772. }, requestFullscreen: function (t) {
  773. var e = this.element.ownerDocument;
  774. this.fulled && !(e.fullscreenElement || e.webkitFullscreenElement || e.mozFullScreenElement || e.msFullscreenElement) && ((e = e.documentElement).requestFullscreen ? S(t) ? e.requestFullscreen(t) : e.requestFullscreen() : e.webkitRequestFullscreen ? e.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT) : e.mozRequestFullScreen ? e.mozRequestFullScreen() : e.msRequestFullscreen && e.msRequestFullscreen())
  775. }, exitFullscreen: function () {
  776. var t = this.element.ownerDocument;
  777. 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())
  778. }, change: function (t) {
  779. var e = this.options, i = this.pointers, n = i[Object.keys(i)[0]];
  780. if (n) {
  781. var s, a, o = n.endX - n.startX, r = n.endY - n.startY;
  782. switch (this.action) {
  783. case h:
  784. 0 == o && 0 == r || (this.pointerMoved = !0, this.move(o, r, t));
  785. break;
  786. case c:
  787. this.zoom((s = P({}, l = i), a = [], A(l, function (o, t) {
  788. delete s[t], A(s, function (t) {
  789. var e = Math.abs(o.startX - t.startX), i = Math.abs(o.startY - t.startY),
  790. n = Math.abs(o.endX - t.endX), t = Math.abs(o.endY - t.endY),
  791. e = Math.sqrt(e * e + i * i), i = Math.sqrt(n * n + t * t);
  792. a.push((i - e) / e)
  793. })
  794. }), a.sort(function (t, e) {
  795. return Math.abs(t) < Math.abs(e)
  796. }), a[0]), !1, null, t);
  797. break;
  798. case j:
  799. this.action = "switched";
  800. var l = Math.abs(o);
  801. 1 < l && l > Math.abs(r) && (this.pointers = {}, 1 < o ? this.prev(e.loop) : o < -1 && this.next(e.loop))
  802. }
  803. A(i, function (t) {
  804. t.startX = t.endX, t.startY = t.endY
  805. })
  806. }
  807. }, isSwitchable: function () {
  808. var t = this.imageData, e = this.viewerData;
  809. return 1 < this.length && 0 <= t.x && 0 <= t.y && t.width <= e.width && t.height <= e.height
  810. }
  811. }, Ot = e.Viewer, Ct = (Dt = -1, function () {
  812. return Dt += 1
  813. }), e = (() => {
  814. function o(t) {
  815. var e = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : {}, i = this, n = o;
  816. if (!(i instanceof n)) throw new TypeError("Cannot call a class as a function");
  817. if (!t || 1 !== t.nodeType) throw new Error("The first argument is required and must be an element.");
  818. this.element = t, this.options = O({}, W, S(e) && e), 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.pointerMoved = !1, this.id = Ct(), this.init()
  819. }
  820. return t = o, i = [{
  821. key: "noConflict", value: function () {
  822. return window.Viewer = Ot, o
  823. }
  824. }, {
  825. key: "setDefaults", value: function (t) {
  826. O(W, S(t) && t)
  827. }
  828. }], (e = [{
  829. key: "init", value: function () {
  830. var t, e, i, n, o = this, s = this.element, a = this.options;
  831. s[g] || (s[g] = this, a.focus && !a.keyboard && (a.focus = !1), e = [], A((t = "img" === s.localName) ? [s] : s.querySelectorAll("img"), function (t) {
  832. I(a.filter) ? a.filter.call(o, t) && e.push(t) : o.getImageURL(t) && e.push(t)
  833. }), this.isImg = t, this.length = e.length, this.images = e, this.initBody(), D(document.createElement(g).style.transition) && (a.transition = !1), a.inline ? (i = 0, n = function () {
  834. var t;
  835. (i += 1) === o.length && (o.initializing = !1, o.delaying = {
  836. abort: function () {
  837. clearTimeout(t)
  838. }
  839. }, t = setTimeout(function () {
  840. o.delaying = !1, o.build()
  841. }, 0))
  842. }, this.initializing = {
  843. abort: function () {
  844. A(e, function (t) {
  845. t.complete || (Y(t, y, n), Y(t, x, n))
  846. })
  847. }
  848. }, A(e, function (t) {
  849. var e, i;
  850. t.complete ? n() : (X(t, y, e = function () {
  851. Y(t, x, i), n()
  852. }, {once: !0}), X(t, x, i = function () {
  853. Y(t, y, e), n()
  854. }, {once: !0}))
  855. })) : X(s, w, this.onStart = function (t) {
  856. t = t.target;
  857. "img" !== t.localName || I(a.filter) && !a.filter.call(o, t) || o.view(o.images.indexOf(t))
  858. }))
  859. }
  860. }, {
  861. key: "build", value: function () {
  862. var t, s, e, i, n, o, a, r, l, h, c, u, d, m;
  863. this.ready || (t = this.element, s = this.options, e = t.parentNode, (d = document.createElement("div")).innerHTML = '<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>', d = (i = d.querySelector(".".concat(g, "-container"))).querySelector(".".concat(g, "-title")), n = i.querySelector(".".concat(g, "-toolbar")), m = i.querySelector(".".concat(g, "-navbar")), o = i.querySelector(".".concat(g, "-button")), a = i.querySelector(".".concat(g, "-canvas")), this.parent = e, this.viewer = i, this.title = d, this.toolbar = n, this.navbar = m, this.button = o, this.canvas = a, this.footer = i.querySelector(".".concat(g, "-footer")), this.tooltipBox = i.querySelector(".".concat(g, "-tooltip")), this.player = i.querySelector(".".concat(g, "-player")), this.list = i.querySelector(".".concat(g, "-list")), i.id = "".concat(g).concat(this.id), d.id = "".concat(g, "Title").concat(this.id), R(d, s.title ? Tt(Array.isArray(s.title) ? s.title[0] : s.title) : v), R(m, s.navbar ? Tt(s.navbar) : v), F(o, v, !s.button), s.keyboard && o.setAttribute("tabindex", 0), s.backdrop && (R(i, "".concat(g, "-backdrop")), s.inline || "static" === s.backdrop || pt(a, ht, "hide")), T(s.className) && s.className && s.className.split(ct).forEach(function (t) {
  864. R(i, t)
  865. }), s.toolbar ? (r = document.createElement("ul"), l = S(s.toolbar), h = ut.slice(0, 3), c = ut.slice(7, 9), u = ut.slice(9), l || R(n, Tt(s.toolbar)), A(l ? s.toolbar : ut, function (t, e) {
  866. var i, n = l && S(t), e = l ? vt(e) : t, o = n && !D(t.show) ? t.show : t;
  867. !o || !s.zoomable && -1 !== h.indexOf(e) || !s.rotatable && -1 !== c.indexOf(e) || !s.scalable && -1 !== u.indexOf(e) || (i = n && !D(t.size) ? t.size : t, n = n && !D(t.click) ? t.click : t, t = document.createElement("li"), s.keyboard && t.setAttribute("tabindex", 0), t.setAttribute("role", "button"), R(t, "".concat(g, "-").concat(e)), I(n) || pt(t, ht, e), E(o) && R(t, Tt(o)), -1 !== ["small", "large"].indexOf(i) ? R(t, "".concat(g, "-").concat(i)) : "play" === e && R(t, "".concat(g, "-large")), I(n) && X(t, w, n), r.appendChild(t))
  868. }), n.appendChild(r)) : R(n, v), s.rotatable || (R(d = n.querySelectorAll('li[class*="rotate"]'), p), A(d, function (t) {
  869. n.appendChild(t)
  870. })), s.inline ? (R(o, U), C(i, {zIndex: s.zIndexInline}), "static" === window.getComputedStyle(e).position && C(e, {position: "relative"}), e.insertBefore(i, t.nextSibling)) : (R(o, H), R(i, V), R(i, B), R(i, v), C(i, {zIndex: s.zIndex}), (m = (m = T(m = s.container) ? t.ownerDocument.querySelector(m) : m) || this.body).appendChild(i)), s.inline && (this.render(), this.bind(), this.isShown = !0), this.ready = !0, I(s.ready) && X(t, "ready", s.ready, {once: !0}), !1 === q(t, "ready") ? this.ready = !1 : this.ready && s.inline && this.view(this.index))
  871. }
  872. }]) && n(t.prototype, e), i && n(t, i), Object.defineProperty(t, "prototype", {writable: !1}), t;
  873. var t, e, i
  874. })();
  875. return O(e.prototype, i, t, St, It, At), e
  876. });