@peeekpage/viewer 0.3.19 → 0.4.0

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