@peeekpage/viewer 0.3.19 → 0.4.1

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