zoomora 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,53 +1,35 @@
1
1
  (function(t, e) {
2
2
  "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).Zoomora = e();
3
3
  })(this, function() {
4
- var t = (t, e, s) => () => {
5
- if (s) throw s[0];
6
- try {
7
- return t && (e = t(t = 0)), e;
8
- } catch (t) {
9
- throw s = [t], t;
10
- }
11
- }, e = (t, e) => () => (e || (t((e = { exports: {} }).exports, e), t = null), e.exports), s = t(() => {});
12
- function o(t) {
13
- return o = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
4
+ function t(e) {
5
+ return t = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
14
6
  return typeof t;
15
7
  } : function(t) {
16
8
  return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
17
- }, o(t);
9
+ }, t(e);
18
10
  }
19
- var i = t(() => {});
20
- var n = t(() => {
21
- i();
22
- });
23
- function a(t) {
24
- var e = function(t, e) {
25
- if ("object" != o(t) || !t) return t;
26
- var s = t[Symbol.toPrimitive];
27
- if (void 0 !== s) {
28
- var i = s.call(t, e || "default");
29
- if ("object" != o(i)) return i;
11
+ function e(e) {
12
+ var s = function(e, s) {
13
+ if ("object" != t(e) || !e) return e;
14
+ var o = e[Symbol.toPrimitive];
15
+ if (void 0 !== o) {
16
+ var i = o.call(e, s || "default");
17
+ if ("object" != t(i)) return i;
30
18
  throw new TypeError("@@toPrimitive must return a primitive value.");
31
19
  }
32
- return ("string" === e ? String : Number)(t);
33
- }(t, "string");
34
- return "symbol" == o(e) ? e : e + "";
20
+ return ("string" === s ? String : Number)(e);
21
+ }(e, "string");
22
+ return "symbol" == t(s) ? s : s + "";
35
23
  }
36
- var r = t(() => {
37
- i(), n();
38
- });
39
- function l(t, e, s) {
40
- return (e = a(e)) in t ? Object.defineProperty(t, e, {
41
- value: s,
24
+ function s(t, s, o) {
25
+ return (s = e(s)) in t ? Object.defineProperty(t, s, {
26
+ value: o,
42
27
  enumerable: !0,
43
28
  configurable: !0,
44
29
  writable: !0
45
- }) : t[e] = s, t;
30
+ }) : t[s] = o, t;
46
31
  }
47
- var h = t(() => {
48
- r();
49
- });
50
- function c(t, e) {
32
+ function o(t, e) {
51
33
  var s = Object.keys(t);
52
34
  if (Object.getOwnPropertySymbols) {
53
35
  var o = Object.getOwnPropertySymbols(t);
@@ -57,498 +39,501 @@
57
39
  }
58
40
  return s;
59
41
  }
60
- function d(t) {
42
+ function i(t) {
61
43
  for (var e = 1; e < arguments.length; e++) {
62
- var s = null != arguments[e] ? arguments[e] : {};
63
- e % 2 ? c(Object(s), !0).forEach(function(e) {
64
- l(t, e, s[e]);
65
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(s)) : c(Object(s)).forEach(function(e) {
66
- Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(s, e));
44
+ var i = null != arguments[e] ? arguments[e] : {};
45
+ e % 2 ? o(Object(i), !0).forEach(function(e) {
46
+ s(t, e, i[e]);
47
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(i)) : o(Object(i)).forEach(function(e) {
48
+ Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(i, e));
67
49
  });
68
50
  }
69
51
  return t;
70
52
  }
71
- var u = t(() => {
72
- h();
73
- });
74
- return e((t, e) => {
75
- s(), u(), function(t, s) {
76
- "use strict";
77
- /*!
78
- * Zoomora Lightbox Plugin v1.3.0
79
- * A modern, responsive lightbox plugin with zoom, fullscreen, and gallery features
80
- *
81
- * Copyright (c) 2026 Faruk Ahmed (FrontTheme)
82
- * Licensed under MIT License
83
- */
84
- "object" == typeof e && "object" == typeof e.exports ? e.exports = s() : "function" == typeof define && define.amd ? define(s) : t.Zoomora = s();
85
- }("undefined" != typeof window ? window : t, function() {
86
- "use strict";
87
- class t {
88
- static get defaults() {
89
- return {
90
- selector: "[data-zoomora]",
91
- showCounter: !0,
92
- showThumbnails: !0,
93
- showFullscreen: !0,
94
- showZoom: !0,
95
- transition: "fade",
96
- useHref: !1,
97
- maxZoomScale: 3,
98
- zoomStep: .1,
99
- animationDuration: 300,
100
- closeOnBackgroundClick: !0,
101
- onOpen: null,
102
- onClose: null,
103
- onNext: null,
104
- onPrev: null,
105
- showAutoHideToggle: !0,
106
- autoHideDelay: 3e3,
107
- autoHideEnabled: !1
108
- };
109
- }
110
- constructor(e = {}) {
111
- this.options = d(d({}, t.defaults), e), this.currentIndex = 0, this.items = [], this.isZoomed = !1, this.isFullscreen = !1, this.isDragging = !1, this.thumbnailsVisible = !0, this.startX = 0, this.startY = 0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.isInitialized = !1, this.eventListeners = /* @__PURE__ */ new Map(), this.autoHideEnabled = !1, this.autoHideTimeout = null, this.autoHideDelay = 3e3, this.isControlsVisible = !0, this.lastDragTime = 0, this.boundMethods = {
112
- handleDocumentClick: this.handleDocumentClick.bind(this),
113
- handleKeydown: this.handleKeydown.bind(this),
114
- handleFullscreenChange: this.handleFullscreenChange.bind(this),
115
- handleZoomoraClick: this.handleZoomoraClick.bind(this),
116
- handleContentClick: this.handleContentClick.bind(this),
117
- handleMouseDown: this.handleMouseDown.bind(this),
118
- handleMouseMove: this.handleMouseMove.bind(this),
119
- handleMouseUp: this.handleMouseUp.bind(this),
120
- handleTouchStart: this.handleTouchStart.bind(this),
121
- handleTouchMove: this.handleTouchMove.bind(this),
122
- handleTouchEnd: this.handleTouchEnd.bind(this),
123
- handleWheel: this.handleWheel.bind(this)
124
- }, this.init();
125
- }
126
- init() {
127
- if (!this.isInitialized) try {
128
- this.createLightbox(), this.bindEvents(), this.isInitialized = !0;
129
- } catch (t) {}
130
- }
131
- static bind(e, s = {}) {
132
- return new t(d(d({}, s), {}, {
133
- selector: e,
134
- useHref: !0
135
- }));
136
- }
137
- createLightbox() {
138
- if (document.getElementById("zoomoraLightbox")) return;
139
- const t = this.options.showAutoHideToggle ? "\n <button class=\"zoomora-btn\" id=\"zoomoraAutoHideBtn\" title=\"Toggle Auto-Hide Controls\">\n <i class=\"zoomorai-controls-off\"></i>\n </button>\n " : "", e = `\n <div class="zoomora" id="zoomoraLightbox">\n <div class="zoomora-container">\n <div class="zoomora-header" id="zoomoraHeader">\n <div class="zoomora-counter" id="zoomoraCounter" ${this.options.showCounter ? "" : "style=\"opacity:0;visibility:hidden;\""}>1 / 1</div>\n <div class="zoomora-controls">\n ${this.options.showThumbnails ? "\n <button class=\"zoomora-btn\" id=\"zoomoraThumbnailBtn\" title=\"Toggle Thumbnails\">\n <i class=\"zoomorai-thumbnails\"></i>\n </button>\n " : ""}\n ${t}\n ${this.options.showZoom ? "\n <button class=\"zoomora-btn\" id=\"zoomoraZoomBtn\" title=\"Zoom\">\n <i class=\"zoomorai-zoom\"></i>\n </button>\n " : ""}\n ${this.options.showFullscreen ? "\n <button class=\"zoomora-btn\" id=\"zoomoraFullscreenBtn\" title=\"Fullscreen\">\n <i class=\"zoomorai-expand\"></i>\n </button>\n <button class=\"zoomora-btn\" id=\"zoomoraCollapseBtn\" title=\"Exit Fullscreen\" style=\"display: none;\">\n <i class=\"zoomorai-collapse\"></i>\n </button>\n " : ""}\n <button class="zoomora-btn" id="zoomoraCloseBtn" title="Close">\n <i class="zoomorai-close"></i>\n </button>\n </div>\n </div>\n \n <div class="zoomora-content" id="zoomoraContent">\n <div class="zoomora-loading" id="zoomoraLoading"></div>\n <div class="zoomora-slides-container" id="zoomoraSlidesContainer"></div>\n </div>\n \n <button class="zoomora-nav prev" id="zoomoraPrevBtn">\n <i class="zoomorai-arrow-left"></i>\n </button>\n <button class="zoomora-nav next" id="zoomoraNextBtn">\n <i class="zoomorai-arrow-right"></i>\n </button>\n \n <div class="zoomora-caption" id="zoomoraCaption" ${this.options.showThumbnails ? "" : "style=\"bottom:20px;\""}></div>\n <div class="zoomora-thumbnails" id="zoomoraThumbs" ${this.options.showThumbnails ? "" : "style=\"display:none;\""}></div>\n </div>\n </div>\n `;
140
- if (document.body.insertAdjacentHTML("beforeend", e), this.zoomora = document.getElementById("zoomoraLightbox"), this.header = document.getElementById("zoomoraHeader"), this.content = document.getElementById("zoomoraContent"), this.slidesContainer = document.getElementById("zoomoraSlidesContainer"), this.counter = document.getElementById("zoomoraCounter"), this.thumbs = document.getElementById("zoomoraThumbs"), this.loading = document.getElementById("zoomoraLoading"), this.caption = document.getElementById("zoomoraCaption"), this.prevBtn = document.getElementById("zoomoraPrevBtn"), this.nextBtn = document.getElementById("zoomoraNextBtn"), !(this.zoomora && this.content && this.counter && this.thumbs && this.loading && this.caption)) throw new Error("Failed to create required DOM elements");
141
- }
142
- bindEvents() {
143
- this.addEventListener(document, "click", this.boundMethods.handleDocumentClick), this.addEventListener(document.getElementById("zoomoraCloseBtn"), "click", () => this.close()), this.addEventListener(document.getElementById("zoomoraPrevBtn"), "click", () => this.prev()), this.addEventListener(document.getElementById("zoomoraNextBtn"), "click", () => this.next()), this.options.showZoom && this.addEventListener(document.getElementById("zoomoraZoomBtn"), "click", () => this.toggleZoom()), this.options.showFullscreen && (this.addEventListener(document.getElementById("zoomoraFullscreenBtn"), "click", () => this.toggleFullscreen()), this.addEventListener(document.getElementById("zoomoraCollapseBtn"), "click", () => this.exitFullscreen())), this.options.showThumbnails && this.addEventListener(document.getElementById("zoomoraThumbnailBtn"), "click", () => this.toggleThumbnails()), this.addEventListener(document, "fullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "webkitfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "mozfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "MSFullscreenChange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "keydown", this.boundMethods.handleKeydown), this.addEventListener(this.zoomora, "click", this.boundMethods.handleZoomoraClick), this.addEventListener(this.content, "click", this.boundMethods.handleContentClick), this.addEventListener(this.content, "mousedown", this.boundMethods.handleMouseDown), this.addEventListener(this.content, "mousemove", this.boundMethods.handleMouseMove), this.addEventListener(this.content, "mouseup", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "mouseleave", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "touchstart", this.boundMethods.handleTouchStart, { passive: !1 }), this.addEventListener(this.content, "touchmove", this.boundMethods.handleTouchMove, { passive: !1 }), this.addEventListener(this.content, "touchend", this.boundMethods.handleTouchEnd), this.options.showZoom && this.addEventListener(this.content, "wheel", this.boundMethods.handleWheel, { passive: !1 }), this.options.showAutoHideToggle && (this.addEventListener(document.getElementById("zoomoraAutoHideBtn"), "click", () => this.toggleAutoHide()), this.addEventListener(this.zoomora, "mousemove", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "touchstart", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "keydown", () => this.handleUserActivity()));
144
- }
145
- addEventListener(t, e, s, o = {}) {
146
- if (!t) return;
147
- t.addEventListener(e, s, o);
148
- const i = `${t.constructor.name}_${e}`;
149
- this.eventListeners.has(i) || this.eventListeners.set(i, []), this.eventListeners.get(i).push({
150
- element: t,
151
- event: e,
152
- handler: s,
153
- options: o
154
- });
155
- }
156
- handleDocumentClick(t) {
157
- const e = t.target.closest(this.options.selector);
158
- e && (t.preventDefault(), this.open(e));
159
- }
160
- handleKeydown(t) {
161
- if (this.zoomora.classList.contains("active")) switch (t.key) {
162
- case "Escape":
163
- this.isFullscreen ? this.exitFullscreen() : this.close();
164
- break;
165
- case "ArrowLeft":
166
- this.prev();
167
- break;
168
- case "ArrowRight":
169
- this.next();
170
- break;
171
- case "z":
172
- case "Z":
173
- this.toggleZoom();
174
- break;
175
- case "f":
176
- case "F":
177
- this.toggleFullscreen();
178
- break;
179
- case "t":
180
- case "T": this.toggleThumbnails();
181
- }
182
- }
183
- handleFullscreenChange() {
184
- const t = !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
185
- !t && this.isFullscreen ? (this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : t && !this.isFullscreen && (this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons());
186
- }
187
- handleZoomoraClick(t) {
188
- t.target === this.zoomora && this.options.closeOnBackgroundClick && this.close();
189
- }
190
- handleContentClick(t) {
191
- if (Date.now() - this.lastDragTime < 200) return;
192
- if (this.header && this.header.contains(t.target)) return;
193
- if (t.target.closest("button")) return;
194
- const e = t.target.closest(".zoomora-media, .zoomora-video, .zoomora-iframe");
195
- if (e) return void (e.classList.contains("zoomora-media") && !e.classList.contains("no-zoom") && this.toggleZoom());
196
- if (t.target.closest(".zoomora-video-container")) {
197
- if (t.target.closest(".zoomora-play-button")) return;
198
- this.options.closeOnBackgroundClick && this.close();
199
- return;
200
- }
201
- const s = t.target;
202
- ((s.classList.contains("zoomora-content") || s.classList.contains("zoomora-slide-container") || s.classList.contains("zoomora-slide") || s.classList.contains("zoomora-slides-container") || "zoomoraContent" === s.id || "zoomoraSlidesContainer" === s.id) && this.options.closeOnBackgroundClick || this.options.closeOnBackgroundClick) && this.close();
203
- }
204
- handleMouseDown(t) {
205
- this.startDrag(t);
206
- }
207
- handleMouseMove(t) {
208
- this.drag(t);
209
- }
210
- handleMouseUp() {
211
- this.endDrag();
212
- }
213
- handleTouchStart(t) {
214
- this.startDrag(t);
215
- }
216
- handleTouchMove(t) {
217
- this.drag(t);
218
- }
219
- handleTouchEnd() {
220
- this.endDrag();
221
- }
222
- handleWheel(t) {
223
- const e = this.content.querySelector(".zoomora-media");
224
- if (!e || "IMG" !== e.tagName) return;
225
- const s = this.calculateZoomLevels(e);
226
- if (!s.canZoom) return;
227
- t.preventDefault();
228
- const o = s.levels[s.levels.length - 1], i = this.options.zoomStep || .1, n = t.deltaY < 0 ? 1 : -1;
229
- let a = (this.currentScale || 1) + n * i * o;
230
- if (a = Math.max(1, Math.min(o, a)), a === this.currentScale) return;
231
- this.currentScale = a, this.isZoomed = a > 1, this.currentX = 0, this.currentY = 0, this.isZoomed ? (e.style.transform = `scale(${a})`, e.style.cursor = "grab", e.classList.add("zoomed")) : (e.style.transform = "", e.style.cursor = "pointer", e.classList.remove("zoomed"));
232
- let r = 0;
233
- s.levels.forEach((t, e) => {
234
- Math.abs(t - a) < Math.abs(s.levels[r] - a) && (r = e);
235
- }), e.dataset.zoomLevel = r.toString();
236
- }
237
- getImageSource(t) {
238
- const e = t.dataset.src || t.src || t.getAttribute("src");
239
- return "video" === (t.dataset.type || "image") && e ? this.convertToEmbedUrl(e) : e;
240
- }
241
- convertToEmbedUrl(t) {
242
- if (t.includes("youtube.com/embed/")) return t;
243
- let e = null, s = null;
244
- if (t.includes("youtube.com/watch")) {
245
- const o = new URLSearchParams(t.split("?")[1]);
246
- e = o.get("v");
247
- const i = o.get("t");
248
- i && (s = i.replace("s", ""));
249
- } else if (t.includes("youtu.be/")) {
250
- const o = t.split("/"), i = o[o.length - 1];
251
- if (i.includes("?")) {
252
- e = i.split("?")[0];
253
- const t = new URLSearchParams(i.split("?")[1]).get("t");
254
- t && (s = t.replace("s", ""));
255
- } else e = i;
256
- }
257
- if (e) {
258
- let t = `https://www.youtube.com/embed/${e}`;
259
- const o = new URLSearchParams();
260
- return s && o.append("start", s), o.append("rel", "0"), o.append("modestbranding", "1"), o.toString() && (t += "?" + o.toString()), t;
261
- }
262
- return t;
263
- }
264
- getThumbnailSource(t) {
265
- return "video" === (t.dataset.type || "image") ? t.src || t.getAttribute("src") : t.dataset.src || t.src || t.getAttribute("src");
266
- }
267
- getGroup(t) {
268
- return this.options.useHref ? t.dataset.lightbox || t.dataset.gallery || "default" : t.dataset.zoomora || "default";
269
- }
270
- open(t) {
271
- if (!t) return;
272
- const e = this.getGroup(t);
273
- let s;
274
- s = this.options.useHref ? t.dataset.lightbox ? `[data-lightbox="${e}"]` : t.dataset.gallery ? `[data-gallery="${e}"]` : this.options.selector : `[data-zoomora="${e}"]`, this.items = Array.from(document.querySelectorAll(s)), this.currentIndex = Math.max(0, this.items.indexOf(t)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(t, this.currentIndex);
275
- }
276
- openImage(t, e = {}) {
277
- const s = Array.isArray(t) ? t : [t];
278
- this.items = s.map((t) => this.createVirtualItem("string" == typeof t ? { src: t } : t)), this.currentIndex = Math.max(0, Math.min(e.startIndex || 0, this.items.length - 1)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(this.items[this.currentIndex], this.currentIndex);
279
- }
280
- createVirtualItem({ src: t, thumb: e, type: s = "image", caption: o = "", alt: i = "" }) {
281
- const n = e || t;
282
- return {
283
- dataset: {
284
- src: t,
285
- type: s,
286
- caption: o
287
- },
288
- src: n,
289
- alt: i,
290
- title: o,
291
- getAttribute: (t) => "src" === t ? n : null
292
- };
293
- }
294
- _activateLightbox() {
295
- this.isZoomed = !1, this.isFullscreen = !1, this.thumbnailsVisible = !0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.zoomora.classList.add("active"), document.body.style.overflow = "hidden", this.loadContent(), this.updateThumbnails(), this.updateCounter(), this.updateNavigation(), this.updateCaption(), this.updateButtons(), this.autoHideEnabled ? this.startAutoHideTimer() : this.showControls();
296
- }
297
- close() {
298
- this.isFullscreen && this.exitFullscreen(), this.zoomora.classList.remove("active"), document.body.style.overflow = "", this.isZoomed = !1, this.isFullscreen = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1;
299
- const t = this.content.querySelector(".zoomora-media");
300
- t && (t.classList.remove("zoomed"), t.style.transform = "", t.style.cursor = ""), this.zoomora.classList.remove("fullscreen"), this.updateButtons(), this.stopAutoHideTimer(), this.showControls(), "function" == typeof this.options.onClose && this.options.onClose(this.currentIndex);
301
- }
302
- prev() {
303
- this.currentIndex > 0 && (this.currentIndex--, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onPrev && this.options.onPrev(this.currentIndex));
304
- }
305
- next() {
306
- this.currentIndex < this.items.length - 1 && (this.currentIndex++, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onNext && this.options.onNext(this.currentIndex));
307
- }
308
- loadContent() {
309
- if (!this.items[this.currentIndex]) return;
310
- const t = this.items[this.currentIndex], e = this.getImageSource(t), s = t.dataset.type || "image";
311
- e && (this.isZoomed = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.loading.style.display = "block", this.slidesContainer && (this.slidesContainer.innerHTML = ""), setTimeout(() => {
312
- this.renderContent(e, s, t);
313
- }, 100));
314
- }
315
- renderContent(t, e, s) {
316
- const o = document.createElement("div");
317
- o.className = "zoomora-slide-container";
318
- const i = document.createElement("div");
319
- let n;
320
- i.className = "zoomora-slide " + ("slide" === this.options.transition ? "slide-effect" : "fade-effect"), i.style.opacity = "0", i.style.transform = "slide" === this.options.transition ? "translateX(100%)" : "scale(0.8)";
321
- try {
322
- switch (e) {
323
- case "video":
324
- if (t.endsWith(".mp4") || t.endsWith(".webm") || t.endsWith(".ogg")) {
325
- const e = document.createElement("div");
326
- e.className = "zoomora-video-container", n = document.createElement("video"), n.src = t, n.className = "zoomora-video", n.setAttribute("preload", "metadata");
327
- const i = s.src || s.getAttribute("src");
328
- i && n.setAttribute("poster", i);
329
- const a = document.createElement("div");
330
- a.className = "zoomora-play-button", a.innerHTML = "<svg viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M8 5v14l11-7z\"/></svg>", a.addEventListener("click", () => {
331
- n.play(), a.style.display = "none", n.setAttribute("controls", "");
332
- }), n.addEventListener("ended", () => {
333
- a.style.display = "flex";
334
- }), e.appendChild(n), e.appendChild(a), o.appendChild(e);
335
- } else n = document.createElement("iframe"), n.src = t, n.className = "zoomora-video", n.setAttribute("allowfullscreen", ""), n.setAttribute("frameborder", "0"), o.appendChild(n);
336
- break;
337
- case "iframe":
338
- n = document.createElement("iframe"), n.src = t, n.className = "zoomora-iframe", n.setAttribute("frameborder", "0"), o.appendChild(n);
339
- break;
340
- default: n = document.createElement("img"), n.src = t, n.className = "zoomora-media", n.alt = s.alt || s.title || "", n.onload = () => {
341
- this.loading.style.display = "none", this.checkZoomability(n), this.animateSlideIn(i);
342
- }, n.onerror = () => {
343
- this.loading.style.display = "none", this.animateSlideIn(i);
344
- }, o.appendChild(n);
345
- }
346
- i.appendChild(o), this.slidesContainer.innerHTML = "", this.slidesContainer.appendChild(i), "image" !== e && (this.loading.style.display = "none", this.animateSlideIn(i));
347
- } catch (t) {
348
- this.loading.style.display = "none";
349
- }
350
- }
351
- animateSlideIn(t) {
352
- t.offsetHeight, t.classList.add("active"), "slide" === this.options.transition ? (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "translateX(0)", t.style.opacity = "1") : (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "scale(1)", t.style.opacity = "1");
353
- }
354
- toggleAutoHide() {
355
- this.autoHideEnabled = !this.autoHideEnabled;
356
- const t = document.getElementById("zoomoraAutoHideBtn");
357
- this.autoHideEnabled ? (t.classList.add("active"), t.title = "Disable Auto-Hide Controls", this.startAutoHideTimer()) : (t.classList.remove("active"), t.title = "Enable Auto-Hide Controls", this.stopAutoHideTimer(), this.showControls());
358
- }
359
- handleUserActivity() {
360
- this.autoHideEnabled && (this.showControls(), this.startAutoHideTimer());
361
- }
362
- startAutoHideTimer() {
363
- this.stopAutoHideTimer(), this.autoHideTimeout = setTimeout(() => {
364
- this.hideControls();
365
- }, this.options.autoHideDelay);
366
- }
367
- stopAutoHideTimer() {
368
- this.autoHideTimeout && (clearTimeout(this.autoHideTimeout), this.autoHideTimeout = null);
369
- }
370
- showControls() {
371
- this.isControlsVisible || (this.isControlsVisible = !0, this.zoomora.classList.remove("controls-hidden"), this.header && (this.header.style.transform = "translateY(0)", this.header.style.opacity = "1"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(0)", this.thumbs.style.opacity = "1"), this.prevBtn && (this.prevBtn.style.transform = "translateX(0)", this.prevBtn.style.opacity = "1"), this.nextBtn && (this.nextBtn.style.transform = "translateX(0)", this.nextBtn.style.opacity = "1"));
372
- }
373
- hideControls() {
374
- this.isControlsVisible && (this.isControlsVisible = !1, this.zoomora.classList.add("controls-hidden"), this.header && (this.header.style.transform = "translateY(-100%)", this.header.style.opacity = "0"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(100%)", this.thumbs.style.opacity = "0"), this.prevBtn && (this.prevBtn.style.transform = "translateX(-100%)", this.prevBtn.style.opacity = "0"), this.nextBtn && (this.nextBtn.style.transform = "translateX(100%)", this.nextBtn.style.opacity = "0"));
375
- }
376
- checkZoomability(t) {
377
- if (!t || !t.naturalWidth || !t.naturalHeight) return;
378
- const e = t.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = i > s || n > o, r = i / s, l = n / o, h = Math.max(r, l);
379
- t.dataset.zoomRatio = h.toString(), t.dataset.naturalWidth = i.toString(), t.dataset.naturalHeight = n.toString(), t.dataset.renderedWidth = s.toString(), t.dataset.renderedHeight = o.toString(), a && h > 1.1 ? t.classList.remove("no-zoom") : t.classList.add("no-zoom");
380
- }
381
- calculateZoomLevels(t) {
382
- if (!t || !t.naturalWidth || !t.naturalHeight) return {
383
- canZoom: !1,
384
- levels: [],
385
- currentLevel: 0
386
- };
387
- const e = this.content.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = s / i, r = o / n, l = Math.min(a, r);
388
- if (l >= .95) return {
389
- canZoom: !1,
390
- levels: [],
391
- currentLevel: 0
392
- };
393
- const h = Number(this.options.maxZoomScale), c = Number.isFinite(h) && h > 0 ? Math.max(1, h) : 3, d = [1];
394
- [
395
- 1.5,
396
- 2,
397
- 3,
398
- 4,
399
- 5
400
- ].forEach((t) => {
401
- t <= c && l * t <= 1 && d.push(t);
402
- });
403
- const u = Math.min(1 / l, c);
404
- return u > d[d.length - 1] && d.push(u), {
405
- canZoom: d.length > 1,
406
- levels: d,
407
- currentLevel: 0,
408
- baseScale: l,
409
- naturalWidth: i,
410
- naturalHeight: n
411
- };
412
- }
413
- updateCounter() {
414
- this.options.showCounter && this.counter && (this.counter.textContent = `${this.currentIndex + 1} / ${this.items.length}`);
415
- }
416
- updateCaption() {
417
- if (!this.caption || !this.items[this.currentIndex]) return;
418
- const t = this.items[this.currentIndex], e = t.dataset.caption || t.title || "";
419
- e ? (this.caption.textContent = e, this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1", this.caption.style.pointerEvents = "auto", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease") : (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0", this.caption.style.pointerEvents = "none", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease");
420
- }
421
- updateThumbnails() {
422
- if (this.options.showThumbnails && this.thumbs) {
423
- if (1 === this.items.length) return this.caption.classList.add("single-item-thumbnail"), void (this.thumbs.style.display = "none");
424
- this.caption.classList.remove("single-item-thumbnail"), this.thumbs.style.display = "flex", this.thumbs.innerHTML = "", this.items.forEach((t, e) => {
425
- const s = document.createElement("div");
426
- s.className = "zoomora-thumb", e === this.currentIndex && s.classList.add("active");
427
- const o = document.createElement("img"), i = this.getThumbnailSource(t);
428
- i && (o.src = i, o.alt = t.alt || t.title || "", o.onerror = () => {
429
- s.style.display = "none";
430
- }), s.appendChild(o), s.addEventListener("click", () => {
431
- this.currentIndex = e, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption();
432
- }), this.thumbs.appendChild(s);
433
- });
434
- }
435
- }
436
- updateNavigation() {
437
- const t = document.getElementById("zoomoraPrevBtn"), e = document.getElementById("zoomoraNextBtn");
438
- t && (t.style.display = this.currentIndex > 0 ? "flex" : "none"), e && (e.style.display = this.currentIndex < this.items.length - 1 ? "flex" : "none");
439
- }
440
- updateButtons() {
441
- const t = document.getElementById("zoomoraFullscreenBtn"), e = document.getElementById("zoomoraCollapseBtn");
442
- t && e && (this.isFullscreen ? (t.style.display = "none", e.style.display = "flex") : (t.style.display = "flex", e.style.display = "none"));
443
- }
444
- toggleZoom() {
445
- const t = this.content.querySelector(".zoomora-media");
446
- if (!t || "IMG" !== t.tagName) return;
447
- const e = this.calculateZoomLevels(t);
448
- if (!e.canZoom) return;
449
- t.dataset.zoomLevel || (t.dataset.zoomLevel = "0");
450
- let s = parseInt(t.dataset.zoomLevel) || 0;
451
- s++, s >= e.levels.length && (s = 0);
452
- const o = e.levels[s];
453
- t.dataset.zoomLevel = s.toString(), 0 === s ? (this.isZoomed = !1, this.isDragging = !1, t.classList.remove("dragging"), t.style.transform = "", t.style.cursor = "pointer", t.classList.remove("zoomed"), this.currentX = 0, this.currentY = 0, this.currentScale = 1) : (this.isZoomed = !0, this.currentScale = o, this.currentX = 0, this.currentY = 0, t.style.transform = `translate(0px, 0px) scale(${o})`, t.style.cursor = "grab", t.classList.add("zoomed"));
454
- }
455
- toggleFullscreen() {
456
- this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen();
457
- }
458
- enterFullscreen() {
459
- const t = this.zoomora;
460
- try {
461
- t.requestFullscreen ? t.requestFullscreen().then(() => {
462
- this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
463
- }).catch((t) => {
464
- this.fallbackFullscreen();
465
- }) : t.webkitRequestFullscreen ? (t.webkitRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.mozRequestFullScreen ? (t.mozRequestFullScreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.msRequestFullscreen ? (t.msRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : this.fallbackFullscreen();
466
- } catch (t) {
467
- this.fallbackFullscreen();
468
- }
469
- }
470
- exitFullscreen() {
471
- if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) try {
472
- document.exitFullscreen ? document.exitFullscreen().then(() => {
473
- this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
474
- }).catch((t) => {
475
- this.fallbackExitFullscreen();
476
- }) : document.webkitExitFullscreen ? (document.webkitExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.mozCancelFullScreen ? (document.mozCancelFullScreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.msExitFullscreen ? (document.msExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : this.fallbackExitFullscreen();
477
- } catch (t) {
478
- this.fallbackExitFullscreen();
479
- }
480
- else this.fallbackExitFullscreen();
481
- }
482
- fallbackFullscreen() {
53
+ /*!
54
+ * Zoomora Lightbox Plugin v1.4.0
55
+ * A modern, responsive lightbox plugin with zoom, fullscreen, and gallery features
56
+ *
57
+ * Copyright (c) 2026 Faruk Ahmed (FrontTheme)
58
+ * Licensed under MIT License
59
+ */ return class t {
60
+ static get defaults() {
61
+ return {
62
+ selector: "[data-zoomora]",
63
+ showCounter: !0,
64
+ showThumbnails: !0,
65
+ showFullscreen: !0,
66
+ showZoom: !0,
67
+ transition: "fade",
68
+ useHref: !1,
69
+ maxZoomScale: 3,
70
+ zoomStep: .1,
71
+ animationDuration: 300,
72
+ closeOnBackgroundClick: !0,
73
+ autoplayVideos: !1,
74
+ onOpen: null,
75
+ onClose: null,
76
+ onNext: null,
77
+ onPrev: null,
78
+ showAutoHideToggle: !0,
79
+ autoHideDelay: 3e3,
80
+ autoHideEnabled: !1
81
+ };
82
+ }
83
+ constructor(e = {}) {
84
+ this.options = i(i({}, t.defaults), e), this.currentIndex = 0, this.items = [], this.isZoomed = !1, this.isFullscreen = !1, this.isDragging = !1, this.thumbnailsVisible = !0, this.startX = 0, this.startY = 0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.isInitialized = !1, this.eventListeners = /* @__PURE__ */ new Map(), this.autoHideEnabled = !1, this.autoHideTimeout = null, this.autoHideDelay = 3e3, this.isControlsVisible = !0, this.lastDragTime = 0, this.boundMethods = {
85
+ handleDocumentClick: this.handleDocumentClick.bind(this),
86
+ handleKeydown: this.handleKeydown.bind(this),
87
+ handleFullscreenChange: this.handleFullscreenChange.bind(this),
88
+ handleZoomoraClick: this.handleZoomoraClick.bind(this),
89
+ handleContentClick: this.handleContentClick.bind(this),
90
+ handleMouseDown: this.handleMouseDown.bind(this),
91
+ handleMouseMove: this.handleMouseMove.bind(this),
92
+ handleMouseUp: this.handleMouseUp.bind(this),
93
+ handleTouchStart: this.handleTouchStart.bind(this),
94
+ handleTouchMove: this.handleTouchMove.bind(this),
95
+ handleTouchEnd: this.handleTouchEnd.bind(this),
96
+ handleWheel: this.handleWheel.bind(this)
97
+ }, this.init();
98
+ }
99
+ init() {
100
+ if (!this.isInitialized) try {
101
+ this.createLightbox(), this.bindEvents(), this.isInitialized = !0;
102
+ } catch (t) {}
103
+ }
104
+ static bind(e, s = {}) {
105
+ return new t(i(i({}, s), {}, {
106
+ selector: e,
107
+ useHref: !0
108
+ }));
109
+ }
110
+ createLightbox() {
111
+ if (document.getElementById("zoomoraLightbox")) return;
112
+ const t = this.options.showAutoHideToggle ? "\n <button class=\"zoomora-btn\" id=\"zoomoraAutoHideBtn\" title=\"Toggle Auto-Hide Controls\">\n <i class=\"zoomorai-controls-off\"></i>\n </button>\n " : "", e = `\n <div class="zoomora" id="zoomoraLightbox">\n <div class="zoomora-container">\n <div class="zoomora-header" id="zoomoraHeader">\n <div class="zoomora-counter" id="zoomoraCounter" ${this.options.showCounter ? "" : "style=\"opacity:0;visibility:hidden;\""}>1 / 1</div>\n <div class="zoomora-controls">\n ${this.options.showThumbnails ? "\n <button class=\"zoomora-btn\" id=\"zoomoraThumbnailBtn\" title=\"Toggle Thumbnails\">\n <i class=\"zoomorai-thumbnails\"></i>\n </button>\n " : ""}\n ${t}\n ${this.options.showZoom ? "\n <button class=\"zoomora-btn\" id=\"zoomoraZoomBtn\" title=\"Zoom\">\n <i class=\"zoomorai-zoom\"></i>\n </button>\n " : ""}\n ${this.options.showFullscreen ? "\n <button class=\"zoomora-btn\" id=\"zoomoraFullscreenBtn\" title=\"Fullscreen\">\n <i class=\"zoomorai-expand\"></i>\n </button>\n <button class=\"zoomora-btn\" id=\"zoomoraCollapseBtn\" title=\"Exit Fullscreen\" style=\"display: none;\">\n <i class=\"zoomorai-collapse\"></i>\n </button>\n " : ""}\n <button class="zoomora-btn" id="zoomoraCloseBtn" title="Close">\n <i class="zoomorai-close"></i>\n </button>\n </div>\n </div>\n \n <div class="zoomora-content" id="zoomoraContent">\n <div class="zoomora-loading" id="zoomoraLoading"></div>\n <div class="zoomora-slides-container" id="zoomoraSlidesContainer"></div>\n </div>\n \n <button class="zoomora-nav prev" id="zoomoraPrevBtn">\n <i class="zoomorai-arrow-left"></i>\n </button>\n <button class="zoomora-nav next" id="zoomoraNextBtn">\n <i class="zoomorai-arrow-right"></i>\n </button>\n \n <div class="zoomora-caption" id="zoomoraCaption" ${this.options.showThumbnails ? "" : "style=\"bottom:20px;\""}></div>\n <div class="zoomora-thumbnails" id="zoomoraThumbs" ${this.options.showThumbnails ? "" : "style=\"display:none;\""}></div>\n </div>\n </div>\n `;
113
+ if (document.body.insertAdjacentHTML("beforeend", e), this.zoomora = document.getElementById("zoomoraLightbox"), this.header = document.getElementById("zoomoraHeader"), this.content = document.getElementById("zoomoraContent"), this.slidesContainer = document.getElementById("zoomoraSlidesContainer"), this.counter = document.getElementById("zoomoraCounter"), this.thumbs = document.getElementById("zoomoraThumbs"), this.loading = document.getElementById("zoomoraLoading"), this.caption = document.getElementById("zoomoraCaption"), this.prevBtn = document.getElementById("zoomoraPrevBtn"), this.nextBtn = document.getElementById("zoomoraNextBtn"), !(this.zoomora && this.content && this.counter && this.thumbs && this.loading && this.caption)) throw new Error("Failed to create required DOM elements");
114
+ }
115
+ bindEvents() {
116
+ this.addEventListener(document, "click", this.boundMethods.handleDocumentClick), this.addEventListener(document.getElementById("zoomoraCloseBtn"), "click", () => this.close()), this.addEventListener(document.getElementById("zoomoraPrevBtn"), "click", () => this.prev()), this.addEventListener(document.getElementById("zoomoraNextBtn"), "click", () => this.next()), this.options.showZoom && this.addEventListener(document.getElementById("zoomoraZoomBtn"), "click", () => this.toggleZoom()), this.options.showFullscreen && (this.addEventListener(document.getElementById("zoomoraFullscreenBtn"), "click", () => this.toggleFullscreen()), this.addEventListener(document.getElementById("zoomoraCollapseBtn"), "click", () => this.exitFullscreen())), this.options.showThumbnails && this.addEventListener(document.getElementById("zoomoraThumbnailBtn"), "click", () => this.toggleThumbnails()), this.addEventListener(document, "fullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "webkitfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "mozfullscreenchange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "MSFullscreenChange", this.boundMethods.handleFullscreenChange), this.addEventListener(document, "keydown", this.boundMethods.handleKeydown), this.addEventListener(this.zoomora, "click", this.boundMethods.handleZoomoraClick), this.addEventListener(this.content, "click", this.boundMethods.handleContentClick), this.addEventListener(this.content, "mousedown", this.boundMethods.handleMouseDown), this.addEventListener(this.content, "mousemove", this.boundMethods.handleMouseMove), this.addEventListener(this.content, "mouseup", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "mouseleave", this.boundMethods.handleMouseUp), this.addEventListener(this.content, "touchstart", this.boundMethods.handleTouchStart, { passive: !1 }), this.addEventListener(this.content, "touchmove", this.boundMethods.handleTouchMove, { passive: !1 }), this.addEventListener(this.content, "touchend", this.boundMethods.handleTouchEnd), this.options.showZoom && this.addEventListener(this.content, "wheel", this.boundMethods.handleWheel, { passive: !1 }), this.options.showAutoHideToggle && (this.addEventListener(document.getElementById("zoomoraAutoHideBtn"), "click", () => this.toggleAutoHide()), this.addEventListener(this.zoomora, "mousemove", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "touchstart", () => this.handleUserActivity()), this.addEventListener(this.zoomora, "keydown", () => this.handleUserActivity()));
117
+ }
118
+ addEventListener(t, e, s, o = {}) {
119
+ if (!t) return;
120
+ t.addEventListener(e, s, o);
121
+ const i = `${t.constructor.name}_${e}`;
122
+ this.eventListeners.has(i) || this.eventListeners.set(i, []), this.eventListeners.get(i).push({
123
+ element: t,
124
+ event: e,
125
+ handler: s,
126
+ options: o
127
+ });
128
+ }
129
+ handleDocumentClick(t) {
130
+ const e = t.target.closest(this.options.selector);
131
+ e && (t.preventDefault(), this.open(e));
132
+ }
133
+ handleKeydown(t) {
134
+ if (this.zoomora.classList.contains("active")) switch (t.key) {
135
+ case "Escape":
136
+ this.isFullscreen ? this.exitFullscreen() : this.close();
137
+ break;
138
+ case "ArrowLeft":
139
+ this.prev();
140
+ break;
141
+ case "ArrowRight":
142
+ this.next();
143
+ break;
144
+ case "z":
145
+ case "Z":
146
+ this.toggleZoom();
147
+ break;
148
+ case "f":
149
+ case "F":
150
+ this.toggleFullscreen();
151
+ break;
152
+ case "t":
153
+ case "T": this.toggleThumbnails();
154
+ }
155
+ else this.handleTriggerKeydown(t);
156
+ }
157
+ handleTriggerKeydown(t) {
158
+ if ("Enter" !== t.key && " " !== t.key) return;
159
+ const e = t.target.closest(this.options.selector);
160
+ e && (t.preventDefault(), this.open(e));
161
+ }
162
+ handleFullscreenChange() {
163
+ const t = !!(document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement);
164
+ !t && this.isFullscreen ? (this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : t && !this.isFullscreen && (this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons());
165
+ }
166
+ handleZoomoraClick(t) {
167
+ t.target === this.zoomora && this.options.closeOnBackgroundClick && this.close();
168
+ }
169
+ handleContentClick(t) {
170
+ if (Date.now() - this.lastDragTime < 200) return;
171
+ if (this.header && this.header.contains(t.target)) return;
172
+ if (t.target.closest("button")) return;
173
+ const e = t.target.closest(".zoomora-media, .zoomora-video, .zoomora-iframe");
174
+ if (e) return void (e.classList.contains("zoomora-media") && !e.classList.contains("no-zoom") && this.toggleZoom());
175
+ if (t.target.closest(".zoomora-video-container")) {
176
+ if (t.target.closest(".zoomora-play-button")) return;
177
+ this.options.closeOnBackgroundClick && this.close();
178
+ return;
179
+ }
180
+ const s = t.target;
181
+ ((s.classList.contains("zoomora-content") || s.classList.contains("zoomora-slide-container") || s.classList.contains("zoomora-slide") || s.classList.contains("zoomora-slides-container") || "zoomoraContent" === s.id || "zoomoraSlidesContainer" === s.id) && this.options.closeOnBackgroundClick || this.options.closeOnBackgroundClick) && this.close();
182
+ }
183
+ handleMouseDown(t) {
184
+ this.startDrag(t);
185
+ }
186
+ handleMouseMove(t) {
187
+ this.drag(t);
188
+ }
189
+ handleMouseUp() {
190
+ this.endDrag();
191
+ }
192
+ handleTouchStart(t) {
193
+ this.startDrag(t);
194
+ }
195
+ handleTouchMove(t) {
196
+ this.drag(t);
197
+ }
198
+ handleTouchEnd() {
199
+ this.endDrag();
200
+ }
201
+ handleWheel(t) {
202
+ const e = this.content.querySelector(".zoomora-media");
203
+ if (!e || "IMG" !== e.tagName) return;
204
+ const s = this.calculateZoomLevels(e);
205
+ if (!s.canZoom) return;
206
+ t.preventDefault();
207
+ const o = s.levels[s.levels.length - 1], i = this.options.zoomStep || .1, n = t.deltaY < 0 ? 1 : -1;
208
+ let a = (this.currentScale || 1) + n * i * o;
209
+ if (a = Math.max(1, Math.min(o, a)), a === this.currentScale) return;
210
+ this.currentScale = a, this.isZoomed = a > 1, this.currentX = 0, this.currentY = 0, this.isZoomed ? (e.style.transform = `scale(${a})`, e.style.cursor = "grab", e.classList.add("zoomed")) : (e.style.transform = "", e.style.cursor = "pointer", e.classList.remove("zoomed"));
211
+ let r = 0;
212
+ s.levels.forEach((t, e) => {
213
+ Math.abs(t - a) < Math.abs(s.levels[r] - a) && (r = e);
214
+ }), e.dataset.zoomLevel = r.toString();
215
+ }
216
+ getImageSource(t) {
217
+ const e = t.dataset.src || t.getAttribute("href") || t.src || t.getAttribute("src");
218
+ return "video" === (t.dataset.type || "image") && e ? this.convertToEmbedUrl(e) : e;
219
+ }
220
+ convertToEmbedUrl(t) {
221
+ if (t.includes("youtube.com/embed/")) return t;
222
+ let e = null, s = null;
223
+ if (t.includes("youtube.com/watch")) {
224
+ const o = new URLSearchParams(t.split("?")[1]);
225
+ e = o.get("v");
226
+ const i = o.get("t");
227
+ i && (s = i.replace("s", ""));
228
+ } else if (t.includes("youtu.be/")) {
229
+ const o = t.split("/"), i = o[o.length - 1];
230
+ if (i.includes("?")) {
231
+ e = i.split("?")[0];
232
+ const t = new URLSearchParams(i.split("?")[1]).get("t");
233
+ t && (s = t.replace("s", ""));
234
+ } else e = i;
235
+ }
236
+ if (e) {
237
+ let t = `https://www.youtube.com/embed/${e}`;
238
+ const o = new URLSearchParams();
239
+ return s && o.append("start", s), o.append("rel", "0"), o.append("modestbranding", "1"), this.options.autoplayVideos && o.append("autoplay", "1"), o.toString() && (t += "?" + o.toString()), t;
240
+ }
241
+ return t;
242
+ }
243
+ getThumbnailSource(t) {
244
+ var e;
245
+ if (t.dataset.thumbnail) return t.dataset.thumbnail;
246
+ const s = null === (e = t.querySelector) || void 0 === e ? void 0 : e.call(t, "img"), o = t.getAttribute("src") || (null == s ? void 0 : s.getAttribute("src"));
247
+ return "video" === (t.dataset.type || "image") ? o : o || t.dataset.src || t.getAttribute("href");
248
+ }
249
+ getGroup(t) {
250
+ return this.options.useHref ? t.dataset.lightbox || t.dataset.gallery || "default" : t.dataset.zoomora || "default";
251
+ }
252
+ open(t) {
253
+ if (!t) return;
254
+ const e = this.getGroup(t);
255
+ let s;
256
+ s = this.options.useHref ? t.dataset.lightbox ? `[data-lightbox="${e}"]` : t.dataset.gallery ? `[data-gallery="${e}"]` : this.options.selector : `[data-zoomora="${e}"]`, this.items = Array.from(document.querySelectorAll(s)), this.currentIndex = Math.max(0, this.items.indexOf(t)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(t, this.currentIndex);
257
+ }
258
+ openImage(t, e = {}) {
259
+ const s = Array.isArray(t) ? t : [t];
260
+ this.items = s.map((t) => this.createVirtualItem("string" == typeof t ? { src: t } : t)), this.currentIndex = Math.max(0, Math.min(e.startIndex || 0, this.items.length - 1)), this._activateLightbox(), "function" == typeof this.options.onOpen && this.options.onOpen(this.items[this.currentIndex], this.currentIndex);
261
+ }
262
+ createVirtualItem({ src: t, thumb: e, type: s = "image", caption: o = "", alt: i = "" }) {
263
+ const n = e || t;
264
+ return {
265
+ dataset: {
266
+ src: t,
267
+ type: s,
268
+ caption: o
269
+ },
270
+ src: n,
271
+ alt: i,
272
+ title: o,
273
+ getAttribute: (t) => "src" === t ? n : null
274
+ };
275
+ }
276
+ _activateLightbox() {
277
+ this.isZoomed = !1, this.isFullscreen = !1, this.thumbnailsVisible = !0, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.zoomora.classList.add("active"), document.body.style.overflow = "hidden", this.loadContent(), this.updateThumbnails(), this.updateCounter(), this.updateNavigation(), this.updateCaption(), this.updateButtons(), this.autoHideEnabled ? this.startAutoHideTimer() : this.showControls();
278
+ }
279
+ close() {
280
+ this.isFullscreen && this.exitFullscreen(), this.zoomora.classList.remove("active"), document.body.style.overflow = "";
281
+ const t = this.content.querySelector("video");
282
+ t && t.pause();
283
+ const e = this.content.querySelector("iframe");
284
+ e && (e.src = "about:blank"), this.isZoomed = !1, this.isFullscreen = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1;
285
+ const s = this.content.querySelector(".zoomora-media");
286
+ s && (s.classList.remove("zoomed"), s.style.transform = "", s.style.cursor = ""), this.zoomora.classList.remove("fullscreen"), this.updateButtons(), this.stopAutoHideTimer(), this.showControls(), "function" == typeof this.options.onClose && this.options.onClose(this.currentIndex);
287
+ }
288
+ prev() {
289
+ this.currentIndex > 0 && (this.currentIndex--, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onPrev && this.options.onPrev(this.currentIndex));
290
+ }
291
+ next() {
292
+ this.currentIndex < this.items.length - 1 && (this.currentIndex++, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption(), "function" == typeof this.options.onNext && this.options.onNext(this.currentIndex));
293
+ }
294
+ loadContent() {
295
+ if (!this.items[this.currentIndex]) return;
296
+ const t = this.items[this.currentIndex], e = this.getImageSource(t), s = t.dataset.type || "image";
297
+ e && (this.isZoomed = !1, this.currentX = 0, this.currentY = 0, this.currentScale = 1, this.loading.style.display = "block", this.slidesContainer && (this.slidesContainer.innerHTML = ""), setTimeout(() => {
298
+ this.renderContent(e, s, t);
299
+ }, 100));
300
+ }
301
+ renderContent(t, e, s) {
302
+ const o = document.createElement("div");
303
+ o.className = "zoomora-slide-container";
304
+ const i = document.createElement("div");
305
+ let n;
306
+ i.className = "zoomora-slide " + ("slide" === this.options.transition ? "slide-effect" : "fade-effect"), i.style.opacity = "0", i.style.transform = "slide" === this.options.transition ? "translateX(100%)" : "scale(0.8)";
307
+ try {
308
+ switch (e) {
309
+ case "video":
310
+ if (t.endsWith(".mp4") || t.endsWith(".webm") || t.endsWith(".ogg")) {
311
+ const e = document.createElement("div");
312
+ e.className = "zoomora-video-container", n = document.createElement("video"), n.src = t, n.className = "zoomora-video", n.setAttribute("preload", "metadata");
313
+ const i = s.src || s.getAttribute("src");
314
+ i && n.setAttribute("poster", i);
315
+ const a = document.createElement("div");
316
+ a.className = "zoomora-play-button", a.innerHTML = "<svg viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M8 5v14l11-7z\"/></svg>", a.addEventListener("click", () => {
317
+ n.play(), a.style.display = "none", n.setAttribute("controls", "");
318
+ }), n.addEventListener("ended", () => {
319
+ a.style.display = "flex";
320
+ }), e.appendChild(n), e.appendChild(a), this.options.autoplayVideos && n.play().then(() => {
321
+ a.style.display = "none", n.setAttribute("controls", "");
322
+ }).catch(() => {}), o.appendChild(e);
323
+ } else n = document.createElement("iframe"), n.src = t, n.className = "zoomora-video", n.setAttribute("allowfullscreen", ""), n.setAttribute("allow", "autoplay; fullscreen; picture-in-picture"), n.setAttribute("frameborder", "0"), o.appendChild(n);
324
+ break;
325
+ case "iframe":
326
+ n = document.createElement("iframe"), n.src = t, n.className = "zoomora-iframe", n.setAttribute("frameborder", "0"), o.appendChild(n);
327
+ break;
328
+ default: n = document.createElement("img"), n.src = t, n.className = "zoomora-media", n.alt = s.alt || s.title || "", n.onload = () => {
329
+ this.loading.style.display = "none", this.checkZoomability(n), this.animateSlideIn(i);
330
+ }, n.onerror = () => {
331
+ this.loading.style.display = "none", this.animateSlideIn(i);
332
+ }, o.appendChild(n);
333
+ }
334
+ i.appendChild(o), this.slidesContainer.innerHTML = "", this.slidesContainer.appendChild(i), "image" !== e && (this.loading.style.display = "none", this.animateSlideIn(i));
335
+ } catch (t) {
336
+ this.loading.style.display = "none";
337
+ }
338
+ }
339
+ animateSlideIn(t) {
340
+ t.offsetHeight, t.classList.add("active"), "slide" === this.options.transition ? (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "translateX(0)", t.style.opacity = "1") : (t.style.transition = `transform ${this.options.animationDuration}ms ease, opacity ${this.options.animationDuration}ms ease`, t.style.transform = "scale(1)", t.style.opacity = "1");
341
+ }
342
+ toggleAutoHide() {
343
+ this.autoHideEnabled = !this.autoHideEnabled;
344
+ const t = document.getElementById("zoomoraAutoHideBtn");
345
+ this.autoHideEnabled ? (t.classList.add("active"), t.title = "Disable Auto-Hide Controls", this.startAutoHideTimer()) : (t.classList.remove("active"), t.title = "Enable Auto-Hide Controls", this.stopAutoHideTimer(), this.showControls());
346
+ }
347
+ handleUserActivity() {
348
+ this.autoHideEnabled && (this.showControls(), this.startAutoHideTimer());
349
+ }
350
+ startAutoHideTimer() {
351
+ this.stopAutoHideTimer(), this.autoHideTimeout = setTimeout(() => {
352
+ this.hideControls();
353
+ }, this.options.autoHideDelay);
354
+ }
355
+ stopAutoHideTimer() {
356
+ this.autoHideTimeout && (clearTimeout(this.autoHideTimeout), this.autoHideTimeout = null);
357
+ }
358
+ showControls() {
359
+ this.isControlsVisible || (this.isControlsVisible = !0, this.zoomora.classList.remove("controls-hidden"), this.header && (this.header.style.transform = "translateY(0)", this.header.style.opacity = "1"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(0)", this.thumbs.style.opacity = "1"), this.prevBtn && (this.prevBtn.style.transform = "translateX(0)", this.prevBtn.style.opacity = "1"), this.nextBtn && (this.nextBtn.style.transform = "translateX(0)", this.nextBtn.style.opacity = "1"));
360
+ }
361
+ hideControls() {
362
+ this.isControlsVisible && (this.isControlsVisible = !1, this.zoomora.classList.add("controls-hidden"), this.header && (this.header.style.transform = "translateY(-100%)", this.header.style.opacity = "0"), this.caption && (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0"), this.thumbs && (this.thumbs.style.transform = "translateX(-50%) translateY(100%)", this.thumbs.style.opacity = "0"), this.prevBtn && (this.prevBtn.style.transform = "translateX(-100%)", this.prevBtn.style.opacity = "0"), this.nextBtn && (this.nextBtn.style.transform = "translateX(100%)", this.nextBtn.style.opacity = "0"));
363
+ }
364
+ checkZoomability(t) {
365
+ if (!t || !t.naturalWidth || !t.naturalHeight) return;
366
+ const e = t.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = i > s || n > o, r = i / s, l = n / o, h = Math.max(r, l);
367
+ t.dataset.zoomRatio = h.toString(), t.dataset.naturalWidth = i.toString(), t.dataset.naturalHeight = n.toString(), t.dataset.renderedWidth = s.toString(), t.dataset.renderedHeight = o.toString(), a && h > 1.1 ? t.classList.remove("no-zoom") : t.classList.add("no-zoom");
368
+ }
369
+ calculateZoomLevels(t) {
370
+ if (!t || !t.naturalWidth || !t.naturalHeight) return {
371
+ canZoom: !1,
372
+ levels: [],
373
+ currentLevel: 0
374
+ };
375
+ const e = this.content.getBoundingClientRect(), s = e.width, o = e.height, i = t.naturalWidth, n = t.naturalHeight, a = s / i, r = o / n, l = Math.min(a, r);
376
+ if (l >= .95) return {
377
+ canZoom: !1,
378
+ levels: [],
379
+ currentLevel: 0
380
+ };
381
+ const h = Number(this.options.maxZoomScale), c = Number.isFinite(h) && h > 0 ? Math.max(1, h) : 3, d = [1];
382
+ [
383
+ 1.5,
384
+ 2,
385
+ 3,
386
+ 4,
387
+ 5
388
+ ].forEach((t) => {
389
+ t <= c && l * t <= 1 && d.push(t);
390
+ });
391
+ const u = Math.min(1 / l, c);
392
+ return u > d[d.length - 1] && d.push(u), {
393
+ canZoom: d.length > 1,
394
+ levels: d,
395
+ currentLevel: 0,
396
+ baseScale: l,
397
+ naturalWidth: i,
398
+ naturalHeight: n
399
+ };
400
+ }
401
+ updateCounter() {
402
+ this.options.showCounter && this.counter && (this.counter.textContent = `${this.currentIndex + 1} / ${this.items.length}`);
403
+ }
404
+ updateCaption() {
405
+ if (!this.caption || !this.items[this.currentIndex]) return;
406
+ const t = this.items[this.currentIndex], e = t.dataset.caption || t.title || "";
407
+ e ? (this.caption.textContent = e, this.caption.style.transform = "translateX(-50%) translateY(0)", this.caption.style.opacity = "1", this.caption.style.pointerEvents = "auto", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease") : (this.caption.style.transform = "translateX(-50%) translateY(100%)", this.caption.style.opacity = "0", this.caption.style.pointerEvents = "none", this.caption.style.transition = "opacity 0.3s ease, transform 0.3s ease");
408
+ }
409
+ updateThumbnails() {
410
+ if (this.options.showThumbnails && this.thumbs) {
411
+ if (1 === this.items.length) return this.caption.classList.add("single-item-thumbnail"), void (this.thumbs.style.display = "none");
412
+ this.caption.classList.remove("single-item-thumbnail"), this.thumbs.style.display = "flex", this.thumbs.innerHTML = "", this.items.forEach((t, e) => {
413
+ const s = document.createElement("div");
414
+ s.className = "zoomora-thumb", e === this.currentIndex && s.classList.add("active");
415
+ const o = document.createElement("img"), i = this.getThumbnailSource(t);
416
+ i && (o.src = i, o.alt = t.alt || t.title || "", o.onerror = () => {
417
+ s.style.display = "none";
418
+ }), s.appendChild(o), s.addEventListener("click", () => {
419
+ this.currentIndex = e, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption();
420
+ }), this.thumbs.appendChild(s);
421
+ });
422
+ }
423
+ }
424
+ updateNavigation() {
425
+ const t = document.getElementById("zoomoraPrevBtn"), e = document.getElementById("zoomoraNextBtn");
426
+ t && (t.style.display = this.currentIndex > 0 ? "flex" : "none"), e && (e.style.display = this.currentIndex < this.items.length - 1 ? "flex" : "none");
427
+ }
428
+ updateButtons() {
429
+ const t = document.getElementById("zoomoraFullscreenBtn"), e = document.getElementById("zoomoraCollapseBtn");
430
+ t && e && (this.isFullscreen ? (t.style.display = "none", e.style.display = "flex") : (t.style.display = "flex", e.style.display = "none"));
431
+ }
432
+ toggleZoom() {
433
+ const t = this.content.querySelector(".zoomora-media");
434
+ if (!t || "IMG" !== t.tagName) return;
435
+ const e = this.calculateZoomLevels(t);
436
+ if (!e.canZoom) return;
437
+ t.dataset.zoomLevel || (t.dataset.zoomLevel = "0");
438
+ let s = parseInt(t.dataset.zoomLevel) || 0;
439
+ s++, s >= e.levels.length && (s = 0);
440
+ const o = e.levels[s];
441
+ t.dataset.zoomLevel = s.toString(), 0 === s ? (this.isZoomed = !1, this.isDragging = !1, t.classList.remove("dragging"), t.style.transform = "", t.style.cursor = "pointer", t.classList.remove("zoomed"), this.currentX = 0, this.currentY = 0, this.currentScale = 1) : (this.isZoomed = !0, this.currentScale = o, this.currentX = 0, this.currentY = 0, t.style.transform = `translate(0px, 0px) scale(${o})`, t.style.cursor = "grab", t.classList.add("zoomed"));
442
+ }
443
+ toggleFullscreen() {
444
+ this.isFullscreen ? this.exitFullscreen() : this.enterFullscreen();
445
+ }
446
+ enterFullscreen() {
447
+ const t = this.zoomora;
448
+ try {
449
+ t.requestFullscreen ? t.requestFullscreen().then(() => {
483
450
  this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
484
- }
485
- fallbackExitFullscreen() {
451
+ }).catch((t) => {
452
+ this.fallbackFullscreen();
453
+ }) : t.webkitRequestFullscreen ? (t.webkitRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.mozRequestFullScreen ? (t.mozRequestFullScreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : t.msRequestFullscreen ? (t.msRequestFullscreen(), this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons()) : this.fallbackFullscreen();
454
+ } catch (t) {
455
+ this.fallbackFullscreen();
456
+ }
457
+ }
458
+ exitFullscreen() {
459
+ if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) try {
460
+ document.exitFullscreen ? document.exitFullscreen().then(() => {
486
461
  this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
487
- }
488
- toggleThumbnails() {
489
- if (1 !== this.items.length && (this.thumbnailsVisible = !this.thumbnailsVisible, this.thumbs)) {
490
- if (this.thumbs.classList.toggle("thumbs-hidden", !this.thumbnailsVisible), !this.caption || !this.items[this.currentIndex]) return;
491
- const t = this.items[this.currentIndex];
492
- (t.dataset.caption || t.title) && this.thumbs.classList.contains("thumbs-hidden") ? (this.caption.style.bottom = "20px", this.caption.style.transition = "bottom 0.3s ease, transform 0.3s ease") : this.caption.style.bottom = "120px";
493
- }
494
- }
495
- startDrag(t) {
496
- const e = this.content.querySelector(".zoomora-media");
497
- if (!e || !this.isZoomed) return;
498
- this.isDragging = !0, e.classList.add("dragging"), e.style.cursor = "grabbing", this.startX = t.clientX || t.touches && t.touches[0].clientX || 0, this.startY = t.clientY || t.touches && t.touches[0].clientY || 0;
499
- const s = window.getComputedStyle(e).transform;
500
- if (s && "none" !== s) {
501
- const t = new DOMMatrix(s);
502
- this.currentX = t.m41, this.currentY = t.m42;
503
- } else this.currentX = 0, this.currentY = 0;
504
- t.preventDefault();
505
- }
506
- drag(t) {
507
- if (!this.isDragging) return;
508
- t.preventDefault();
509
- const e = this.content.querySelector(".zoomora-media");
510
- if (!e) return;
511
- const s = t.clientX || t.touches && t.touches[0].clientX || 0, o = t.clientY || t.touches && t.touches[0].clientY || 0, i = s - this.startX, n = o - this.startY;
512
- let a = this.currentX + i, r = this.currentY + n;
513
- const l = this.content.getBoundingClientRect(), h = e.getBoundingClientRect(), c = Math.max(0, (h.width - l.width) / 2), d = Math.max(0, (h.height - l.height) / 2);
514
- a = c > 0 ? Math.max(-c, Math.min(c, a)) : 0, r = d > 0 ? Math.max(-d, Math.min(d, r)) : 0, e.style.transform = `translate(${a}px, ${r}px) scale(${this.currentScale})`, this.startX = s, this.startY = o, this.currentX = a, this.currentY = r;
515
- }
516
- endDrag() {
517
- if (!this.isDragging) return;
518
- this.isDragging = !1, this.lastDragTime = Date.now();
519
- const t = this.content.querySelector(".zoomora-media");
520
- t && (t.classList.remove("dragging"), this.isZoomed && (t.style.cursor = "grab"));
521
- }
522
- goTo(t) {
523
- t < 0 || t >= this.items.length || (this.currentIndex = t, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption());
524
- }
525
- getCurrentIndex() {
526
- return this.currentIndex;
527
- }
528
- getTotalItems() {
529
- return this.items.length;
530
- }
531
- isOpen() {
532
- return this.zoomora && this.zoomora.classList.contains("active");
533
- }
534
- updateOptions(t) {
535
- this.options = d(d({}, this.options), t);
536
- }
537
- refresh() {
538
- if (this.isOpen()) {
539
- const t = this.items[this.currentIndex];
540
- t && this.open(t);
541
- }
542
- }
543
- destroy() {
544
- this.isInitialized && (this.isOpen() && this.close(), this.stopAutoHideTimer(), this.eventListeners.forEach((t, e) => {
545
- t.forEach(({ element: t, event: e, handler: s, options: o }) => {
546
- t && t.removeEventListener && t.removeEventListener(e, s, o);
547
- });
548
- }), this.eventListeners.clear(), this.zoomora && this.zoomora.parentNode && this.zoomora.parentNode.removeChild(this.zoomora), this.isInitialized = !1, this.items = [], this.currentIndex = 0, this.zoomora = null, this.content = null, this.counter = null, this.thumbs = null, this.loading = null, this.caption = null);
549
- }
462
+ }).catch((t) => {
463
+ this.fallbackExitFullscreen();
464
+ }) : document.webkitExitFullscreen ? (document.webkitExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.mozCancelFullScreen ? (document.mozCancelFullScreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : document.msExitFullscreen ? (document.msExitFullscreen(), this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons()) : this.fallbackExitFullscreen();
465
+ } catch (t) {
466
+ this.fallbackExitFullscreen();
550
467
  }
551
- return t;
552
- });
553
- })();
468
+ else this.fallbackExitFullscreen();
469
+ }
470
+ fallbackFullscreen() {
471
+ this.isFullscreen = !0, this.zoomora.classList.add("fullscreen"), this.updateButtons();
472
+ }
473
+ fallbackExitFullscreen() {
474
+ this.isFullscreen = !1, this.zoomora.classList.remove("fullscreen"), this.updateButtons();
475
+ }
476
+ toggleThumbnails() {
477
+ if (1 !== this.items.length && (this.thumbnailsVisible = !this.thumbnailsVisible, this.thumbs)) {
478
+ if (this.thumbs.classList.toggle("thumbs-hidden", !this.thumbnailsVisible), !this.caption || !this.items[this.currentIndex]) return;
479
+ const t = this.items[this.currentIndex];
480
+ (t.dataset.caption || t.title) && this.thumbs.classList.contains("thumbs-hidden") ? (this.caption.style.bottom = "20px", this.caption.style.transition = "bottom 0.3s ease, transform 0.3s ease") : this.caption.style.bottom = "120px";
481
+ }
482
+ }
483
+ startDrag(t) {
484
+ const e = this.content.querySelector(".zoomora-media");
485
+ if (!e || !this.isZoomed) return;
486
+ this.isDragging = !0, e.classList.add("dragging"), e.style.cursor = "grabbing", this.startX = t.clientX || t.touches && t.touches[0].clientX || 0, this.startY = t.clientY || t.touches && t.touches[0].clientY || 0;
487
+ const s = window.getComputedStyle(e).transform;
488
+ if (s && "none" !== s) {
489
+ const t = new DOMMatrix(s);
490
+ this.currentX = t.m41, this.currentY = t.m42;
491
+ } else this.currentX = 0, this.currentY = 0;
492
+ t.preventDefault();
493
+ }
494
+ drag(t) {
495
+ if (!this.isDragging) return;
496
+ t.preventDefault();
497
+ const e = this.content.querySelector(".zoomora-media");
498
+ if (!e) return;
499
+ const s = t.clientX || t.touches && t.touches[0].clientX || 0, o = t.clientY || t.touches && t.touches[0].clientY || 0, i = s - this.startX, n = o - this.startY;
500
+ let a = this.currentX + i, r = this.currentY + n;
501
+ const l = this.content.getBoundingClientRect(), h = e.getBoundingClientRect(), c = Math.max(0, (h.width - l.width) / 2), d = Math.max(0, (h.height - l.height) / 2);
502
+ a = c > 0 ? Math.max(-c, Math.min(c, a)) : 0, r = d > 0 ? Math.max(-d, Math.min(d, r)) : 0, e.style.transform = `translate(${a}px, ${r}px) scale(${this.currentScale})`, this.startX = s, this.startY = o, this.currentX = a, this.currentY = r;
503
+ }
504
+ endDrag() {
505
+ if (!this.isDragging) return;
506
+ this.isDragging = !1, this.lastDragTime = Date.now();
507
+ const t = this.content.querySelector(".zoomora-media");
508
+ t && (t.classList.remove("dragging"), this.isZoomed && (t.style.cursor = "grab"));
509
+ }
510
+ goTo(t) {
511
+ t < 0 || t >= this.items.length || (this.currentIndex = t, this.loadContent(), this.updateCounter(), this.updateThumbnails(), this.updateNavigation(), this.updateCaption());
512
+ }
513
+ getCurrentIndex() {
514
+ return this.currentIndex;
515
+ }
516
+ getTotalItems() {
517
+ return this.items.length;
518
+ }
519
+ isOpen() {
520
+ return this.zoomora && this.zoomora.classList.contains("active");
521
+ }
522
+ updateOptions(t) {
523
+ this.options = i(i({}, this.options), t);
524
+ }
525
+ refresh() {
526
+ if (this.isOpen()) {
527
+ const t = this.items[this.currentIndex];
528
+ t && this.open(t);
529
+ }
530
+ }
531
+ destroy() {
532
+ this.isInitialized && (this.isOpen() && this.close(), this.stopAutoHideTimer(), this.eventListeners.forEach((t, e) => {
533
+ t.forEach(({ element: t, event: e, handler: s, options: o }) => {
534
+ t && t.removeEventListener && t.removeEventListener(e, s, o);
535
+ });
536
+ }), this.eventListeners.clear(), this.zoomora && this.zoomora.parentNode && this.zoomora.parentNode.removeChild(this.zoomora), this.isInitialized = !1, this.items = [], this.currentIndex = 0, this.zoomora = null, this.content = null, this.counter = null, this.thumbs = null, this.loading = null, this.caption = null);
537
+ }
538
+ };
554
539
  });