vistaview 0.3.4 → 0.3.6

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.
package/dist/vistaview.js CHANGED
@@ -1,26 +1,26 @@
1
- var k = Object.defineProperty;
2
- var O = (s, t, e) => t in s ? k(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var f = (s, t, e) => O(s, typeof t != "symbol" ? t + "" : t, e);
4
- function Z(s) {
5
- const t = getComputedStyle(s), e = s.getBoundingClientRect();
1
+ var X = Object.defineProperty;
2
+ var Y = (s, t, i) => t in s ? X(s, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : s[t] = i;
3
+ var w = (s, t, i) => Y(s, typeof t != "symbol" ? t + "" : t, i);
4
+ function z(s) {
5
+ const t = getComputedStyle(s), i = s.getBoundingClientRect();
6
6
  return {
7
7
  objectFit: t.objectFit,
8
8
  borderRadius: t.borderRadius,
9
9
  objectPosition: t.objectPosition,
10
10
  overflow: t.overflow,
11
- top: e.top,
12
- left: e.left,
13
- width: e.width,
14
- height: e.height,
11
+ top: i.top,
12
+ left: i.left,
13
+ width: i.width,
14
+ height: i.height,
15
15
  naturalWidth: s.naturalWidth,
16
16
  naturalHeight: s.naturalHeight
17
17
  };
18
18
  }
19
- let D = null;
20
- function X() {
21
- return D || (window.trustedTypes || (window.trustedTypes = {
19
+ let S = null;
20
+ function V() {
21
+ return S || (window.trustedTypes || (window.trustedTypes = {
22
22
  createPolicy: (s, t) => t
23
- }), D = window.trustedTypes.createPolicy("vistaView-policy", {
23
+ }), S = window.trustedTypes.createPolicy("vistaView-policy", {
24
24
  createHTML: (s) => s,
25
25
  // HTML is generated by us, not user input
26
26
  createScript: () => {
@@ -29,86 +29,86 @@ function X() {
29
29
  createScriptURL: () => {
30
30
  throw new Error("Not implemented");
31
31
  }
32
- }), D);
32
+ }), S);
33
33
  }
34
- function T(s) {
35
- const e = X().createHTML(s), n = document.createElement("template");
36
- n.innerHTML = e;
37
- const i = n.content;
38
- return n.remove(), i;
34
+ function W(s) {
35
+ const i = V().createHTML(s), n = document.createElement("template");
36
+ n.innerHTML = i;
37
+ const e = n.content;
38
+ return n.remove(), e;
39
39
  }
40
- function z(s) {
40
+ function R(s) {
41
41
  return s && !/^0(px|%|r?em|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/i.test(s.trim()) && s;
42
42
  }
43
- function A(s) {
44
- const e = window.getComputedStyle(s).objectFit || "", { width: n, height: i } = s.getBoundingClientRect(), o = s.naturalWidth, l = s.naturalHeight;
45
- if (!e)
46
- return { width: n, height: i };
47
- if (!o || !l)
48
- return { width: n, height: i };
49
- const a = o / l, r = n / i;
50
- switch (e) {
43
+ function B(s) {
44
+ const i = window.getComputedStyle(s).objectFit || "", { width: n, height: e } = s.getBoundingClientRect(), a = s.naturalWidth, d = s.naturalHeight;
45
+ if (!i)
46
+ return { width: n, height: e };
47
+ if (!a || !d)
48
+ return { width: n, height: e };
49
+ const o = a / d, l = n / e;
50
+ switch (i) {
51
51
  case "fill":
52
- return { width: n, height: i };
52
+ return { width: n, height: e };
53
53
  case "none":
54
- return { width: o, height: l };
54
+ return { width: a, height: d };
55
55
  case "contain":
56
- return a > r ? { width: n, height: n / a } : { width: i * a, height: i };
56
+ return o > l ? { width: n, height: n / o } : { width: e * o, height: e };
57
57
  case "cover":
58
- return a < r ? { width: n, height: n / a } : { width: i * a, height: i };
58
+ return o < l ? { width: n, height: n / o } : { width: e * o, height: e };
59
59
  case "scale-down": {
60
- const h = { width: o, height: l }, c = a > r ? { width: n, height: n / a } : { width: i * a, height: i };
61
- return c.width <= h.width && c.height <= h.height ? c : h;
60
+ const c = { width: a, height: d }, r = o > l ? { width: n, height: n / o } : { width: e * o, height: e };
61
+ return r.width <= c.width && r.height <= c.height ? r : c;
62
62
  }
63
63
  }
64
- return { width: n, height: i };
64
+ return { width: n, height: e };
65
65
  }
66
- function P(s) {
67
- const t = window.innerWidth, e = window.innerHeight, n = s.naturalWidth, i = s.naturalHeight;
68
- if (!n || !i)
66
+ function H(s) {
67
+ const t = window.innerWidth, i = window.innerHeight, n = s.naturalWidth, e = s.naturalHeight;
68
+ if (!n || !e)
69
69
  throw console.error("Error", s), new Error("Image natural dimensions are zero");
70
- if (n < t && i < e)
70
+ if (n < t && e < i)
71
71
  return {
72
72
  width: n,
73
- height: i
73
+ height: e
74
74
  };
75
- const o = n / i, l = t / e;
76
- let a, r;
77
- return o > l ? (a = t, r = t / o) : (r = e, a = e * o), {
78
- width: a,
79
- height: r
75
+ const a = n / e, d = t / i;
76
+ let o, l;
77
+ return a > d ? (o = t, l = t / a) : (l = i, o = i * a), {
78
+ width: o,
79
+ height: l
80
80
  };
81
81
  }
82
- function R(s, t) {
83
- const e = window.innerHeight, n = window.innerWidth, i = s, o = t, l = Math.max(0, (i - n) / 2) + n / 2, a = Math.max(0, (o - e) / 2) + e / 2, r = -l, h = -a;
82
+ function T(s, t) {
83
+ const i = window.innerHeight, n = window.innerWidth, e = s, a = t, d = Math.max(0, (e - n) / 2) + n / 2, o = Math.max(0, (a - i) / 2) + i / 2, l = -d, c = -o;
84
84
  return {
85
- maxDiffX: l,
86
- minDiffY: h,
87
- maxDiffY: a,
88
- minDiffX: r
85
+ maxDiffX: d,
86
+ minDiffY: c,
87
+ maxDiffY: o,
88
+ minDiffX: l
89
89
  };
90
90
  }
91
- const _ = '<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', B = '<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', F = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', V = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', Y = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', U = '<svg viewBox="0 0 24 24"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>';
92
- function N() {
91
+ const _ = '<svg viewBox="0 0 24 24"><path d="m15 18-6-6 6-6"/></svg>', F = '<svg viewBox="0 0 24 24"><path d="m9 18 6-6-6-6"/></svg>', N = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="11" x2="11" y1="8" y2="14"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', U = '<svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="8"/><line x1="21" x2="16.65" y1="21" y2="16.65"/><line x1="8" x2="14" y1="11" y2="11"/></svg>', K = '<svg viewBox="0 0 24 24"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>', j = '<svg viewBox="0 0 24 24"><path d="M12 15V3"/><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><path d="m7 10 5 5 5-5"/></svg>';
92
+ function G() {
93
93
  return {
94
94
  name: "download",
95
- icon: U,
95
+ icon: j,
96
96
  onClick: async (s) => {
97
- var o;
98
- const t = await fetch(s.src), e = await t.blob(), n = t.url, i = document.createElement("a");
99
- i.href = URL.createObjectURL(e), i.download = ((o = n.split("/").pop()) == null ? void 0 : o.split("?")[0].split("#")[0]) || "download", document.body.appendChild(i), i.click(), document.body.removeChild(i);
97
+ var a;
98
+ const t = await fetch(s.src), i = await t.blob(), n = t.url, e = document.createElement("a");
99
+ e.href = URL.createObjectURL(i), e.download = ((a = n.split("/").pop()) == null ? void 0 : a.split("?")[0].split("#")[0]) || "download", document.body.appendChild(e), e.click(), document.body.removeChild(e);
100
100
  }
101
101
  };
102
102
  }
103
- function j(s) {
103
+ function J(s) {
104
104
  if (typeof s == "string")
105
105
  switch (s) {
106
106
  case "zoomIn":
107
- return `<button class="vistaview-zoom-in-btn">${F}</button>`;
107
+ return `<button class="vistaview-zoom-in-btn">${N}</button>`;
108
108
  case "zoomOut":
109
- return `<button disabled class="vistaview-zoom-out-btn">${V}</button>`;
109
+ return `<button disabled class="vistaview-zoom-out-btn">${U}</button>`;
110
110
  case "close":
111
- return `<button class="vistaview-close-btn">${Y}</button>`;
111
+ return `<button class="vistaview-close-btn">${K}</button>`;
112
112
  case "indexDisplay":
113
113
  return '<div class="vistaview-index-display"></div>';
114
114
  case "description":
@@ -118,149 +118,203 @@ function j(s) {
118
118
  }
119
119
  return `<button data-vistaview-custom-control="${s.name}">${s.icon}</button>`;
120
120
  }
121
- function H(s, t) {
122
- var c, d;
123
- const e = s.imageElm ? getComputedStyle(s.imageElm) : null, n = (e == null ? void 0 : e.objectFit) || "", i = ((c = s.imageElm) == null ? void 0 : c.naturalWidth) || "", o = ((d = s.imageElm) == null ? void 0 : d.naturalHeight) || "", l = (e == null ? void 0 : e.width) || "", a = (e == null ? void 0 : e.height) || "", r = document.createElement("div");
124
- r.className = "vistaview-item", r.dataset.vistaviewPos = `${t !== void 0 ? t : ""}`, r.dataset.vistaviewIndex = s.index.toString();
125
- const h = T(`<img class="vistaview-image-lowres"
126
- style="${n ? `object-fit:${n};` : ""}${l ? `width:${l};` : ""}${a ? `height:${a};` : ""}"
121
+ function q(s, t) {
122
+ var r, h;
123
+ const i = s.imageElm ? getComputedStyle(s.imageElm) : null, n = (i == null ? void 0 : i.objectFit) || "", e = ((r = s.imageElm) == null ? void 0 : r.naturalWidth) || "", a = ((h = s.imageElm) == null ? void 0 : h.naturalHeight) || "", d = (i == null ? void 0 : i.width) || "", o = (i == null ? void 0 : i.height) || "", l = document.createElement("div");
124
+ l.className = "vistaview-item", l.dataset.vistaviewPos = `${t !== void 0 ? t : ""}`, l.dataset.vistaviewIndex = s.index.toString();
125
+ const c = W(`<img class="vistaview-image-lowres"
126
+ style="${n ? `object-fit:${n};` : ""}${d ? `width:${d};` : ""}${o ? `height:${o};` : ""}"
127
127
  src="${s.thumb || s.src}"
128
128
  alt="${s.alt || ""}"
129
- ${i ? `width="${i}"` : ""}
130
- ${o ? `height="${o}"` : ""}
129
+ ${e ? `width="${e}"` : ""}
130
+ ${a ? `height="${a}"` : ""}
131
131
  />
132
132
  <img class="vistaview-image-highres" src="${s.src}" alt="${s.alt || ""}" />`);
133
- return r.appendChild(h), r;
133
+ return l.appendChild(c), l;
134
134
  }
135
- function K({
135
+ function Q({
136
136
  controls: s,
137
137
  isReducedMotion: t
138
138
  }) {
139
- const e = (i) => i ? i.map(j).join("") : "";
140
- return T(
139
+ const i = (e) => e ? e.map(J).join("") : "";
140
+ return W(
141
141
  `<div class="vistaview-root${t ? " vistaview--reduced-motion" : ""}" id="vistaview-root">
142
142
  <div class="vistaview-container">
143
143
  <div class="vistaview-image-container"></div>
144
- <div class="vistaview-top-bar vistaview-ui"><div>${e(s == null ? void 0 : s.topLeft)}</div><div>${e(s == null ? void 0 : s.topCenter)}</div><div>${e(s == null ? void 0 : s.topRight)}</div></div>
145
- <div class="vistaview-bottom-bar vistaview-ui"><div>${e(s == null ? void 0 : s.bottomLeft)}</div><div>${e(s == null ? void 0 : s.bottomCenter)}</div><div>${e(s == null ? void 0 : s.bottomRight)}</div></div>
144
+ <div class="vistaview-top-bar vistaview-ui"><div>${i(s == null ? void 0 : s.topLeft)}</div><div>${i(s == null ? void 0 : s.topCenter)}</div><div>${i(s == null ? void 0 : s.topRight)}</div></div>
145
+ <div class="vistaview-bottom-bar vistaview-ui"><div>${i(s == null ? void 0 : s.bottomLeft)}</div><div>${i(s == null ? void 0 : s.bottomCenter)}</div><div>${i(s == null ? void 0 : s.bottomRight)}</div></div>
146
146
  <div class="vistaview-prev-btn vistaview-ui"><button>${_}</button></div>
147
- <div class="vistaview-next-btn vistaview-ui"><button>${B}</button></div>
147
+ <div class="vistaview-next-btn vistaview-ui"><button>${F}</button></div>
148
148
  </div>
149
149
  </div>`
150
150
  );
151
151
  }
152
- let $ = null, S = null, M = null;
153
- function G(s) {
154
- q(s);
155
- const t = s.imageContainerElm, e = s.elements.length;
152
+ let A = null, $ = null, Z = null, M = null;
153
+ function tt(s) {
154
+ O(s);
155
+ const t = s.imageContainerElm, i = s.elements.length;
156
156
  if (!t) return;
157
- let n = 0, i = 0, o = 0, l = 0, a = !1;
158
- $ = (r) => {
159
- r.preventDefault(), r.stopPropagation(), s.isZoomed === !1 && (a = !0, n = r.pageX, i = r.pageY, o = r.pageX, l = Date.now());
160
- }, S = (r) => {
161
- if (r.preventDefault(), r.stopPropagation(), s.isZoomed !== !1 || !a) return;
162
- const h = r.pageX - n, c = r.pageY - i;
163
- o = r.pageX, t.style.setProperty("--vistaview-pointer-diff-x", `${h}px`), t.style.setProperty("--vistaview-pointer-diff-y", `${c}px`);
157
+ let n = 0, e = 0, a = 0, d = 0, o = null, l = 0, c = !1;
158
+ A = (r) => {
159
+ r.preventDefault(), r.stopPropagation(), s.isZoomed === !1 && (c = !0, n = r.pageX, e = r.pageY, a = r.pageX, d = r.pageY, l = Date.now(), o = null, t.setPointerCapture(r.pointerId));
160
+ }, $ = (r) => {
161
+ if (r.preventDefault(), r.stopPropagation(), s.isZoomed !== !1 || !c) return;
162
+ const h = r.pageX - n, m = r.pageY - e;
163
+ a = r.pageX, d = r.pageY, Math.abs(h) >= Math.abs(m) && (o === null || o === !0) ? (t.style.setProperty("--vistaview-pointer-diff-x", `${h}px`), o = !0) : Math.abs(m) > Math.abs(h) && (o === null || o === !1) && (t.style.setProperty("--vistaview-pointer-diff-y", `${m}px`), o = !1);
164
164
  }, M = (r) => {
165
- if (r.preventDefault(), r.stopPropagation(), s.isZoomed !== !1 || !a) return;
166
- a = !1;
167
- const h = Array.from(t.querySelectorAll(".vistaview-item")), c = o - n, d = Date.now() - l, v = c / d, u = s.options.touchSpeedThreshold || 0.7, g = h.find(
168
- (p) => p.dataset.vistaviewPos === "0"
169
- ), m = Number(g.dataset.vistaviewIndex), E = s.isReducedMotion;
170
- function w() {
171
- h[0].removeEventListener("transitionend", w), t.style.removeProperty("--vistaview-pointer-diff-x"), t.style.removeProperty("--vistaview-pointer-diff-y"), h.forEach((p) => {
172
- p.style.transition = "", p.style.translate = "";
165
+ if (r.preventDefault(), r.stopPropagation(), t.releasePointerCapture(r.pointerId), s.isZoomed !== !1 || !c) return;
166
+ c = !1, o = null;
167
+ const h = Array.from(t.querySelectorAll(".vistaview-item"));
168
+ t.style.removeProperty("--vistaview-pointer-diff-x"), t.style.removeProperty("--vistaview-pointer-diff-y"), h.forEach((m) => {
169
+ m.style.transition = "", m.style.translate = "";
170
+ });
171
+ }, Z = (r) => {
172
+ if (r.preventDefault(), r.stopPropagation(), t.releasePointerCapture(r.pointerId), s.isZoomed !== !1 || !c) return;
173
+ c = !1;
174
+ const h = Array.from(t.querySelectorAll(".vistaview-item")), m = a - n, f = d - e, u = Date.now() - l, v = m / u, y = f / u, p = s.options.touchSpeedThreshold || 0.5, b = h.find(
175
+ (E) => E.dataset.vistaviewPos === "0"
176
+ ), x = Number(b.dataset.vistaviewIndex);
177
+ function g() {
178
+ h[0].removeEventListener("transitionend", g), t.style.removeProperty("--vistaview-pointer-diff-x"), t.style.removeProperty("--vistaview-pointer-diff-y"), h.forEach((E) => {
179
+ E.style.transition = "", E.style.translate = "";
173
180
  });
174
181
  }
175
- function y(p) {
176
- h.forEach((x) => {
177
- x.style.transition = `translate ${s.options.animationDurationBase * 0.5}ms ease-out`, x.style.translate = p;
182
+ function I(E = "0%", L = "0%") {
183
+ h.forEach((D) => {
184
+ D.style.transition = `translate ${s.options.animationDurationBase * 0.5}ms ease-out`, D.style.translate = `${E} ${L}`;
178
185
  });
179
186
  }
180
- v < -u || v > u ? (h[0].addEventListener("transitionend", () => {
181
- s.isReducedMotion = !0, w(), s.view(
182
- v < -u ? (m + 1) % e : (m - 1 + e) % e,
183
- {
184
- next: v < -u,
185
- prev: v > u
186
- }
187
- ), s.isReducedMotion = E;
188
- }), y(v < -u ? "-100%" : "100%")) : (h[0].addEventListener("transitionend", w), y("0%"));
189
- }, t.addEventListener("pointermove", S), t.addEventListener("pointerup", M), t.addEventListener("pointerdown", $);
187
+ if (v < -p || v > p) {
188
+ let E = function() {
189
+ h[0].removeEventListener("transitionend", E), setTimeout(() => {
190
+ const L = s.isReducedMotion;
191
+ s.isReducedMotion = !0, g(), s.view(
192
+ v < -p ? (x + 1) % i : (x - 1 + i) % i,
193
+ {
194
+ next: v < -p,
195
+ prev: v > p
196
+ }
197
+ ), s.isReducedMotion = L;
198
+ }, 100);
199
+ };
200
+ I(v < -p ? "-100%" : "100%"), h[0].addEventListener("transitionend", E);
201
+ } else y < -p || y > p ? (s.close(), I("0%", "0%")) : (h[0].addEventListener("transitionend", g), I("0%"));
202
+ }, t.addEventListener("pointermove", $), t.addEventListener("pointerup", Z), t.addEventListener("pointerdown", A), t.addEventListener("pointercancel", M);
190
203
  }
191
- function q(s) {
204
+ function O(s) {
192
205
  const t = s.imageContainerElm;
193
- t && (S && t.removeEventListener("pointermove", S), M && t.removeEventListener("pointerup", M), $ && t.removeEventListener("pointerdown", $));
206
+ t && ($ && t.removeEventListener("pointermove", $), Z && t.removeEventListener("pointerup", Z), A && t.removeEventListener("pointerdown", A), M && t.removeEventListener("pointercancel", M));
194
207
  }
195
- const J = (s) => {
196
- G(s);
197
- }, Q = ({
208
+ const et = (s) => {
209
+ tt(s);
210
+ }, it = ({
198
211
  htmlElements: { to: s },
199
212
  index: { to: t },
200
- elements: e
213
+ elements: i
201
214
  }) => {
202
- e instanceof NodeList && t !== null && (e.forEach((n) => n.style.opacity = "1"), e[t].style.opacity = "0"), s && s.forEach((n) => {
203
- const i = Number(n.dataset.vistaviewPos);
204
- i !== 0 ? (n.style.zIndex = "1", n.style.left = 100 * i + "%") : n.style.zIndex = "2";
215
+ i instanceof NodeList && t !== null && (i.forEach((n) => n.style.opacity = "1"), i[t].style.opacity = "0"), s && s.forEach((n) => {
216
+ const e = Number(n.dataset.vistaviewPos);
217
+ e !== 0 ? (n.style.zIndex = "1", n.style.left = 100 * e + "%") : n.style.zIndex = "2";
205
218
  });
206
- }, tt = async ({
219
+ }, nt = async ({
207
220
  htmlElements: { from: s, to: t },
208
- images: { to: e },
209
- via: { next: n, prev: i },
210
- container: o,
211
- options: l,
212
- isReducedMotion: a
221
+ images: { to: i },
222
+ via: { next: n, prev: e },
223
+ options: a,
224
+ isReducedMotion: d
213
225
  // index: { from: fromIndex, to: toIndex },
214
- }) => {
215
- if (!e) throw new Error("VistaView: images is null in defaultTransition()");
216
- if (a)
217
- return o.innerHTML = "", t.forEach((h) => {
218
- o.appendChild(h);
219
- }), e[e.length === 1 ? 0 : Math.floor(e.length / 2)];
220
- const r = s.filter((h) => h.dataset.vistaviewPos === "0" || (n ? h.dataset.vistaviewPos === "1" : h.dataset.vistaviewPos === "-1"));
221
- return await new Promise((h) => {
222
- function c() {
223
- o.innerHTML = "", t.forEach((d) => {
224
- o.appendChild(d);
225
- }), h(0);
226
+ }, o) => {
227
+ if (console.log("defaultTransition called"), !i) throw new Error("VistaView: images is null in defaultTransition()");
228
+ const l = s.filter((c) => c.dataset.vistaviewPos === "0" || (n ? c.dataset.vistaviewPos === "1" : c.dataset.vistaviewPos === "-1"));
229
+ if (d) {
230
+ console.log("reduced motion, no transition");
231
+ return;
232
+ }
233
+ await new Promise((c, r) => {
234
+ let h = 0;
235
+ if (o.aborted) {
236
+ console.log("transition aborted before start"), r(new P("Transition aborted"));
237
+ return;
226
238
  }
227
- r[r.length - 1].addEventListener("transitionend", c), r.forEach((d) => {
228
- d.style.transition = `translate ${l.animationDurationBase * 0.5}ms ease-out`, d.style.translate = n ? "-100%" : i ? "100%" : "0%";
239
+ const m = (f) => {
240
+ if (o.aborted) {
241
+ console.log("transition aborted before start"), r(new P("Transition aborted"));
242
+ return;
243
+ }
244
+ if (f.currentTarget.removeEventListener("transitionend", m), h++, h < l.length) return;
245
+ const u = t == null ? void 0 : t.find((g) => g.dataset.vistaviewPos === "0"), v = u ? Number(u.dataset.vistaviewIndex) : 0, y = l.find((g) => Number(g.dataset.vistaviewIndex) === v), p = y == null ? void 0 : y.querySelector(
246
+ ".vistaview-image-highres"
247
+ );
248
+ if (!p) {
249
+ r(new Error("current image element not found"));
250
+ return;
251
+ }
252
+ if (!p.classList.contains("vistaview-image-loaded")) {
253
+ console.log("current image not loaded yet"), c(0);
254
+ return;
255
+ }
256
+ if (u == null || u.classList.add("vistaview-image-loaded"), p.classList.contains("vistaview-image-settled")) {
257
+ console.log("current image already settled"), u == null || u.classList.add("vistaview-image-settled"), c(0);
258
+ return;
259
+ }
260
+ let b = 0;
261
+ console.log("waiting for image to be settled...");
262
+ const x = setInterval(() => {
263
+ if (o.aborted) {
264
+ console.log("transition aborted during wait"), clearInterval(x), r(new P("Transition aborted"));
265
+ return;
266
+ }
267
+ if (b++, b > a.animationDurationBase / 20 * 1.5) {
268
+ console.log("timeout waiting for image to be settled"), clearInterval(x), c(0);
269
+ return;
270
+ }
271
+ p.classList.contains("vistaview-image-settled") && (console.log("image settled"), u == null || u.classList.add("vistaview-image-settled"), clearInterval(x), c(0));
272
+ }, 20);
273
+ };
274
+ l.forEach((f) => {
275
+ f.style.transition = `translate ${a.animationDurationBase * 0.5}ms ease-out`, f.style.translate = n ? "-100%" : e ? "100%" : "0%", f.addEventListener("transitionend", m);
229
276
  });
230
- }), e[e.length === 1 ? 0 : Math.floor(e.length / 2)];
231
- }, et = (s) => {
232
- s.elements instanceof NodeList && s.elements.forEach((t) => t.style.opacity = "1"), q(s);
233
- }, W = {
277
+ });
278
+ }, st = (s) => {
279
+ s.elements instanceof NodeList && s.elements.forEach((t) => t.style.opacity = "1"), O(s);
280
+ };
281
+ class P extends Error {
282
+ constructor(t) {
283
+ super(t), this.name = "VistaViewTransitionAbortedError";
284
+ }
285
+ }
286
+ const k = {
234
287
  detectReducedMotion: !0,
235
288
  // debug, don't remove
236
289
  // animationDurationBase: 1000,
237
290
  animationDurationBase: 333,
238
291
  zoomStep: 500,
239
292
  maxZoomLevel: 2,
240
- touchSpeedThreshold: 0.7,
293
+ touchSpeedThreshold: 0.5,
241
294
  preloads: 1,
242
295
  keyboardListeners: !0,
296
+ arrowOnSmallScreens: !1,
243
297
  controls: {
244
298
  topLeft: ["indexDisplay"],
245
- topRight: ["zoomIn", "zoomOut", N(), "close"],
299
+ topRight: ["zoomIn", "zoomOut", G(), "close"],
246
300
  bottomCenter: ["description"]
247
301
  }
248
- }, b = {
302
+ }, C = {
249
303
  somethingOpened: null
250
304
  };
251
- class it {
252
- constructor(t, e) {
253
- f(this, "options");
254
- f(this, "elements");
255
- f(this, "isReducedMotion");
256
- f(this, "currentIndex", {
305
+ class ot {
306
+ constructor(t, i) {
307
+ w(this, "options");
308
+ w(this, "elements");
309
+ w(this, "isReducedMotion");
310
+ w(this, "currentIndex", {
257
311
  _value: null,
258
312
  _vistaView: null,
259
313
  _via: { next: !1, prev: !1 },
260
314
  set value(t) {
261
315
  var n;
262
- const e = this._value;
263
- this._value = t, (n = this._vistaView) == null || n.swap(e, this._value);
316
+ const i = this._value;
317
+ this._value = t, (n = this._vistaView) == null || n.swap(i, this._value);
264
318
  },
265
319
  get value() {
266
320
  return this._value;
@@ -272,57 +326,52 @@ class it {
272
326
  this._via = t;
273
327
  }
274
328
  });
275
- f(this, "rootElm", null);
276
- f(this, "imageContainerElm", null);
277
- f(this, "customControls", {});
278
- f(this, "currentImages", null);
279
- f(this, "currentItems", null);
280
- f(this, "navActive", !0);
281
- f(this, "isZoomed", !1);
282
- f(this, "onClickElements", []);
283
- f(this, "onResizeHandler", null);
284
- f(this, "onKeyDown", null);
285
- f(this, "userSetup", Q);
286
- f(this, "userTransition", tt);
287
- f(this, "userClose", et);
288
- f(this, "userInit", J);
289
- f(this, "onZoomedPointerDown", null);
290
- f(this, "onZoomedPointerMove", null);
291
- f(this, "onZoomedPointerUp", null);
329
+ w(this, "rootElm", null);
330
+ w(this, "imageContainerElm", null);
331
+ w(this, "customControls", {});
332
+ w(this, "currentImages", null);
333
+ w(this, "currentItems", null);
334
+ w(this, "navActive", !0);
335
+ w(this, "isZoomed", !1);
336
+ w(this, "onClickElements", (t) => {
337
+ t.preventDefault();
338
+ const i = t.currentTarget;
339
+ i.dataset.vistaviewIndex && this.open(parseInt(i.dataset.vistaviewIndex));
340
+ });
341
+ w(this, "defaultOnClickHandler", (t) => t.preventDefault());
342
+ w(this, "onResizeHandler", null);
343
+ w(this, "onKeyDown", null);
344
+ w(this, "userSetup", it);
345
+ w(this, "userTransition", nt);
346
+ w(this, "userClose", st);
347
+ w(this, "userInit", et);
348
+ w(this, "onZoomedPointerDown", null);
349
+ w(this, "onZoomedPointerMove", null);
350
+ w(this, "onZoomedPointerUp", null);
351
+ w(this, "transitionAbortController", null);
292
352
  this.elements = t, this.currentIndex._vistaView = this, this.options = {
293
- ...W,
294
- ...e || {},
353
+ ...k,
354
+ ...i || {},
295
355
  controls: {
296
- ...W.controls,
297
- ...(e == null ? void 0 : e.controls) || {}
356
+ ...k.controls,
357
+ ...(i == null ? void 0 : i.controls) || {}
298
358
  }
299
- }, this.options.initFunction && (this.userInit = this.options.initFunction), this.options.transitionFunction && (this.userTransition = this.options.transitionFunction), this.options.closeFunction && (this.userClose = this.options.closeFunction), this.options.initFunction && (this.userInit = this.options.initFunction), this.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.elements instanceof NodeList && this.elements.forEach((n, i) => {
300
- this.onClickElements.push((o) => {
301
- o.preventDefault(), this.open(i);
302
- }), n.addEventListener("click", this.onClickElements[i]);
359
+ }, this.options.initFunction && (this.userInit = this.options.initFunction), this.options.transitionFunction && (this.userTransition = this.options.transitionFunction), this.options.closeFunction && (this.userClose = this.options.closeFunction), this.options.initFunction && (this.userInit = this.options.initFunction), this.isReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.elements instanceof NodeList && this.elements.forEach((n, e) => {
360
+ n.dataset.vistaviewIndex = e.toString(), n.addEventListener("click", this.defaultOnClickHandler), n.addEventListener("pointerup", this.onClickElements);
303
361
  });
304
362
  }
305
- async swap(t, e) {
306
- var h, c;
307
- if (!b.somethingOpened || t === e || t === null || this.elements.length === 1) return;
308
- if (!this.imageContainerElm)
363
+ async swap(t, i) {
364
+ var l, c;
365
+ if (!C.somethingOpened || t === i || t === null) return;
366
+ if (console.log("Swapping from", t, "to", i), this.transitionAbortController && this.transitionAbortController.abort(), !this.imageContainerElm)
309
367
  throw new Error("VistaView: imageContainerElm is null in swap()");
310
368
  this.setIndexDisplay(), this.clearZoom();
311
- const { images: n, positions: i } = this.getCurrentIndexes(e), o = this.getImages(n), l = o.map((d, v) => H(d, i[v]));
312
- l.forEach((d, v) => {
313
- var m, E;
314
- const u = d.querySelector(".vistaview-image-highres"), g = o[v].imageElm;
315
- if (u.complete && u.naturalWidth > 0) {
316
- const { width: w, height: y } = A(g);
317
- w && y && (u.style.setProperty("--vistaview-fitted-width", `${w}px`), u.style.setProperty("--vistaview-fitted-height", `${y}px`)), u.classList.add("vistaview-image-loaded"), (m = d.querySelector(".vistaview-image-lowres")) == null || m.classList.add("vistaview-image--hidden");
318
- const { width: p, height: x } = P(u);
319
- u.style.width = `${p}px`, u.style.height = `${x}px`, u.width = u.naturalWidth, u.height = u.naturalHeight, (E = u.parentElement) != null && E.matches('[data-vistaview-pos="0"]') && this.updateZoomButtonsVisibility();
320
- }
321
- }), this.navActive = !1;
322
- const a = {
323
- htmlElements: { from: this.currentItems, to: l },
324
- images: { from: this.currentImages, to: o },
325
- index: { from: t, to: e },
369
+ const { images: n, positions: e } = this.getCurrentIndexes(i), a = this.getImages(n), d = a.map((r, h) => q(r, e[h]));
370
+ console.log("swap prepared");
371
+ const o = {
372
+ htmlElements: { from: this.currentItems, to: d },
373
+ images: { from: this.currentImages, to: a },
374
+ index: { from: t, to: i },
326
375
  via: this.currentIndex.via,
327
376
  container: this.imageContainerElm,
328
377
  elements: this.elements,
@@ -331,117 +380,131 @@ class it {
331
380
  isZoomed: this.isZoomed,
332
381
  options: this.options
333
382
  };
334
- this.userSetup(a);
335
- const r = await this.userTransition(a);
336
- this.navActive = !0, this.setInitialDimPos(r), this.currentImages = o, this.currentItems = l, this.loadImages(), this.setCurrentDescription(), (c = (h = this.options).onImageView) == null || c.call(h, a);
383
+ this.userSetup(o), this.transitionAbortController = new AbortController();
384
+ try {
385
+ await this.userTransition(o, this.transitionAbortController.signal);
386
+ } catch (r) {
387
+ r instanceof P || console.error(r);
388
+ }
389
+ console.log("swap completed"), this.imageContainerElm.innerHTML = "", d.forEach((r) => {
390
+ const h = r.dataset.vistaviewPos, m = r.dataset.vistaviewIndex;
391
+ if (h === "0") {
392
+ const f = this.currentItems.find((y) => y.dataset.vistaviewIndex === m), u = r.querySelector(".vistaview-image-highres"), v = f == null ? void 0 : f.querySelector(".vistaview-image-highres");
393
+ v && (u.setAttribute("class", v.getAttribute("class") || ""), u.setAttribute("style", v.getAttribute("style") || "")), this.imageContainerElm.appendChild(r);
394
+ } else
395
+ this.imageContainerElm.appendChild(r);
396
+ }), this.setInitialDimPos(), this.currentImages = a, this.currentItems = d, this.loadImages(), this.setCurrentDescription(), this.updateZoomButtonsVisibility(), (c = (l = this.options).onImageView) == null || c.call(l, o);
337
397
  }
338
398
  //
339
399
  setZoomed(t) {
340
- var e, n, i, o, l, a;
400
+ var i, n, e, a, d, o;
341
401
  if (this.isZoomed !== t) {
342
402
  if (this.isZoomed) {
343
- let r = this.isZoomed;
344
- if (r.classList.remove("vistaview-image--zooming"), this.onZoomedPointerDown && ((e = r.parentElement) == null || e.removeEventListener("pointerdown", this.onZoomedPointerDown), this.onZoomedPointerDown = null), this.onZoomedPointerMove && ((n = r.parentElement) == null || n.removeEventListener("pointermove", this.onZoomedPointerMove), this.onZoomedPointerMove = null), this.onZoomedPointerUp && ((i = r.parentElement) == null || i.removeEventListener("pointerup", this.onZoomedPointerUp), this.onZoomedPointerUp = null), r == null || r.style.removeProperty("--pointer-diff-x"), r == null || r.style.removeProperty("--pointer-diff-y"), setTimeout(() => {
345
- r == null || r.classList.remove("vistaview-image--zooming");
403
+ let l = this.isZoomed;
404
+ if (l.classList.remove("vistaview-image--zooming"), this.onZoomedPointerDown && ((i = l.parentElement) == null || i.removeEventListener("pointerdown", this.onZoomedPointerDown), this.onZoomedPointerDown = null), this.onZoomedPointerMove && ((n = l.parentElement) == null || n.removeEventListener("pointermove", this.onZoomedPointerMove), this.onZoomedPointerMove = null), this.onZoomedPointerUp && ((e = l.parentElement) == null || e.removeEventListener("pointerup", this.onZoomedPointerUp), this.onZoomedPointerUp = null), l == null || l.style.removeProperty("--pointer-diff-x"), l == null || l.style.removeProperty("--pointer-diff-y"), setTimeout(() => {
405
+ l == null || l.classList.remove("vistaview-image--zooming");
346
406
  }, 500), this.isZoomed = !1, !t) return;
347
407
  }
348
408
  if (t) {
349
409
  this.isZoomed = t, t.classList.add("vistaview-image--zooming"), t == null || t.style.setProperty("--pointer-diff-x", "0px"), t == null || t.style.setProperty("--pointer-diff-y", "0px");
350
- let r = !1, h = 0, c = 0, d = 0, v = 0, u = 0, g = 0;
351
- this.onZoomedPointerDown = (m) => {
352
- m.preventDefault(), m.stopPropagation(), r = !0, h = m.pageX, c = m.pageY, t.setPointerCapture(m.pointerId);
353
- }, this.onZoomedPointerMove = (m) => {
354
- if (!r) return;
355
- m.preventDefault(), u = m.pageX - h, g = m.pageY - c;
356
- const E = parseInt((t == null ? void 0 : t.dataset.vistaviewCurrentWidth) || "0"), w = parseInt((t == null ? void 0 : t.dataset.vistaviewCurrentHeight) || "0"), { maxDiffX: y, minDiffY: p, maxDiffY: x, minDiffX: I } = R(
357
- E,
358
- w
359
- ), L = Math.min(y, Math.max(I, d + u)), C = Math.min(x, Math.max(p, v + g));
360
- u = L - d, g = C - v, t == null || t.style.setProperty("--pointer-diff-x", `${L}px`), t == null || t.style.setProperty("--pointer-diff-y", `${C}px`);
361
- }, this.onZoomedPointerUp = (m) => {
362
- r = !1, t.releasePointerCapture(m.pointerId), d += u, v += g, u = 0, g = 0;
363
- }, (o = t == null ? void 0 : t.parentElement) == null || o.addEventListener("pointerdown", this.onZoomedPointerDown), (l = t == null ? void 0 : t.parentElement) == null || l.addEventListener("pointermove", this.onZoomedPointerMove), (a = t == null ? void 0 : t.parentElement) == null || a.addEventListener("pointerup", this.onZoomedPointerUp);
410
+ let l = !1, c = 0, r = 0, h = 0, m = 0, f = 0, u = 0;
411
+ this.onZoomedPointerDown = (v) => {
412
+ v.preventDefault(), v.stopPropagation(), l = !0, c = v.pageX, r = v.pageY, t.setPointerCapture(v.pointerId);
413
+ }, this.onZoomedPointerMove = (v) => {
414
+ if (!l) return;
415
+ v.preventDefault(), f = v.pageX - c, u = v.pageY - r;
416
+ const y = parseInt((t == null ? void 0 : t.dataset.vistaviewCurrentWidth) || "0"), p = parseInt((t == null ? void 0 : t.dataset.vistaviewCurrentHeight) || "0"), { maxDiffX: b, minDiffY: x, maxDiffY: g, minDiffX: I } = T(
417
+ y,
418
+ p
419
+ ), E = Math.min(b, Math.max(I, h + f)), L = Math.min(g, Math.max(x, m + u));
420
+ f = E - h, u = L - m, t == null || t.style.setProperty("--pointer-diff-x", `${E}px`), t == null || t.style.setProperty("--pointer-diff-y", `${L}px`);
421
+ }, this.onZoomedPointerUp = (v) => {
422
+ l = !1, t.releasePointerCapture(v.pointerId), h += f, m += u, f = 0, u = 0;
423
+ }, (a = t == null ? void 0 : t.parentElement) == null || a.addEventListener("pointerdown", this.onZoomedPointerDown), (d = t == null ? void 0 : t.parentElement) == null || d.addEventListener("pointermove", this.onZoomedPointerMove), (o = t == null ? void 0 : t.parentElement) == null || o.addEventListener("pointerup", this.onZoomedPointerUp);
364
424
  return;
365
425
  }
366
426
  }
367
427
  }
368
428
  zoomIn() {
369
- var o, l, a, r, h;
370
- const t = (o = this.rootElm) == null ? void 0 : o.querySelector(
429
+ var a, d, o, l, c;
430
+ const t = (a = this.rootElm) == null ? void 0 : a.querySelector(
371
431
  '[data-vistaview-pos="0"] .vistaview-image-highres'
372
- ), e = t.width, n = t.height;
373
- t.dataset.vistaviewInitialWidth || (t.dataset.vistaviewInitialWidth = e.toString()), t.dataset.vistaviewInitialHeight || (t.dataset.vistaviewInitialHeight = n.toString()), this.setZoomed(t);
374
- const i = (t.naturalWidth || 0) * this.options.maxZoomLevel;
375
- if (e && i && e < i) {
376
- const c = Math.min(e + this.options.zoomStep, i);
377
- t.style.width = `${c}px`;
378
- const d = c / e * n;
379
- t.style.height = `${d}px`, (a = (l = this.rootElm) == null ? void 0 : l.querySelector("button.vistaview-zoom-out-btn")) == null || a.removeAttribute("disabled"), t.dataset.vistaviewCurrentWidth = c.toString(), t.dataset.vistaviewCurrentHeight = d.toString(), c === i && ((h = (r = this.rootElm) == null ? void 0 : r.querySelector("button.vistaview-zoom-in-btn")) == null || h.setAttribute("disabled", "true"));
432
+ ), i = t.width, n = t.height;
433
+ t.dataset.vistaviewInitialWidth || (t.dataset.vistaviewInitialWidth = i.toString()), t.dataset.vistaviewInitialHeight || (t.dataset.vistaviewInitialHeight = n.toString()), this.setZoomed(t);
434
+ const e = (t.naturalWidth || 0) * this.options.maxZoomLevel;
435
+ if (i && e && i < e) {
436
+ const r = Math.min(i + this.options.zoomStep, e);
437
+ t.style.width = `${r}px`;
438
+ const h = r / i * n;
439
+ t.style.height = `${h}px`, (o = (d = this.rootElm) == null ? void 0 : d.querySelector("button.vistaview-zoom-out-btn")) == null || o.removeAttribute("disabled"), t.dataset.vistaviewCurrentWidth = r.toString(), t.dataset.vistaviewCurrentHeight = h.toString(), r === e && ((c = (l = this.rootElm) == null ? void 0 : l.querySelector("button.vistaview-zoom-in-btn")) == null || c.setAttribute("disabled", "true"));
380
440
  }
381
441
  }
382
442
  zoomOut() {
383
- var l, a, r, h, c;
384
- const t = (l = this.rootElm) == null ? void 0 : l.querySelector(
443
+ var d, o, l, c, r;
444
+ const t = (d = this.rootElm) == null ? void 0 : d.querySelector(
385
445
  '[data-vistaview-pos="0"] .vistaview-image-highres'
386
- ), e = t.width, n = t.height, i = t.dataset.vistaviewInitialWidth ? parseInt(t.dataset.vistaviewInitialWidth) : 0, o = (d) => {
387
- d.target === t && (t.classList.remove("vistaview-image--zooming-out"), t.removeEventListener("transitionend", o));
446
+ ), i = t.width, n = t.height, e = t.dataset.vistaviewInitialWidth ? parseInt(t.dataset.vistaviewInitialWidth) : 0, a = (h) => {
447
+ h.target === t && (t.classList.remove("vistaview-image--zooming-out"), t.removeEventListener("transitionend", a));
388
448
  };
389
- if (t.addEventListener("transitionend", o), t.classList.add("vistaview-image--zooming-out"), e && i && e > i) {
390
- const d = Math.max(e - this.options.zoomStep, i);
391
- t.style.width = `${d}px`;
392
- const v = d / e * n;
393
- t.style.height = `${v}px`, (r = (a = this.rootElm) == null ? void 0 : a.querySelector("button.vistaview-zoom-in-btn")) == null || r.removeAttribute("disabled"), t.dataset.vistaviewCurrentWidth = d.toString(), t.dataset.vistaviewCurrentHeight = v.toString();
394
- const { maxDiffX: u, minDiffY: g, maxDiffY: m, minDiffX: E } = R(d, v);
395
- let w = parseInt(
449
+ if (t.addEventListener("transitionend", a), t.classList.add("vistaview-image--zooming-out"), i && e && i > e) {
450
+ const h = Math.max(i - this.options.zoomStep, e);
451
+ t.style.width = `${h}px`;
452
+ const m = h / i * n;
453
+ t.style.height = `${m}px`, (l = (o = this.rootElm) == null ? void 0 : o.querySelector("button.vistaview-zoom-in-btn")) == null || l.removeAttribute("disabled"), t.dataset.vistaviewCurrentWidth = h.toString(), t.dataset.vistaviewCurrentHeight = m.toString();
454
+ const { maxDiffX: f, minDiffY: u, maxDiffY: v, minDiffX: y } = T(h, m);
455
+ let p = parseInt(
396
456
  (t == null ? void 0 : t.style.getPropertyValue("--pointer-diff-x").replace("px", "")) || "0"
397
- ), y = parseInt(
457
+ ), b = parseInt(
398
458
  (t == null ? void 0 : t.style.getPropertyValue("--pointer-diff-y").replace("px", "")) || "0"
399
459
  );
400
- w = Math.min(u, Math.max(E, w)), y = Math.min(m, Math.max(g, y)), t == null || t.style.setProperty("--pointer-diff-x", `${w}px`), t == null || t.style.setProperty("--pointer-diff-y", `${y}px`), d === i && ((c = (h = this.rootElm) == null ? void 0 : h.querySelector("button.vistaview-zoom-out-btn")) == null || c.setAttribute("disabled", "true"), t.removeAttribute("data-vistaview-current-width"), t.removeAttribute("data-vistaview-current-height"), t.removeAttribute("data-vistaview-initial-width"), t.removeAttribute("data-vistaview-initial-height"), this.setZoomed(!1));
460
+ p = Math.min(f, Math.max(y, p)), b = Math.min(v, Math.max(u, b)), t == null || t.style.setProperty("--pointer-diff-x", `${p}px`), t == null || t.style.setProperty("--pointer-diff-y", `${b}px`), h === e && ((r = (c = this.rootElm) == null ? void 0 : c.querySelector("button.vistaview-zoom-out-btn")) == null || r.setAttribute("disabled", "true"), t.removeAttribute("data-vistaview-current-width"), t.removeAttribute("data-vistaview-current-height"), t.removeAttribute("data-vistaview-initial-width"), t.removeAttribute("data-vistaview-initial-height"), this.setZoomed(!1));
401
461
  }
402
462
  }
403
463
  clearZoom() {
404
464
  }
405
465
  getImages(t) {
406
- return t.map((e, n) => {
407
- const i = this.elements[e];
408
- if (i instanceof HTMLElement) {
409
- const o = i.querySelector("img"), l = i.getAttribute("href") || "", a = i.getAttribute("src") || "", r = i.dataset.vistaviewSrc || l || a || (o == null ? void 0 : o.src) || "", h = i.dataset.vistaviewAlt || i.getAttribute("alt") || (o == null ? void 0 : o.alt) || "", c = i.dataset.vistaviewThumb || (o == null ? void 0 : o.src) || l || a || "";
466
+ return t.map((i, n) => {
467
+ const e = this.elements[i];
468
+ if (e instanceof HTMLElement) {
469
+ const a = e.querySelector("img"), d = e.getAttribute("href") || "", o = e.getAttribute("src") || "", l = e.dataset.vistaviewSrc || d || o || (a == null ? void 0 : a.src) || "", c = e.dataset.vistaviewAlt || e.getAttribute("alt") || (a == null ? void 0 : a.alt) || "", r = e.dataset.vistaviewThumb || (a == null ? void 0 : a.src) || d || o || "";
410
470
  return {
411
471
  index: t[n],
412
- src: r,
413
- alt: h,
414
- thumb: c,
415
- imageElm: i instanceof HTMLImageElement ? i : o,
416
- anchorElm: i instanceof HTMLAnchorElement ? i : void 0
472
+ src: l,
473
+ alt: c,
474
+ thumb: r,
475
+ imageElm: e instanceof HTMLImageElement ? e : a,
476
+ anchorElm: e instanceof HTMLAnchorElement ? e : void 0
417
477
  };
418
478
  } else
419
- return { index: t[n], ...i };
479
+ return { index: t[n], ...e };
420
480
  });
421
481
  }
422
- setInitialDimPos(t) {
482
+ setInitialDimPos() {
483
+ var c, r;
423
484
  if (!this.rootElm) return;
424
- const e = t.imageElm ? Z(t.imageElm) : void 0, n = t.anchorElm ? Z(t.anchorElm) : void 0, i = (n == null ? void 0 : n.width) || (e == null ? void 0 : e.width) || 0, o = (n == null ? void 0 : n.height) || (e == null ? void 0 : e.height) || 0, l = ((n == null ? void 0 : n.left) || (e == null ? void 0 : e.left) || 0) + i / 2, a = ((n == null ? void 0 : n.top) || (e == null ? void 0 : e.top) || 0) + o / 2;
425
- this.rootElm.style.setProperty("--vistaview-container-initial-width", i + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-height", o + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-top", a + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-left", l + "px"), this.rootElm.style.setProperty(
485
+ const t = (c = this.rootElm.querySelector('[data-vistaview-pos="0"]')) == null ? void 0 : c.dataset.vistaviewIndex, i = ((r = this.currentImages) == null ? void 0 : r.find((h) => h.index === Number(t))) || null;
486
+ if (!i) return;
487
+ const n = i.imageElm ? z(i.imageElm) : void 0, e = i.anchorElm ? z(i.anchorElm) : void 0, a = (e == null ? void 0 : e.width) || (n == null ? void 0 : n.width) || 0, d = (e == null ? void 0 : e.height) || (n == null ? void 0 : n.height) || 0, o = ((e == null ? void 0 : e.left) || (n == null ? void 0 : n.left) || 0) + a / 2, l = ((e == null ? void 0 : e.top) || (n == null ? void 0 : n.top) || 0) + d / 2;
488
+ this.rootElm.style.setProperty("--vistaview-container-initial-width", a + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-height", d + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-top", l + "px"), this.rootElm.style.setProperty("--vistaview-container-initial-left", o + "px"), this.rootElm.style.setProperty(
426
489
  "--vistaview-image-border-radius",
427
- z(n == null ? void 0 : n.borderRadius) || z(e == null ? void 0 : e.borderRadius) || "0px"
490
+ R(e == null ? void 0 : e.borderRadius) || R(n == null ? void 0 : n.borderRadius) || "0px"
428
491
  );
429
492
  }
430
493
  updateZoomButtonsVisibility() {
431
- var i;
432
- const t = (i = this.rootElm) == null ? void 0 : i.querySelector(
494
+ var e;
495
+ const t = (e = this.rootElm) == null ? void 0 : e.querySelector(
433
496
  '[data-vistaview-pos="0"] img.vistaview-image-highres'
434
497
  );
435
498
  if (!t) return;
436
- const e = this;
499
+ const i = this;
437
500
  function n() {
438
- var c, d;
439
- const o = (c = e.rootElm) == null ? void 0 : c.querySelector(
501
+ var r, h;
502
+ const a = (r = i.rootElm) == null ? void 0 : r.querySelector(
440
503
  "button.vistaview-zoom-in-btn"
441
- ), l = (d = e.rootElm) == null ? void 0 : d.querySelector(
504
+ ), d = (h = i.rootElm) == null ? void 0 : h.querySelector(
442
505
  "button.vistaview-zoom-out-btn"
443
- ), a = parseInt(t.style.width) || t.width, r = t.naturalWidth * e.options.maxZoomLevel, h = a < r && r > 0;
444
- o && (o.style.display = h ? "" : "none"), l && (l.style.display = h ? "" : "none");
506
+ ), o = parseInt(t.style.width) || t.width, l = t.naturalWidth * i.options.maxZoomLevel, c = o < l && l > 0;
507
+ a && (a.style.display = c ? "" : "none"), d && (d.style.display = c ? "" : "none");
445
508
  }
446
509
  t.complete && t.naturalWidth > 0 ? n() : t.addEventListener("load", n);
447
510
  }
@@ -449,28 +512,38 @@ class it {
449
512
  if (!this.rootElm) return;
450
513
  this.rootElm.querySelectorAll(
451
514
  ".vistaview-image-highres:not(.vistaview-image-loaded)"
452
- ).forEach((e, n) => {
453
- const i = e, l = this.currentImages[n].imageElm, a = { w: 0, h: 0 };
454
- if (l) {
455
- const { width: h, height: c } = A(l);
456
- a.w = Math.min(l.width, h), a.h = Math.min(l.height, c);
515
+ ).forEach((i, n) => {
516
+ const e = i, d = this.currentImages[n].imageElm, o = { w: 0, h: 0 };
517
+ if (d) {
518
+ const { width: c, height: r } = B(d);
519
+ o.w = Math.min(d.width, c), o.h = Math.min(d.height, r);
457
520
  }
458
- const r = (h = !1) => () => {
459
- var c;
460
- if (a.w && a.h && (i.style.width = `${a.w}px`, i.style.height = `${a.h}px`, i.style.setProperty("--vistaview-fitted-width", `${a.w}px`), i.style.setProperty("--vistaview-fitted-height", `${a.h}px`)), i.classList.add("vistaview-image-loaded"), i.width = i.naturalWidth, i.height = i.naturalHeight, h) {
461
- const { width: d, height: v } = P(i);
462
- i.style.width = `${d}px`, i.style.height = `${v}px`;
463
- } else
464
- setTimeout(() => {
465
- const { width: d, height: v } = P(i);
466
- i.style.width = `${d}px`, i.style.height = `${v}px`;
467
- }, 333);
468
- setTimeout(() => {
469
- var d, v;
470
- (v = (d = i.parentElement) == null ? void 0 : d.querySelector(".vistaview-image-lowres")) == null || v.classList.add("vistaview-image--hidden");
471
- }, 500), (c = e.parentElement) != null && c.matches('[data-vistaview-pos="0"]') && this.updateZoomButtonsVisibility();
521
+ const l = () => {
522
+ var r;
523
+ const c = () => {
524
+ var h;
525
+ o.w && o.h && (e.style.width = `${o.w}px`, e.style.height = `${o.h}px`, e.style.setProperty("--vistaview-fitted-width", `${o.w}px`), e.style.setProperty("--vistaview-fitted-height", `${o.h}px`)), e.classList.add("vistaview-image-loaded"), e.width = e.naturalWidth, e.height = e.naturalHeight, setTimeout(() => {
526
+ var y, p;
527
+ let m = 0;
528
+ const f = () => {
529
+ var b, x;
530
+ m++, !(m < 3) && (e.removeEventListener("transitionend", f), (x = (b = e.parentElement) == null ? void 0 : b.querySelector(".vistaview-image-lowres")) == null || x.classList.add("vistaview-image--hidden"), e.classList.add("vistaview-image-settled"));
531
+ };
532
+ e.addEventListener("transitionend", f);
533
+ const { width: u, height: v } = H(e);
534
+ e.style.width = `${u}px`, e.style.height = `${v}px`, o.w && o.h && u === o.w && v === o.h ? ((p = (y = e.parentElement) == null ? void 0 : y.querySelector(".vistaview-image-lowres")) == null || p.classList.add("vistaview-image--hidden"), e.classList.add("vistaview-image-settled")) : (e.style.width = `${u}px`, e.style.height = `${v}px`);
535
+ }, 100), (h = i.parentElement) != null && h.matches('[data-vistaview-pos="0"]') && this.updateZoomButtonsVisibility();
536
+ };
537
+ if ((r = this.rootElm) != null && r.classList.contains("vistaview--opened"))
538
+ c();
539
+ else {
540
+ const h = setInterval(() => {
541
+ var m;
542
+ (m = this.rootElm) != null && m.classList.contains("vistaview--opened") && (clearInterval(h), c());
543
+ }, 50);
544
+ }
472
545
  };
473
- i.complete && i.naturalWidth > 0 ? r(!0)() : i.onload = r(!1);
546
+ e.complete && e.naturalWidth > 0 ? l() : e.onload = l;
474
547
  });
475
548
  }
476
549
  setIndexDisplay() {
@@ -480,19 +553,19 @@ class it {
480
553
  this.rootElm.querySelector(".vistaview-description").textContent = (this.currentImages[1] || this.currentImages[0]).alt || "";
481
554
  }
482
555
  getCurrentIndexes(t) {
483
- const e = this.options.preloads, n = this.elements.length, i = n < 1 || !e ? [t] : [
556
+ const i = this.options.preloads, n = this.elements.length, e = n < 1 || !i ? [t] : [
484
557
  .../* @__PURE__ */ new Set([
485
558
  ...Array.from(
486
- { length: e },
487
- (l, a) => ((t - e + a) % n + n) % n
559
+ { length: i },
560
+ (d, o) => ((t - i + o) % n + n) % n
488
561
  ),
489
562
  t,
490
- ...Array.from({ length: e }, (l, a) => (t + 1 + a) % n)
563
+ ...Array.from({ length: i }, (d, o) => (t + 1 + o) % n)
491
564
  ])
492
- ], o = n < 1 || !e ? [0] : i.map((l, a) => a - Math.floor(i.length / 2));
565
+ ], a = n < 1 || !i ? [0] : e.map((d, o) => o - Math.floor(e.length / 2));
493
566
  return {
494
- images: i,
495
- positions: o
567
+ images: e,
568
+ positions: a
496
569
  };
497
570
  }
498
571
  setKeyboardListeners() {
@@ -518,36 +591,36 @@ class it {
518
591
  }
519
592
  setResizeListeners() {
520
593
  this.onResizeHandler = () => {
521
- var n;
522
- const t = this.currentImages[this.currentImages.length === 1 ? 0 : Math.floor(this.currentImages.length / 2)];
523
- this.setInitialDimPos(t);
524
- const e = (n = this.rootElm) == null ? void 0 : n.querySelectorAll(
594
+ var i;
595
+ this.setInitialDimPos();
596
+ const t = (i = this.rootElm) == null ? void 0 : i.querySelectorAll(
525
597
  ".vistaview-image-highres.vistaview-image-loaded"
526
598
  );
527
- e == null || e.forEach((i) => {
528
- const o = i, { width: l, height: a } = P(o);
529
- o.classList.contains("vistaview-image--zooming") ? (o.dataset.vistaviewInitialWidth = l.toString(), o.dataset.vistaviewInitialHeight = a.toString()) : (o.style.width = `${l}px`, o.style.height = `${a}px`);
599
+ t == null || t.forEach((n) => {
600
+ const e = n, { width: a, height: d } = H(e);
601
+ e.classList.contains("vistaview-image--zooming") ? (e.dataset.vistaviewInitialWidth = a.toString(), e.dataset.vistaviewInitialHeight = d.toString()) : (e.style.width = `${a}px`, e.style.height = `${d}px`);
530
602
  });
531
603
  }, window.addEventListener("resize", this.onResizeHandler);
532
604
  }
533
605
  open(t = 0) {
534
- var l, a, r, h, c, d, v, u, g, m, E, w, y;
535
- if (b.somethingOpened) {
606
+ var o, l, c, r, h, m, f, u, v, y, p, b, x;
607
+ if (C.somethingOpened) {
536
608
  console.error("VistaView: another instance is already opened. Returning.");
537
609
  return;
538
610
  }
539
- if (b.somethingOpened = this, this.currentIndex._value = t, document.body.prepend(
540
- K({
611
+ if (C.somethingOpened = this, this.currentIndex._value = t, document.body.prepend(
612
+ Q({
541
613
  controls: this.options.controls,
542
614
  isReducedMotion: this.isReducedMotion
543
615
  })
544
- ), this.rootElm = document.querySelector("#vistaview-root"), this.imageContainerElm = ((l = this.rootElm) == null ? void 0 : l.querySelector(".vistaview-image-container")) || null, !this.rootElm || !this.imageContainerElm)
545
- throw b.somethingOpened = null, new Error("Failed to create VistaView element");
546
- const { images: e, positions: n } = this.getCurrentIndexes(t);
547
- this.currentImages = this.getImages(e);
548
- const i = this.currentImages.map((p, x) => H(p, n[x]));
549
- this.currentItems = i;
550
- const o = {
616
+ ), this.rootElm = document.querySelector("#vistaview-root"), this.imageContainerElm = ((o = this.rootElm) == null ? void 0 : o.querySelector(".vistaview-image-container")) || null, !this.rootElm || !this.imageContainerElm)
617
+ throw C.somethingOpened = null, new Error("Failed to create VistaView element");
618
+ this.options.arrowOnSmallScreens || this.rootElm.classList.add("vistaview-no-arrows-sm");
619
+ const { images: i, positions: n } = this.getCurrentIndexes(t);
620
+ this.currentImages = this.getImages(i);
621
+ const e = this.currentImages.map((g, I) => q(g, n[I]));
622
+ this.currentItems = e;
623
+ const a = {
551
624
  htmlElements: { from: null, to: this.currentItems },
552
625
  images: { from: null, to: this.currentImages },
553
626
  index: { from: null, to: t },
@@ -559,25 +632,30 @@ class it {
559
632
  isZoomed: this.isZoomed,
560
633
  options: this.options
561
634
  };
562
- this.userSetup(o), this.imageContainerElm.innerHTML = "", this.currentItems.forEach((p) => {
563
- this.imageContainerElm.appendChild(p);
564
- }), (a = this.rootElm.querySelector(".vistaview-close-btn")) == null || a.addEventListener("click", () => this.close()), (r = this.rootElm.querySelector(".vistaview-zoom-in-btn")) == null || r.addEventListener("click", () => this.zoomIn()), (h = this.rootElm.querySelector(".vistaview-zoom-out-btn")) == null || h.addEventListener("click", () => this.zoomOut()), (c = this.rootElm.querySelector(".vistaview-prev-btn>button")) == null || c.addEventListener("click", () => this.prev()), (d = this.rootElm.querySelector(".vistaview-next-btn>button")) == null || d.addEventListener("click", () => this.next()), [
635
+ this.userSetup(a), this.imageContainerElm.innerHTML = "", this.currentItems.forEach((g) => {
636
+ this.imageContainerElm.appendChild(g);
637
+ });
638
+ let d = 0;
639
+ this.rootElm.addEventListener("animationend", (g) => {
640
+ var I;
641
+ g.currentTarget === this.rootElm && (d++, d >= 2 && ((I = this.rootElm) == null || I.classList.add("vistaview--opened")));
642
+ }), (l = this.rootElm.querySelector(".vistaview-close-btn")) == null || l.addEventListener("click", () => this.close()), (c = this.rootElm.querySelector(".vistaview-zoom-in-btn")) == null || c.addEventListener("click", () => this.zoomIn()), (r = this.rootElm.querySelector(".vistaview-zoom-out-btn")) == null || r.addEventListener("click", () => this.zoomOut()), (h = this.rootElm.querySelector(".vistaview-prev-btn>button")) == null || h.addEventListener("click", () => this.prev()), (m = this.rootElm.querySelector(".vistaview-next-btn>button")) == null || m.addEventListener("click", () => this.next()), [
565
643
  ...this.options.controls.topLeft || [],
566
644
  ...this.options.controls.topRight || [],
567
645
  ...this.options.controls.topCenter || [],
568
646
  ...this.options.controls.bottomCenter || [],
569
647
  ...this.options.controls.bottomLeft || [],
570
648
  ...this.options.controls.bottomRight || []
571
- ].forEach((p) => {
572
- typeof p != "string" && (this.customControls[p.name] = p);
573
- }), this.rootElm.querySelectorAll("button[data-vistaview-custom-control]").forEach((p) => {
574
- p.addEventListener("click", (x) => {
575
- const I = this.customControls[x.currentTarget.dataset.vistaviewCustomControl], L = this.currentImages.find(
576
- (C) => C.index === this.currentIndex.value
649
+ ].forEach((g) => {
650
+ typeof g != "string" && (this.customControls[g.name] = g);
651
+ }), this.rootElm.querySelectorAll("button[data-vistaview-custom-control]").forEach((g) => {
652
+ g.addEventListener("click", (I) => {
653
+ const E = this.customControls[I.currentTarget.dataset.vistaviewCustomControl], L = this.currentImages.find(
654
+ (D) => D.index === this.currentIndex.value
577
655
  );
578
- I && L && (I.onClick.constructor.name === "AsyncFunction" ? (p.classList.add("vistaview-button--loading"), I.onClick(L).finally(() => {
579
- p.classList.remove("vistaview-button--loading");
580
- })) : I.onClick(L));
656
+ E && L && (E.onClick.constructor.name === "AsyncFunction" ? (g.classList.add("vistaview-button--loading"), E.onClick(L).finally(() => {
657
+ g.classList.remove("vistaview-button--loading");
658
+ })) : E.onClick(L));
581
659
  });
582
660
  }), this.options.animationDurationBase && this.rootElm.style.setProperty(
583
661
  "--vistaview-animation-duration",
@@ -585,23 +663,21 @@ class it {
585
663
  ), this.options.initialZIndex !== void 0 && this.rootElm.style.setProperty(
586
664
  "--vistaview-initial-z-index",
587
665
  `${this.options.initialZIndex}`
588
- ), this.setInitialDimPos(
589
- this.currentImages[this.currentImages.length === 1 ? 0 : Math.floor(this.currentImages.length / 2)]
590
- ), this.setResizeListeners(), this.options.keyboardListeners && this.setKeyboardListeners(), this.elements.length === 1 && ((v = this.rootElm.querySelector(".vistaview-prev-btn")) == null || v.classList.add("vistaview-ui--none"), (u = this.rootElm.querySelector(".vistaview-next-btn")) == null || u.classList.add("vistaview-ui--none"), (g = this.rootElm.querySelector(".vistaview-index-display")) == null || g.classList.add("vistaview-ui--none")), this.rootElm && this.rootElm.classList.add("vistaview--initialized"), this.loadImages(), this.setCurrentDescription(), this.setIndexDisplay(), this.userInit(this), (E = (m = this.options).onOpen) == null || E.call(m, o), (y = (w = this.options).onImageView) == null || y.call(w, o);
666
+ ), this.setInitialDimPos(), this.setResizeListeners(), this.options.keyboardListeners && this.setKeyboardListeners(), this.elements.length === 1 && ((f = this.rootElm.querySelector(".vistaview-prev-btn")) == null || f.classList.add("vistaview-ui--none"), (u = this.rootElm.querySelector(".vistaview-next-btn")) == null || u.classList.add("vistaview-ui--none"), (v = this.rootElm.querySelector(".vistaview-index-display")) == null || v.classList.add("vistaview-ui--none")), this.rootElm && this.rootElm.classList.add("vistaview--initialized"), this.loadImages(), this.setCurrentDescription(), this.setIndexDisplay(), this.userInit(this), (p = (y = this.options).onOpen) == null || p.call(y, a), (x = (b = this.options).onImageView) == null || x.call(b, a);
591
667
  }
592
668
  async close(t = !0) {
593
- var n, i, o;
594
- if (b.somethingOpened !== this) return;
595
- t && ((n = this.rootElm) == null || n.classList.add("vistaview--closing"), await new Promise((l) => {
596
- var r;
597
- let a;
598
- (r = this.rootElm) == null || r.addEventListener("transitionend", (h) => {
599
- h.currentTarget === this.rootElm && (a && clearTimeout(a), a = setTimeout(() => {
600
- l();
669
+ var n, e, a;
670
+ if (C.somethingOpened !== this) return;
671
+ t && ((n = this.rootElm) == null || n.classList.add("vistaview--closing"), await new Promise((d) => {
672
+ var l;
673
+ let o;
674
+ (l = this.rootElm) == null || l.addEventListener("transitionend", (c) => {
675
+ c.currentTarget === this.rootElm && (o && clearTimeout(o), o = setTimeout(() => {
676
+ d();
601
677
  }, 333));
602
678
  });
603
679
  }));
604
- const e = {
680
+ const i = {
605
681
  htmlElements: { from: this.currentItems, to: null },
606
682
  images: { from: this.currentImages, to: null },
607
683
  index: { from: this.currentIndex.value, to: null },
@@ -613,68 +689,69 @@ class it {
613
689
  isZoomed: this.isZoomed,
614
690
  options: this.options
615
691
  };
616
- this.userClose(this), (o = (i = this.options).onClose) == null || o.call(i, e), document.body.removeChild(this.rootElm), this.currentIndex._value = null, this.currentIndex._via = { next: !1, prev: !1 }, this.rootElm = null, this.imageContainerElm = null, this.currentImages = null, this.currentItems = null, this.navActive = !0, this.onResizeHandler && (window.removeEventListener("resize", this.onResizeHandler), this.onResizeHandler = null), this.onKeyDown && (window.removeEventListener("keydown", this.onKeyDown), this.onKeyDown = null), (this.onZoomedPointerDown || this.onZoomedPointerMove || this.onZoomedPointerUp) && (this.setZoomed(!1), this.onZoomedPointerDown = null, this.onZoomedPointerMove = null, this.onZoomedPointerUp = null), b.somethingOpened = null;
692
+ this.userClose(this), (a = (e = this.options).onClose) == null || a.call(e, i), document.body.removeChild(this.rootElm), this.currentIndex._value = null, this.currentIndex._via = { next: !1, prev: !1 }, this.rootElm = null, this.imageContainerElm = null, this.currentImages = null, this.currentItems = null, this.navActive = !0, this.onResizeHandler && (window.removeEventListener("resize", this.onResizeHandler), this.onResizeHandler = null), this.onKeyDown && (window.removeEventListener("keydown", this.onKeyDown), this.onKeyDown = null), (this.onZoomedPointerDown || this.onZoomedPointerMove || this.onZoomedPointerUp) && (this.setZoomed(!1), this.onZoomedPointerDown = null, this.onZoomedPointerMove = null, this.onZoomedPointerUp = null), this.transitionAbortController && (this.transitionAbortController.abort(), this.transitionAbortController = null), C.somethingOpened = null;
617
693
  }
618
694
  destroy() {
619
- this.close(!1), this.elements instanceof NodeList && this.elements.forEach((t, e) => {
620
- t.removeEventListener("click", this.onClickElements[e]);
695
+ this.close(!1), this.elements instanceof NodeList && this.elements.forEach((t) => {
696
+ t.dataset.vistaviewIndex && delete t.dataset.vistaviewIndex, t.removeEventListener("click", this.defaultOnClickHandler), t.removeEventListener("pointerup", this.onClickElements);
621
697
  });
622
698
  }
623
- view(t, e) {
624
- b.somethingOpened === this && this.navActive && (t < 0 && (t = this.elements.length - 1), t >= this.elements.length && (t = 0), this.currentIndex.via = e || { next: !1, prev: !1 }, this.currentIndex.value = t);
699
+ view(t, i) {
700
+ C.somethingOpened === this && this.navActive && (t < 0 && (t = this.elements.length - 1), t >= this.elements.length && (t = 0), this.currentIndex.via = i || { next: !1, prev: !1 }, this.currentIndex.value = t);
625
701
  }
626
702
  next() {
627
- b.somethingOpened === this && this.view(this.currentIndex.value + 1, { next: !0, prev: !1 });
703
+ C.somethingOpened === this && this.view(this.currentIndex.value + 1, { next: !0, prev: !1 });
628
704
  }
629
705
  prev() {
630
- b.somethingOpened === this && this.view(this.currentIndex.value - 1, { next: !1, prev: !0 });
706
+ C.somethingOpened === this && this.view(this.currentIndex.value - 1, { next: !1, prev: !0 });
631
707
  }
632
708
  getCurrentIndex() {
633
- return b.somethingOpened === this ? this.currentIndex.value : -1;
709
+ return C.somethingOpened === this ? this.currentIndex.value : -1;
634
710
  }
635
711
  }
636
- function nt(s) {
712
+ function rt(s) {
637
713
  let t = null;
638
714
  if (typeof s == "string" ? t = document.querySelectorAll(s) : s instanceof NodeList && (t = s), t)
639
- for (let e = 0; e < t.length; e++) {
640
- const n = t[e];
715
+ for (let i = 0; i < t.length; i++) {
716
+ const n = t[i];
641
717
  if (!(n.dataset.vistaviewSrc || n.getAttribute("href") || n.getAttribute("src") || ""))
642
- return `Element at index ${e} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`;
718
+ return `Element at index ${i} is missing 'src' / 'data-vistaview-src' / 'href' attribute.`;
643
719
  }
644
720
  else {
645
- const e = s;
646
- for (let n = 0; n < e.length; n++)
647
- if (!e[n].src)
721
+ const i = s;
722
+ for (let n = 0; n < i.length; n++)
723
+ if (!i[n].src)
648
724
  return `Element at index ${n} is missing 'src' attribute.`;
649
725
  }
650
726
  return t || s;
651
727
  }
652
- function ot({ elements: s, ...t }) {
728
+ function lt({ elements: s, ...t }) {
653
729
  if (!s) throw new Error("No elements");
654
- let e = nt(s);
655
- if (typeof e == "string")
656
- return console.error(e), console.warn("VistaView: silently returning."), null;
657
- const n = new it(e, t);
730
+ let i = rt(s);
731
+ if (typeof i == "string")
732
+ return console.error(i), console.warn("VistaView: silently returning."), null;
733
+ const n = new ot(i, t);
658
734
  return {
659
- open: (i = 0) => n.open(i),
735
+ open: (e = 0) => n.open(e),
660
736
  close: () => n.close(),
661
737
  next: () => n.next(),
662
738
  prev: () => n.prev(),
663
739
  destroy: () => n.destroy(),
664
740
  getCurrentIndex: () => n.getCurrentIndex(),
665
- view: (i) => {
666
- n.view(i);
741
+ view: (e) => {
742
+ n.view(e);
667
743
  }
668
744
  };
669
745
  }
670
746
  export {
671
- W as DefaultOptions,
672
- et as defaultClose,
673
- J as defaultInit,
674
- Q as defaultSetup,
675
- tt as defaultTransition,
676
- q as removeTouchActions,
677
- G as setTouchActions,
678
- ot as vistaView,
679
- N as vistaViewDownload
747
+ k as DefaultOptions,
748
+ P as VistaViewTransitionAbortedError,
749
+ st as defaultClose,
750
+ et as defaultInit,
751
+ it as defaultSetup,
752
+ nt as defaultTransition,
753
+ O as removeTouchActions,
754
+ tt as setTouchActions,
755
+ lt as vistaView,
756
+ G as vistaViewDownload
680
757
  };