@peeekpage/viewer 0.4.1 → 0.4.3

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.
Files changed (2) hide show
  1. package/dist/index.js +447 -422
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsxs as _, jsx as o, Fragment as Ye } from "react/jsx-runtime";
2
- import { useState as T, useRef as j, useEffect as C, useCallback as E, useMemo as qe } from "react";
3
- const Je = /* @__PURE__ */ new Set(["http:", "https:"]);
1
+ import { jsxs as y, jsx as o, Fragment as Qe } from "react/jsx-runtime";
2
+ import { useState as v, useRef as E, useEffect as C, useCallback as L, useMemo as et } from "react";
3
+ const tt = /* @__PURE__ */ new Set(["http:", "https:"]);
4
4
  function G(t) {
5
5
  if (typeof t != "string") return null;
6
6
  const e = t.trim();
@@ -12,23 +12,23 @@ function G(t) {
12
12
  } catch {
13
13
  return null;
14
14
  }
15
- return Je.has(a.protocol) ? a.href : null;
15
+ return tt.has(a.protocol) ? a.href : null;
16
16
  }
17
- const Qe = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, et = /^rgba?\([ \t]*\d{1,3}[ \t]*,[ \t]*\d{1,3}[ \t]*,[ \t]*\d{1,3}[ \t]*(?:,[ \t]*(?:0|1|0?\.\d+)[ \t]*)?\)$/;
18
- function se(t) {
17
+ const nt = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/, at = /^rgba?\([ \t]*\d{1,3}[ \t]*,[ \t]*\d{1,3}[ \t]*,[ \t]*\d{1,3}[ \t]*(?:,[ \t]*(?:0|1|0?\.\d+)[ \t]*)?\)$/;
18
+ function de(t) {
19
19
  if (typeof t != "string") return null;
20
20
  const e = t.trim();
21
- return Qe.test(e) || et.test(e) ? e : null;
21
+ return nt.test(e) || at.test(e) ? e : null;
22
22
  }
23
- const tt = /url\(|image\(|image-set\(|element\(|expression|@|\/\*|;|\{|\}|<|>|\\/i, nt = /^(repeating-)?(linear|radial|conic)-gradient\([a-z0-9#.,%()\/\s-]*\)$/i, at = /^hsla?\([a-z0-9.,%\/\s-]*\)$/i;
24
- function ot(t) {
23
+ const ot = /url\(|image\(|image-set\(|element\(|expression|@|\/\*|;|\{|\}|<|>|\\/i, rt = /^(repeating-)?(linear|radial|conic)-gradient\([a-z0-9#.,%()\/\s-]*\)$/i, lt = /^hsla?\([a-z0-9.,%\/\s-]*\)$/i;
24
+ function it(t) {
25
25
  if (typeof t != "string") return null;
26
26
  const e = t.trim();
27
- if (e === "" || tt.test(e)) return null;
28
- const n = se(e);
29
- return n !== null ? n : at.test(e) || nt.test(e) ? e : null;
27
+ if (e === "" || ot.test(e)) return null;
28
+ const n = de(e);
29
+ return n !== null ? n : lt.test(e) || rt.test(e) ? e : null;
30
30
  }
31
- const rt = ["en", "pt-BR"], ye = {
31
+ const st = ["en", "pt-BR"], Ne = {
32
32
  prev: "Previous page",
33
33
  next: "Next page",
34
34
  zoom: "Zoom level",
@@ -50,7 +50,7 @@ const rt = ["en", "pt-BR"], ye = {
50
50
  rotate: "Rotate page",
51
51
  singlePage: "Single page",
52
52
  doublePage: "Two pages"
53
- }, lt = {
53
+ }, ct = {
54
54
  prev: "Página anterior",
55
55
  next: "Próxima página",
56
56
  zoom: "Nível de zoom",
@@ -72,34 +72,34 @@ const rt = ["en", "pt-BR"], ye = {
72
72
  rotate: "Girar página",
73
73
  singlePage: "Página única",
74
74
  doublePage: "Duas páginas"
75
- }, it = { en: ye, "pt-BR": lt };
76
- function st(t) {
77
- return it[t] ?? ye;
75
+ }, ut = { en: Ne, "pt-BR": ct };
76
+ function dt(t) {
77
+ return ut[t] ?? Ne;
78
78
  }
79
- const ct = "#6E79D6";
79
+ const ft = "#6E79D6";
80
80
  function I(t, e) {
81
81
  return typeof t == "boolean" ? t : e;
82
82
  }
83
- function Y(t, e, n) {
83
+ function J(t, e, n) {
84
84
  return e.includes(t) ? t : n;
85
85
  }
86
- function ut(t) {
86
+ function gt(t) {
87
87
  return {
88
88
  src: typeof t.src == "string" ? t.src : "",
89
- mode: Y(t.mode, ["flip", "coverflow"], "flip"),
89
+ mode: J(t.mode, ["flip", "coverflow"], "flip"),
90
90
  logo: G(t.logo),
91
91
  logoLink: G(t.logoLink),
92
- accentColor: se(t.accentColor) ?? ct,
93
- background: Y(t.background, ["color", "image", "transparent"], "color"),
94
- backgroundColor: ot(t.backgroundColor),
92
+ accentColor: de(t.accentColor) ?? ft,
93
+ background: J(t.background, ["color", "image", "transparent"], "color"),
94
+ backgroundColor: it(t.backgroundColor),
95
95
  backgroundImage: G(t.backgroundImage),
96
- layout: Y(t.layout, ["single", "double"], "double"),
96
+ layout: J(t.layout, ["single", "double"], "double"),
97
97
  fillHeight: I(t.fillHeight, !1),
98
98
  pageShadows: I(t.pageShadows, !0),
99
99
  rtl: I(t.rtl, !1),
100
100
  animateInteractions: I(t.animateInteractions, !0),
101
- skin: Y(t.skin, ["classic", "minimal", "showcase"], "classic"),
102
- language: Y(t.language, rt, "en"),
101
+ skin: J(t.skin, ["classic", "minimal", "showcase"], "classic"),
102
+ language: J(t.language, st, "en"),
103
103
  autoTransition: I(t.autoTransition, !1),
104
104
  autoTransitionInterval: typeof t.autoTransitionInterval == "number" && t.autoTransitionInterval > 0 ? t.autoTransitionInterval : 5e3,
105
105
  navigationControls: I(t.navigationControls, !0),
@@ -114,52 +114,52 @@ function ut(t) {
114
114
  layoutToggle: I(t.layoutToggle, !0),
115
115
  loadingImage: G(t.loadingImage),
116
116
  loadingCaption: typeof t.loadingCaption == "string" && t.loadingCaption.length > 0 ? t.loadingCaption : null,
117
- loadingColor: se(t.loadingColor),
117
+ loadingColor: de(t.loadingColor),
118
118
  pollInterval: typeof t.pollInterval == "number" && t.pollInterval > 0 ? t.pollInterval : 2e3,
119
119
  className: typeof t.className == "string" ? t.className : ""
120
120
  };
121
121
  }
122
- const ce = 5e3;
123
- function q(t) {
122
+ const fe = 5e3;
123
+ function Q(t) {
124
124
  return typeof t == "string" ? t : "";
125
125
  }
126
- function dt(t) {
126
+ function mt(t) {
127
127
  if (t === null || typeof t != "object" || Array.isArray(t))
128
128
  return { ok: !1, error: "manifest is not an object" };
129
129
  const e = t;
130
130
  if (!Array.isArray(e.pages))
131
131
  return { ok: !1, error: "manifest.pages is missing or not an array" };
132
- if (e.pages.length > ce)
132
+ if (e.pages.length > fe)
133
133
  return { ok: !1, error: "manifest.pages exceeds the maximum" };
134
134
  const n = e.total_pages, a = typeof n == "number" && Number.isFinite(n) && n >= 0 ? n : e.pages.length;
135
- if (a > ce)
135
+ if (a > fe)
136
136
  return { ok: !1, error: "manifest.total_pages exceeds the maximum" };
137
- const l = [];
137
+ const i = [];
138
138
  for (const g of e.pages) {
139
139
  if (g === null || typeof g != "object") continue;
140
- const s = G(g.url);
141
- s && l.push(s);
140
+ const c = G(g.url);
141
+ c && i.push(c);
142
142
  }
143
- if (l.length === 0)
143
+ if (i.length === 0)
144
144
  return { ok: !1, error: "manifest has no usable pages" };
145
- const c = e.status === "wip" ? "wip" : "done", b = e.metadata && typeof e.metadata == "object" ? e.metadata : {}, p = {
146
- fileId: q(b.file_id),
147
- filename: q(b.filename),
148
- creationDate: q(b.creation_date),
149
- fileSize: q(b.file_size),
150
- mimeType: q(b.mime_type)
145
+ const d = e.status === "wip" ? "wip" : "done", _ = e.metadata && typeof e.metadata == "object" ? e.metadata : {}, h = {
146
+ fileId: Q(_.file_id),
147
+ filename: Q(_.filename),
148
+ creationDate: Q(_.creation_date),
149
+ fileSize: Q(_.file_size),
150
+ mimeType: Q(_.mime_type)
151
151
  };
152
152
  return {
153
153
  ok: !0,
154
- value: { status: c, totalPages: a, pages: l, metadata: p }
154
+ value: { status: d, totalPages: a, pages: i, metadata: h }
155
155
  };
156
156
  }
157
- function gt(t, e) {
158
- if (!Array.isArray(t) || t.length > ce) return null;
157
+ function pt(t, e) {
158
+ if (!Array.isArray(t) || t.length > fe) return null;
159
159
  const n = [];
160
- for (const l of t) {
161
- const c = G(l);
162
- c && n.push(c);
160
+ for (const i of t) {
161
+ const d = G(i);
162
+ d && n.push(d);
163
163
  }
164
164
  return n.length === 0 ? null : {
165
165
  status: "done",
@@ -174,70 +174,70 @@ function gt(t, e) {
174
174
  }
175
175
  };
176
176
  }
177
- function ft(t, e) {
178
- const [n, a] = T("loading"), [l, c] = T(null), [b, p] = T(null), g = j(null);
177
+ function bt(t, e) {
178
+ const [n, a] = v("loading"), [i, d] = v(null), [_, h] = v(null), g = E(null);
179
179
  return C(() => {
180
- let s = !1;
181
- if (a("loading"), c(null), p(null), !t) return;
182
- const k = () => {
180
+ let c = !1;
181
+ if (a("loading"), d(null), h(null), !t) return;
182
+ const w = () => {
183
183
  g.current !== null && (clearTimeout(g.current), g.current = null);
184
- }, h = async () => {
185
- let d;
184
+ }, k = async () => {
185
+ let f;
186
186
  try {
187
- const i = await fetch(t);
188
- if (!i.ok) throw new Error(`HTTP ${i.status}`);
189
- d = await i.json();
190
- } catch (i) {
191
- if (s) return;
192
- p(i instanceof Error ? i.message : "fetch failed"), a("error");
187
+ const l = await fetch(t);
188
+ if (!l.ok) throw new Error(`HTTP ${l.status}`);
189
+ f = await l.json();
190
+ } catch (l) {
191
+ if (c) return;
192
+ h(l instanceof Error ? l.message : "fetch failed"), a("error");
193
193
  return;
194
194
  }
195
- if (s) return;
196
- const u = dt(d);
195
+ if (c) return;
196
+ const u = mt(f);
197
197
  if (!u.ok) {
198
- p(u.error), a("error");
198
+ h(u.error), a("error");
199
199
  return;
200
200
  }
201
- c(u.value), a("ready"), u.value.status === "wip" && (g.current = setTimeout(h, e));
201
+ d(u.value), a("ready"), u.value.status === "wip" && (g.current = setTimeout(k, e));
202
202
  };
203
- return h(), () => {
204
- s = !0, k();
203
+ return k(), () => {
204
+ c = !0, w();
205
205
  };
206
- }, [t, e]), { state: n, manifest: l, error: b };
206
+ }, [t, e]), { state: n, manifest: i, error: _ };
207
207
  }
208
- function mt(t) {
209
- const [e, n] = T(!1);
208
+ function ht(t) {
209
+ const [e, n] = v(!1);
210
210
  C(() => {
211
- const l = () => n(document.fullscreenElement != null);
212
- return document.addEventListener("fullscreenchange", l), () => document.removeEventListener("fullscreenchange", l);
211
+ const i = () => n(document.fullscreenElement != null);
212
+ return document.addEventListener("fullscreenchange", i), () => document.removeEventListener("fullscreenchange", i);
213
213
  }, []);
214
- const a = E(async () => {
215
- const l = t.current;
216
- if (l)
214
+ const a = L(async () => {
215
+ const i = t.current;
216
+ if (i)
217
217
  try {
218
- document.fullscreenElement ? await document.exitFullscreen() : await l.requestFullscreen();
218
+ document.fullscreenElement ? await document.exitFullscreen() : await i.requestFullscreen();
219
219
  } catch {
220
220
  }
221
221
  }, [t]);
222
222
  return { isFullscreen: e, toggle: a };
223
223
  }
224
- const _e = "(prefers-reduced-motion: reduce)";
225
- function ve() {
226
- const [t, e] = T(() => {
224
+ const we = "(prefers-reduced-motion: reduce)";
225
+ function Ce() {
226
+ const [t, e] = v(() => {
227
227
  var n;
228
- return ((n = matchMedia == null ? void 0 : matchMedia(_e)) == null ? void 0 : n.matches) ?? !1;
228
+ return ((n = matchMedia == null ? void 0 : matchMedia(we)) == null ? void 0 : n.matches) ?? !1;
229
229
  });
230
230
  return C(() => {
231
- const n = typeof matchMedia == "function" ? matchMedia(_e) : void 0;
231
+ const n = typeof matchMedia == "function" ? matchMedia(we) : void 0;
232
232
  if (!(n != null && n.addEventListener)) return;
233
233
  const a = () => e(n.matches);
234
234
  return n.addEventListener("change", a), () => n.removeEventListener("change", a);
235
235
  }, []), t;
236
236
  }
237
- function we({ go: t, jump: e, total: n, rtl: a }) {
238
- return { onKeyDown: E(
239
- (c) => {
240
- switch (c.key) {
237
+ function Pe({ go: t, jump: e, total: n, rtl: a }) {
238
+ return { onKeyDown: L(
239
+ (d) => {
240
+ switch (d.key) {
241
241
  case "ArrowRight":
242
242
  t(a ? -1 : 1);
243
243
  break;
@@ -245,109 +245,109 @@ function we({ go: t, jump: e, total: n, rtl: a }) {
245
245
  t(a ? 1 : -1);
246
246
  break;
247
247
  case "Home":
248
- c.preventDefault(), n > 0 && e(0);
248
+ d.preventDefault(), n > 0 && e(0);
249
249
  break;
250
250
  case "End":
251
- c.preventDefault(), n > 0 && e(n - 1);
251
+ d.preventDefault(), n > 0 && e(n - 1);
252
252
  break;
253
253
  case " ":
254
254
  case "Spacebar":
255
- c.preventDefault(), t(c.shiftKey ? -1 : 1);
255
+ d.preventDefault(), t(d.shiftKey ? -1 : 1);
256
256
  break;
257
257
  case "PageDown":
258
- c.preventDefault(), t(1);
258
+ d.preventDefault(), t(1);
259
259
  break;
260
260
  case "PageUp":
261
- c.preventDefault(), t(-1);
261
+ d.preventDefault(), t(-1);
262
262
  break;
263
263
  }
264
264
  },
265
265
  [t, e, n, a]
266
266
  ) };
267
267
  }
268
- function Te(t, e) {
268
+ function Ie(t, e) {
269
269
  if (e <= 0) return null;
270
270
  const n = t.trim();
271
271
  if (!/^\d+$/.test(n)) return null;
272
272
  const a = Number(n);
273
273
  return Number.isFinite(a) ? Math.max(1, Math.min(e, a)) - 1 : null;
274
274
  }
275
- const pt = 640;
276
- function bt(t, e) {
277
- const [n, a] = T("auto"), [l, c] = T(null);
275
+ const _t = 640;
276
+ function kt(t, e) {
277
+ const [n, a] = v("auto"), [i, d] = v(null);
278
278
  C(() => {
279
- const s = t.current;
280
- if (!s || (s.clientWidth > 0 && c(s.clientWidth), typeof ResizeObserver > "u")) return;
281
- const k = new ResizeObserver((h) => {
279
+ const c = t.current;
280
+ if (!c || (c.clientWidth > 0 && d(c.clientWidth), typeof ResizeObserver > "u")) return;
281
+ const w = new ResizeObserver((k) => {
282
282
  var u;
283
- const d = (u = h[0]) == null ? void 0 : u.contentRect.width;
284
- typeof d == "number" && d > 0 && c(d);
283
+ const f = (u = k[0]) == null ? void 0 : u.contentRect.width;
284
+ typeof f == "number" && f > 0 && d(f);
285
285
  });
286
- return k.observe(s), () => k.disconnect();
286
+ return w.observe(c), () => w.disconnect();
287
287
  }, [t]);
288
- const b = l != null && l < pt ? "single" : e, p = n === "auto" ? b : n, g = E(() => {
289
- a(p === "single" ? "double" : "single");
290
- }, [p]);
291
- return { layout: p, toggle: g };
288
+ const _ = i != null && i < _t ? "single" : e, h = n === "auto" ? _ : n, g = L(() => {
289
+ a(h === "single" ? "double" : "single");
290
+ }, [h]);
291
+ return { layout: h, toggle: g };
292
292
  }
293
- function ue(t, e) {
293
+ function me(t, e) {
294
294
  return t <= 0 ? 0 : e === "single" ? t : 1 + Math.ceil((t - 1) / 2);
295
295
  }
296
- function ht(t, e) {
296
+ function yt(t, e) {
297
297
  return e === "single" ? t : t <= 0 ? 0 : Math.floor((t - 1) / 2) + 1;
298
298
  }
299
- function te(t, e, n) {
299
+ function oe(t, e, n) {
300
300
  if (e <= 0) return { left: -1, right: -1 };
301
301
  if (n === "single")
302
302
  return { left: -1, right: t >= 0 && t < e ? t : -1 };
303
303
  if (t <= 0)
304
304
  return { left: -1, right: 0 };
305
- const a = 2 * t - 1, l = 2 * t;
306
- return { left: a < e ? a : -1, right: l < e ? l : -1 };
305
+ const a = 2 * t - 1, i = 2 * t;
306
+ return { left: a < e ? a : -1, right: i < e ? i : -1 };
307
307
  }
308
- function Ne(t, e, n) {
309
- const { left: a, right: l } = te(t, e, n), c = [];
310
- return a >= 0 && c.push(a), l >= 0 && c.push(l), c;
308
+ function ge(t, e, n) {
309
+ const { left: a, right: i } = oe(t, e, n), d = [];
310
+ return a >= 0 && d.push(a), i >= 0 && d.push(i), d;
311
311
  }
312
- function ie(t, e, n) {
313
- const a = ue(e, n) - 1;
312
+ function ne(t, e, n) {
313
+ const a = me(e, n) - 1;
314
314
  return t < 0 ? 0 : t > a ? a : t;
315
315
  }
316
- function _t(t) {
316
+ function vt(t) {
317
317
  const {
318
318
  strings: e,
319
319
  label: n,
320
320
  progress: a,
321
- zoom: l,
322
- minZoom: c,
323
- maxZoom: b,
324
- total: p,
321
+ zoom: i,
322
+ minZoom: d,
323
+ maxZoom: _,
324
+ total: h,
325
325
  currentPage: g,
326
- layout: s,
327
- thumbsOpen: k,
328
- isFullscreen: h,
329
- downloadUrl: d,
326
+ layout: c,
327
+ thumbsOpen: w,
328
+ isFullscreen: k,
329
+ downloadUrl: f,
330
330
  show: u,
331
- onZoomIn: i,
332
- onZoomOut: L,
333
- onZoomSet: D,
334
- onJump: M,
335
- onRotate: O,
331
+ onZoomIn: l,
332
+ onZoomOut: D,
333
+ onZoomSet: O,
334
+ onJump: F,
335
+ onRotate: R,
336
336
  onToggleLayout: x,
337
- onToggleThumbs: $,
338
- onToggleFullscreen: U,
339
- onAbout: X
340
- } = t, [A, z] = T(String(g));
341
- C(() => z(String(g)), [g]);
342
- const Z = () => {
343
- const N = Te(A, p);
344
- if (N === null) {
345
- z(String(g));
337
+ onToggleThumbs: A,
338
+ onToggleFullscreen: Z,
339
+ onAbout: j
340
+ } = t, [M, $] = v(String(g));
341
+ C(() => $(String(g)), [g]);
342
+ const B = () => {
343
+ const P = Ie(M, h);
344
+ if (P === null) {
345
+ $(String(g));
346
346
  return;
347
347
  }
348
- M(N), z(String(N + 1));
348
+ F(P), $(String(P + 1));
349
349
  };
350
- return /* @__PURE__ */ _("div", { className: "peeek__toolbar", children: [
350
+ return /* @__PURE__ */ y("div", { className: "peeek__toolbar", children: [
351
351
  /* @__PURE__ */ o("span", { className: "peeek__label", children: n }),
352
352
  u.bar && /* @__PURE__ */ o("div", { className: "peeek__scrubber", "aria-hidden": !0, children: /* @__PURE__ */ o("div", { className: "peeek__scrubber-fill", style: { width: `${a}%` } }) }),
353
353
  u.goto && /* @__PURE__ */ o(
@@ -357,11 +357,11 @@ function _t(t) {
357
357
  type: "text",
358
358
  inputMode: "numeric",
359
359
  "aria-label": e.goToPage,
360
- value: A,
361
- onChange: (N) => z(N.target.value),
362
- onBlur: Z,
363
- onKeyDown: (N) => {
364
- N.key === "Enter" && (N.preventDefault(), Z());
360
+ value: M,
361
+ onChange: (P) => $(P.target.value),
362
+ onBlur: B,
363
+ onKeyDown: (P) => {
364
+ P.key === "Enter" && (P.preventDefault(), B());
365
365
  }
366
366
  }
367
367
  ),
@@ -371,8 +371,8 @@ function _t(t) {
371
371
  type: "button",
372
372
  className: "peeek__btn",
373
373
  "aria-label": e.zoomOut,
374
- disabled: l <= c,
375
- onClick: L,
374
+ disabled: i <= d,
375
+ onClick: D,
376
376
  children: "−"
377
377
  }
378
378
  ),
@@ -381,11 +381,11 @@ function _t(t) {
381
381
  {
382
382
  type: "range",
383
383
  "aria-label": e.zoom,
384
- min: c,
385
- max: b,
384
+ min: d,
385
+ max: _,
386
386
  step: 0.25,
387
- value: l,
388
- onChange: (N) => D(Number(N.target.value))
387
+ value: i,
388
+ onChange: (P) => O(Number(P.target.value))
389
389
  }
390
390
  ),
391
391
  /* @__PURE__ */ o(
@@ -394,8 +394,8 @@ function _t(t) {
394
394
  type: "button",
395
395
  className: "peeek__btn",
396
396
  "aria-label": e.zoomIn,
397
- disabled: l >= b,
398
- onClick: i,
397
+ disabled: i >= _,
398
+ onClick: l,
399
399
  children: "+"
400
400
  }
401
401
  ),
@@ -405,7 +405,7 @@ function _t(t) {
405
405
  type: "button",
406
406
  className: "peeek__btn",
407
407
  "aria-label": e.rotate,
408
- onClick: O,
408
+ onClick: R,
409
409
  children: "⟳"
410
410
  }
411
411
  ),
@@ -414,28 +414,28 @@ function _t(t) {
414
414
  {
415
415
  type: "button",
416
416
  className: "peeek__btn",
417
- "aria-label": s === "single" ? e.doublePage : e.singlePage,
418
- "aria-pressed": s === "double",
417
+ "aria-label": c === "single" ? e.doublePage : e.singlePage,
418
+ "aria-pressed": c === "double",
419
419
  onClick: x,
420
- children: s === "single" ? "▭" : "▥"
420
+ children: c === "single" ? "▭" : "▥"
421
421
  }
422
422
  ),
423
423
  u.thumbnails && /* @__PURE__ */ o(
424
424
  "button",
425
425
  {
426
426
  type: "button",
427
- className: `peeek__btn${k ? " peeek__btn--active" : ""}`,
427
+ className: `peeek__btn${w ? " peeek__btn--active" : ""}`,
428
428
  "aria-label": e.thumbnails,
429
- "aria-pressed": k,
430
- onClick: $,
429
+ "aria-pressed": w,
430
+ onClick: A,
431
431
  children: "▦"
432
432
  }
433
433
  ),
434
- d && /* @__PURE__ */ o(
434
+ f && /* @__PURE__ */ o(
435
435
  "a",
436
436
  {
437
437
  className: "peeek__btn",
438
- href: d,
438
+ href: f,
439
439
  "aria-label": e.download,
440
440
  target: "_blank",
441
441
  rel: "noopener noreferrer",
@@ -447,10 +447,10 @@ function _t(t) {
447
447
  "button",
448
448
  {
449
449
  type: "button",
450
- className: `peeek__btn${h ? " peeek__btn--active" : ""}`,
450
+ className: `peeek__btn${k ? " peeek__btn--active" : ""}`,
451
451
  "aria-label": e.fullscreen,
452
- "aria-pressed": h,
453
- onClick: U,
452
+ "aria-pressed": k,
453
+ onClick: Z,
454
454
  children: "⛶"
455
455
  }
456
456
  ),
@@ -460,143 +460,158 @@ function _t(t) {
460
460
  type: "button",
461
461
  className: "peeek__btn",
462
462
  "aria-label": e.about,
463
- onClick: X,
463
+ onClick: j,
464
464
  children: "?"
465
465
  }
466
466
  )
467
467
  ] });
468
468
  }
469
- function kt({ pages: t, layout: e, rtl: n, activePages: a, onJump: l }) {
470
- const c = t.length, b = new Set(a), p = ue(c, e);
471
- return /* @__PURE__ */ o("div", { className: "peeek__thumbs", role: "group", "aria-label": "Pages", children: Array.from({ length: p }, (g, s) => {
472
- const k = Ne(s, c, e), h = k.length === 2;
473
- return /* @__PURE__ */ _("div", { className: "peeek__thumb-group", children: [
474
- k.map((d, u) => {
475
- let i = "";
476
- return h && (i = (n ? u === 1 : u === 0) ? " peeek__thumb--flat-right" : " peeek__thumb--flat-left"), /* @__PURE__ */ o(
469
+ function wt({ pages: t, layout: e, rtl: n, activePages: a, onJump: i }) {
470
+ const d = t.length, _ = new Set(a), h = me(d, e);
471
+ return /* @__PURE__ */ o("div", { className: "peeek__thumbs", role: "group", "aria-label": "Pages", children: Array.from({ length: h }, (g, c) => {
472
+ const w = ge(c, d, e), k = w.length === 2;
473
+ return /* @__PURE__ */ y("div", { className: "peeek__thumb-group", children: [
474
+ w.map((f, u) => {
475
+ let l = "";
476
+ return k && (l = (n ? u === 1 : u === 0) ? " peeek__thumb--flat-right" : " peeek__thumb--flat-left"), /* @__PURE__ */ o(
477
477
  "button",
478
478
  {
479
479
  type: "button",
480
- "aria-label": `Go to page ${d + 1}`,
481
- "aria-current": b.has(d),
482
- className: `peeek__thumb${b.has(d) ? " peeek__thumb--active" : ""}${i}`,
483
- onClick: () => l(d),
484
- children: /* @__PURE__ */ o("img", { src: t[d], alt: "", loading: "lazy", referrerPolicy: "no-referrer" })
480
+ "aria-label": `Go to page ${f + 1}`,
481
+ "aria-current": _.has(f),
482
+ className: `peeek__thumb${_.has(f) ? " peeek__thumb--active" : ""}${l}`,
483
+ onClick: () => i(f),
484
+ children: /* @__PURE__ */ o("img", { src: t[f], alt: "", loading: "lazy", referrerPolicy: "no-referrer" })
485
485
  },
486
- d
486
+ f
487
487
  );
488
488
  }),
489
- /* @__PURE__ */ o("span", { className: "peeek__thumb-badge", "aria-hidden": !0, children: k.map((d) => d + 1).join("-") })
490
- ] }, s);
489
+ /* @__PURE__ */ o("span", { className: "peeek__thumb-badge", "aria-hidden": !0, children: w.map((f) => f + 1).join("-") })
490
+ ] }, c);
491
491
  }) });
492
492
  }
493
- const J = 1, ee = 2, ke = 0.25;
494
- function yt(t) {
493
+ const ee = 1, ae = 2, Te = 0.25;
494
+ function Tt(t) {
495
495
  const {
496
496
  pages: e,
497
497
  strings: n,
498
498
  layout: a,
499
- rtl: l,
500
- pageShadows: c,
501
- animateInteractions: b,
502
- autoTransition: p,
499
+ rtl: i,
500
+ pageShadows: d,
501
+ animateInteractions: _,
502
+ autoTransition: h,
503
503
  autoTransitionInterval: g,
504
- show: s,
505
- downloadUrl: k,
506
- isFullscreen: h,
507
- onToggleFullscreen: d,
504
+ show: c,
505
+ downloadUrl: w,
506
+ isFullscreen: k,
507
+ onToggleFullscreen: f,
508
508
  onAbout: u
509
- } = t, i = e.length, D = ve() || !b, [M, O] = T(0), [x, $] = T(1), [U, X] = T(!1), [A, z] = T({ x: 0, y: 0 }), [Z, N] = T(!1), [f, y] = T(0), S = j(null), F = j(null), { layout: v, toggle: Ce } = bt(F, a), ne = ue(i, v), [w, de] = T(null), ge = j(null), [fe, Pe] = T(0.707);
509
+ } = t, l = e.length, O = Ce() || !_, [F, R] = v(0), [x, A] = v(1), [Z, j] = v(!1), [M, $] = v({ x: 0, y: 0 }), [B, P] = v(!1), [X, m] = v(0), p = E(null), z = E(null), { layout: b, toggle: K } = kt(z, a), re = me(l, b), [T, le] = v(null), [xe, pe] = v(!1), ie = E(null), [be, ze] = v(0.707);
510
510
  C(() => {
511
511
  if (!e[0]) return;
512
512
  const r = new globalThis.Image();
513
513
  r.onload = () => {
514
- r.naturalWidth && r.naturalHeight && Pe(r.naturalWidth / r.naturalHeight);
514
+ r.naturalWidth && r.naturalHeight && ze(r.naturalWidth / r.naturalHeight);
515
515
  }, r.src = e[0];
516
516
  }, [e]);
517
- const R = ie(M, i, v), Ie = R <= 0, ae = R >= ne - 1, K = E(
517
+ const S = ne(F, l, b), Se = S <= 0, se = S >= re - 1, he = E(/* @__PURE__ */ new Set());
518
+ C(() => {
519
+ const r = [S - 1, S + 1, S + 2].map((s) => ne(s, l, b)).flatMap((s) => ge(s, l, b)).filter((s) => s >= 0);
520
+ for (const s of r) {
521
+ const N = e[s];
522
+ if (!N || he.current.has(N)) continue;
523
+ he.current.add(N);
524
+ const q = new globalThis.Image();
525
+ q.src = N;
526
+ }
527
+ }, [S, l, b, e]);
528
+ const W = L(
518
529
  (r) => {
519
- w || O((m) => {
520
- const P = ie(m + r, i, v);
521
- return P === m ? m : D ? P : (de({ dir: r, to: P }), m);
530
+ T || R((s) => {
531
+ const N = ne(s + r, l, b);
532
+ return N === s ? s : O ? N : (le({ dir: r, to: N }), s);
522
533
  });
523
534
  },
524
- [i, v, D, w]
525
- ), xe = E(() => {
526
- de((r) => (r && O(r.to), null));
535
+ [l, b, O, T]
536
+ ), $e = L((r) => {
537
+ r.target === ie.current && (r.propertyName && r.propertyName !== "transform" || le((s) => s && (R(s.to), pe(!0), requestAnimationFrame(
538
+ () => requestAnimationFrame(() => {
539
+ le(null), pe(!1);
540
+ })
541
+ ), s)));
527
542
  }, []);
528
543
  C(() => {
529
- if (!w) return;
530
- const r = ge.current;
544
+ if (!T) return;
545
+ const r = ie.current;
531
546
  if (!r) return;
532
547
  r.style.transform = "rotateY(0deg)";
533
- let m = 0;
534
- const P = requestAnimationFrame(() => {
535
- m = requestAnimationFrame(() => {
536
- r.style.transform = `rotateY(${w.dir === 1 ? -180 : 180}deg)`;
548
+ let s = 0;
549
+ const N = requestAnimationFrame(() => {
550
+ s = requestAnimationFrame(() => {
551
+ r.style.transform = `rotateY(${T.dir === 1 ? -180 : 180}deg)`;
537
552
  });
538
553
  });
539
554
  return () => {
540
- cancelAnimationFrame(P), cancelAnimationFrame(m);
555
+ cancelAnimationFrame(N), cancelAnimationFrame(s);
541
556
  };
542
- }, [w]);
543
- const oe = E(
557
+ }, [T]);
558
+ const ce = L(
544
559
  (r) => {
545
- O(ie(ht(r, v), i, v));
560
+ R(ne(yt(r, b), l, b));
546
561
  },
547
- [i, v]
548
- ), { onKeyDown: ze } = we({ go: K, jump: oe, total: i, rtl: l });
562
+ [l, b]
563
+ ), { onKeyDown: Ae } = Pe({ go: W, jump: ce, total: l, rtl: i });
549
564
  C(() => {
550
- if (!p || ae) return;
551
- const r = setTimeout(() => K(1), g);
565
+ if (!h || se) return;
566
+ const r = setTimeout(() => W(1), g);
552
567
  return () => clearTimeout(r);
553
- }, [p, g, ae, R, K]);
554
- const Se = () => $((r) => Math.min(ee, r + ke)), $e = () => $((r) => Math.max(J, r - ke)), Ae = () => {
555
- w || $((r) => r > J ? J : ee);
556
- }, Fe = () => y((r) => (r + 90) % 360), Me = f === 90 || f === 270 ? fe : 1, re = E((r, m, P) => {
557
- const le = F.current;
558
- if (!le || P <= 1) return { x: 0, y: 0 };
559
- const be = (P - 1) * le.clientWidth / 2, he = (P - 1) * le.clientHeight / 2;
560
- return { x: Math.max(-be, Math.min(be, r)), y: Math.max(-he, Math.min(he, m)) };
568
+ }, [h, g, se, S, W]);
569
+ const Fe = () => A((r) => Math.min(ae, r + Te)), Me = () => A((r) => Math.max(ee, r - Te)), Ee = () => {
570
+ T || A((r) => r > ee ? ee : ae);
571
+ }, Le = () => m((r) => (r + 90) % 360), De = X === 90 || X === 270 ? be : 1, ue = L((r, s, N) => {
572
+ const q = z.current;
573
+ if (!q || N <= 1) return { x: 0, y: 0 };
574
+ const ye = (N - 1) * q.clientWidth / 2, ve = (N - 1) * q.clientHeight / 2;
575
+ return { x: Math.max(-ye, Math.min(ye, r)), y: Math.max(-ve, Math.min(ve, s)) };
561
576
  }, []);
562
- C(() => z((r) => re(r.x, r.y, x)), [x, re]), C(() => z({ x: 0, y: 0 }), [R]);
563
- const Ee = (r) => {
564
- var m, P;
565
- x <= 1 || (S.current = { x: r.clientX, y: r.clientY, px: A.x, py: A.y }, N(!0), (P = (m = r.currentTarget).setPointerCapture) == null || P.call(m, r.pointerId));
566
- }, Le = (r) => {
567
- const m = S.current;
568
- m && z(re(m.px + (r.clientX - m.x), m.py + (r.clientY - m.y), x));
569
- }, me = (r) => {
570
- if (S.current) {
571
- S.current = null, N(!1);
577
+ C(() => $((r) => ue(r.x, r.y, x)), [x, ue]), C(() => $({ x: 0, y: 0 }), [S]);
578
+ const Oe = (r) => {
579
+ var s, N;
580
+ x <= 1 || (p.current = { x: r.clientX, y: r.clientY, px: M.x, py: M.y }, P(!0), (N = (s = r.currentTarget).setPointerCapture) == null || N.call(s, r.pointerId));
581
+ }, Re = (r) => {
582
+ const s = p.current;
583
+ s && $(ue(s.px + (r.clientX - s.x), s.py + (r.clientY - s.y), x));
584
+ }, _e = (r) => {
585
+ if (p.current) {
586
+ p.current = null, P(!1);
572
587
  try {
573
588
  r.currentTarget.releasePointerCapture(r.pointerId);
574
589
  } catch {
575
590
  }
576
591
  }
577
- }, W = Ne(R, i, v), Q = W[0] ?? 0, De = v === "double" && W.length === 2 ? `${W[0] + 1} - ${W[1] + 1} / ${i}` : `${Q + 1} / ${i}`, Oe = ne <= 1 ? 100 : R / (ne - 1) * 100, Re = n.prev, Be = n.next, Ue = w ? w.to : R, H = te(Ue, i, v), Ze = H.left < 0 && H.right >= 0, He = H.left >= 0 && H.right < 0, Ge = H.left >= 0 && H.right >= 0, je = Ze ? "-25%" : He ? "25%" : "0%", B = te(R, i, v), V = w ? te(w.to, i, v) : B, Ve = w ? w.dir === 1 ? B.right >= 0 ? B.right : B.left : B.left >= 0 ? B.left : B.right : Q, Xe = w ? w.dir === 1 ? V.left >= 0 ? V.left : V.right : V.right >= 0 ? V.right : V.left : Q, Ke = w ? w.dir === 1 ? "left" : "right" : null, pe = (r) => r === Ke ? B[r] : H[r], We = [
578
- ["left", pe("left")],
579
- ["right", pe("right")]
592
+ }, Y = ge(S, l, b), te = Y[0] ?? 0, Be = b === "double" && Y.length === 2 ? `${Y[0] + 1} - ${Y[1] + 1} / ${l}` : `${te + 1} / ${l}`, Ue = re <= 1 ? 100 : S / (re - 1) * 100, Ze = n.prev, He = n.next, Ge = T ? T.to : S, H = oe(Ge, l, b), je = H.left < 0 && H.right >= 0, Ve = H.left >= 0 && H.right < 0, Xe = H.left >= 0 && H.right >= 0, Ke = je ? "-25%" : Ve ? "25%" : "0%", U = oe(S, l, b), V = T ? oe(T.to, l, b) : U, We = T ? T.dir === 1 ? U.right >= 0 ? U.right : U.left : U.left >= 0 ? U.left : U.right : te, Ye = T ? T.dir === 1 ? V.left >= 0 ? V.left : V.right : V.right >= 0 ? V.right : V.left : te, qe = T ? T.dir === 1 ? "left" : "right" : null, ke = (r) => r === qe && !xe ? U[r] : H[r], Je = [
593
+ ["left", ke("left")],
594
+ ["right", ke("right")]
580
595
  ];
581
- return /* @__PURE__ */ _(Ye, { children: [
582
- /* @__PURE__ */ _(
596
+ return /* @__PURE__ */ y(Qe, { children: [
597
+ /* @__PURE__ */ y(
583
598
  "div",
584
599
  {
585
- ref: F,
600
+ ref: z,
586
601
  className: "peeek__stage",
587
- "data-layout": v,
602
+ "data-layout": b,
588
603
  tabIndex: 0,
589
- onKeyDown: ze,
590
- style: { "--peeek-aspect": `${fe}` },
604
+ onKeyDown: Ae,
605
+ style: { "--peeek-aspect": `${be}` },
591
606
  children: [
592
- s.arrows && /* @__PURE__ */ o(
607
+ c.arrows && /* @__PURE__ */ o(
593
608
  "button",
594
609
  {
595
610
  type: "button",
596
611
  className: "peeek__arrow peeek__arrow--prev",
597
- "aria-label": Re,
598
- disabled: Ie,
599
- onClick: () => K(-1),
612
+ "aria-label": Ze,
613
+ disabled: Se,
614
+ onClick: () => W(-1),
600
615
  children: "‹"
601
616
  }
602
617
  ),
@@ -605,49 +620,49 @@ function yt(t) {
605
620
  {
606
621
  className: `peeek__zoom${x > 1 ? " peeek__zoom--pannable" : ""}`,
607
622
  style: {
608
- transform: `translate(${A.x}px, ${A.y}px) scale(${x * Me}) rotate(${f}deg)`,
609
- transition: D || Z ? "none" : void 0
623
+ transform: `translate(${M.x}px, ${M.y}px) scale(${x * De}) rotate(${X}deg)`,
624
+ transition: O || B ? "none" : void 0
610
625
  },
611
- onDoubleClick: Ae,
612
- onPointerDown: Ee,
613
- onPointerMove: Le,
614
- onPointerUp: me,
615
- onPointerCancel: me,
616
- children: /* @__PURE__ */ _(
626
+ onDoubleClick: Ee,
627
+ onPointerDown: Oe,
628
+ onPointerMove: Re,
629
+ onPointerUp: _e,
630
+ onPointerCancel: _e,
631
+ children: /* @__PURE__ */ y(
617
632
  "div",
618
633
  {
619
- className: `peeek__spread${c ? " peeek--shadows" : ""}${Ge ? " peeek__spread--pair" : ""}`,
620
- style: { transform: `translateX(${je})` },
634
+ className: `peeek__spread${d ? " peeek--shadows" : ""}${Xe ? " peeek__spread--pair" : ""}`,
635
+ style: { transform: `translateX(${Ke})` },
621
636
  children: [
622
- We.map(([r, m]) => {
623
- const P = m >= 0 && s.fullscreen && !h && !w && x === 1;
637
+ Je.map(([r, s]) => {
638
+ const N = s >= 0 && c.fullscreen && !k && !T && x === 1;
624
639
  return /* @__PURE__ */ o(
625
640
  "div",
626
641
  {
627
- className: `peeek__page peeek__page--${r}${m < 0 ? " peeek__page--empty" : ""}`,
628
- children: m >= 0 && (P ? /* @__PURE__ */ o(
642
+ className: `peeek__page peeek__page--${r}${s < 0 ? " peeek__page--empty" : ""}`,
643
+ children: s >= 0 && (N ? /* @__PURE__ */ o(
629
644
  "button",
630
645
  {
631
646
  type: "button",
632
647
  className: "peeek__page-btn",
633
648
  "aria-label": n.openFullscreen,
634
- onClick: d,
635
- children: /* @__PURE__ */ o("img", { src: e[m], alt: `Page ${m + 1}`, loading: "lazy", referrerPolicy: "no-referrer" })
649
+ onClick: f,
650
+ children: /* @__PURE__ */ o("img", { src: e[s], alt: `Page ${s + 1}`, loading: "lazy", referrerPolicy: "no-referrer" })
636
651
  }
637
- ) : /* @__PURE__ */ o("img", { src: e[m], alt: `Page ${m + 1}`, loading: "lazy", referrerPolicy: "no-referrer" }))
652
+ ) : /* @__PURE__ */ o("img", { src: e[s], alt: `Page ${s + 1}`, loading: "lazy", referrerPolicy: "no-referrer" }))
638
653
  },
639
654
  r
640
655
  );
641
656
  }),
642
- w && /* @__PURE__ */ _(
657
+ T && /* @__PURE__ */ y(
643
658
  "div",
644
659
  {
645
- ref: ge,
646
- className: `peeek__leaf peeek__leaf--${w.dir === 1 ? "fwd" : "back"}`,
647
- onTransitionEnd: xe,
660
+ ref: ie,
661
+ className: `peeek__leaf peeek__leaf--${T.dir === 1 ? "fwd" : "back"}`,
662
+ onTransitionEnd: $e,
648
663
  children: [
649
- /* @__PURE__ */ o("div", { className: "peeek__leaf-face peeek__leaf-face--front", children: /* @__PURE__ */ o("img", { src: e[Ve], alt: "", referrerPolicy: "no-referrer" }) }),
650
- /* @__PURE__ */ o("div", { className: "peeek__leaf-face peeek__leaf-face--back", children: /* @__PURE__ */ o("img", { src: e[Xe], alt: "", referrerPolicy: "no-referrer" }) })
664
+ /* @__PURE__ */ o("div", { className: "peeek__leaf-face peeek__leaf-face--front", children: /* @__PURE__ */ o("img", { src: e[We], alt: "", referrerPolicy: "no-referrer" }) }),
665
+ /* @__PURE__ */ o("div", { className: "peeek__leaf-face peeek__leaf-face--back", children: /* @__PURE__ */ o("img", { src: e[Ye], alt: "", referrerPolicy: "no-referrer" }) })
651
666
  ]
652
667
  }
653
668
  )
@@ -656,59 +671,59 @@ function yt(t) {
656
671
  )
657
672
  }
658
673
  ),
659
- s.arrows && /* @__PURE__ */ o(
674
+ c.arrows && /* @__PURE__ */ o(
660
675
  "button",
661
676
  {
662
677
  type: "button",
663
678
  className: "peeek__arrow peeek__arrow--next",
664
- "aria-label": Be,
665
- disabled: ae,
666
- onClick: () => K(1),
679
+ "aria-label": He,
680
+ disabled: se,
681
+ onClick: () => W(1),
667
682
  children: "›"
668
683
  }
669
684
  )
670
685
  ]
671
686
  }
672
687
  ),
673
- s.toolbar && /* @__PURE__ */ o(
674
- _t,
688
+ c.toolbar && /* @__PURE__ */ o(
689
+ vt,
675
690
  {
676
691
  strings: n,
677
- label: De,
678
- progress: Oe,
692
+ label: Be,
693
+ progress: Ue,
679
694
  zoom: x,
680
- minZoom: J,
681
- maxZoom: ee,
682
- total: i,
683
- currentPage: Q + 1,
684
- layout: v,
685
- thumbsOpen: U,
686
- isFullscreen: h,
687
- downloadUrl: k,
695
+ minZoom: ee,
696
+ maxZoom: ae,
697
+ total: l,
698
+ currentPage: te + 1,
699
+ layout: b,
700
+ thumbsOpen: Z,
701
+ isFullscreen: k,
702
+ downloadUrl: w,
688
703
  show: {
689
- bar: s.bar,
690
- fullscreen: s.fullscreen,
691
- thumbnails: s.thumbnails && s.overview,
692
- about: s.about,
693
- goto: s.goto,
694
- rotate: s.rotate,
695
- layoutToggle: s.layoutToggle
704
+ bar: c.bar,
705
+ fullscreen: c.fullscreen,
706
+ thumbnails: c.thumbnails && c.overview,
707
+ about: c.about,
708
+ goto: c.goto,
709
+ rotate: c.rotate,
710
+ layoutToggle: c.layoutToggle
696
711
  },
697
- onZoomIn: Se,
698
- onZoomOut: $e,
699
- onZoomSet: (r) => $(Math.min(ee, Math.max(J, r))),
700
- onJump: oe,
701
- onRotate: Fe,
702
- onToggleLayout: Ce,
703
- onToggleThumbs: () => X((r) => !r),
704
- onToggleFullscreen: d,
712
+ onZoomIn: Fe,
713
+ onZoomOut: Me,
714
+ onZoomSet: (r) => A(Math.min(ae, Math.max(ee, r))),
715
+ onJump: ce,
716
+ onRotate: Le,
717
+ onToggleLayout: K,
718
+ onToggleThumbs: () => j((r) => !r),
719
+ onToggleFullscreen: f,
705
720
  onAbout: u
706
721
  }
707
722
  ),
708
- s.overview && U && /* @__PURE__ */ o(kt, { pages: e, layout: v, rtl: l, activePages: W, onJump: oe })
723
+ c.overview && Z && /* @__PURE__ */ o(wt, { pages: e, layout: b, rtl: i, activePages: Y, onJump: ce })
709
724
  ] });
710
725
  }
711
- function vt(t, e) {
726
+ function Nt(t, e) {
712
727
  const n = e.toLowerCase();
713
728
  if (n.includes("pdf")) return "PDF";
714
729
  if (n.includes("wordprocessingml")) return "DOCX";
@@ -716,7 +731,7 @@ function vt(t, e) {
716
731
  const a = t.toLowerCase().split(".").pop() ?? "";
717
732
  return a ? a.toUpperCase().slice(0, 4) : "FILE";
718
733
  }
719
- function wt(t, e) {
734
+ function Ct(t, e) {
720
735
  if (t === 0) return { transform: "translateX(0) scale(1)", zIndex: 30, opacity: 1 };
721
736
  const n = t < 0 ? -1 : 1, a = e ? -1 : 1;
722
737
  return {
@@ -725,73 +740,83 @@ function wt(t, e) {
725
740
  opacity: 0.55
726
741
  };
727
742
  }
728
- function Tt(t) {
743
+ function Pt(t) {
729
744
  const {
730
745
  pages: e,
731
746
  strings: n,
732
747
  filename: a,
733
- mimeType: l,
734
- rtl: c,
735
- autoTransition: b,
736
- autoTransitionInterval: p,
748
+ mimeType: i,
749
+ rtl: d,
750
+ autoTransition: _,
751
+ autoTransitionInterval: h,
737
752
  downloadUrl: g,
738
- isFullscreen: s,
739
- onToggleFullscreen: k,
740
- onAbout: h,
741
- show: d
742
- } = t, u = e.length, [i, L] = T(0), D = ve(), M = E(
743
- (f) => L((y) => Math.max(0, Math.min(u - 1, y + f))),
753
+ isFullscreen: c,
754
+ onToggleFullscreen: w,
755
+ onAbout: k,
756
+ show: f
757
+ } = t, u = e.length, [l, D] = v(0), O = Ce(), F = L(
758
+ (m) => D((p) => Math.max(0, Math.min(u - 1, p + m))),
744
759
  [u]
745
- ), O = E(
746
- (f) => L(Math.max(0, Math.min(u - 1, f))),
760
+ ), R = L(
761
+ (m) => D(Math.max(0, Math.min(u - 1, m))),
747
762
  [u]
748
- ), x = i <= 0, $ = i >= u - 1, U = j([]);
763
+ ), x = l <= 0, A = l >= u - 1, Z = E(/* @__PURE__ */ new Set());
764
+ C(() => {
765
+ for (const m of [l - 2, l - 1, l + 1, l + 2]) {
766
+ const p = m >= 0 && m < u ? e[m] : void 0;
767
+ if (!p || Z.current.has(p)) continue;
768
+ Z.current.add(p);
769
+ const z = new globalThis.Image();
770
+ z.src = p;
771
+ }
772
+ }, [l, u, e]);
773
+ const j = E([]);
749
774
  C(() => {
750
- var f, y;
751
- (y = (f = U.current[i]) == null ? void 0 : f.scrollIntoView) == null || y.call(f, { behavior: "smooth", inline: "center", block: "nearest" });
752
- }, [i]), C(() => {
753
- if (!b || D || $) return;
754
- const f = setTimeout(() => M(1), p);
755
- return () => clearTimeout(f);
756
- }, [b, p, D, $, i, M]);
757
- const { onKeyDown: X } = we({ go: M, jump: O, total: u, rtl: c }), [A, z] = T(String(i + 1));
758
- C(() => z(String(i + 1)), [i]);
759
- const Z = () => {
760
- const f = Te(A, u);
761
- if (f === null) {
762
- z(String(i + 1));
775
+ var m, p;
776
+ (p = (m = j.current[l]) == null ? void 0 : m.scrollIntoView) == null || p.call(m, { behavior: "smooth", inline: "center", block: "nearest" });
777
+ }, [l]), C(() => {
778
+ if (!_ || O || A) return;
779
+ const m = setTimeout(() => F(1), h);
780
+ return () => clearTimeout(m);
781
+ }, [_, h, O, A, l, F]);
782
+ const { onKeyDown: M } = Pe({ go: F, jump: R, total: u, rtl: d }), [$, B] = v(String(l + 1));
783
+ C(() => B(String(l + 1)), [l]);
784
+ const P = () => {
785
+ const m = Ie($, u);
786
+ if (m === null) {
787
+ B(String(l + 1));
763
788
  return;
764
789
  }
765
- O(f);
766
- }, N = vt(a, l);
767
- return /* @__PURE__ */ _("div", { className: "peeek__cf", children: [
768
- /* @__PURE__ */ _("div", { className: "peeek__cf-header", children: [
769
- /* @__PURE__ */ o("span", { className: "peeek__cf-badge", children: N }),
770
- /* @__PURE__ */ _("div", { className: "peeek__cf-meta", children: [
790
+ R(m);
791
+ }, X = Nt(a, i);
792
+ return /* @__PURE__ */ y("div", { className: "peeek__cf", children: [
793
+ /* @__PURE__ */ y("div", { className: "peeek__cf-header", children: [
794
+ /* @__PURE__ */ o("span", { className: "peeek__cf-badge", children: X }),
795
+ /* @__PURE__ */ y("div", { className: "peeek__cf-meta", children: [
771
796
  /* @__PURE__ */ o("span", { className: "peeek__cf-name", children: a }),
772
- /* @__PURE__ */ _("span", { className: "peeek__cf-count", children: [
797
+ /* @__PURE__ */ y("span", { className: "peeek__cf-count", children: [
773
798
  u,
774
799
  " ",
775
800
  u === 1 ? n.page : n.pages
776
801
  ] })
777
802
  ] }),
778
- /* @__PURE__ */ _("span", { className: "peeek__cf-indicator", children: [
779
- i + 1,
803
+ /* @__PURE__ */ y("span", { className: "peeek__cf-indicator", children: [
804
+ l + 1,
780
805
  " / ",
781
806
  u
782
807
  ] }),
783
- d.goto && /* @__PURE__ */ o(
808
+ f.goto && /* @__PURE__ */ o(
784
809
  "input",
785
810
  {
786
811
  className: "peeek__goto",
787
812
  type: "text",
788
813
  inputMode: "numeric",
789
814
  "aria-label": n.goToPage,
790
- value: A,
791
- onChange: (f) => z(f.target.value),
792
- onBlur: Z,
793
- onKeyDown: (f) => {
794
- f.key === "Enter" && (f.preventDefault(), Z());
815
+ value: $,
816
+ onChange: (m) => B(m.target.value),
817
+ onBlur: P,
818
+ onKeyDown: (m) => {
819
+ m.key === "Enter" && (m.preventDefault(), P());
795
820
  }
796
821
  }
797
822
  ),
@@ -807,107 +832,107 @@ function Tt(t) {
807
832
  children: "↓"
808
833
  }
809
834
  ),
810
- d.fullscreen && /* @__PURE__ */ o(
835
+ f.fullscreen && /* @__PURE__ */ o(
811
836
  "button",
812
837
  {
813
838
  type: "button",
814
- className: `peeek__btn${s ? " peeek__btn--active" : ""}`,
839
+ className: `peeek__btn${c ? " peeek__btn--active" : ""}`,
815
840
  "aria-label": n.fullscreen,
816
- "aria-pressed": s,
817
- onClick: k,
841
+ "aria-pressed": c,
842
+ onClick: w,
818
843
  children: "⛶"
819
844
  }
820
845
  ),
821
- d.about && /* @__PURE__ */ o(
846
+ f.about && /* @__PURE__ */ o(
822
847
  "button",
823
848
  {
824
849
  type: "button",
825
850
  className: "peeek__btn",
826
851
  "aria-label": n.about,
827
- onClick: h,
852
+ onClick: k,
828
853
  children: "?"
829
854
  }
830
855
  )
831
856
  ] }),
832
- /* @__PURE__ */ _(
857
+ /* @__PURE__ */ y(
833
858
  "div",
834
859
  {
835
860
  className: "peeek__cf-stage",
836
861
  tabIndex: 0,
837
- onKeyDown: X,
862
+ onKeyDown: M,
838
863
  children: [
839
- d.arrows && /* @__PURE__ */ o(
864
+ f.arrows && /* @__PURE__ */ o(
840
865
  "button",
841
866
  {
842
867
  type: "button",
843
868
  className: "peeek__arrow peeek__arrow--prev",
844
869
  "aria-label": n.prev,
845
870
  disabled: x,
846
- onClick: () => M(-1),
871
+ onClick: () => F(-1),
847
872
  children: "‹"
848
873
  }
849
874
  ),
850
- e.map((f, y) => {
851
- const S = y - i;
852
- if (Math.abs(S) > 1) return null;
853
- const F = S === 0, v = F && d.fullscreen;
875
+ e.map((m, p) => {
876
+ const z = p - l;
877
+ if (Math.abs(z) > 1) return null;
878
+ const b = z === 0, K = b && f.fullscreen;
854
879
  return /* @__PURE__ */ o(
855
880
  "button",
856
881
  {
857
882
  type: "button",
858
- className: `peeek__cf-card${F ? " peeek__cf-card--center" : ""}${v ? " peeek__cf-card--zoom" : ""}`,
859
- style: wt(S, c),
860
- tabIndex: F ? 0 : -1,
861
- "aria-label": v ? n.openFullscreen : `Go to page ${y + 1}`,
862
- onClick: () => v ? k() : L(y),
863
- children: /* @__PURE__ */ o("img", { src: f, alt: F ? `Page ${y + 1}` : "", loading: "lazy", referrerPolicy: "no-referrer" })
883
+ className: `peeek__cf-card${b ? " peeek__cf-card--center" : ""}${K ? " peeek__cf-card--zoom" : ""}`,
884
+ style: Ct(z, d),
885
+ tabIndex: b ? 0 : -1,
886
+ "aria-label": K ? n.openFullscreen : `Go to page ${p + 1}`,
887
+ onClick: () => K ? w() : D(p),
888
+ children: /* @__PURE__ */ o("img", { src: m, alt: b ? `Page ${p + 1}` : "", loading: "lazy", referrerPolicy: "no-referrer" })
864
889
  },
865
- y
890
+ p
866
891
  );
867
892
  }),
868
- d.arrows && /* @__PURE__ */ o(
893
+ f.arrows && /* @__PURE__ */ o(
869
894
  "button",
870
895
  {
871
896
  type: "button",
872
897
  className: "peeek__arrow peeek__arrow--next",
873
898
  "aria-label": n.next,
874
- disabled: $,
875
- onClick: () => M(1),
899
+ disabled: A,
900
+ onClick: () => F(1),
876
901
  children: "›"
877
902
  }
878
903
  )
879
904
  ]
880
905
  }
881
906
  ),
882
- d.thumbnails && /* @__PURE__ */ o("div", { className: "peeek__cf-thumbs", role: "group", "aria-label": "Pages", children: e.map((f, y) => {
883
- const S = y === i;
884
- return /* @__PURE__ */ _(
907
+ f.thumbnails && /* @__PURE__ */ o("div", { className: "peeek__cf-thumbs", role: "group", "aria-label": "Pages", children: e.map((m, p) => {
908
+ const z = p === l;
909
+ return /* @__PURE__ */ y(
885
910
  "button",
886
911
  {
887
- ref: (F) => {
888
- U.current[y] = F;
912
+ ref: (b) => {
913
+ j.current[p] = b;
889
914
  },
890
915
  type: "button",
891
- className: `peeek__cf-thumb${S ? " peeek__cf-thumb--active" : ""}`,
892
- "aria-label": `Go to page ${y + 1}`,
893
- "aria-current": S ? "page" : void 0,
894
- onClick: () => L(y),
916
+ className: `peeek__cf-thumb${z ? " peeek__cf-thumb--active" : ""}`,
917
+ "aria-label": `Go to page ${p + 1}`,
918
+ "aria-current": z ? "page" : void 0,
919
+ onClick: () => D(p),
895
920
  children: [
896
- /* @__PURE__ */ o("img", { src: f, alt: "", loading: "lazy", referrerPolicy: "no-referrer" }),
897
- /* @__PURE__ */ o("span", { className: "peeek__cf-thumb-num", children: String(y + 1).padStart(2, "0") })
921
+ /* @__PURE__ */ o("img", { src: m, alt: "", loading: "lazy", referrerPolicy: "no-referrer" }),
922
+ /* @__PURE__ */ o("span", { className: "peeek__cf-thumb-num", children: String(p + 1).padStart(2, "0") })
898
923
  ]
899
924
  },
900
- y
925
+ p
901
926
  );
902
927
  }) })
903
928
  ] });
904
929
  }
905
- function Nt({ logo: t, logoLink: e }) {
930
+ function It({ logo: t, logoLink: e }) {
906
931
  if (!t) return null;
907
932
  const n = /* @__PURE__ */ o("img", { src: t, alt: "Logo", loading: "lazy", referrerPolicy: "no-referrer" });
908
933
  return /* @__PURE__ */ o("div", { className: "peeek__branding", children: e ? /* @__PURE__ */ o("a", { href: e, target: "_blank", rel: "noopener noreferrer", children: n }) : n });
909
934
  }
910
- const Ct = [
935
+ const xt = [
911
936
  { top: "12%", left: "10%", size: 3, v: "A", dur: 13, delay: 0 },
912
937
  { top: "22%", left: "82%", size: 2, v: "B", dur: 16, delay: 2 },
913
938
  { top: "40%", left: "16%", size: 2, v: "C", dur: 12, delay: 1 },
@@ -921,17 +946,17 @@ const Ct = [
921
946
  { top: "16%", left: "50%", size: 2, v: "B", dur: 14, delay: 3 },
922
947
  { top: "62%", left: "34%", size: 2, v: "C", dur: 12, delay: 2 }
923
948
  ];
924
- function Pt({ strings: t, onClose: e }) {
925
- const n = j(null);
949
+ function zt({ strings: t, onClose: e }) {
950
+ const n = E(null);
926
951
  return C(() => {
927
952
  var a;
928
953
  (a = n.current) == null || a.focus();
929
954
  }, []), C(() => {
930
- const a = (l) => {
931
- l.key === "Escape" && e();
955
+ const a = (i) => {
956
+ i.key === "Escape" && e();
932
957
  };
933
958
  return document.addEventListener("keydown", a), () => document.removeEventListener("keydown", a);
934
- }, [e]), /* @__PURE__ */ o("div", { className: "peeek__about-backdrop", onClick: e, children: /* @__PURE__ */ _(
959
+ }, [e]), /* @__PURE__ */ o("div", { className: "peeek__about-backdrop", onClick: e, children: /* @__PURE__ */ y(
935
960
  "div",
936
961
  {
937
962
  role: "dialog",
@@ -940,7 +965,7 @@ function Pt({ strings: t, onClose: e }) {
940
965
  className: "peeek__about",
941
966
  onClick: (a) => a.stopPropagation(),
942
967
  children: [
943
- /* @__PURE__ */ o("span", { className: "peeek__about-particles", "aria-hidden": "true", children: Ct.map((a, l) => /* @__PURE__ */ o(
968
+ /* @__PURE__ */ o("span", { className: "peeek__about-particles", "aria-hidden": "true", children: xt.map((a, i) => /* @__PURE__ */ o(
944
969
  "span",
945
970
  {
946
971
  className: "peeek__about-particle",
@@ -952,7 +977,7 @@ function Pt({ strings: t, onClose: e }) {
952
977
  animation: `peeekAboutDrift${a.v} ${a.dur}s ease-in-out ${a.delay}s infinite`
953
978
  }
954
979
  },
955
- l
980
+ i
956
981
  )) }),
957
982
  /* @__PURE__ */ o(
958
983
  "button",
@@ -965,10 +990,10 @@ function Pt({ strings: t, onClose: e }) {
965
990
  children: "×"
966
991
  }
967
992
  ),
968
- /* @__PURE__ */ _("div", { className: "peeek__about-content", children: [
969
- /* @__PURE__ */ _("div", { className: "peeek__about-orbwrap", children: [
993
+ /* @__PURE__ */ y("div", { className: "peeek__about-content", children: [
994
+ /* @__PURE__ */ y("div", { className: "peeek__about-orbwrap", children: [
970
995
  /* @__PURE__ */ o("span", { className: "peeek__about-ring", "aria-hidden": "true" }),
971
- /* @__PURE__ */ _(
996
+ /* @__PURE__ */ y(
972
997
  "svg",
973
998
  {
974
999
  className: "peeek__about-mark",
@@ -977,7 +1002,7 @@ function Pt({ strings: t, onClose: e }) {
977
1002
  viewBox: "0 0 256 256",
978
1003
  "aria-hidden": "true",
979
1004
  children: [
980
- /* @__PURE__ */ o("defs", { children: /* @__PURE__ */ _("radialGradient", { id: "peeek-about-orb", cx: "38%", cy: "30%", r: "80%", children: [
1005
+ /* @__PURE__ */ o("defs", { children: /* @__PURE__ */ y("radialGradient", { id: "peeek-about-orb", cx: "38%", cy: "30%", r: "80%", children: [
981
1006
  /* @__PURE__ */ o("stop", { offset: "0%", stopColor: "#9aa2e6" }),
982
1007
  /* @__PURE__ */ o("stop", { offset: "55%", stopColor: "#6E79D6" }),
983
1008
  /* @__PURE__ */ o("stop", { offset: "100%", stopColor: "#535cc0" })
@@ -1000,9 +1025,9 @@ function Pt({ strings: t, onClose: e }) {
1000
1025
  ] }),
1001
1026
  /* @__PURE__ */ o("div", { className: "peeek__about-name", children: "Peeek Viewer" }),
1002
1027
  /* @__PURE__ */ o("div", { className: "peeek__about-tagline", children: t.aboutTagline }),
1003
- /* @__PURE__ */ _("div", { className: "peeek__about-version", children: [
1028
+ /* @__PURE__ */ y("div", { className: "peeek__about-version", children: [
1004
1029
  "v",
1005
- "0.4.1"
1030
+ "0.4.3"
1006
1031
  ] }),
1007
1032
  /* @__PURE__ */ o("p", { className: "peeek__about-desc", children: t.aboutDescription })
1008
1033
  ] })
@@ -1010,15 +1035,15 @@ function Pt({ strings: t, onClose: e }) {
1010
1035
  }
1011
1036
  ) });
1012
1037
  }
1013
- function St(t) {
1014
- const e = ut(t), n = st(e.language), a = j(null), { isFullscreen: l, toggle: c } = mt(a), [b, p] = T(!1), g = t.pages !== void 0, s = qe(
1015
- () => g ? gt(t.pages, { filename: t.filename, mimeType: t.mimeType }) : null,
1038
+ function Ft(t) {
1039
+ const e = gt(t), n = dt(e.language), a = E(null), { isFullscreen: i, toggle: d } = ht(a), [_, h] = v(!1), g = t.pages !== void 0, c = et(
1040
+ () => g ? pt(t.pages, { filename: t.filename, mimeType: t.mimeType }) : null,
1016
1041
  [g, t.pages, t.filename, t.mimeType]
1017
- ), k = ft(g ? null : e.src, e.pollInterval), h = g ? s : k.manifest, d = g ? s ? "ready" : "loading" : k.state, u = {
1042
+ ), w = bt(g ? null : e.src, e.pollInterval), k = g ? c : w.manifest, f = g ? c ? "ready" : "loading" : w.state, u = {
1018
1043
  "--peeek-accent": e.accentColor
1019
1044
  };
1020
1045
  e.background === "transparent" ? u["--peeek-bg"] = "transparent" : e.background === "color" && e.backgroundColor ? u["--peeek-bg"] = e.backgroundColor : e.background === "image" && e.backgroundImage && (u["--peeek-bg"] = `center / cover no-repeat url("${e.backgroundImage}")`);
1021
- const i = {
1046
+ const l = {
1022
1047
  toolbar: e.navigationControls,
1023
1048
  bar: e.navigationBar,
1024
1049
  fullscreen: e.fullscreen,
@@ -1030,7 +1055,7 @@ function St(t) {
1030
1055
  rotate: e.rotateControl,
1031
1056
  layoutToggle: e.layoutToggle
1032
1057
  };
1033
- return /* @__PURE__ */ _(
1058
+ return /* @__PURE__ */ y(
1034
1059
  "div",
1035
1060
  {
1036
1061
  ref: a,
@@ -1040,33 +1065,33 @@ function St(t) {
1040
1065
  dir: e.rtl ? "rtl" : void 0,
1041
1066
  style: u,
1042
1067
  children: [
1043
- /* @__PURE__ */ o(Nt, { logo: e.logo, logoLink: e.logoLink }),
1044
- d === "loading" && /* @__PURE__ */ _("div", { className: "peeek__state", style: e.loadingColor ? { color: e.loadingColor } : void 0, children: [
1068
+ /* @__PURE__ */ o(It, { logo: e.logo, logoLink: e.logoLink }),
1069
+ f === "loading" && /* @__PURE__ */ y("div", { className: "peeek__state", style: e.loadingColor ? { color: e.loadingColor } : void 0, children: [
1045
1070
  e.loadingImage && /* @__PURE__ */ o("img", { className: "peeek__state-img", src: e.loadingImage, alt: "", referrerPolicy: "no-referrer" }),
1046
1071
  /* @__PURE__ */ o("span", { children: e.loadingCaption ?? n.loading })
1047
1072
  ] }),
1048
- d === "error" && /* @__PURE__ */ o("div", { className: "peeek__state", children: n.error }),
1049
- d === "ready" && h && e.mode === "coverflow" && /* @__PURE__ */ o(
1050
- Tt,
1073
+ f === "error" && /* @__PURE__ */ o("div", { className: "peeek__state", children: n.error }),
1074
+ f === "ready" && k && e.mode === "coverflow" && /* @__PURE__ */ o(
1075
+ Pt,
1051
1076
  {
1052
- pages: h.pages,
1077
+ pages: k.pages,
1053
1078
  strings: n,
1054
- filename: h.metadata.filename,
1055
- mimeType: h.metadata.mimeType,
1079
+ filename: k.metadata.filename,
1080
+ mimeType: k.metadata.mimeType,
1056
1081
  rtl: e.rtl,
1057
1082
  autoTransition: e.autoTransition,
1058
1083
  autoTransitionInterval: e.autoTransitionInterval,
1059
1084
  downloadUrl: e.downloadUrl,
1060
- isFullscreen: l,
1061
- onToggleFullscreen: c,
1062
- onAbout: () => p(!0),
1085
+ isFullscreen: i,
1086
+ onToggleFullscreen: d,
1087
+ onAbout: () => h(!0),
1063
1088
  show: { arrows: e.arrows, thumbnails: e.pagesOverview, fullscreen: e.fullscreen, about: e.aboutButton, goto: e.goToPage }
1064
1089
  }
1065
1090
  ),
1066
- d === "ready" && h && e.mode === "flip" && /* @__PURE__ */ o(
1067
- yt,
1091
+ f === "ready" && k && e.mode === "flip" && /* @__PURE__ */ o(
1092
+ Tt,
1068
1093
  {
1069
- pages: h.pages,
1094
+ pages: k.pages,
1070
1095
  strings: n,
1071
1096
  layout: e.layout,
1072
1097
  rtl: e.rtl,
@@ -1074,18 +1099,18 @@ function St(t) {
1074
1099
  animateInteractions: e.animateInteractions,
1075
1100
  autoTransition: e.autoTransition,
1076
1101
  autoTransitionInterval: e.autoTransitionInterval,
1077
- show: i,
1102
+ show: l,
1078
1103
  downloadUrl: e.downloadUrl,
1079
- isFullscreen: l,
1080
- onToggleFullscreen: c,
1081
- onAbout: () => p(!0)
1104
+ isFullscreen: i,
1105
+ onToggleFullscreen: d,
1106
+ onAbout: () => h(!0)
1082
1107
  }
1083
1108
  ),
1084
- b && /* @__PURE__ */ o(Pt, { strings: n, onClose: () => p(!1) })
1109
+ _ && /* @__PURE__ */ o(zt, { strings: n, onClose: () => h(!1) })
1085
1110
  ]
1086
1111
  }
1087
1112
  );
1088
1113
  }
1089
1114
  export {
1090
- St as PeeekViewer
1115
+ Ft as PeeekViewer
1091
1116
  };