@peeekpage/viewer 0.3.13 → 0.3.14

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