@cocoar/vue-document-viewer 2.3.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.
Files changed (54) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +212 -0
  3. package/dist/CoarDocumentViewer.vue.d.ts +243 -0
  4. package/dist/CoarDocumentViewer.vue.d.ts.map +1 -0
  5. package/dist/index.d.ts +7 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +3283 -0
  8. package/dist/internal/AnnotationLayer.vue.d.ts +23 -0
  9. package/dist/internal/AnnotationLayer.vue.d.ts.map +1 -0
  10. package/dist/internal/AnnotationPopover.vue.d.ts +35 -0
  11. package/dist/internal/AnnotationPopover.vue.d.ts.map +1 -0
  12. package/dist/internal/DocumentAnnotationPanel.vue.d.ts +27 -0
  13. package/dist/internal/DocumentAnnotationPanel.vue.d.ts.map +1 -0
  14. package/dist/internal/DocumentInfoSection.vue.d.ts +18 -0
  15. package/dist/internal/DocumentInfoSection.vue.d.ts.map +1 -0
  16. package/dist/internal/DocumentSearchBar.vue.d.ts +23 -0
  17. package/dist/internal/DocumentSearchBar.vue.d.ts.map +1 -0
  18. package/dist/internal/DocumentSidebar.vue.d.ts +33 -0
  19. package/dist/internal/DocumentSidebar.vue.d.ts.map +1 -0
  20. package/dist/internal/DocumentToolbar.vue.d.ts +92 -0
  21. package/dist/internal/DocumentToolbar.vue.d.ts.map +1 -0
  22. package/dist/internal/PdfOutlineList.vue.d.ts +35 -0
  23. package/dist/internal/PdfOutlineList.vue.d.ts.map +1 -0
  24. package/dist/internal/effective-tools.d.ts +10 -0
  25. package/dist/internal/effective-tools.d.ts.map +1 -0
  26. package/dist/internal/page-provider.d.ts +51 -0
  27. package/dist/internal/page-provider.d.ts.map +1 -0
  28. package/dist/internal/useAnnotationEditor.d.ts +210 -0
  29. package/dist/internal/useAnnotationEditor.d.ts.map +1 -0
  30. package/dist/internal/useDocumentLoader.d.ts +20 -0
  31. package/dist/internal/useDocumentLoader.d.ts.map +1 -0
  32. package/dist/internal/usePageRenderer.d.ts +52 -0
  33. package/dist/internal/usePageRenderer.d.ts.map +1 -0
  34. package/dist/internal/usePdfSearch.d.ts +27 -0
  35. package/dist/internal/usePdfSearch.d.ts.map +1 -0
  36. package/dist/internal/usePositionMemory.d.ts +24 -0
  37. package/dist/internal/usePositionMemory.d.ts.map +1 -0
  38. package/dist/pdf.js +19 -0
  39. package/dist/source-types.d.ts +100 -0
  40. package/dist/source-types.d.ts.map +1 -0
  41. package/dist/sources/image-adapter.d.ts +38 -0
  42. package/dist/sources/image-adapter.d.ts.map +1 -0
  43. package/dist/sources/image-gallery-adapter.d.ts +14 -0
  44. package/dist/sources/image-gallery-adapter.d.ts.map +1 -0
  45. package/dist/sources/image.d.ts +32 -0
  46. package/dist/sources/image.d.ts.map +1 -0
  47. package/dist/sources/pdf-adapter.d.ts +27 -0
  48. package/dist/sources/pdf-adapter.d.ts.map +1 -0
  49. package/dist/sources/pdf.d.ts +20 -0
  50. package/dist/sources/pdf.d.ts.map +1 -0
  51. package/dist/types.d.ts +132 -0
  52. package/dist/types.d.ts.map +1 -0
  53. package/dist/vue-document-viewer.css +2 -0
  54. package/package.json +64 -0
package/dist/index.js ADDED
@@ -0,0 +1,3283 @@
1
+ import { Fragment as e, Teleport as t, computed as n, createBlock as r, createCommentVNode as i, createElementBlock as a, createElementVNode as o, createTextVNode as s, createVNode as c, defineComponent as l, mergeProps as u, nextTick as d, normalizeClass as f, normalizeStyle as p, onBeforeUnmount as m, onMounted as h, openBlock as g, ref as _, renderList as v, renderSlot as y, resolveComponent as b, shallowReactive as x, shallowRef as S, toDisplayString as C, toHandlers as w, unref as T, vModelText as E, vShow as D, watch as O, withCtx as k, withDirectives as A, withKeys as j, withModifiers as M } from "vue";
2
+ import * as N from "pdfjs-dist";
3
+ import { TextLayer as P } from "pdfjs-dist";
4
+ import { CoarIcon as F, CoarMenu as I, CoarMenuItem as L, CoarPopover as ee, CoarSegmentedControl as te, CoarSidebar as R, CoarSidebarDivider as ne, CoarSidebarGroup as z, CoarSidebarItem as B } from "@cocoar/vue-ui";
5
+ //#region src/internal/page-provider.ts
6
+ function V(e) {
7
+ let t = e?.name;
8
+ return t === "RenderingCancelledException" || t === "AbortException" || t === "AbortError";
9
+ }
10
+ function re(e) {
11
+ let t = e.getViewport({
12
+ scale: 1,
13
+ rotation: 0
14
+ }), n = /* @__PURE__ */ new Map(), r = null;
15
+ function i(e) {
16
+ let t = n.get(e);
17
+ if (t) {
18
+ try {
19
+ t.cancel();
20
+ } catch {}
21
+ n.delete(e);
22
+ }
23
+ }
24
+ function a() {
25
+ for (let e of n.values()) try {
26
+ e.cancel();
27
+ } catch {}
28
+ n.clear();
29
+ }
30
+ function o() {
31
+ if (r) {
32
+ try {
33
+ r.cancel();
34
+ } catch {}
35
+ r = null;
36
+ }
37
+ }
38
+ return {
39
+ intrinsicWidth: t.width,
40
+ intrinsicHeight: t.height,
41
+ async render(t, r) {
42
+ i(t);
43
+ let a = e.getViewport({
44
+ scale: r.scale * r.dpr,
45
+ rotation: r.rotation
46
+ });
47
+ t.width = Math.floor(a.width), t.height = Math.floor(a.height);
48
+ let o = t.getContext("2d", { alpha: !1 });
49
+ if (!o) return;
50
+ let s = e.render({
51
+ canvasContext: o,
52
+ viewport: a,
53
+ canvas: t
54
+ });
55
+ n.set(t, s);
56
+ try {
57
+ await s.promise;
58
+ } finally {
59
+ n.get(t) === s && n.delete(t);
60
+ }
61
+ },
62
+ cancel() {
63
+ a(), o();
64
+ },
65
+ async getTextLayer(t, n) {
66
+ o();
67
+ let i = e.getViewport({
68
+ scale: n.scale,
69
+ rotation: n.rotation
70
+ });
71
+ t.replaceChildren();
72
+ let a = new P({
73
+ textContentSource: await e.getTextContent(),
74
+ container: t,
75
+ viewport: i
76
+ });
77
+ return r = a, await a.render(), { cancel() {
78
+ try {
79
+ a.cancel();
80
+ } catch {}
81
+ r === a && (r = null);
82
+ } };
83
+ }
84
+ };
85
+ }
86
+ //#endregion
87
+ //#region src/sources/pdf-adapter.ts
88
+ function ie(e) {
89
+ if (!e) return;
90
+ let t = e.match(/^D:(\d{4})(\d{2})(\d{2})(\d{2})?(\d{2})?(\d{2})?/);
91
+ if (!t) return e;
92
+ let [, n, r, i, a = "00", o = "00", s = "00"] = t;
93
+ return `${n}-${r}-${i} ${a}:${o}:${s}`;
94
+ }
95
+ function H(e, t) {
96
+ let n = e?.[t];
97
+ if (typeof n != "string") return;
98
+ let r = n.trim();
99
+ return r.length > 0 ? r : void 0;
100
+ }
101
+ function ae(e) {
102
+ let t = _("idle"), n = S(null), r = S(null), i = S(null), a = _(null), o = {
103
+ loadingTask: null,
104
+ doc: null,
105
+ generation: 0
106
+ };
107
+ async function s() {
108
+ if (o.generation += 1, o.loadingTask) {
109
+ try {
110
+ o.loadingTask.destroy();
111
+ } catch {}
112
+ o.loadingTask = null;
113
+ }
114
+ if (o.doc) {
115
+ try {
116
+ await o.doc.destroy();
117
+ } catch {}
118
+ o.doc = null;
119
+ }
120
+ n.value = null, r.value = null, i.value = null, t.value = "idle", a.value = null;
121
+ }
122
+ async function c(e) {
123
+ await s();
124
+ let c = o.generation;
125
+ t.value = "loading", a.value = null;
126
+ let l = e.headers, u = Object.keys(l).length ? { ...l } : void 0, d;
127
+ try {
128
+ d = N.getDocument({
129
+ url: e.url,
130
+ withCredentials: e.withCredentials,
131
+ httpHeaders: u
132
+ }), o.loadingTask = d;
133
+ } catch (e) {
134
+ c === o.generation && (t.value = "error", a.value = e);
135
+ return;
136
+ }
137
+ let f;
138
+ try {
139
+ f = await d.promise;
140
+ } catch (e) {
141
+ if (c !== o.generation) return;
142
+ o.loadingTask = null, t.value = "error", a.value = e;
143
+ return;
144
+ }
145
+ if (c !== o.generation) {
146
+ try {
147
+ await f.destroy();
148
+ } catch {}
149
+ return;
150
+ }
151
+ o.doc = f;
152
+ let p = [];
153
+ try {
154
+ for (let e = 1; e <= f.numPages; e++) {
155
+ let t = await f.getPage(e);
156
+ if (c !== o.generation) {
157
+ try {
158
+ await f.destroy();
159
+ } catch {}
160
+ return;
161
+ }
162
+ p.push(re(t));
163
+ }
164
+ } catch (e) {
165
+ if (c !== o.generation) return;
166
+ o.loadingTask = null, t.value = "error", a.value = e;
167
+ return;
168
+ }
169
+ let m;
170
+ try {
171
+ let e = await f.getMetadata(), t = e.info, n = {
172
+ title: H(t, "Title"),
173
+ author: H(t, "Author"),
174
+ subject: H(t, "Subject"),
175
+ keywords: H(t, "Keywords"),
176
+ creator: H(t, "Creator"),
177
+ producer: H(t, "Producer"),
178
+ creationDate: ie(H(t, "CreationDate")),
179
+ modificationDate: ie(H(t, "ModDate")),
180
+ version: H(t, "PDFFormatVersion")
181
+ };
182
+ m = {
183
+ kind: "pdf",
184
+ format: n.version ? `PDF · v${n.version}` : "PDF",
185
+ pageCount: f.numPages,
186
+ bytes: typeof e.contentLength == "number" ? e.contentLength : void 0,
187
+ pdf: n
188
+ };
189
+ } catch {
190
+ m = {
191
+ kind: "pdf",
192
+ format: "PDF",
193
+ pageCount: f.numPages
194
+ };
195
+ }
196
+ c === o.generation && (n.value = f, r.value = p, i.value = m, t.value = "ready");
197
+ }
198
+ function l() {
199
+ let t = e.value;
200
+ t && c(t);
201
+ }
202
+ return O(e, (e) => {
203
+ e ? c(e) : s();
204
+ }, { immediate: !0 }), m(() => {
205
+ s();
206
+ }), {
207
+ status: t,
208
+ pdfDoc: n,
209
+ pageProviders: r,
210
+ info: i,
211
+ error: a,
212
+ retry: l,
213
+ destroy: s
214
+ };
215
+ }
216
+ //#endregion
217
+ //#region src/sources/image-adapter.ts
218
+ function oe(e) {
219
+ if (e.startsWith("data:")) {
220
+ let t = e.match(/^data:image\/([a-z0-9+.-]+)/i);
221
+ if (t) {
222
+ let e = t[1].toLowerCase();
223
+ return e === "svg+xml" ? "SVG" : e.toUpperCase();
224
+ }
225
+ return "Image";
226
+ }
227
+ try {
228
+ let t = new URL(e, typeof location < "u" ? location.href : "http://localhost/").pathname.split(".").pop()?.toLowerCase();
229
+ if (t && /^(jpg|jpeg|png|gif|webp|avif|svg|bmp|ico|tif|tiff)$/.test(t)) return t.toUpperCase();
230
+ } catch {}
231
+ return "Image";
232
+ }
233
+ function se(e) {
234
+ return {
235
+ intrinsicWidth: e.naturalWidth,
236
+ intrinsicHeight: e.naturalHeight,
237
+ async render(t, n) {
238
+ let r = e.naturalWidth, i = e.naturalHeight, a = n.rotation === 90 || n.rotation === 270, o = Math.floor((a ? i : r) * n.scale * n.dpr), s = Math.floor((a ? r : i) * n.scale * n.dpr);
239
+ t.width = o, t.height = s;
240
+ let c = t.getContext("2d", { alpha: !1 });
241
+ if (!c) return;
242
+ c.fillStyle = "#ffffff", c.fillRect(0, 0, o, s);
243
+ let l = r * n.scale * n.dpr, u = i * n.scale * n.dpr;
244
+ switch (c.save(), n.rotation) {
245
+ case 90:
246
+ c.translate(o, 0), c.rotate(Math.PI / 2);
247
+ break;
248
+ case 180:
249
+ c.translate(o, s), c.rotate(Math.PI);
250
+ break;
251
+ case 270:
252
+ c.translate(0, s), c.rotate(-Math.PI / 2);
253
+ break;
254
+ }
255
+ c.drawImage(e, 0, 0, l, u), c.restore();
256
+ },
257
+ cancel() {}
258
+ };
259
+ }
260
+ function ce(e) {
261
+ let t = _("idle"), n = S(null), r = S(null), i = _(null), a = 0, o = null;
262
+ async function s() {
263
+ a += 1, o &&= (o.onload = null, o.onerror = null, o.src = "", null), n.value = null, r.value = null, t.value = "idle", i.value = null;
264
+ }
265
+ function c(e) {
266
+ s().then(() => {
267
+ let s = ++a;
268
+ t.value = "loading", i.value = null;
269
+ let c = new Image();
270
+ o = c, c.onload = () => {
271
+ s === a && (n.value = [se(c)], r.value = {
272
+ kind: "image",
273
+ format: `Image · ${oe(e.url)}`,
274
+ pageCount: 1
275
+ }, t.value = "ready");
276
+ }, c.onerror = () => {
277
+ s === a && (t.value = "error", i.value = /* @__PURE__ */ Error(`Failed to load image: ${e.url}`));
278
+ }, c.src = e.url;
279
+ });
280
+ }
281
+ function l() {
282
+ let t = e.value;
283
+ t && c(t);
284
+ }
285
+ return O(e, (e) => {
286
+ e ? c(e) : s();
287
+ }, { immediate: !0 }), m(() => {
288
+ s();
289
+ }), {
290
+ status: t,
291
+ pageProviders: n,
292
+ info: r,
293
+ error: i,
294
+ retry: l,
295
+ destroy: s
296
+ };
297
+ }
298
+ //#endregion
299
+ //#region src/sources/image-gallery-adapter.ts
300
+ function le(e) {
301
+ let t = new Image(), n = new Promise((n, r) => {
302
+ t.onload = () => n(t), t.onerror = () => r(/* @__PURE__ */ Error(`Failed to load image: ${e}`));
303
+ });
304
+ return t.src = e, {
305
+ img: t,
306
+ promise: n
307
+ };
308
+ }
309
+ function ue(e) {
310
+ let t = _("idle"), n = S(null), r = S(null), i = _(null), a = 0, o = [];
311
+ async function s() {
312
+ a += 1;
313
+ for (let e of o) e.onload = null, e.onerror = null, e.src = "";
314
+ o = [], n.value = null, r.value = null, t.value = "idle", i.value = null;
315
+ }
316
+ function c(e, t) {
317
+ let n = new Set(e.map(oe));
318
+ return {
319
+ kind: "image-gallery",
320
+ format: n.size === 0 ? "Image gallery" : n.size === 1 ? `Image gallery · ${[...n][0]}` : "Image gallery · mixed",
321
+ pageCount: t
322
+ };
323
+ }
324
+ function l(e) {
325
+ s().then(async () => {
326
+ let s = ++a;
327
+ if (t.value = "loading", i.value = null, e.urls.length === 0) {
328
+ n.value = [], r.value = c(e.urls, 0), t.value = "ready";
329
+ return;
330
+ }
331
+ let l = e.urls.map((e) => le(e));
332
+ o = l.map((e) => e.img);
333
+ try {
334
+ let i = await Promise.all(l.map((e) => e.promise));
335
+ if (s !== a) return;
336
+ n.value = i.map((e) => se(e)), r.value = c(e.urls, i.length), t.value = "ready";
337
+ } catch (e) {
338
+ if (s !== a) return;
339
+ t.value = "error", i.value = e;
340
+ }
341
+ });
342
+ }
343
+ function u() {
344
+ let t = e.value;
345
+ t && l(t);
346
+ }
347
+ return O(e, (e) => {
348
+ e ? l(e) : s();
349
+ }, { immediate: !0 }), m(() => {
350
+ s();
351
+ }), {
352
+ status: t,
353
+ pageProviders: n,
354
+ info: r,
355
+ error: i,
356
+ retry: u,
357
+ destroy: s
358
+ };
359
+ }
360
+ //#endregion
361
+ //#region src/internal/useDocumentLoader.ts
362
+ function de(e) {
363
+ let t = n(() => {
364
+ let t = e.value;
365
+ return t?.kind === "pdf" ? t : null;
366
+ }), r = n(() => {
367
+ let t = e.value;
368
+ return t?.kind === "image" ? t : null;
369
+ }), i = n(() => {
370
+ let t = e.value;
371
+ return t?.kind === "image-gallery" ? t : null;
372
+ }), a = ae(t), o = ce(r), s = ue(i), c = n(() => {
373
+ let t = e.value;
374
+ return t ? t.kind === "pdf" ? a.status.value : t.kind === "image" ? o.status.value : t.kind === "image-gallery" ? s.status.value : "idle" : "idle";
375
+ }), l = n(() => {
376
+ let t = e.value;
377
+ return t?.kind === "pdf" ? a.error.value : t?.kind === "image" ? o.error.value : t?.kind === "image-gallery" ? s.error.value : null;
378
+ }), u = n(() => {
379
+ let t = e.value;
380
+ return t?.kind === "pdf" ? a.pageProviders.value : t?.kind === "image" ? o.pageProviders.value : t?.kind === "image-gallery" ? s.pageProviders.value : null;
381
+ }), d = n(() => {
382
+ let t = e.value;
383
+ return t?.kind === "pdf" ? a.info.value : t?.kind === "image" ? o.info.value : t?.kind === "image-gallery" ? s.info.value : null;
384
+ });
385
+ function f() {
386
+ let t = e.value;
387
+ t?.kind === "pdf" ? a.retry() : t?.kind === "image" ? o.retry() : t?.kind === "image-gallery" && s.retry();
388
+ }
389
+ async function p() {
390
+ await a.destroy(), await o.destroy(), await s.destroy();
391
+ }
392
+ return {
393
+ status: c,
394
+ pdfDoc: a.pdfDoc,
395
+ pageProviders: u,
396
+ info: d,
397
+ error: l,
398
+ retry: f,
399
+ destroy: p
400
+ };
401
+ }
402
+ //#endregion
403
+ //#region src/internal/usePageRenderer.ts
404
+ var fe = 2;
405
+ function pe(e) {
406
+ let t = x([]), n = _(0), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = null;
407
+ function o() {
408
+ return e.devicePixelRatio ? e.devicePixelRatio() : typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, fe);
409
+ }
410
+ function s() {
411
+ for (let e of r.values()) e.cancel();
412
+ }
413
+ function c() {
414
+ a &&= (a.disconnect(), null);
415
+ let n = e.scrollContainer.value;
416
+ if (!(!n || typeof IntersectionObserver > "u")) {
417
+ a = new IntersectionObserver((e) => {
418
+ for (let n of e) {
419
+ let e = n.target.dataset.pageIndex;
420
+ if (e == null) continue;
421
+ let r = Number(e);
422
+ if (i.set(r, n.intersectionRatio), n.isIntersecting) {
423
+ let e = t[r];
424
+ e && !e.rendered && !e.rendering && p(r);
425
+ }
426
+ }
427
+ l();
428
+ }, {
429
+ root: n,
430
+ rootMargin: "300px 0px 300px 0px",
431
+ threshold: [
432
+ 0,
433
+ .1,
434
+ .5,
435
+ 1
436
+ ]
437
+ });
438
+ for (let e of t) e.wrapper && a.observe(e.wrapper);
439
+ }
440
+ }
441
+ function l() {
442
+ let e = 0, r = -1;
443
+ for (let n of t) {
444
+ let t = i.get(n.index) ?? 0;
445
+ t > r && (r = t, e = n.index);
446
+ }
447
+ r > 0 && n.value !== e && (n.value = e);
448
+ }
449
+ function u(t, n) {
450
+ let r = e.scale.value, i = e.rotation.value, a = i === 90 || i === 270;
451
+ return {
452
+ w: (a ? n : t) * r,
453
+ h: (a ? t : n) * r
454
+ };
455
+ }
456
+ function d(e) {
457
+ t.splice(0, t.length), r.clear(), i.clear();
458
+ for (let n = 0; n < e.length; n++) {
459
+ let i = e[n];
460
+ r.set(n, i);
461
+ let { w: a, h: o } = u(i.intrinsicWidth, i.intrinsicHeight);
462
+ t.push({
463
+ index: n,
464
+ intrinsicWidth: i.intrinsicWidth,
465
+ intrinsicHeight: i.intrinsicHeight,
466
+ displayWidth: a,
467
+ displayHeight: o,
468
+ wrapper: null,
469
+ rendered: !1,
470
+ rendering: !1
471
+ });
472
+ }
473
+ }
474
+ function f() {
475
+ for (let e = 0; e < t.length; e++) {
476
+ let n = t[e], { w: r, h: i } = u(n.intrinsicWidth, n.intrinsicHeight);
477
+ if (t[e] = {
478
+ ...n,
479
+ displayWidth: r,
480
+ displayHeight: i
481
+ }, n.wrapper) {
482
+ let e = n.wrapper.querySelector("canvas.coar-pdf-page__canvas");
483
+ e && (e.style.width = `${r}px`, e.style.height = `${i}px`);
484
+ let t = n.wrapper.querySelector("div.textLayer");
485
+ t && (t.style.width = `${r}px`, t.style.height = `${i}px`);
486
+ }
487
+ }
488
+ }
489
+ async function p(n) {
490
+ let i = t[n], a = r.get(n);
491
+ if (!i || !a || !i.wrapper || i.rendering) return;
492
+ i.rendering = !0;
493
+ let s = e.scale.value, c = e.rotation.value, l = o(), u = i.wrapper.querySelector("canvas.coar-pdf-page__canvas");
494
+ u || (u = document.createElement("canvas"), u.className = "coar-pdf-page__canvas", i.wrapper.insertBefore(u, i.wrapper.firstChild)), u.style.width = `${i.displayWidth}px`, u.style.height = `${i.displayHeight}px`;
495
+ try {
496
+ await a.render(u, {
497
+ scale: s,
498
+ rotation: c,
499
+ dpr: l
500
+ }), i.rendered = !0;
501
+ } catch (e) {
502
+ V(e) || console.error(`[CoarDocumentViewer] page ${n + 1} render failed`, e);
503
+ } finally {
504
+ i.rendering = !1;
505
+ }
506
+ a.getTextLayer && await h(n, a);
507
+ }
508
+ async function h(n, r) {
509
+ if (!r.getTextLayer) return;
510
+ let i = t[n];
511
+ if (!i?.wrapper) return;
512
+ let a = e.scale.value, o = e.rotation.value, s = i.wrapper.querySelector("div.textLayer");
513
+ if (s || (s = document.createElement("div"), s.className = "textLayer", i.wrapper.appendChild(s)), s.style.width = `${i.displayWidth}px`, s.style.height = `${i.displayHeight}px`, s.style.setProperty("--total-scale-factor", String(a)), i.wrapper.contains(s)) try {
514
+ await r.getTextLayer(s, {
515
+ scale: a,
516
+ rotation: o
517
+ });
518
+ } catch (e) {
519
+ V(e) || console.warn(`[CoarDocumentViewer] text layer for page ${n + 1} failed`, e);
520
+ }
521
+ }
522
+ function g(e, n) {
523
+ let r = t[e];
524
+ if (!r) return;
525
+ let i = n instanceof HTMLDivElement ? n : null;
526
+ r.wrapper !== i && (r.wrapper && a && a.unobserve(r.wrapper), r.wrapper = i, i && (i.dataset.pageIndex = String(e), a?.observe(i)));
527
+ }
528
+ function v(e, n = {}) {
529
+ let r = t[e];
530
+ r?.wrapper && r.wrapper.scrollIntoView({
531
+ behavior: n.behavior ?? "auto",
532
+ block: "start",
533
+ inline: "nearest"
534
+ });
535
+ }
536
+ function y() {
537
+ f(), s();
538
+ for (let e of t) e.rendered = !1;
539
+ for (let [e, t] of i) t > 0 && p(e);
540
+ }
541
+ return O(() => e.pageProviders.value, (e) => {
542
+ if (s(), r.clear(), i.clear(), t.splice(0, t.length), n.value = 0, e && (d(e), a)) for (let e of t) e.wrapper && a.observe(e.wrapper);
543
+ }, { immediate: !0 }), O(() => e.scrollContainer.value, () => {
544
+ c();
545
+ }, { immediate: !0 }), O(() => [e.scale.value, e.rotation.value], () => {
546
+ y();
547
+ }), m(() => {
548
+ a?.disconnect(), a = null, s(), r.clear();
549
+ }), {
550
+ pages: t,
551
+ visiblePage: n,
552
+ bindWrapper: g,
553
+ scrollToPage: v,
554
+ invalidateRenders: y
555
+ };
556
+ }
557
+ //#endregion
558
+ //#region src/internal/usePositionMemory.ts
559
+ var me = 250;
560
+ function he(e) {
561
+ try {
562
+ let t = localStorage.getItem(e);
563
+ if (!t) return null;
564
+ let n = JSON.parse(t);
565
+ return typeof n.page != "number" || typeof n.pageOffset != "number" || typeof n.zoom != "number" || typeof n.rotation != "number" ? null : {
566
+ page: n.page,
567
+ pageOffset: n.pageOffset,
568
+ zoom: n.zoom,
569
+ rotation: n.rotation
570
+ };
571
+ } catch {
572
+ return null;
573
+ }
574
+ }
575
+ function ge(e, t) {
576
+ try {
577
+ localStorage.setItem(e, JSON.stringify(t));
578
+ } catch {}
579
+ }
580
+ function _e(e) {
581
+ let t = _(!1), r = _(!1), i = null, a = null;
582
+ function o() {
583
+ let t = e.scrollContainer.value;
584
+ if (!t) return null;
585
+ let n = e.visiblePage.value, r = e.pages[n];
586
+ if (!r?.wrapper) return {
587
+ page: n,
588
+ pageOffset: 0,
589
+ zoom: e.scale.value,
590
+ rotation: e.rotation.value
591
+ };
592
+ let i = r.wrapper.offsetTop - t.offsetTop, a = (t.scrollTop - i) / Math.max(1, r.displayHeight);
593
+ return {
594
+ page: n,
595
+ pageOffset: Math.max(0, Math.min(1, a)),
596
+ zoom: e.scale.value,
597
+ rotation: e.rotation.value
598
+ };
599
+ }
600
+ function s() {
601
+ if (i != null && (clearTimeout(i), i = null), t.value) return;
602
+ let n = o();
603
+ if (!n) return;
604
+ let r = JSON.stringify(n);
605
+ if (r === a) return;
606
+ a = r, e.emitPosition(n);
607
+ let s = e.storageKey.value;
608
+ s && ge(s, n);
609
+ }
610
+ function c() {
611
+ t.value || (i != null && clearTimeout(i), i = setTimeout(s, me));
612
+ }
613
+ function l(t) {
614
+ let n = e.scrollContainer.value;
615
+ if (!n) return;
616
+ let r = e.pages[t.page];
617
+ r?.wrapper && (n.scrollTop = r.wrapper.offsetTop - n.offsetTop + t.pageOffset * r.displayHeight);
618
+ }
619
+ async function u() {
620
+ if (r.value || !e.ready.value || e.pages.length === 0) return;
621
+ let n = e.externalPosition.value, i = e.storageKey.value ? he(e.storageKey.value) : null, a = n ?? i;
622
+ if (!a) {
623
+ r.value = !0;
624
+ return;
625
+ }
626
+ t.value = !0, typeof a.zoom == "number" && Number.isFinite(a.zoom) && (e.scale.value = a.zoom), (a.rotation === 0 || a.rotation === 90 || a.rotation === 180 || a.rotation === 270) && (e.rotation.value = a.rotation), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(() => e()))), l(a), await new Promise((e) => setTimeout(e, 0)), t.value = !1, r.value = !0;
627
+ }
628
+ O(() => e.pages.length === 0, (e) => {
629
+ e && (r.value = !1, a = null);
630
+ }), O(() => [e.ready.value, e.pages.length], ([e, t]) => {
631
+ e && t > 0 && !r.value && u();
632
+ }), O(() => [
633
+ e.visiblePage.value,
634
+ e.scale.value,
635
+ e.rotation.value
636
+ ], c);
637
+ let d = null;
638
+ function f() {
639
+ p();
640
+ let t = e.scrollContainer.value;
641
+ t && (d = t, t.addEventListener("scroll", c, { passive: !0 }));
642
+ }
643
+ function p() {
644
+ d &&= (d.removeEventListener("scroll", c), null);
645
+ }
646
+ return O(() => e.scrollContainer.value, f), h(f), m(() => {
647
+ p(), i != null && clearTimeout(i);
648
+ }), O(() => e.externalPosition.value, (n) => {
649
+ if (!n || !e.ready.value || !r.value) return;
650
+ let i = o();
651
+ i && JSON.stringify(i) === JSON.stringify(n) || (t.value = !0, e.scale.value = n.zoom, e.rotation.value = n.rotation, requestAnimationFrame(() => {
652
+ requestAnimationFrame(() => {
653
+ l(n), setTimeout(() => {
654
+ t.value = !1;
655
+ }, 0);
656
+ });
657
+ }));
658
+ }), {
659
+ current: n(() => o()),
660
+ flush: s
661
+ };
662
+ }
663
+ //#endregion
664
+ //#region src/internal/useAnnotationEditor.ts
665
+ function ve(e, t) {
666
+ if (!t) return null;
667
+ let n = t.closest(".coar-pdf-page");
668
+ if (!n) return null;
669
+ let r = n.dataset.pageIndex;
670
+ if (r == null) return null;
671
+ let i = Number(r), a = e[i];
672
+ return a ? {
673
+ idx: i,
674
+ page: a,
675
+ wrapper: n
676
+ } : null;
677
+ }
678
+ var ye = 3, U = 18, W = 14, be = .25, G = .06, xe = [
679
+ 1.5,
680
+ 3,
681
+ 6
682
+ ], Se = [
683
+ 10,
684
+ 18,
685
+ 30
686
+ ];
687
+ function Ce(e) {
688
+ let t = _(null), r = _(null), i = _(null), a = _(null), o = _(null), s = _(null), c = _(ye), l = _(""), u = _(U), d = _("");
689
+ function f() {
690
+ return e.pages;
691
+ }
692
+ function p(t) {
693
+ let n = e.mode.value;
694
+ if (n !== "comment" && n !== "freetext" || t.target?.closest("[data-annotation-id]")) return;
695
+ let a = ve(f(), t.target);
696
+ if (!a) return;
697
+ let { idx: o, wrapper: s } = a, c = s.getBoundingClientRect(), l = Math.max(0, Math.min(1, (t.clientX - c.left) / Math.max(1, c.width))), u = Math.max(0, Math.min(1, (t.clientY - c.top) / Math.max(1, c.height))), d = new DOMRect(t.clientX, t.clientY, 1, 1);
698
+ if (n === "comment") r.value = {
699
+ pageIndex: o,
700
+ anchor: {
701
+ x: l,
702
+ y: u
703
+ },
704
+ viewportRect: d,
705
+ color: e.colors.value[0] ?? "#2563eb"
706
+ };
707
+ else {
708
+ let t = be, n = G;
709
+ i.value = {
710
+ pageIndex: o,
711
+ rect: {
712
+ x: Math.max(0, Math.min(1 - t, l - t / 2)),
713
+ y: Math.max(0, Math.min(1 - n, u - n / 2)),
714
+ w: t,
715
+ h: n
716
+ },
717
+ viewportRect: d,
718
+ color: e.colors.value[0] ?? "#16a34a"
719
+ };
720
+ }
721
+ }
722
+ let m = null;
723
+ function h(e) {
724
+ if (!a.value || !m) return;
725
+ let t = m.getBoundingClientRect(), n = {
726
+ x: K((e.clientX - t.left) / Math.max(1, t.width)),
727
+ y: K((e.clientY - t.top) / Math.max(1, t.height))
728
+ }, r = a.value.strokes, i = r[r.length - 1];
729
+ if ((e.shiftKey || e.ctrlKey || e.metaKey) && i.length >= 1) {
730
+ let t = i[0], a = e.shiftKey ? Te(t, n) : n;
731
+ r[r.length - 1] = [t, a];
732
+ } else i.push(n);
733
+ a.value = {
734
+ ...a.value,
735
+ strokes: r.slice()
736
+ };
737
+ }
738
+ function g(t) {
739
+ let n = e.mode.value;
740
+ if (n === "select") {
741
+ E(t);
742
+ return;
743
+ }
744
+ if (n === "eraser") {
745
+ A(t);
746
+ return;
747
+ }
748
+ if (n !== "ink" && n !== "marker" || t.button !== 0 || !t.altKey && t.target?.closest("[data-annotation-id]")) return;
749
+ let r = ve(f(), t.target);
750
+ if (!r) return;
751
+ m = r.wrapper, t.preventDefault(), t.target.setPointerCapture?.(t.pointerId);
752
+ let i = n === "marker", o = t.altKey && s.value && s.value.pageIndex === r.idx && s.value.kind === (i ? "marker" : "ink") ? e.annotations.value.find((e) => e.id === s.value.id) : void 0, p = o && (o.type === "ink" || o.type === "marker") ? o : void 0;
753
+ a.value = {
754
+ kind: i ? "marker" : "ink",
755
+ pageIndex: r.idx,
756
+ strokes: [[]],
757
+ width: p?.width ?? (i ? u.value : c.value),
758
+ color: p?.color || (i ? d.value : l.value) || e.colors.value[0] || (i ? "#fde68a" : "#dc2626"),
759
+ appendToId: p?.id
760
+ }, h(t), window.addEventListener("pointermove", v), window.addEventListener("pointerup", y), window.addEventListener("pointercancel", y);
761
+ }
762
+ function v(e) {
763
+ a.value && h(e);
764
+ }
765
+ function y() {
766
+ window.removeEventListener("pointermove", v), window.removeEventListener("pointerup", y), window.removeEventListener("pointercancel", y);
767
+ let t = a.value;
768
+ if (m = null, a.value = null, !t) return;
769
+ let n = t.strokes.filter((e) => e.length >= 2);
770
+ if (n.length !== 0) {
771
+ if (t.appendToId) {
772
+ let r = e.annotations.value.find((e) => e.id === t.appendToId);
773
+ if (r && (r.type === "ink" || r.type === "marker")) {
774
+ let t = r;
775
+ e.emitUpdate({
776
+ id: r.id,
777
+ patch: { strokes: [...t.strokes, ...n] }
778
+ });
779
+ return;
780
+ }
781
+ }
782
+ e.emitCreate({
783
+ type: t.kind,
784
+ pageIndex: t.pageIndex,
785
+ color: t.color,
786
+ width: t.width,
787
+ strokes: n
788
+ });
789
+ }
790
+ }
791
+ function b(t, n) {
792
+ let r = i.value;
793
+ if (r) {
794
+ if (!t.trim()) {
795
+ i.value = null;
796
+ return;
797
+ }
798
+ e.emitCreate({
799
+ type: "freetext",
800
+ pageIndex: r.pageIndex,
801
+ color: n,
802
+ rect: r.rect,
803
+ text: t,
804
+ fontSize: W
805
+ }), i.value = null;
806
+ }
807
+ }
808
+ function x() {
809
+ i.value = null;
810
+ }
811
+ function S(t, n) {
812
+ let i = r.value;
813
+ i && (e.emitCreate({
814
+ type: "comment",
815
+ pageIndex: i.pageIndex,
816
+ anchor: i.anchor,
817
+ color: n,
818
+ comment: t
819
+ }), r.value = null);
820
+ }
821
+ function C() {
822
+ r.value = null;
823
+ }
824
+ let w = null;
825
+ function T(e) {
826
+ if (!e) return null;
827
+ let t = e.closest("[data-annotation-id]");
828
+ if (!t) return null;
829
+ let n = t.dataset?.annotationId ?? t.getAttribute?.("data-annotation-id") ?? "";
830
+ return n ? {
831
+ el: t,
832
+ id: n
833
+ } : null;
834
+ }
835
+ function E(n) {
836
+ if (n.button !== 0) return;
837
+ let r = T(n.target);
838
+ if (!r) {
839
+ t.value = null;
840
+ return;
841
+ }
842
+ if (!e.annotations.value.find((e) => e.id === r.id)) return;
843
+ let i = ve(f(), n.target);
844
+ if (!i) return;
845
+ n.preventDefault(), t.value = r.id, w = r.el;
846
+ let a = i.wrapper.getBoundingClientRect();
847
+ o.value = {
848
+ id: r.id,
849
+ pageIndex: i.idx,
850
+ wrapperWidth: a.width,
851
+ wrapperHeight: a.height,
852
+ startX: n.clientX,
853
+ startY: n.clientY,
854
+ dx: 0,
855
+ dy: 0
856
+ }, n.target.setPointerCapture?.(n.pointerId), window.addEventListener("pointermove", D), window.addEventListener("pointerup", k), window.addEventListener("pointercancel", k);
857
+ }
858
+ function D(e) {
859
+ let t = o.value;
860
+ if (!t || !w) return;
861
+ let n = e.clientX - t.startX, r = e.clientY - t.startY;
862
+ t.dx = n / Math.max(1, t.wrapperWidth), t.dy = r / Math.max(1, t.wrapperHeight), w.style.transform = `translate(${n}px, ${r}px)`;
863
+ }
864
+ function k() {
865
+ window.removeEventListener("pointermove", D), window.removeEventListener("pointerup", k), window.removeEventListener("pointercancel", k);
866
+ let t = o.value, n = w;
867
+ if (w = null, o.value = null, !t || !n || (n.style.transform = "", Math.abs(t.dx) < 1e-4 && Math.abs(t.dy) < 1e-4)) return;
868
+ let r = e.annotations.value.find((e) => e.id === t.id);
869
+ if (!r) return;
870
+ let i = we(r, t.dx, t.dy);
871
+ i && e.emitUpdate({
872
+ id: t.id,
873
+ patch: i
874
+ });
875
+ }
876
+ function A(n) {
877
+ if (n.button !== 0) return;
878
+ let r = T(n.target);
879
+ if (!r) return;
880
+ n.preventDefault();
881
+ let i = e.annotations.value.find((e) => e.id === r.id);
882
+ if (i) {
883
+ if (i.type === "ink" || i.type === "marker") {
884
+ let t = n.target.closest?.("[data-stroke-index]")?.dataset?.strokeIndex ?? null, r = i;
885
+ if (t !== null && r.strokes.length > 1) {
886
+ let n = Number(t), a = r.strokes.filter((e, t) => t !== n);
887
+ e.emitUpdate({
888
+ id: i.id,
889
+ patch: { strokes: a }
890
+ });
891
+ return;
892
+ }
893
+ }
894
+ e.emitDelete(i.id), t.value === i.id && (t.value = null);
895
+ }
896
+ }
897
+ function j(e) {
898
+ t.value = e, e && (r.value = null);
899
+ }
900
+ let M = n(() => {
901
+ let n = t.value;
902
+ return n ? e.annotations.value.find((e) => e.id === n) ?? null : null;
903
+ }), N = null;
904
+ function P() {
905
+ F();
906
+ let t = e.scrollContainer.value;
907
+ t && (N = t, t.addEventListener("click", p), t.addEventListener("pointerdown", g));
908
+ }
909
+ function F() {
910
+ N &&= (N.removeEventListener("click", p), N.removeEventListener("pointerdown", g), null), window.removeEventListener("pointermove", v), window.removeEventListener("pointerup", y), window.removeEventListener("pointercancel", y), window.removeEventListener("pointermove", D), window.removeEventListener("pointerup", k), window.removeEventListener("pointercancel", k);
911
+ }
912
+ O(() => e.scrollContainer.value, P, { immediate: !0 }), O(() => e.mode.value, () => {
913
+ r.value = null, i.value = null, a.value = null, w &&= (w.style.transform = "", null), o.value = null, s.value = null, t.value = null;
914
+ });
915
+ let I = /* @__PURE__ */ new Set();
916
+ return O(() => e.annotations.value, (e) => {
917
+ let t = [];
918
+ for (let n of e) I.has(n.id) || t.push(n);
919
+ I = new Set(e.map((e) => e.id));
920
+ for (let e = t.length - 1; e >= 0; e--) {
921
+ let n = t[e];
922
+ if (n.type === "ink" || n.type === "marker") {
923
+ s.value = {
924
+ id: n.id,
925
+ kind: n.type,
926
+ pageIndex: n.pageIndex
927
+ };
928
+ return;
929
+ }
930
+ }
931
+ }, { immediate: !0 }), {
932
+ selectedAnnotationId: t,
933
+ selectedAnnotation: M,
934
+ selectAnnotation: j,
935
+ draftPin: r,
936
+ commitDraftPin: S,
937
+ cancelDraftPin: C,
938
+ draftFreetext: i,
939
+ commitDraftFreetext: b,
940
+ cancelDraftFreetext: x,
941
+ draftInk: a,
942
+ draftMove: o,
943
+ inkWidth: c,
944
+ inkColor: l,
945
+ markerWidth: u,
946
+ markerColor: d,
947
+ detach: F
948
+ };
949
+ }
950
+ function we(e, t, n) {
951
+ switch (e.type) {
952
+ case "comment": return { anchor: {
953
+ x: K(e.anchor.x + t),
954
+ y: K(e.anchor.y + n)
955
+ } };
956
+ case "freetext": {
957
+ let r = e, i = Math.max(0, 1 - r.rect.w), a = Math.max(0, 1 - r.rect.h);
958
+ return { rect: {
959
+ x: Math.max(0, Math.min(i, r.rect.x + t)),
960
+ y: Math.max(0, Math.min(a, r.rect.y + n)),
961
+ w: r.rect.w,
962
+ h: r.rect.h
963
+ } };
964
+ }
965
+ case "ink":
966
+ case "marker": return { strokes: e.strokes.map((e) => e.map((e) => ({
967
+ x: K(e.x + t),
968
+ y: K(e.y + n)
969
+ }))) };
970
+ }
971
+ }
972
+ function K(e) {
973
+ return Math.max(0, Math.min(1, e));
974
+ }
975
+ var q = Math.PI / 12;
976
+ function Te(e, t) {
977
+ let n = t.x - e.x, r = t.y - e.y;
978
+ if (n === 0 && r === 0) return t;
979
+ let i = Math.round(Math.atan2(r, n) / q) * q, a = Math.hypot(n, r);
980
+ return {
981
+ x: K(e.x + Math.cos(i) * a),
982
+ y: K(e.y + Math.sin(i) * a)
983
+ };
984
+ }
985
+ //#endregion
986
+ //#region src/internal/usePdfSearch.ts
987
+ var Ee = 350, De = 2;
988
+ function Oe(e) {
989
+ let t = _(""), r = _(!1), i = _([]), a = _(-1), o = _(!1), s = /* @__PURE__ */ new Map(), c = 0, l = null;
990
+ async function u(t) {
991
+ let n = s.get(t);
992
+ if (n) return n;
993
+ let r = e.doc.value;
994
+ if (!r) throw Error("No document");
995
+ let i = await r.getPage(t + 1), a = await i.getTextContent(), o = i.getViewport({
996
+ scale: 1,
997
+ rotation: 0
998
+ }), c = [], l = "";
999
+ for (let e of a.items) {
1000
+ let t = e;
1001
+ typeof t.str == "string" && (c.push({
1002
+ start: l.length,
1003
+ transform: t.transform ?? [
1004
+ 1,
1005
+ 0,
1006
+ 0,
1007
+ 1,
1008
+ 0,
1009
+ 0
1010
+ ],
1011
+ str: t.str,
1012
+ width: t.width ?? 0,
1013
+ height: t.height ?? 0
1014
+ }), l += t.str);
1015
+ }
1016
+ let u = {
1017
+ text: l,
1018
+ items: c,
1019
+ viewport: o
1020
+ };
1021
+ return s.set(t, u), u;
1022
+ }
1023
+ function d(e, t, n, r) {
1024
+ let i = Math.max(1, e.str.length), a = e.width / i, o = a * n, s = a * (r - n), c = e.transform[4] + o, l = e.transform[5], u = c + s, d = l + e.height, [f, p, m, h] = t.viewport.convertToViewportRectangle([
1025
+ c,
1026
+ l,
1027
+ u,
1028
+ d
1029
+ ]), g = Math.min(f, m), _ = Math.max(f, m), v = Math.min(p, h), y = Math.max(p, h), b = Math.max(1, t.viewport.width), x = Math.max(1, t.viewport.height);
1030
+ return {
1031
+ x: g / b,
1032
+ y: v / x,
1033
+ w: (_ - g) / b,
1034
+ h: (y - v) / x
1035
+ };
1036
+ }
1037
+ function f(e, t, n) {
1038
+ let r = [];
1039
+ for (let i of e.items) {
1040
+ if (i.start + i.str.length <= t) continue;
1041
+ if (i.start >= n) break;
1042
+ let a = Math.max(0, t - i.start), o = Math.min(i.str.length, n - i.start);
1043
+ o <= a || r.push(d(i, e, a, o));
1044
+ }
1045
+ return r;
1046
+ }
1047
+ async function p(t) {
1048
+ let n = ++c, s = e.doc.value, l = t.trim();
1049
+ if (!s || l.length < De) {
1050
+ i.value = [], a.value = -1, o.value = !1;
1051
+ return;
1052
+ }
1053
+ o.value = !0;
1054
+ try {
1055
+ let e = s.numPages, o = [], l = r.value ? t : t.toLowerCase();
1056
+ for (let t = 0; t < e; t++) {
1057
+ if (n !== c) return;
1058
+ let e;
1059
+ try {
1060
+ e = await u(t);
1061
+ } catch {
1062
+ continue;
1063
+ }
1064
+ let i = r.value ? e.text : e.text.toLowerCase(), a = 0;
1065
+ for (; a >= 0 && (a = i.indexOf(l, a), !(a < 0));) {
1066
+ let n = a + l.length, r = f(e, a, n);
1067
+ r.length > 0 && o.push({
1068
+ pageIndex: t,
1069
+ rects: r,
1070
+ text: e.text.slice(a, n)
1071
+ }), a = n;
1072
+ }
1073
+ }
1074
+ if (n !== c) return;
1075
+ i.value = o, a.value = o.length > 0 ? 0 : -1;
1076
+ } finally {
1077
+ n === c && (o.value = !1);
1078
+ }
1079
+ }
1080
+ async function m(e) {
1081
+ return t.value = e, l != null && clearTimeout(l), new Promise((t) => {
1082
+ l = setTimeout(() => {
1083
+ p(e).then(t);
1084
+ }, Ee);
1085
+ });
1086
+ }
1087
+ function h() {
1088
+ i.value.length !== 0 && (a.value = (a.value + 1) % i.value.length);
1089
+ }
1090
+ function g() {
1091
+ i.value.length !== 0 && (a.value = (a.value - 1 + i.value.length) % i.value.length);
1092
+ }
1093
+ function v() {
1094
+ c++, l != null && clearTimeout(l), t.value = "", i.value = [], a.value = -1, o.value = !1;
1095
+ }
1096
+ async function y(e) {
1097
+ let t = c;
1098
+ for (let n = 0; n < e.numPages; n++) {
1099
+ if (t !== c) return;
1100
+ if (!s.has(n)) {
1101
+ try {
1102
+ await u(n);
1103
+ } catch {}
1104
+ await new Promise((e) => setTimeout(e, 0));
1105
+ }
1106
+ }
1107
+ }
1108
+ return O(r, () => {
1109
+ t.value && p(t.value);
1110
+ }), O(() => e.doc.value, (e) => {
1111
+ s.clear(), v(), e && y(e);
1112
+ }, { immediate: !0 }), {
1113
+ query: t,
1114
+ caseSensitive: r,
1115
+ matches: i,
1116
+ currentIndex: a,
1117
+ currentMatch: n(() => {
1118
+ let e = a.value;
1119
+ return e >= 0 && e < i.value.length ? i.value[e] : null;
1120
+ }),
1121
+ searching: o,
1122
+ setQuery: m,
1123
+ next: h,
1124
+ prev: g,
1125
+ clear: v
1126
+ };
1127
+ }
1128
+ //#endregion
1129
+ //#region src/types.ts
1130
+ var ke = /* @__PURE__ */ "sidebar-toggle.annotations-panel.separator.prev-page.page-input.next-page.separator.zoom-out.zoom-reset.zoom-in.separator.fit-width.fit-page.reset-view.separator.rotate-ccw.rotate-cw.separator.pan.select.eraser.separator.marker.note.ink.freetext.separator.search.print.download".split("."), Ae = [
1131
+ "pan",
1132
+ "select",
1133
+ "eraser",
1134
+ "marker",
1135
+ "note",
1136
+ "ink",
1137
+ "freetext"
1138
+ ];
1139
+ function je(e, t) {
1140
+ let n = [];
1141
+ for (let r of e) r === "sidebar-toggle" && !t.showSidebarToggle || r === "annotations-panel" && !t.showAnnotationsPanelToggle || r === "search" && !t.showSearch || (r === "print" || r === "download") && !t.showPrintDownload || !t.showAnnotationModes && Ae.includes(r) || n.push(r);
1142
+ for (; n.length > 0 && n[0] === "separator";) n.shift();
1143
+ for (; n.length > 0 && n[n.length - 1] === "separator";) n.pop();
1144
+ let r = [];
1145
+ for (let e of n) e === "separator" && r[r.length - 1] === "separator" || r.push(e);
1146
+ return r;
1147
+ }
1148
+ //#endregion
1149
+ //#region src/internal/DocumentToolbar.vue?vue&type=script&setup=true&lang.ts
1150
+ var Me = ["aria-label"], Ne = [
1151
+ "aria-label",
1152
+ "title",
1153
+ "disabled"
1154
+ ], J = { class: "coar-pdf-toolbar__page-total" }, Pe = ["aria-label"], Fe = ["aria-label", "title"], Ie = { class: "coar-pdf-toolbar__flyout" }, Le = ["aria-label"], Re = [
1155
+ "title",
1156
+ "aria-label",
1157
+ "aria-pressed",
1158
+ "onClick"
1159
+ ], ze = ["aria-label"], Be = [
1160
+ "title",
1161
+ "aria-label",
1162
+ "aria-checked",
1163
+ "onClick"
1164
+ ], Ve = { class: "coar-pdf-toolbar__flyout" }, Y = ["aria-label"], He = [
1165
+ "title",
1166
+ "aria-pressed",
1167
+ "onClick"
1168
+ ], Ue = ["aria-label"], X = [
1169
+ "title",
1170
+ "aria-checked",
1171
+ "onClick"
1172
+ ], We = /* @__PURE__ */ l({
1173
+ __name: "DocumentToolbar",
1174
+ props: {
1175
+ currentPage: {},
1176
+ pageCount: {},
1177
+ zoom: {},
1178
+ minZoom: {},
1179
+ maxZoom: {},
1180
+ pointerMode: {},
1181
+ annotationMode: {},
1182
+ markerWidthPresets: {},
1183
+ inkWidthPresets: {},
1184
+ markerWidth: {},
1185
+ markerColor: {},
1186
+ inkWidth: {},
1187
+ inkColor: {},
1188
+ colors: {},
1189
+ labels: {},
1190
+ side: {},
1191
+ showSearch: { type: Boolean },
1192
+ showPrintDownload: { type: Boolean },
1193
+ showAnnotationModes: { type: Boolean },
1194
+ showSidebarToggle: { type: Boolean },
1195
+ sidebarOpen: { type: Boolean },
1196
+ showAnnotationsPanelToggle: { type: Boolean },
1197
+ annotationsPanelOpen: { type: Boolean },
1198
+ tools: {},
1199
+ capabilities: {}
1200
+ },
1201
+ emits: [
1202
+ "prev",
1203
+ "next",
1204
+ "jump",
1205
+ "zoom-in",
1206
+ "zoom-out",
1207
+ "fit-width",
1208
+ "fit-page",
1209
+ "reset-zoom",
1210
+ "set-zoom",
1211
+ "reset-view",
1212
+ "rotate-cw",
1213
+ "rotate-ccw",
1214
+ "toggle-pan",
1215
+ "toggle-sidebar",
1216
+ "toggle-annotations-panel",
1217
+ "set-annotation-mode",
1218
+ "update:marker-width",
1219
+ "update:marker-color",
1220
+ "update:ink-width",
1221
+ "update:ink-color",
1222
+ "search",
1223
+ "print",
1224
+ "download"
1225
+ ],
1226
+ setup(t, { emit: s }) {
1227
+ let c = t, l = s, u = _(String(c.currentPage + 1)), d = _(null);
1228
+ O(() => c.currentPage, (e) => {
1229
+ document.activeElement !== d.value && (u.value = String(e + 1));
1230
+ });
1231
+ function m() {
1232
+ let e = u.value.trim(), t = Number(e);
1233
+ if (!e || !Number.isFinite(t)) {
1234
+ u.value = String(c.currentPage + 1);
1235
+ return;
1236
+ }
1237
+ let n = Math.max(1, Math.min(c.pageCount, Math.round(t)));
1238
+ u.value = String(n), l("jump", n - 1);
1239
+ }
1240
+ function h(e) {
1241
+ e.key === "Enter" ? (e.preventDefault(), m(), d.value?.blur()) : e.key === "Escape" && (e.preventDefault(), u.value = String(c.currentPage + 1), d.value?.blur());
1242
+ }
1243
+ let b = _(String(Math.round(c.zoom * 100))), x = _(null);
1244
+ O(() => c.zoom, (e) => {
1245
+ document.activeElement !== x.value && (b.value = String(Math.round(e * 100)));
1246
+ });
1247
+ function S() {
1248
+ let e = b.value.trim().replace(/%$/, "").replace(",", ".").trim(), t = Number(e);
1249
+ if (!e || !Number.isFinite(t) || t <= 0) {
1250
+ b.value = String(Math.round(c.zoom * 100));
1251
+ return;
1252
+ }
1253
+ let n = Math.round(c.minZoom * 100), r = Math.round(c.maxZoom * 100), i = Math.max(n, Math.min(r, Math.round(t)));
1254
+ b.value = String(i), l("set-zoom", i / 100);
1255
+ }
1256
+ function w(e) {
1257
+ e.key === "Enter" ? (e.preventDefault(), S(), x.value?.blur()) : e.key === "Escape" && (e.preventDefault(), b.value = String(Math.round(c.zoom * 100)), x.value?.blur());
1258
+ }
1259
+ function D() {
1260
+ x.value?.select();
1261
+ }
1262
+ let j = n(() => c.currentPage > 0), M = n(() => c.currentPage < c.pageCount - 1), N = n(() => c.zoom < c.maxZoom - 1e-6), P = n(() => c.zoom > c.minZoom + 1e-6);
1263
+ function F(e, t) {
1264
+ return t === "marker" ? Math.min(22, Math.max(8, e * .7)) : Math.min(16, Math.max(3, e * 2));
1265
+ }
1266
+ function I(e) {
1267
+ let t = c.capabilities;
1268
+ switch (e) {
1269
+ case "prev-page":
1270
+ case "next-page":
1271
+ case "page-input": return !t.multiPage;
1272
+ case "search": return !t.search;
1273
+ case "print": return !t.print;
1274
+ default: return !1;
1275
+ }
1276
+ }
1277
+ function L(e, t) {
1278
+ return I(e) ? `${t} — ${c.labels.notAvailableForSource}` : t;
1279
+ }
1280
+ let ee = n(() => je(c.tools ?? ke, {
1281
+ showSidebarToggle: c.showSidebarToggle,
1282
+ showAnnotationsPanelToggle: c.showAnnotationsPanelToggle,
1283
+ showSearch: c.showSearch,
1284
+ showPrintDownload: c.showPrintDownload,
1285
+ showAnnotationModes: c.showAnnotationModes
1286
+ }));
1287
+ return (n, s) => (g(), r(T(R), {
1288
+ side: t.side,
1289
+ collapsed: !0,
1290
+ size: "s",
1291
+ variant: "primary",
1292
+ borderless: !1,
1293
+ "aria-label": t.labels.pageOf,
1294
+ class: "coar-pdf-toolbar"
1295
+ }, {
1296
+ default: k(() => [(g(!0), a(e, null, v(ee.value, (n, c) => (g(), a(e, { key: `${n}-${c}` }, [n === "separator" ? (g(), r(T(ne), { key: 0 })) : n === "sidebar-toggle" ? (g(), r(T(B), {
1297
+ key: 1,
1298
+ icon: "panel-left",
1299
+ label: t.labels.thumbnails,
1300
+ active: t.sidebarOpen,
1301
+ onClick: s[0] ||= (e) => l("toggle-sidebar")
1302
+ }, null, 8, ["label", "active"])) : n === "annotations-panel" ? (g(), r(T(B), {
1303
+ key: 2,
1304
+ icon: "panel-right",
1305
+ label: t.labels.annotationsPanel,
1306
+ active: t.annotationsPanelOpen,
1307
+ onClick: s[1] ||= (e) => l("toggle-annotations-panel")
1308
+ }, null, 8, ["label", "active"])) : n === "prev-page" ? (g(), r(T(B), {
1309
+ key: 3,
1310
+ icon: "chevron-up",
1311
+ label: L("prev-page", t.labels.prevPage),
1312
+ disabled: !j.value || I("prev-page"),
1313
+ onClick: s[2] ||= (e) => l("prev")
1314
+ }, null, 8, ["label", "disabled"])) : n === "page-input" ? (g(), a("div", {
1315
+ key: 4,
1316
+ class: f(["coar-pdf-toolbar__inline-page", { "coar-pdf-toolbar__inline-page--disabled": I("page-input") }]),
1317
+ role: "group",
1318
+ "aria-label": t.labels.pageJumpAria
1319
+ }, [
1320
+ A(o("input", {
1321
+ ref_for: !0,
1322
+ ref_key: "pageInputEl",
1323
+ ref: d,
1324
+ "onUpdate:modelValue": s[3] ||= (e) => u.value = e,
1325
+ class: "coar-pdf-toolbar__page-input",
1326
+ type: "text",
1327
+ inputmode: "numeric",
1328
+ "aria-label": t.labels.pageJumpAria,
1329
+ title: L("page-input", t.labels.pageJumpAria),
1330
+ disabled: I("page-input"),
1331
+ onBlur: m,
1332
+ onKeydown: h
1333
+ }, null, 40, Ne), [[E, u.value]]),
1334
+ s[23] ||= o("span", {
1335
+ class: "coar-pdf-toolbar__page-sep",
1336
+ "aria-hidden": "true"
1337
+ }, "/", -1),
1338
+ o("span", J, C(t.pageCount), 1)
1339
+ ], 10, Me)) : n === "next-page" ? (g(), r(T(B), {
1340
+ key: 5,
1341
+ icon: "chevron-down",
1342
+ label: L("next-page", t.labels.nextPage),
1343
+ disabled: !M.value || I("next-page"),
1344
+ onClick: s[4] ||= (e) => l("next")
1345
+ }, null, 8, ["label", "disabled"])) : n === "zoom-out" ? (g(), r(T(B), {
1346
+ key: 6,
1347
+ icon: "minus",
1348
+ label: t.labels.zoomOut,
1349
+ disabled: !P.value,
1350
+ onClick: s[5] ||= (e) => l("zoom-out")
1351
+ }, null, 8, ["label", "disabled"])) : n === "zoom-reset" ? (g(), a("div", {
1352
+ key: 7,
1353
+ class: "coar-pdf-toolbar__zoom-readout",
1354
+ role: "group",
1355
+ "aria-label": t.labels.zoomLevel
1356
+ }, [A(o("input", {
1357
+ ref_for: !0,
1358
+ ref_key: "zoomInputEl",
1359
+ ref: x,
1360
+ "onUpdate:modelValue": s[6] ||= (e) => b.value = e,
1361
+ class: "coar-pdf-toolbar__zoom-input",
1362
+ type: "text",
1363
+ inputmode: "numeric",
1364
+ "aria-label": t.labels.zoomLevel,
1365
+ title: t.labels.zoomLevel,
1366
+ onBlur: S,
1367
+ onKeydown: w,
1368
+ onFocus: D
1369
+ }, null, 40, Fe), [[E, b.value]]), s[24] ||= o("span", {
1370
+ class: "coar-pdf-toolbar__zoom-suffix",
1371
+ "aria-hidden": "true"
1372
+ }, "%", -1)], 8, Pe)) : n === "zoom-in" ? (g(), r(T(B), {
1373
+ key: 8,
1374
+ icon: "plus",
1375
+ label: t.labels.zoomIn,
1376
+ disabled: !N.value,
1377
+ onClick: s[7] ||= (e) => l("zoom-in")
1378
+ }, null, 8, ["label", "disabled"])) : n === "fit-width" ? (g(), r(T(B), {
1379
+ key: 9,
1380
+ icon: "move-horizontal",
1381
+ label: t.labels.fitWidth,
1382
+ onClick: s[8] ||= (e) => l("fit-width")
1383
+ }, null, 8, ["label"])) : n === "fit-page" ? (g(), r(T(B), {
1384
+ key: 10,
1385
+ icon: "file-text",
1386
+ label: t.labels.fitPage,
1387
+ onClick: s[9] ||= (e) => l("fit-page")
1388
+ }, null, 8, ["label"])) : n === "reset-view" ? (g(), r(T(B), {
1389
+ key: 11,
1390
+ icon: "refresh-cw",
1391
+ label: t.labels.resetView,
1392
+ onClick: s[10] ||= (e) => l("reset-view")
1393
+ }, null, 8, ["label"])) : n === "rotate-ccw" ? (g(), r(T(B), {
1394
+ key: 12,
1395
+ icon: "rotate-ccw",
1396
+ label: t.labels.rotateCcw,
1397
+ onClick: s[11] ||= (e) => l("rotate-ccw")
1398
+ }, null, 8, ["label"])) : n === "rotate-cw" ? (g(), r(T(B), {
1399
+ key: 13,
1400
+ icon: "rotate-cw",
1401
+ label: t.labels.rotateCw,
1402
+ onClick: s[12] ||= (e) => l("rotate-cw")
1403
+ }, null, 8, ["label"])) : n === "pan" ? (g(), r(T(B), {
1404
+ key: 14,
1405
+ icon: "hand",
1406
+ label: t.labels.pan,
1407
+ active: t.pointerMode === "pan",
1408
+ onClick: s[13] ||= (e) => l("toggle-pan")
1409
+ }, null, 8, ["label", "active"])) : n === "select" ? (g(), r(T(B), {
1410
+ key: 15,
1411
+ icon: "mouse-pointer-2",
1412
+ label: t.labels.modeSelect,
1413
+ active: t.annotationMode === "select",
1414
+ onClick: s[14] ||= (e) => l("set-annotation-mode", t.annotationMode === "select" ? "view" : "select")
1415
+ }, null, 8, ["label", "active"])) : n === "eraser" ? (g(), r(T(B), {
1416
+ key: 16,
1417
+ icon: "eraser",
1418
+ label: t.labels.modeEraser,
1419
+ active: t.annotationMode === "eraser",
1420
+ onClick: s[15] ||= (e) => l("set-annotation-mode", t.annotationMode === "eraser" ? "view" : "eraser")
1421
+ }, null, 8, ["label", "active"])) : n === "marker" ? (g(), r(T(z), {
1422
+ key: 17,
1423
+ icon: "highlighter",
1424
+ label: t.labels.modeMarker,
1425
+ mode: "flyout",
1426
+ "open-on-hover": !0,
1427
+ "split-trigger": !0,
1428
+ active: t.annotationMode === "marker",
1429
+ onTriggerClick: s[16] ||= (e) => l("set-annotation-mode", t.annotationMode === "marker" ? "view" : "marker")
1430
+ }, {
1431
+ default: k(() => [o("div", Ie, [o("div", {
1432
+ class: "coar-pdf-toolbar__flyout-row",
1433
+ "aria-label": t.labels.strokeWidth
1434
+ }, [(g(!0), a(e, null, v(t.markerWidthPresets, (e) => (g(), a("button", {
1435
+ key: e,
1436
+ type: "button",
1437
+ class: f(["coar-pdf-toolbar__flyout-width", { "coar-pdf-toolbar__flyout-width--active": Math.abs(t.markerWidth - e) < .01 }]),
1438
+ title: `${e}px`,
1439
+ "aria-label": `${e}px`,
1440
+ "aria-pressed": Math.abs(t.markerWidth - e) < .01,
1441
+ onClick: (t) => l("update:marker-width", e)
1442
+ }, [o("span", {
1443
+ class: "coar-pdf-toolbar__flyout-width-dot",
1444
+ style: p({
1445
+ width: F(e, "marker") + "px",
1446
+ height: F(e, "marker") + "px",
1447
+ background: t.markerColor
1448
+ })
1449
+ }, null, 4)], 10, Re))), 128))], 8, Le), o("div", {
1450
+ class: "coar-pdf-toolbar__flyout-row",
1451
+ role: "radiogroup",
1452
+ "aria-label": t.labels.annotationColor
1453
+ }, [(g(!0), a(e, null, v(t.colors, (e) => (g(), a("button", {
1454
+ key: e,
1455
+ type: "button",
1456
+ class: f(["coar-pdf-toolbar__flyout-color", { "coar-pdf-toolbar__flyout-color--active": e === t.markerColor }]),
1457
+ title: e,
1458
+ "aria-label": e,
1459
+ "aria-checked": e === t.markerColor,
1460
+ role: "radio",
1461
+ style: p({ background: e }),
1462
+ onClick: (t) => l("update:marker-color", e)
1463
+ }, null, 14, Be))), 128))], 8, ze)])]),
1464
+ _: 1
1465
+ }, 8, ["label", "active"])) : n === "note" ? (g(), r(T(B), {
1466
+ key: 18,
1467
+ icon: "message-square",
1468
+ label: t.labels.modeNote,
1469
+ active: t.annotationMode === "comment",
1470
+ onClick: s[17] ||= (e) => l("set-annotation-mode", t.annotationMode === "comment" ? "view" : "comment")
1471
+ }, null, 8, ["label", "active"])) : n === "ink" ? (g(), r(T(z), {
1472
+ key: 19,
1473
+ icon: "pencil",
1474
+ label: t.labels.modeInk,
1475
+ mode: "flyout",
1476
+ "open-on-hover": !0,
1477
+ "split-trigger": !0,
1478
+ active: t.annotationMode === "ink",
1479
+ onTriggerClick: s[18] ||= (e) => l("set-annotation-mode", t.annotationMode === "ink" ? "view" : "ink")
1480
+ }, {
1481
+ default: k(() => [o("div", Ve, [o("div", {
1482
+ class: "coar-pdf-toolbar__flyout-row",
1483
+ "aria-label": t.labels.strokeWidth
1484
+ }, [(g(!0), a(e, null, v(t.inkWidthPresets, (e) => (g(), a("button", {
1485
+ key: e,
1486
+ type: "button",
1487
+ class: f(["coar-pdf-toolbar__flyout-width", { "coar-pdf-toolbar__flyout-width--active": Math.abs(t.inkWidth - e) < .01 }]),
1488
+ title: `${e}px`,
1489
+ "aria-pressed": Math.abs(t.inkWidth - e) < .01,
1490
+ onClick: (t) => l("update:ink-width", e)
1491
+ }, [o("span", {
1492
+ class: "coar-pdf-toolbar__flyout-width-dot",
1493
+ style: p({
1494
+ width: F(e, "ink") + "px",
1495
+ height: F(e, "ink") + "px",
1496
+ background: t.inkColor
1497
+ })
1498
+ }, null, 4)], 10, He))), 128))], 8, Y), o("div", {
1499
+ class: "coar-pdf-toolbar__flyout-row",
1500
+ role: "radiogroup",
1501
+ "aria-label": t.labels.annotationColor
1502
+ }, [(g(!0), a(e, null, v(t.colors, (e) => (g(), a("button", {
1503
+ key: e,
1504
+ type: "button",
1505
+ class: f(["coar-pdf-toolbar__flyout-color", { "coar-pdf-toolbar__flyout-color--active": e === t.inkColor }]),
1506
+ title: e,
1507
+ "aria-checked": e === t.inkColor,
1508
+ role: "radio",
1509
+ style: p({ background: e }),
1510
+ onClick: (t) => l("update:ink-color", e)
1511
+ }, null, 14, X))), 128))], 8, Ue)])]),
1512
+ _: 1
1513
+ }, 8, ["label", "active"])) : n === "freetext" ? (g(), r(T(B), {
1514
+ key: 20,
1515
+ icon: "type",
1516
+ label: t.labels.modeFreetext,
1517
+ active: t.annotationMode === "freetext",
1518
+ onClick: s[19] ||= (e) => l("set-annotation-mode", t.annotationMode === "freetext" ? "view" : "freetext")
1519
+ }, null, 8, ["label", "active"])) : n === "search" ? (g(), r(T(B), {
1520
+ key: 21,
1521
+ icon: "search",
1522
+ label: L("search", t.labels.search),
1523
+ disabled: I("search"),
1524
+ onClick: s[20] ||= (e) => l("search")
1525
+ }, null, 8, ["label", "disabled"])) : n === "print" ? (g(), r(T(B), {
1526
+ key: 22,
1527
+ icon: "printer",
1528
+ label: L("print", t.labels.print),
1529
+ disabled: I("print"),
1530
+ onClick: s[21] ||= (e) => l("print")
1531
+ }, null, 8, ["label", "disabled"])) : n === "download" ? (g(), r(T(B), {
1532
+ key: 23,
1533
+ icon: "download",
1534
+ label: t.labels.download,
1535
+ onClick: s[22] ||= (e) => l("download")
1536
+ }, null, 8, ["label"])) : i("", !0)], 64))), 128)), n.$slots.actions ? y(n.$slots, "actions", { key: 0 }, void 0, !0) : i("", !0)]),
1537
+ _: 3
1538
+ }, 8, ["side", "aria-label"]));
1539
+ }
1540
+ }), Z = (e, t) => {
1541
+ let n = e.__vccOpts || e;
1542
+ for (let [e, r] of t) n[e] = r;
1543
+ return n;
1544
+ }, Ge = /* @__PURE__ */ Z(We, [["__scopeId", "data-v-131f9026"]]), Ke = {
1545
+ class: "coar-pdf-searchbar",
1546
+ role: "search"
1547
+ }, qe = [
1548
+ "placeholder",
1549
+ "aria-label",
1550
+ "value"
1551
+ ], Je = ["data-empty"], Ye = [
1552
+ "disabled",
1553
+ "title",
1554
+ "aria-label"
1555
+ ], Xe = [
1556
+ "disabled",
1557
+ "title",
1558
+ "aria-label"
1559
+ ], Ze = /* @__PURE__ */ Z(/* @__PURE__ */ l({
1560
+ __name: "DocumentSearchBar",
1561
+ props: {
1562
+ query: {},
1563
+ matchCount: {},
1564
+ currentIndex: {},
1565
+ searching: { type: Boolean },
1566
+ labels: {}
1567
+ },
1568
+ emits: [
1569
+ "update:query",
1570
+ "next",
1571
+ "prev",
1572
+ "close"
1573
+ ],
1574
+ setup(e, { emit: t }) {
1575
+ let r = e, i = t, s = _(null), l = _(r.query);
1576
+ O(() => r.query, (e) => {
1577
+ e !== l.value && (l.value = e);
1578
+ });
1579
+ function u(e) {
1580
+ let t = e.target.value;
1581
+ l.value = t, i("update:query", t);
1582
+ }
1583
+ function f(e) {
1584
+ e.key === "Enter" ? (e.preventDefault(), e.shiftKey ? i("prev") : i("next")) : e.key === "Escape" && (e.preventDefault(), i("close"));
1585
+ }
1586
+ let p = n(() => r.searching ? "…" : r.matchCount === 0 ? r.query ? "0" : "" : r.labels.searchMatchOf.replace("{current}", String(r.currentIndex + 1)).replace("{total}", String(r.matchCount)));
1587
+ return d(() => s.value?.focus()), (t, n) => (g(), a("div", Ke, [
1588
+ c(T(F), {
1589
+ name: "search",
1590
+ size: "s",
1591
+ class: "coar-pdf-searchbar__icon"
1592
+ }),
1593
+ o("input", {
1594
+ ref_key: "inputEl",
1595
+ ref: s,
1596
+ class: "coar-pdf-searchbar__input",
1597
+ type: "search",
1598
+ placeholder: e.labels.search,
1599
+ "aria-label": e.labels.search,
1600
+ value: l.value,
1601
+ onInput: u,
1602
+ onKeydown: f
1603
+ }, null, 40, qe),
1604
+ o("span", {
1605
+ class: "coar-pdf-searchbar__count",
1606
+ "aria-live": "polite",
1607
+ "data-empty": !p.value
1608
+ }, C(p.value), 9, Je),
1609
+ o("button", {
1610
+ type: "button",
1611
+ class: "coar-pdf-searchbar__btn",
1612
+ disabled: e.matchCount === 0,
1613
+ title: e.labels.searchPrev,
1614
+ "aria-label": e.labels.searchPrev,
1615
+ onClick: n[0] ||= (e) => i("prev")
1616
+ }, [c(T(F), {
1617
+ name: "chevron-up",
1618
+ size: "s"
1619
+ })], 8, Ye),
1620
+ o("button", {
1621
+ type: "button",
1622
+ class: "coar-pdf-searchbar__btn",
1623
+ disabled: e.matchCount === 0,
1624
+ title: e.labels.searchNext,
1625
+ "aria-label": e.labels.searchNext,
1626
+ onClick: n[1] ||= (e) => i("next")
1627
+ }, [c(T(F), {
1628
+ name: "chevron-down",
1629
+ size: "s"
1630
+ })], 8, Xe),
1631
+ o("button", {
1632
+ type: "button",
1633
+ class: "coar-pdf-searchbar__btn",
1634
+ title: "Close",
1635
+ "aria-label": "Close",
1636
+ onClick: n[2] ||= (e) => i("close")
1637
+ }, [c(T(F), {
1638
+ name: "x",
1639
+ size: "s"
1640
+ })])
1641
+ ]));
1642
+ }
1643
+ }), [["__scopeId", "data-v-ec33c527"]]), Qe = { class: "coar-pdf-sidebar__outline-list" }, $e = ["onClick"], et = /* @__PURE__ */ l({
1644
+ __name: "PdfOutlineList",
1645
+ props: {
1646
+ nodes: {
1647
+ type: Array,
1648
+ required: !0
1649
+ },
1650
+ depth: {
1651
+ type: Number,
1652
+ default: 0
1653
+ }
1654
+ },
1655
+ emits: ["jump"],
1656
+ setup(t) {
1657
+ return (n, s) => {
1658
+ let c = b("PdfOutlineList", !0);
1659
+ return g(), a("ul", Qe, [(g(!0), a(e, null, v(t.nodes, (e, l) => (g(), a("li", {
1660
+ key: l,
1661
+ class: "coar-pdf-sidebar__outline-item"
1662
+ }, [o("button", {
1663
+ type: "button",
1664
+ class: "coar-pdf-sidebar__outline-link",
1665
+ style: p({ paddingLeft: `${8 + t.depth * 12}px` }),
1666
+ onClick: (t) => n.$emit("jump", e)
1667
+ }, C(e.title || "(untitled)"), 13, $e), e.items && e.items.length > 0 ? (g(), r(c, {
1668
+ key: 0,
1669
+ nodes: e.items,
1670
+ depth: t.depth + 1,
1671
+ onJump: s[0] ||= (e) => n.$emit("jump", e)
1672
+ }, null, 8, ["nodes", "depth"])) : i("", !0)]))), 128))]);
1673
+ };
1674
+ }
1675
+ }), tt = ["aria-label"], nt = { class: "coar-pdf-sidebar__header" }, Q = {
1676
+ class: "coar-pdf-sidebar__tabs",
1677
+ role: "tablist"
1678
+ }, rt = ["aria-selected"], it = ["aria-selected"], at = [
1679
+ "data-thumb-page",
1680
+ "aria-label",
1681
+ "aria-current",
1682
+ "onClick"
1683
+ ], ot = { class: "coar-pdf-sidebar__thumb-label" }, st = {
1684
+ key: 0,
1685
+ class: "coar-pdf-sidebar__outline",
1686
+ role: "tabpanel"
1687
+ }, ct = 120, lt = /* @__PURE__ */ Z(/* @__PURE__ */ l({
1688
+ __name: "DocumentSidebar",
1689
+ props: {
1690
+ doc: {},
1691
+ pageProviders: {},
1692
+ pageCount: {},
1693
+ visiblePage: {},
1694
+ showThumbnails: { type: Boolean },
1695
+ showOutline: { type: Boolean },
1696
+ labels: {}
1697
+ },
1698
+ emits: ["jump", "close"],
1699
+ setup(t, { emit: s }) {
1700
+ let l = t, u = s, p = _("thumbnails"), h = S(null), y = _(!1);
1701
+ O(() => l.doc, async (e) => {
1702
+ if (h.value = null, e) {
1703
+ y.value = !0;
1704
+ try {
1705
+ let t = await e.getOutline();
1706
+ !t || t.length === 0 ? h.value = null : h.value = t;
1707
+ } catch {
1708
+ h.value = null;
1709
+ } finally {
1710
+ y.value = !1;
1711
+ }
1712
+ }
1713
+ }, { immediate: !0 });
1714
+ let b = n(() => h.value && h.value.length > 0);
1715
+ O(b, (e) => {
1716
+ !e && p.value === "outline" && (p.value = "thumbnails");
1717
+ });
1718
+ let x = _(null), w = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Set(), k = null;
1719
+ async function j(e) {
1720
+ if (w.has(e) || E.has(e)) return;
1721
+ let t = x.value?.querySelector(`[data-thumb-page="${e}"]`);
1722
+ if (!t) return;
1723
+ let n = l.pageProviders?.[e];
1724
+ if (n) {
1725
+ E.add(e);
1726
+ try {
1727
+ let r = typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, 2), i = ct / n.intrinsicWidth, a = t.querySelector("canvas");
1728
+ a || (a = document.createElement("canvas"), a.className = "coar-pdf-sidebar__thumb-canvas", t.insertBefore(a, t.firstChild)), a.style.width = `${ct}px`, a.style.height = `${Math.floor(n.intrinsicHeight * i)}px`, await n.render(a, {
1729
+ scale: i,
1730
+ rotation: 0,
1731
+ dpr: r
1732
+ }), w.add(e);
1733
+ } catch {} finally {
1734
+ E.delete(e);
1735
+ }
1736
+ }
1737
+ }
1738
+ function M() {
1739
+ k?.disconnect();
1740
+ let e = x.value;
1741
+ if (!(!e || typeof IntersectionObserver > "u")) {
1742
+ k = new IntersectionObserver((e) => {
1743
+ for (let t of e) {
1744
+ if (!t.isIntersecting) continue;
1745
+ let e = Number(t.target.dataset.thumbPage);
1746
+ Number.isFinite(e) && j(e);
1747
+ }
1748
+ }, {
1749
+ root: e,
1750
+ rootMargin: "200px 0px",
1751
+ threshold: 0
1752
+ });
1753
+ for (let t of e.querySelectorAll("[data-thumb-page]")) k.observe(t);
1754
+ }
1755
+ }
1756
+ O(() => [l.pageProviders, l.pageCount], async () => {
1757
+ w.clear(), E.clear(), await d(), M();
1758
+ }, { immediate: !0 }), O(p, async () => {
1759
+ p.value === "thumbnails" && (await d(), M());
1760
+ }), O(() => l.visiblePage, async (e) => {
1761
+ p.value === "thumbnails" && (await d(), (x.value?.querySelector(`[data-thumb-page="${e}"]`))?.scrollIntoView({
1762
+ block: "nearest",
1763
+ behavior: "smooth"
1764
+ }));
1765
+ }), m(() => {
1766
+ k?.disconnect(), k = null;
1767
+ });
1768
+ async function N(e) {
1769
+ if (e.resolvedPageIndex != null) return e.resolvedPageIndex;
1770
+ let t = e.dest;
1771
+ if (!t || !l.doc) return null;
1772
+ try {
1773
+ let n = t;
1774
+ if (typeof t == "string") {
1775
+ let e = await l.doc.getDestination(t);
1776
+ if (!e) return null;
1777
+ n = e;
1778
+ }
1779
+ if (!Array.isArray(n) || n.length === 0) return null;
1780
+ let r = n[0], i = await l.doc.getPageIndex(r);
1781
+ return e.resolvedPageIndex = i, i;
1782
+ } catch {
1783
+ return null;
1784
+ }
1785
+ }
1786
+ async function P(e) {
1787
+ let t = await N(e);
1788
+ t != null && u("jump", t);
1789
+ }
1790
+ return (n, s) => (g(), a("aside", {
1791
+ class: "coar-pdf-sidebar",
1792
+ "aria-label": t.labels.thumbnails
1793
+ }, [
1794
+ o("div", nt, [o("div", Q, [t.showThumbnails ? (g(), a("button", {
1795
+ key: 0,
1796
+ type: "button",
1797
+ class: f(["coar-pdf-sidebar__tab", { "coar-pdf-sidebar__tab--active": p.value === "thumbnails" }]),
1798
+ role: "tab",
1799
+ "aria-selected": p.value === "thumbnails",
1800
+ onClick: s[0] ||= (e) => p.value = "thumbnails"
1801
+ }, C(t.labels.thumbnails), 11, rt)) : i("", !0), t.showOutline && b.value ? (g(), a("button", {
1802
+ key: 1,
1803
+ type: "button",
1804
+ class: f(["coar-pdf-sidebar__tab", { "coar-pdf-sidebar__tab--active": p.value === "outline" }]),
1805
+ role: "tab",
1806
+ "aria-selected": p.value === "outline",
1807
+ onClick: s[1] ||= (e) => p.value = "outline"
1808
+ }, C(t.labels.outline), 11, it)) : i("", !0)]), o("button", {
1809
+ type: "button",
1810
+ class: "coar-pdf-sidebar__close",
1811
+ title: "Close",
1812
+ "aria-label": "Close",
1813
+ onClick: s[2] ||= (e) => u("close")
1814
+ }, [c(T(F), {
1815
+ name: "x",
1816
+ size: "s"
1817
+ })])]),
1818
+ A(o("div", {
1819
+ ref_key: "thumbsContainer",
1820
+ ref: x,
1821
+ class: "coar-pdf-sidebar__thumbs",
1822
+ role: "tabpanel"
1823
+ }, [(g(!0), a(e, null, v(t.pageCount, (e) => (g(), a("button", {
1824
+ key: e,
1825
+ type: "button",
1826
+ class: f(["coar-pdf-sidebar__thumb", { "coar-pdf-sidebar__thumb--current": e - 1 === t.visiblePage }]),
1827
+ "data-thumb-page": e - 1,
1828
+ "aria-label": `Page ${e}`,
1829
+ "aria-current": e - 1 === t.visiblePage ? "page" : void 0,
1830
+ onClick: (t) => u("jump", e - 1)
1831
+ }, [o("span", ot, C(e), 1)], 10, at))), 128))], 512), [[D, p.value === "thumbnails" && t.showThumbnails]]),
1832
+ p.value === "outline" ? (g(), a("div", st, [h.value ? (g(), r(et, {
1833
+ key: 0,
1834
+ nodes: h.value,
1835
+ onJump: P
1836
+ }, null, 8, ["nodes"])) : i("", !0)])) : i("", !0)
1837
+ ], 8, tt));
1838
+ }
1839
+ }), [["__scopeId", "data-v-d8662946"]]), ut = ["aria-label"], dt = ["aria-expanded"], ft = { class: "coar-pdf-info__title" }, pt = {
1840
+ key: 0,
1841
+ class: "coar-pdf-info__body"
1842
+ }, mt = { class: "coar-pdf-info__rows" }, ht = { class: "coar-pdf-info__dt" }, gt = { class: "coar-pdf-info__dd" }, $ = { class: "coar-pdf-info__rows" }, _t = { class: "coar-pdf-info__dt" }, vt = { class: "coar-pdf-info__dd" }, yt = { class: "coar-pdf-info__rows" }, bt = { class: "coar-pdf-info__dt" }, xt = { class: "coar-pdf-info__dd" }, St = /* @__PURE__ */ Z(/* @__PURE__ */ l({
1843
+ __name: "DocumentInfoSection",
1844
+ props: {
1845
+ info: {},
1846
+ currentPage: {},
1847
+ labels: {}
1848
+ },
1849
+ setup(t) {
1850
+ let r = t, s = _(!0);
1851
+ function l() {
1852
+ s.value = !s.value;
1853
+ }
1854
+ let u = n(() => r.info?.kind === "pdf" ? "pt" : "px");
1855
+ function d(e) {
1856
+ if (e < 1024) return `${e} B`;
1857
+ let t = e / 1024;
1858
+ if (t < 1024) return `${t.toFixed(+(t < 10))} KB`;
1859
+ let n = t / 1024;
1860
+ return n < 1024 ? `${n.toFixed(+(n < 10))} MB` : `${(n / 1024).toFixed(2)} GB`;
1861
+ }
1862
+ let p = n(() => {
1863
+ let e = r.info;
1864
+ if (!e) return [];
1865
+ let t = [{
1866
+ label: r.labels.infoFormat,
1867
+ value: e.format
1868
+ }, {
1869
+ label: r.labels.infoPages,
1870
+ value: String(e.pageCount)
1871
+ }];
1872
+ if (r.currentPage) {
1873
+ let { index: e, width: n, height: i } = r.currentPage;
1874
+ t.push({
1875
+ label: `${r.labels.infoPage} ${e + 1}`,
1876
+ value: `${Math.round(n)} × ${Math.round(i)} ${u.value}`
1877
+ });
1878
+ }
1879
+ return typeof e.bytes == "number" && t.push({
1880
+ label: r.labels.infoSize,
1881
+ value: d(e.bytes)
1882
+ }), t;
1883
+ }), m = n(() => {
1884
+ let e = r.info?.pdf;
1885
+ if (!e) return [];
1886
+ let t = [];
1887
+ return e.title && t.push({
1888
+ label: r.labels.infoTitle,
1889
+ value: e.title
1890
+ }), e.author && t.push({
1891
+ label: r.labels.infoAuthor,
1892
+ value: e.author
1893
+ }), e.subject && t.push({
1894
+ label: r.labels.infoSubject,
1895
+ value: e.subject
1896
+ }), e.keywords && t.push({
1897
+ label: r.labels.infoKeywords,
1898
+ value: e.keywords
1899
+ }), t;
1900
+ }), h = n(() => {
1901
+ let e = r.info?.pdf;
1902
+ if (!e) return [];
1903
+ let t = [];
1904
+ return e.creator && t.push({
1905
+ label: r.labels.infoCreator,
1906
+ value: e.creator
1907
+ }), e.producer && t.push({
1908
+ label: r.labels.infoProducer,
1909
+ value: e.producer
1910
+ }), e.creationDate && t.push({
1911
+ label: r.labels.infoCreated,
1912
+ value: e.creationDate
1913
+ }), e.modificationDate && t.push({
1914
+ label: r.labels.infoModified,
1915
+ value: e.modificationDate
1916
+ }), e.version && t.push({
1917
+ label: r.labels.infoPdfVersion,
1918
+ value: e.version
1919
+ }), t;
1920
+ });
1921
+ return (n, r) => t.info ? (g(), a("section", {
1922
+ key: 0,
1923
+ class: f(["coar-pdf-info", { "coar-pdf-info--collapsed": !s.value }]),
1924
+ "aria-label": t.labels.infoSection
1925
+ }, [o("button", {
1926
+ type: "button",
1927
+ class: "coar-pdf-info__header",
1928
+ "aria-expanded": s.value,
1929
+ onClick: l
1930
+ }, [c(T(F), {
1931
+ name: s.value ? "chevron-down" : "chevron-right",
1932
+ size: "xs"
1933
+ }, null, 8, ["name"]), o("span", ft, C(t.labels.infoSection), 1)], 8, dt), s.value ? (g(), a("div", pt, [
1934
+ o("dl", mt, [(g(!0), a(e, null, v(p.value, (t) => (g(), a(e, { key: t.label }, [o("dt", ht, C(t.label), 1), o("dd", gt, C(t.value), 1)], 64))), 128))]),
1935
+ m.value.length > 0 ? (g(), a(e, { key: 0 }, [r[0] ||= o("div", {
1936
+ class: "coar-pdf-info__divider",
1937
+ role: "separator"
1938
+ }, null, -1), o("dl", $, [(g(!0), a(e, null, v(m.value, (t) => (g(), a(e, { key: t.label }, [o("dt", _t, C(t.label), 1), o("dd", vt, C(t.value), 1)], 64))), 128))])], 64)) : i("", !0),
1939
+ h.value.length > 0 ? (g(), a(e, { key: 1 }, [r[1] ||= o("div", {
1940
+ class: "coar-pdf-info__divider",
1941
+ role: "separator"
1942
+ }, null, -1), o("dl", yt, [(g(!0), a(e, null, v(h.value, (t) => (g(), a(e, { key: t.label }, [o("dt", bt, C(t.label), 1), o("dd", xt, C(t.value), 1)], 64))), 128))])], 64)) : i("", !0)
1943
+ ])) : i("", !0)], 10, ut)) : i("", !0);
1944
+ }
1945
+ }), [["__scopeId", "data-v-36bce3d9"]]), Ct = ["aria-label"], wt = { class: "coar-pdf-anno-panel__header" }, Tt = { class: "coar-pdf-anno-panel__title" }, Et = ["title"], Dt = { class: "coar-pdf-anno-panel__controls" }, Ot = { class: "coar-pdf-anno-panel__search-row" }, kt = ["placeholder", "aria-label"], At = ["aria-label"], jt = [
1946
+ "title",
1947
+ "aria-label",
1948
+ "aria-pressed",
1949
+ "onClick"
1950
+ ], Mt = {
1951
+ class: "coar-pdf-anno-panel__list",
1952
+ role: "list"
1953
+ }, Nt = {
1954
+ key: 0,
1955
+ class: "coar-pdf-anno-panel__empty"
1956
+ }, Pt = {
1957
+ key: 0,
1958
+ class: "coar-pdf-anno-panel__group-header"
1959
+ }, Ft = [
1960
+ "aria-current",
1961
+ "onClick",
1962
+ "onKeydown"
1963
+ ], It = { class: "coar-pdf-anno-panel__item-body" }, Lt = { class: "coar-pdf-anno-panel__item-text" }, Rt = { class: "coar-pdf-anno-panel__item-meta" }, zt = ["title", "aria-label"], Bt = /* @__PURE__ */ Z(/* @__PURE__ */ l({
1964
+ __name: "DocumentAnnotationPanel",
1965
+ props: {
1966
+ annotations: {},
1967
+ selectedId: {},
1968
+ info: {},
1969
+ currentPageInfo: {},
1970
+ labels: {}
1971
+ },
1972
+ emits: [
1973
+ "select",
1974
+ "delete",
1975
+ "close"
1976
+ ],
1977
+ setup(t, { emit: r }) {
1978
+ let l = t, u = r, d = _("page"), m = _(""), h = _(new Set([
1979
+ "marker",
1980
+ "comment",
1981
+ "ink",
1982
+ "freetext"
1983
+ ])), y = {
1984
+ marker: "highlighter",
1985
+ comment: "message-square",
1986
+ ink: "pencil",
1987
+ freetext: "type"
1988
+ }, b = [
1989
+ "marker",
1990
+ "comment",
1991
+ "ink",
1992
+ "freetext"
1993
+ ];
1994
+ function x(e) {
1995
+ return e.type === "freetext" ? e.text || "" : e.comment || "";
1996
+ }
1997
+ let S = n(() => {
1998
+ let e = m.value.trim().toLowerCase();
1999
+ return l.annotations.filter((t) => h.value.has(t.type) ? e ? x(t).toLowerCase().includes(e) : !0 : !1);
2000
+ }), w = n(() => {
2001
+ if (d.value === "chronological") return [{
2002
+ pageIndex: -1,
2003
+ items: [...S.value].sort((e, t) => (e.createdAt || "").localeCompare(t.createdAt || ""))
2004
+ }];
2005
+ let e = /* @__PURE__ */ new Map();
2006
+ for (let t of S.value) {
2007
+ let n = e.get(t.pageIndex);
2008
+ n ? n.push(t) : e.set(t.pageIndex, [t]);
2009
+ }
2010
+ return [...e.entries()].sort(([e], [t]) => e - t).map(([e, t]) => ({
2011
+ pageIndex: e,
2012
+ items: t
2013
+ }));
2014
+ });
2015
+ function D(e) {
2016
+ let t = new Set(h.value);
2017
+ t.has(e) ? t.delete(e) : t.add(e), h.value = t;
2018
+ }
2019
+ function O(e) {
2020
+ if (!e) return "";
2021
+ let t = new Date(e).getTime();
2022
+ if (Number.isNaN(t)) return "";
2023
+ let n = Date.now() - t, r = Math.round(n / 6e4);
2024
+ if (r < 1) return l.labels.justNow;
2025
+ if (r < 60) return `${r}m`;
2026
+ let i = Math.round(r / 60);
2027
+ return i < 24 ? `${i}h` : `${Math.round(i / 24)}d`;
2028
+ }
2029
+ let N = n(() => [{
2030
+ value: "page",
2031
+ label: l.labels.sortByPage,
2032
+ icon: "file-text"
2033
+ }, {
2034
+ value: "chronological",
2035
+ label: l.labels.sortChronological,
2036
+ icon: "clock"
2037
+ }]);
2038
+ return (n, r) => (g(), a("aside", {
2039
+ class: "coar-pdf-anno-panel",
2040
+ "aria-label": t.labels.annotationsPanel
2041
+ }, [
2042
+ c(St, {
2043
+ info: t.info ?? null,
2044
+ "current-page": t.currentPageInfo ?? null,
2045
+ labels: t.labels
2046
+ }, null, 8, [
2047
+ "info",
2048
+ "current-page",
2049
+ "labels"
2050
+ ]),
2051
+ o("div", wt, [
2052
+ o("span", Tt, C(t.labels.annotationsPanel), 1),
2053
+ o("span", {
2054
+ class: "coar-pdf-anno-panel__count",
2055
+ title: `${S.value.length} / ${t.annotations.length}`
2056
+ }, C(S.value.length) + "/" + C(t.annotations.length), 9, Et),
2057
+ o("button", {
2058
+ type: "button",
2059
+ class: "coar-pdf-anno-panel__close",
2060
+ title: "Close",
2061
+ "aria-label": "Close",
2062
+ onClick: r[0] ||= (e) => u("close")
2063
+ }, [c(T(F), {
2064
+ name: "x",
2065
+ size: "s"
2066
+ })])
2067
+ ]),
2068
+ o("div", Dt, [
2069
+ c(T(te), {
2070
+ modelValue: d.value,
2071
+ "onUpdate:modelValue": r[1] ||= (e) => d.value = e,
2072
+ size: "xs",
2073
+ "full-width": "",
2074
+ options: N.value,
2075
+ "aria-label": t.labels.sortBy
2076
+ }, null, 8, [
2077
+ "modelValue",
2078
+ "options",
2079
+ "aria-label"
2080
+ ]),
2081
+ o("div", Ot, [c(T(F), {
2082
+ name: "search",
2083
+ size: "xs",
2084
+ class: "coar-pdf-anno-panel__search-icon"
2085
+ }), A(o("input", {
2086
+ "onUpdate:modelValue": r[2] ||= (e) => m.value = e,
2087
+ type: "search",
2088
+ class: "coar-pdf-anno-panel__search-input",
2089
+ placeholder: t.labels.searchAnnotations,
2090
+ "aria-label": t.labels.searchAnnotations
2091
+ }, null, 8, kt), [[E, m.value]])]),
2092
+ o("div", {
2093
+ class: "coar-pdf-anno-panel__filters",
2094
+ role: "group",
2095
+ "aria-label": t.labels.filterBy
2096
+ }, [(g(), a(e, null, v(b, (e) => o("button", {
2097
+ key: e,
2098
+ type: "button",
2099
+ class: f(["coar-pdf-anno-panel__filter", { "coar-pdf-anno-panel__filter--off": !h.value.has(e) }]),
2100
+ title: e,
2101
+ "aria-label": e,
2102
+ "aria-pressed": h.value.has(e),
2103
+ onClick: (t) => D(e)
2104
+ }, [c(T(F), {
2105
+ name: y[e],
2106
+ size: "xs"
2107
+ }, null, 8, ["name"])], 10, jt)), 64))], 8, At)
2108
+ ]),
2109
+ o("div", Mt, [S.value.length === 0 ? (g(), a("div", Nt, C(t.annotations.length === 0 ? t.labels.noAnnotations : t.labels.noMatchingAnnotations), 1)) : (g(!0), a(e, { key: 1 }, v(w.value, (n) => (g(), a(e, { key: n.pageIndex }, [d.value === "page" ? (g(), a("div", Pt, C(t.labels.pagePrefix) + " " + C(n.pageIndex + 1), 1)) : i("", !0), (g(!0), a(e, null, v(n.items, (n) => (g(), a("div", {
2110
+ key: n.id,
2111
+ class: f(["coar-pdf-anno-panel__item", { "coar-pdf-anno-panel__item--selected": n.id === t.selectedId }]),
2112
+ role: "listitem",
2113
+ tabindex: "0",
2114
+ "aria-current": n.id === t.selectedId ? "true" : void 0,
2115
+ onClick: (e) => u("select", n.id),
2116
+ onKeydown: [j(M((e) => u("select", n.id), ["prevent"]), ["enter"]), j(M((e) => u("select", n.id), ["prevent"]), ["space"])]
2117
+ }, [
2118
+ o("span", {
2119
+ class: "coar-pdf-anno-panel__item-icon",
2120
+ style: p({ color: n.color })
2121
+ }, [c(T(F), {
2122
+ name: y[n.type],
2123
+ size: "s"
2124
+ }, null, 8, ["name"])], 4),
2125
+ o("span", It, [o("span", Lt, C(x(n) || `(${n.type})`), 1), o("span", Rt, [
2126
+ n.createdBy ? (g(), a(e, { key: 0 }, [s(C(n.createdBy), 1)], 64)) : i("", !0),
2127
+ n.createdBy && (d.value === "chronological" || n.createdAt) ? (g(), a(e, { key: 1 }, [s(" · ")], 64)) : i("", !0),
2128
+ d.value === "chronological" ? (g(), a(e, { key: 2 }, [s(C(t.labels.pagePrefix) + " " + C(n.pageIndex + 1) + " · ", 1)], 64)) : i("", !0),
2129
+ s(" " + C(O(n.createdAt)), 1)
2130
+ ])]),
2131
+ o("span", {
2132
+ class: "coar-pdf-anno-panel__item-menu-wrap",
2133
+ onClick: r[3] ||= M(() => {}, ["stop"]),
2134
+ onKeydown: r[4] ||= M(() => {}, ["stop"])
2135
+ }, [c(T(ee), {
2136
+ mode: "click",
2137
+ offset: 4
2138
+ }, {
2139
+ default: k(() => [o("button", {
2140
+ type: "button",
2141
+ class: "coar-pdf-anno-panel__item-menu",
2142
+ title: t.labels.moreActions,
2143
+ "aria-label": t.labels.moreActions
2144
+ }, [c(T(F), {
2145
+ name: "more-vertical",
2146
+ size: "xs"
2147
+ })], 8, zt)]),
2148
+ content: k(() => [c(T(I), null, {
2149
+ default: k(() => [c(T(L), {
2150
+ icon: "trash-2",
2151
+ onClick: (e) => u("delete", n.id)
2152
+ }, {
2153
+ default: k(() => [s(C(t.labels.annotationDelete), 1)]),
2154
+ _: 1
2155
+ }, 8, ["onClick"])]),
2156
+ _: 2
2157
+ }, 1024)]),
2158
+ _: 2
2159
+ }, 1024)], 32)
2160
+ ], 42, Ft))), 128))], 64))), 128))])
2161
+ ], 8, Ct));
2162
+ }
2163
+ }), [["__scopeId", "data-v-bacf840c"]]), Vt = ["aria-hidden"], Ht = [
2164
+ "width",
2165
+ "height",
2166
+ "viewBox"
2167
+ ], Ut = ["data-annotation-id"], Wt = [
2168
+ "data-stroke-index",
2169
+ "points",
2170
+ "stroke",
2171
+ "stroke-width",
2172
+ "onClick"
2173
+ ], Gt = [
2174
+ "width",
2175
+ "height",
2176
+ "viewBox"
2177
+ ], Kt = ["data-annotation-id"], qt = [
2178
+ "data-stroke-index",
2179
+ "points",
2180
+ "stroke",
2181
+ "stroke-width",
2182
+ "onClick"
2183
+ ], Jt = ["data-annotation-id", "onClick"], Yt = [
2184
+ "data-annotation-id",
2185
+ "title",
2186
+ "aria-label",
2187
+ "onClick"
2188
+ ], Xt = /* @__PURE__ */ Z(/* @__PURE__ */ l({
2189
+ __name: "AnnotationLayer",
2190
+ props: {
2191
+ annotations: {},
2192
+ displayWidth: {},
2193
+ displayHeight: {},
2194
+ rotation: {}
2195
+ },
2196
+ emits: ["annotation-click"],
2197
+ setup(t, { emit: r }) {
2198
+ let s = t, c = r;
2199
+ function l(e) {
2200
+ return `${e}px`;
2201
+ }
2202
+ function u(e) {
2203
+ return {
2204
+ left: l(e.anchor.x * s.displayWidth),
2205
+ top: l(e.anchor.y * s.displayHeight),
2206
+ background: e.color
2207
+ };
2208
+ }
2209
+ function d(e) {
2210
+ return {
2211
+ left: l(e.rect.x * s.displayWidth),
2212
+ top: l(e.rect.y * s.displayHeight),
2213
+ width: l(e.rect.w * s.displayWidth),
2214
+ height: l(e.rect.h * s.displayHeight),
2215
+ color: e.color,
2216
+ fontSize: l(e.fontSize)
2217
+ };
2218
+ }
2219
+ function f(e) {
2220
+ return e.map((e) => `${e.x * s.displayWidth},${e.y * s.displayHeight}`).join(" ");
2221
+ }
2222
+ let m = n(() => {
2223
+ let e = s.rotation ?? 0, t = s.displayWidth, n = s.displayHeight;
2224
+ switch (e) {
2225
+ case 90: return `translate(${n}px, 0) rotate(90deg)`;
2226
+ case 180: return `translate(${t}px, ${n}px) rotate(180deg)`;
2227
+ case 270: return `translate(0, ${t}px) rotate(270deg)`;
2228
+ default: return "none";
2229
+ }
2230
+ }), h = n(() => s.annotations.filter((e) => e.type === "comment")), _ = n(() => s.annotations.filter((e) => e.type === "ink")), y = n(() => s.annotations.filter((e) => e.type === "marker")), b = n(() => s.annotations.filter((e) => e.type === "freetext"));
2231
+ return (n, r) => (g(), a("div", {
2232
+ class: "coar-pdf-annotation-layer",
2233
+ style: p({
2234
+ width: t.displayWidth + "px",
2235
+ height: t.displayHeight + "px",
2236
+ transform: m.value
2237
+ }),
2238
+ "aria-hidden": t.annotations.length === 0
2239
+ }, [
2240
+ y.value.length > 0 ? (g(), a("svg", {
2241
+ key: 0,
2242
+ class: "coar-pdf-annotation-marker",
2243
+ width: t.displayWidth,
2244
+ height: t.displayHeight,
2245
+ viewBox: `0 0 ${t.displayWidth} ${t.displayHeight}`,
2246
+ "aria-hidden": "true"
2247
+ }, [(g(!0), a(e, null, v(y.value, (t) => (g(), a("g", {
2248
+ key: t.id,
2249
+ "data-annotation-id": t.id
2250
+ }, [(g(!0), a(e, null, v(t.strokes, (e, n) => (g(), a("polyline", {
2251
+ key: n,
2252
+ "data-stroke-index": n,
2253
+ points: f(e),
2254
+ fill: "none",
2255
+ stroke: t.color,
2256
+ "stroke-width": t.width,
2257
+ "stroke-linecap": "butt",
2258
+ "stroke-linejoin": "round",
2259
+ class: "coar-pdf-annotation-marker__stroke",
2260
+ onClick: M((e) => c("annotation-click", t.id), ["stop"])
2261
+ }, null, 8, Wt))), 128))], 8, Ut))), 128))], 8, Ht)) : i("", !0),
2262
+ _.value.length > 0 ? (g(), a("svg", {
2263
+ key: 1,
2264
+ class: "coar-pdf-annotation-ink",
2265
+ width: t.displayWidth,
2266
+ height: t.displayHeight,
2267
+ viewBox: `0 0 ${t.displayWidth} ${t.displayHeight}`,
2268
+ "aria-hidden": "true"
2269
+ }, [(g(!0), a(e, null, v(_.value, (t) => (g(), a("g", {
2270
+ key: t.id,
2271
+ "data-annotation-id": t.id
2272
+ }, [(g(!0), a(e, null, v(t.strokes, (e, n) => (g(), a("polyline", {
2273
+ key: n,
2274
+ "data-stroke-index": n,
2275
+ points: f(e),
2276
+ fill: "none",
2277
+ stroke: t.color,
2278
+ "stroke-width": t.width,
2279
+ "stroke-linecap": "round",
2280
+ "stroke-linejoin": "round",
2281
+ class: "coar-pdf-annotation-ink__stroke",
2282
+ onClick: M((e) => c("annotation-click", t.id), ["stop"])
2283
+ }, null, 8, qt))), 128))], 8, Kt))), 128))], 8, Gt)) : i("", !0),
2284
+ (g(!0), a(e, null, v(b.value, (e) => (g(), a("div", {
2285
+ key: e.id,
2286
+ class: "coar-pdf-annotation-freetext",
2287
+ style: p(d(e)),
2288
+ "data-annotation-id": e.id,
2289
+ onClick: M((t) => c("annotation-click", e.id), ["stop"])
2290
+ }, C(e.text), 13, Jt))), 128)),
2291
+ (g(!0), a(e, null, v(h.value, (e) => (g(), a("button", {
2292
+ key: e.id,
2293
+ type: "button",
2294
+ class: "coar-pdf-annotation-pin",
2295
+ style: p(u(e)),
2296
+ "data-annotation-id": e.id,
2297
+ title: e.comment,
2298
+ "aria-label": e.comment,
2299
+ onClick: M((t) => c("annotation-click", e.id), ["stop"])
2300
+ }, [...r[0] ||= [o("svg", {
2301
+ viewBox: "0 0 24 24",
2302
+ width: "12",
2303
+ height: "12",
2304
+ fill: "none",
2305
+ stroke: "currentColor",
2306
+ "stroke-width": "2.5",
2307
+ "stroke-linecap": "round",
2308
+ "stroke-linejoin": "round",
2309
+ "aria-hidden": "true"
2310
+ }, [o("path", { d: "M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" })], -1)]], 12, Yt))), 128))
2311
+ ], 12, Vt));
2312
+ }
2313
+ }), [["__scopeId", "data-v-28755751"]]), Zt = ["aria-label"], Qt = ["aria-label"], $t = [
2314
+ "aria-label",
2315
+ "aria-checked",
2316
+ "onClick"
2317
+ ], en = ["placeholder", "aria-label"], tn = { class: "coar-pdf-annotation-popover__actions" }, nn = ["title", "aria-label"], rn = /* @__PURE__ */ Z(/* @__PURE__ */ l({
2318
+ __name: "AnnotationPopover",
2319
+ props: {
2320
+ anchor: {},
2321
+ initialComment: {},
2322
+ initialColor: {},
2323
+ colors: {},
2324
+ draft: { type: Boolean },
2325
+ labels: {}
2326
+ },
2327
+ emits: [
2328
+ "save",
2329
+ "delete",
2330
+ "close"
2331
+ ],
2332
+ setup(s, { emit: c }) {
2333
+ let l = s, u = c, y = _(null), b = _(null), x = _(l.initialComment), S = _(l.initialColor), w = _({
2334
+ top: 0,
2335
+ left: 0
2336
+ });
2337
+ function T() {
2338
+ let e = y.value;
2339
+ if (!e) return;
2340
+ let t = e.offsetWidth, n = e.offsetHeight, r = l.anchor, i = r.bottom + 6, a = r.left;
2341
+ i + n > window.innerHeight - 8 && (i = r.top - 6 - n), a = Math.max(8, Math.min(a, window.innerWidth - t - 8)), w.value = {
2342
+ top: i,
2343
+ left: a
2344
+ };
2345
+ }
2346
+ function D() {
2347
+ l.draft || u("save", {
2348
+ comment: x.value,
2349
+ color: S.value
2350
+ });
2351
+ }
2352
+ function k(e) {
2353
+ e.key === "Enter" && (e.ctrlKey || e.metaKey) && (e.preventDefault(), l.draft ? u("save", {
2354
+ comment: x.value,
2355
+ color: S.value
2356
+ }) : D(), b.value?.blur());
2357
+ }
2358
+ function j(e) {
2359
+ y.value && (y.value.contains(e.target) || u("close"));
2360
+ }
2361
+ function N(e) {
2362
+ e.key === "Escape" && (e.preventDefault(), u("close"));
2363
+ }
2364
+ h(async () => {
2365
+ await d(), T(), window.addEventListener("resize", T), window.addEventListener("scroll", T, !0), setTimeout(() => {
2366
+ document.addEventListener("mousedown", j), document.addEventListener("keydown", N);
2367
+ }, 0), l.draft && b.value && b.value.focus();
2368
+ }), m(() => {
2369
+ window.removeEventListener("resize", T), window.removeEventListener("scroll", T, !0), document.removeEventListener("mousedown", j), document.removeEventListener("keydown", N);
2370
+ }), O(() => l.anchor, T, { flush: "post" });
2371
+ let P = n(() => x.value !== l.initialComment || S.value !== l.initialColor);
2372
+ return (n, c) => (g(), r(t, { to: "body" }, [o("div", {
2373
+ ref_key: "root",
2374
+ ref: y,
2375
+ class: "coar-pdf-annotation-popover",
2376
+ role: "dialog",
2377
+ "aria-label": s.draft ? s.labels.modeNote : s.labels.annotationEditComment,
2378
+ style: p({
2379
+ top: w.value.top + "px",
2380
+ left: w.value.left + "px"
2381
+ }),
2382
+ onMousedown: c[4] ||= M(() => {}, ["stop"]),
2383
+ onClick: c[5] ||= M(() => {}, ["stop"])
2384
+ }, [
2385
+ o("div", {
2386
+ class: "coar-pdf-annotation-popover__swatches",
2387
+ role: "radiogroup",
2388
+ "aria-label": s.labels.annotationColor
2389
+ }, [(g(!0), a(e, null, v(s.colors, (e) => (g(), a("button", {
2390
+ key: e,
2391
+ type: "button",
2392
+ class: f(["coar-pdf-annotation-popover__swatch", { "coar-pdf-annotation-popover__swatch--active": e === S.value }]),
2393
+ style: p({ background: e }),
2394
+ "aria-label": e,
2395
+ "aria-checked": e === S.value,
2396
+ role: "radio",
2397
+ onClick: (t) => {
2398
+ S.value = e, D();
2399
+ }
2400
+ }, null, 14, $t))), 128))], 8, Qt),
2401
+ A(o("textarea", {
2402
+ ref_key: "textareaRef",
2403
+ ref: b,
2404
+ "onUpdate:modelValue": c[0] ||= (e) => x.value = e,
2405
+ class: "coar-pdf-annotation-popover__textarea",
2406
+ rows: "3",
2407
+ placeholder: s.labels.annotationEditComment,
2408
+ "aria-label": s.labels.annotationEditComment,
2409
+ onBlur: D,
2410
+ onKeydown: k
2411
+ }, null, 40, en), [[E, x.value]]),
2412
+ o("div", tn, [s.draft ? (g(), a(e, { key: 0 }, [o("button", {
2413
+ type: "button",
2414
+ class: "coar-pdf-annotation-popover__btn coar-pdf-annotation-popover__btn--ghost",
2415
+ onClick: c[1] ||= (e) => u("close")
2416
+ }, "Cancel"), o("button", {
2417
+ type: "button",
2418
+ class: "coar-pdf-annotation-popover__btn coar-pdf-annotation-popover__btn--primary",
2419
+ onClick: c[2] ||= (e) => u("save", {
2420
+ comment: x.value,
2421
+ color: S.value
2422
+ })
2423
+ }, "Save")], 64)) : (g(), a(e, { key: 1 }, [o("button", {
2424
+ type: "button",
2425
+ class: "coar-pdf-annotation-popover__btn coar-pdf-annotation-popover__btn--danger",
2426
+ title: s.labels.annotationDelete,
2427
+ "aria-label": s.labels.annotationDelete,
2428
+ onClick: c[3] ||= (e) => u("delete")
2429
+ }, C(s.labels.annotationDelete), 9, nn), P.value ? (g(), a("button", {
2430
+ key: 0,
2431
+ type: "button",
2432
+ class: "coar-pdf-annotation-popover__btn coar-pdf-annotation-popover__btn--primary",
2433
+ onClick: D
2434
+ }, "Save")) : i("", !0)], 64))])
2435
+ ], 44, Zt)]));
2436
+ }
2437
+ }), [["__scopeId", "data-v-a956f092"]]), an = ["data-status"], on = { class: "coar-pdf-viewer__center" }, sn = { class: "coar-pdf-viewer__body" }, cn = {
2438
+ key: 0,
2439
+ class: "coar-pdf-viewer__pages"
2440
+ }, ln = ["data-page-index", "aria-label"], un = {
2441
+ key: 1,
2442
+ class: "coar-pdf-viewer__overlay coar-pdf-viewer__overlay--loading",
2443
+ role: "status",
2444
+ "aria-live": "polite"
2445
+ }, dn = {
2446
+ key: 5,
2447
+ class: "coar-pdf-viewer__overlay coar-pdf-viewer__overlay--error",
2448
+ role: "alert"
2449
+ }, fn = { class: "coar-pdf-viewer__error-body" }, pn = { class: "coar-pdf-viewer__error-title" }, mn = 32, hn = 220, gn = 160, _n = 280, vn = 220, yn = 320, bn = /* @__PURE__ */ Z(/* @__PURE__ */ l({
2450
+ __name: "CoarDocumentViewer",
2451
+ props: {
2452
+ source: {},
2453
+ showToolbar: {
2454
+ type: Boolean,
2455
+ default: !0
2456
+ },
2457
+ showThumbnails: {
2458
+ type: Boolean,
2459
+ default: !1
2460
+ },
2461
+ showOutline: {
2462
+ type: Boolean,
2463
+ default: !1
2464
+ },
2465
+ showAnnotationsPanel: {
2466
+ type: Boolean,
2467
+ default: !1
2468
+ },
2469
+ showInfoSection: {
2470
+ type: Boolean,
2471
+ default: !0
2472
+ },
2473
+ showSearch: {
2474
+ type: Boolean,
2475
+ default: !0
2476
+ },
2477
+ showPrintDownload: {
2478
+ type: Boolean,
2479
+ default: !1
2480
+ },
2481
+ showAnnotationModes: {
2482
+ type: Boolean,
2483
+ default: !0
2484
+ },
2485
+ toolbarPosition: { default: "top" },
2486
+ storageKey: { default: void 0 },
2487
+ position: { default: void 0 },
2488
+ tools: { default: void 0 },
2489
+ annotations: { default: () => [] },
2490
+ annotationMode: { default: "view" },
2491
+ annotationColors: { default: () => [
2492
+ "#fde68a",
2493
+ "#fca5a5",
2494
+ "#86efac",
2495
+ "#93c5fd",
2496
+ "#c4b5fd",
2497
+ "#facc15",
2498
+ "#ec4899"
2499
+ ] },
2500
+ labels: { default: () => ({}) }
2501
+ },
2502
+ emits: [
2503
+ "update:position",
2504
+ "update:annotationMode",
2505
+ "annotation:create",
2506
+ "annotation:update",
2507
+ "annotation:delete",
2508
+ "error"
2509
+ ],
2510
+ setup(t, { expose: l, emit: m }) {
2511
+ let h = [
2512
+ .25,
2513
+ .33,
2514
+ .5,
2515
+ .67,
2516
+ .75,
2517
+ .9,
2518
+ 1,
2519
+ 1.1,
2520
+ 1.25,
2521
+ 1.5,
2522
+ 1.75,
2523
+ 2,
2524
+ 2.5,
2525
+ 3,
2526
+ 3.5,
2527
+ 4
2528
+ ], b = h[0], x = h[h.length - 1], S = t, E = m, D = {
2529
+ loading: "Loading PDF…",
2530
+ errorTitle: "Could not load the PDF.",
2531
+ errorRetry: "Retry",
2532
+ pageOf: "Page {current} of {total}",
2533
+ pageJumpAria: "Jump to page",
2534
+ prevPage: "Previous page",
2535
+ nextPage: "Next page",
2536
+ zoomIn: "Zoom in",
2537
+ zoomOut: "Zoom out",
2538
+ resetZoom: "Reset zoom to 100%",
2539
+ zoomLevel: "Zoom level (%)",
2540
+ fitWidth: "Fit to width",
2541
+ fitPage: "Fit to page",
2542
+ resetView: "Reset zoom & rotation",
2543
+ pan: "Pan (hand tool)",
2544
+ rotateCw: "Rotate clockwise",
2545
+ rotateCcw: "Rotate counter-clockwise",
2546
+ search: "Search",
2547
+ searchNext: "Next match",
2548
+ searchPrev: "Previous match",
2549
+ searchMatchOf: "{current} of {total}",
2550
+ thumbnails: "Thumbnails",
2551
+ outline: "Outline",
2552
+ print: "Print",
2553
+ download: "Download",
2554
+ annotationsPanel: "Annotations",
2555
+ noAnnotations: "No annotations yet",
2556
+ noMatchingAnnotations: "No annotations match the current filter",
2557
+ searchAnnotations: "Search annotations…",
2558
+ filterBy: "Filter by type",
2559
+ sortBy: "Sort by",
2560
+ sortByPage: "By page",
2561
+ sortChronological: "Chronological",
2562
+ pagePrefix: "Page",
2563
+ justNow: "now",
2564
+ moreActions: "More actions",
2565
+ modeView: "View",
2566
+ modeSelect: "Select — drag to move (Alt+drag a marker/pen to extend it; Ctrl+drag = straight line, Shift+drag = straight + snap to 15°)",
2567
+ modeEraser: "Eraser — click a stroke to remove it",
2568
+ modeMarker: "Marker",
2569
+ modeNote: "Note",
2570
+ modeInk: "Draw",
2571
+ modeFreetext: "Text",
2572
+ strokeWidth: "Stroke width",
2573
+ annotationDelete: "Delete",
2574
+ annotationEditComment: "Edit comment",
2575
+ annotationColor: "Color",
2576
+ notAvailableForSource: "not available for this file",
2577
+ infoSection: "Info",
2578
+ infoFormat: "Format",
2579
+ infoPages: "Pages",
2580
+ infoPage: "Page",
2581
+ infoSize: "Size",
2582
+ infoTitle: "Title",
2583
+ infoAuthor: "Author",
2584
+ infoSubject: "Subject",
2585
+ infoKeywords: "Keywords",
2586
+ infoCreator: "Creator",
2587
+ infoProducer: "Producer",
2588
+ infoCreated: "Created",
2589
+ infoModified: "Modified",
2590
+ infoPdfVersion: "PDF version"
2591
+ }, k = n(() => ({
2592
+ ...D,
2593
+ ...S.labels
2594
+ })), A = _(1), j = _(0), M = _(null), N = _("select"), P = _(!1), { status: F, pdfDoc: I, pageProviders: L, info: ee, error: te, retry: R, destroy: ne } = de(n(() => S.source)), z = pe({
2595
+ pageProviders: L,
2596
+ scale: A,
2597
+ rotation: j,
2598
+ scrollContainer: M
2599
+ }), B = n(() => z.pages.length);
2600
+ _e({
2601
+ storageKey: n(() => S.storageKey),
2602
+ externalPosition: n(() => S.position),
2603
+ ready: n(() => F.value === "ready"),
2604
+ scrollContainer: M,
2605
+ pages: z.pages,
2606
+ visiblePage: z.visiblePage,
2607
+ scale: A,
2608
+ rotation: j,
2609
+ emitPosition: (e) => E("update:position", e)
2610
+ });
2611
+ let V = Ce({
2612
+ mode: n(() => S.annotationMode),
2613
+ annotations: n(() => S.annotations),
2614
+ pages: z.pages,
2615
+ scrollContainer: M,
2616
+ colors: n(() => S.annotationColors),
2617
+ emitCreate: (e) => E("annotation:create", e),
2618
+ emitUpdate: (e) => E("annotation:update", e),
2619
+ emitDelete: (e) => E("annotation:delete", e)
2620
+ }), re = n(() => {
2621
+ let e = /* @__PURE__ */ new Map();
2622
+ for (let t of S.annotations) {
2623
+ let n = e.get(t.pageIndex);
2624
+ n ? n.push(t) : e.set(t.pageIndex, [t]);
2625
+ }
2626
+ return e;
2627
+ });
2628
+ function ie(e) {
2629
+ let t = re.value.get(e) ?? [], n = V.draftInk.value;
2630
+ if (n && n.pageIndex === e) {
2631
+ let r = {
2632
+ id: "__coar-pdf-draft-stroke__",
2633
+ type: n.kind,
2634
+ pageIndex: e,
2635
+ color: n.color,
2636
+ createdAt: "",
2637
+ width: n.width,
2638
+ strokes: n.strokes
2639
+ };
2640
+ return [...t, r];
2641
+ }
2642
+ return t;
2643
+ }
2644
+ function H(e) {
2645
+ let t = M.value?.querySelector(`[data-annotation-id="${CSS.escape(e)}"]`);
2646
+ return t ? t.getBoundingClientRect() : null;
2647
+ }
2648
+ let ae = _(null);
2649
+ function oe() {
2650
+ let e = V.selectedAnnotationId.value;
2651
+ ae.value = e ? H(e) : null;
2652
+ }
2653
+ O(() => V.selectedAnnotationId.value, oe, { flush: "post" }), O([
2654
+ A,
2655
+ j,
2656
+ () => S.annotations
2657
+ ], () => {
2658
+ V.selectedAnnotationId.value && requestAnimationFrame(() => requestAnimationFrame(oe));
2659
+ });
2660
+ function se(e) {
2661
+ S.annotationMode === "eraser" || S.annotationMode === "select" || V.selectAnnotation(e);
2662
+ }
2663
+ function ce(e) {
2664
+ E("update:annotationMode", e), V.selectAnnotation(null), e === "marker" && !V.markerColor.value ? V.markerColor.value = S.annotationColors[0] ?? "#fde68a" : e === "ink" && !V.inkColor.value && (V.inkColor.value = S.annotationColors[0] ?? "#dc2626");
2665
+ }
2666
+ function le() {
2667
+ return V.selectedAnnotation.value?.type === "freetext" ? "text" : "comment";
2668
+ }
2669
+ let ue = n(() => {
2670
+ let e = V.selectedAnnotation.value;
2671
+ return e ? (e.type === "freetext" ? e.text : e.comment) ?? "" : "";
2672
+ });
2673
+ function fe(e) {
2674
+ let t = V.selectedAnnotation.value;
2675
+ if (!t) return;
2676
+ let n = le(), r = n === "text" && t.type === "freetext" ? t.text : t.comment, i = {};
2677
+ e.comment !== r && (i[n] = e.comment), e.color !== t.color && (i.color = e.color), Object.keys(i).length !== 0 && E("annotation:update", {
2678
+ id: t.id,
2679
+ patch: i
2680
+ });
2681
+ }
2682
+ function me() {
2683
+ let e = V.selectedAnnotationId.value;
2684
+ e && (E("annotation:delete", e), V.selectAnnotation(null));
2685
+ }
2686
+ function he() {
2687
+ V.selectAnnotation(null);
2688
+ }
2689
+ function ge(e) {
2690
+ V.commitDraftPin(e.comment, e.color);
2691
+ }
2692
+ function ve(e) {
2693
+ V.commitDraftFreetext(e.comment, e.color);
2694
+ }
2695
+ let ye = _(!1), U = Oe({ doc: I }), W = _(!1);
2696
+ function be() {
2697
+ W.value = !W.value;
2698
+ }
2699
+ let G = _(!1);
2700
+ function we() {
2701
+ G.value = !G.value;
2702
+ }
2703
+ let K = _(hn), q = _(_n), Te = _(null), Ee = _(null);
2704
+ function De(e, t) {
2705
+ t.preventDefault(), Te.value = e;
2706
+ let n = t.clientX, r = K.value, i = q.value;
2707
+ function a(t) {
2708
+ let a = Ee.value?.getBoundingClientRect().width ?? 0;
2709
+ if (!a) return;
2710
+ let o = e === "sidebar" ? G.value ? q.value : 0 : W.value ? K.value : 0, s = +!!W.value + +!!G.value, c = a - o - yn - s, l = t.clientX - n;
2711
+ e === "sidebar" ? K.value = Math.min(Math.max(r + l, gn), Math.max(gn, c)) : q.value = Math.min(Math.max(i - l, vn), Math.max(vn, c));
2712
+ }
2713
+ function o() {
2714
+ Te.value = null, window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", o), window.removeEventListener("pointercancel", o);
2715
+ }
2716
+ window.addEventListener("pointermove", a), window.addEventListener("pointerup", o), window.addEventListener("pointercancel", o);
2717
+ }
2718
+ function ke(e) {
2719
+ let t = S.annotations.find((t) => t.id === e);
2720
+ t && (V.selectAnnotation(e), z.scrollToPage(t.pageIndex, { behavior: "smooth" }));
2721
+ }
2722
+ function Ae(e) {
2723
+ E("annotation:delete", e), V.selectedAnnotationId.value === e && V.selectAnnotation(null);
2724
+ }
2725
+ function je(e) {
2726
+ z.scrollToPage(e, { behavior: "smooth" });
2727
+ }
2728
+ let Me = n(() => {
2729
+ let e = /* @__PURE__ */ new Map();
2730
+ for (let t of U.matches.value) {
2731
+ let n = e.get(t.pageIndex);
2732
+ n ? n.push(t) : e.set(t.pageIndex, [t]);
2733
+ }
2734
+ return e;
2735
+ });
2736
+ function Ne(e) {
2737
+ return Me.value.get(e) ?? [];
2738
+ }
2739
+ function J(e, t) {
2740
+ return {
2741
+ w: e * A.value,
2742
+ h: t * A.value
2743
+ };
2744
+ }
2745
+ let Pe = n(() => (e, t) => {
2746
+ switch (j.value) {
2747
+ case 90: return `translate(${t}px, 0) rotate(90deg)`;
2748
+ case 180: return `translate(${e}px, ${t}px) rotate(180deg)`;
2749
+ case 270: return `translate(0, ${e}px) rotate(270deg)`;
2750
+ default: return "none";
2751
+ }
2752
+ });
2753
+ function Fe(e) {
2754
+ return U.currentMatch.value === e;
2755
+ }
2756
+ function Ie() {
2757
+ ye.value = !0;
2758
+ }
2759
+ function Le() {
2760
+ ye.value = !1, U.clear();
2761
+ }
2762
+ function Re(e) {
2763
+ U.setQuery(e);
2764
+ }
2765
+ O(() => U.currentMatch.value, (e) => {
2766
+ e && (z.scrollToPage(e.pageIndex, { behavior: "smooth" }), requestAnimationFrame(() => {
2767
+ requestAnimationFrame(() => {
2768
+ let t = M.value, n = z.pages[e.pageIndex];
2769
+ if (!t || !n?.wrapper) return;
2770
+ let r = e.rects[0];
2771
+ if (!r) return;
2772
+ let i = n.wrapper.offsetTop - t.offsetTop + r.y * n.displayHeight;
2773
+ t.scrollTop = Math.max(0, i - t.clientHeight / 2);
2774
+ });
2775
+ }));
2776
+ });
2777
+ function ze(e) {
2778
+ return (t) => z.bindWrapper(e, t);
2779
+ }
2780
+ function Be(e) {
2781
+ return Math.max(b, Math.min(x, e));
2782
+ }
2783
+ function Ve(e) {
2784
+ return Math.round(e * 100) / 100;
2785
+ }
2786
+ function Y(e) {
2787
+ let t = M.value, n = z.visiblePage.value, r = z.pages[n], i = 0;
2788
+ if (t && r?.wrapper) {
2789
+ let e = r.wrapper.offsetTop - t.offsetTop;
2790
+ i = Math.max(0, Math.min(1, (t.scrollTop - e) / Math.max(1, r.displayHeight)));
2791
+ }
2792
+ e(), d(() => {
2793
+ let e = M.value, t = z.pages[n];
2794
+ if (!e || !t?.wrapper) return;
2795
+ let r = e.style.scrollBehavior;
2796
+ e.style.scrollBehavior = "auto", e.scrollTop = t.wrapper.offsetTop - e.offsetTop + i * t.displayHeight, e.style.scrollBehavior = r;
2797
+ });
2798
+ }
2799
+ function He() {
2800
+ let e = A.value, t = h.find((t) => t > e + 1e-6);
2801
+ t !== void 0 && Y(() => {
2802
+ A.value = t;
2803
+ });
2804
+ }
2805
+ function Ue() {
2806
+ let e = A.value, t;
2807
+ for (let n of h) if (n < e - 1e-6) t = n;
2808
+ else break;
2809
+ t !== void 0 && Y(() => {
2810
+ A.value = t;
2811
+ });
2812
+ }
2813
+ function X(e) {
2814
+ Y(() => {
2815
+ A.value = Be(Ve(e));
2816
+ });
2817
+ }
2818
+ function We() {
2819
+ let e = M.value, t = z.pages[z.visiblePage.value] ?? z.pages[0];
2820
+ if (!e || !t) return;
2821
+ let n = e.clientWidth - mn;
2822
+ n <= 0 || X(n / (j.value === 90 || j.value === 270 ? t.intrinsicHeight : t.intrinsicWidth));
2823
+ }
2824
+ function Z() {
2825
+ let e = M.value, t = z.pages[z.visiblePage.value] ?? z.pages[0];
2826
+ if (!e || !t) return;
2827
+ let n = e.clientWidth - mn, r = e.clientHeight - mn;
2828
+ if (n <= 0 || r <= 0) return;
2829
+ let i = j.value === 90 || j.value === 270, a = i ? t.intrinsicHeight : t.intrinsicWidth, o = i ? t.intrinsicWidth : t.intrinsicHeight;
2830
+ X(Math.min(n / a, r / o));
2831
+ }
2832
+ function Ke() {
2833
+ Y(() => {
2834
+ A.value = 1, j.value = 0;
2835
+ });
2836
+ }
2837
+ let qe = [
2838
+ 0,
2839
+ 90,
2840
+ 180,
2841
+ 270
2842
+ ];
2843
+ function Je(e) {
2844
+ Y(() => {
2845
+ j.value = qe[(qe.indexOf(j.value) + e + 4) % 4];
2846
+ });
2847
+ }
2848
+ function Ye() {
2849
+ Je(1);
2850
+ }
2851
+ function Xe() {
2852
+ Je(-1);
2853
+ }
2854
+ let Qe = n(() => {
2855
+ let e = z.visiblePage.value, t = z.pages[e];
2856
+ return t ? {
2857
+ index: e,
2858
+ width: t.intrinsicWidth,
2859
+ height: t.intrinsicHeight
2860
+ } : null;
2861
+ }), $e = n(() => {
2862
+ let e = S.source;
2863
+ return e.kind === "pdf" || e.kind === "image" ? e.url : e.kind === "image-gallery" ? e.urls[z.visiblePage.value] ?? e.urls[0] ?? "" : "";
2864
+ });
2865
+ function et() {
2866
+ let e = $e.value;
2867
+ if (!e) return;
2868
+ let t = document.createElement("iframe");
2869
+ t.setAttribute("aria-hidden", "true"), t.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", t.src = e, t.onload = () => {
2870
+ try {
2871
+ t.contentWindow?.focus(), t.contentWindow?.print();
2872
+ } catch {
2873
+ window.open(e, "_blank", "noopener");
2874
+ } finally {
2875
+ setTimeout(() => t.remove(), 6e4);
2876
+ }
2877
+ }, document.body.appendChild(t);
2878
+ }
2879
+ function tt() {
2880
+ let e = $e.value;
2881
+ if (!e) return;
2882
+ let t = document.createElement("a");
2883
+ t.href = e;
2884
+ try {
2885
+ t.download = new URL(e, window.location.href).pathname.split("/").pop() || (S.source.kind === "pdf" ? "document.pdf" : "document");
2886
+ } catch {
2887
+ t.download = S.source.kind === "pdf" ? "document.pdf" : "document";
2888
+ }
2889
+ t.rel = "noopener", document.body.appendChild(t), t.click(), t.remove();
2890
+ }
2891
+ function nt() {
2892
+ N.value = N.value === "pan" ? "select" : "pan";
2893
+ }
2894
+ let Q = null, rt = null;
2895
+ function it(e, t) {
2896
+ return Math.hypot(e.clientX - t.clientX, e.clientY - t.clientY);
2897
+ }
2898
+ function at(e) {
2899
+ e.touches.length === 2 && (Q = it(e.touches[0], e.touches[1]), rt = A.value);
2900
+ }
2901
+ function ot(e) {
2902
+ if (e.touches.length !== 2 || Q === null || rt === null) return;
2903
+ e.preventDefault();
2904
+ let t = M.value;
2905
+ if (!t) return;
2906
+ let n = Be(it(e.touches[0], e.touches[1]) / Q * rt), r = A.value;
2907
+ if (n === r) return;
2908
+ let i = z.visiblePage.value, a = z.pages[i], o = 0;
2909
+ if (a?.wrapper) {
2910
+ let e = a.wrapper.offsetTop - t.offsetTop;
2911
+ o = Math.max(0, Math.min(1, (t.scrollTop - e) / Math.max(1, a.displayHeight)));
2912
+ }
2913
+ let s = t.getBoundingClientRect(), c = (e.touches[0].clientX + e.touches[1].clientX) / 2 - s.left, l = t.scrollLeft + c, u = n / r;
2914
+ A.value = Ve(n), d(() => {
2915
+ let e = M.value;
2916
+ if (!e) return;
2917
+ let t = e.style.scrollBehavior;
2918
+ e.style.scrollBehavior = "auto", e.scrollLeft = l * u - c;
2919
+ let n = z.pages[i];
2920
+ n?.wrapper && (e.scrollTop = n.wrapper.offsetTop - e.offsetTop + o * n.displayHeight), e.style.scrollBehavior = t;
2921
+ });
2922
+ }
2923
+ function st(e) {
2924
+ e.touches.length < 2 && (Q = null, rt = null);
2925
+ }
2926
+ O(() => M.value, (e, t) => {
2927
+ t && (t.removeEventListener("touchstart", at), t.removeEventListener("touchmove", ot), t.removeEventListener("touchend", st), t.removeEventListener("touchcancel", st)), e && (e.addEventListener("touchstart", at, { passive: !0 }), e.addEventListener("touchmove", ot, { passive: !1 }), e.addEventListener("touchend", st, { passive: !0 }), e.addEventListener("touchcancel", st, { passive: !0 }));
2928
+ }, { immediate: !0 });
2929
+ let ct = 0, ut = 0, dt = 0, ft = 0;
2930
+ function pt(e) {
2931
+ if (N.value !== "pan" || e.button !== 0) return;
2932
+ let t = M.value;
2933
+ t && (e.preventDefault(), P.value = !0, ct = e.clientX, ut = e.clientY, dt = t.scrollLeft, ft = t.scrollTop, window.addEventListener("mousemove", mt), window.addEventListener("mouseup", ht));
2934
+ }
2935
+ function mt(e) {
2936
+ let t = M.value;
2937
+ t && (t.scrollLeft = dt - (e.clientX - ct), t.scrollTop = ft - (e.clientY - ut));
2938
+ }
2939
+ function ht() {
2940
+ P.value = !1, window.removeEventListener("mousemove", mt), window.removeEventListener("mouseup", ht);
2941
+ }
2942
+ let gt = n(() => ({
2943
+ currentPage: z.visiblePage.value,
2944
+ pageCount: B.value,
2945
+ zoom: A.value,
2946
+ minZoom: b,
2947
+ maxZoom: x,
2948
+ pointerMode: N.value,
2949
+ annotationMode: S.annotationMode,
2950
+ markerWidthPresets: Se,
2951
+ inkWidthPresets: xe,
2952
+ markerWidth: V.markerWidth.value,
2953
+ markerColor: V.markerColor.value || S.annotationColors[0] || "#fde68a",
2954
+ inkWidth: V.inkWidth.value,
2955
+ inkColor: V.inkColor.value || S.annotationColors[0] || "#dc2626",
2956
+ colors: S.annotationColors,
2957
+ side: S.toolbarPosition,
2958
+ labels: k.value,
2959
+ showSearch: S.showSearch,
2960
+ showPrintDownload: S.showPrintDownload,
2961
+ showAnnotationModes: S.showAnnotationModes,
2962
+ showSidebarToggle: S.showThumbnails || S.showOutline,
2963
+ sidebarOpen: W.value,
2964
+ showAnnotationsPanelToggle: S.showAnnotationsPanel,
2965
+ annotationsPanelOpen: G.value,
2966
+ tools: S.tools,
2967
+ capabilities: S.source.capabilities
2968
+ })), $ = {
2969
+ prev: _t,
2970
+ next: vt,
2971
+ jump: yt,
2972
+ "zoom-in": He,
2973
+ "zoom-out": Ue,
2974
+ "reset-zoom": () => X(1),
2975
+ "set-zoom": (e) => X(e),
2976
+ "reset-view": Ke,
2977
+ "toggle-pan": nt,
2978
+ "toggle-sidebar": be,
2979
+ "toggle-annotations-panel": we,
2980
+ "rotate-cw": Ye,
2981
+ "rotate-ccw": Xe,
2982
+ "set-annotation-mode": ce,
2983
+ "update:marker-width": (e) => V.markerWidth.value = e,
2984
+ "update:marker-color": (e) => V.markerColor.value = e,
2985
+ "update:ink-width": (e) => V.inkWidth.value = e,
2986
+ "update:ink-color": (e) => V.inkColor.value = e,
2987
+ "fit-width": We,
2988
+ "fit-page": Z,
2989
+ search: Ie,
2990
+ print: et,
2991
+ download: tt
2992
+ };
2993
+ function _t() {
2994
+ z.visiblePage.value > 0 && z.scrollToPage(z.visiblePage.value - 1, { behavior: "smooth" });
2995
+ }
2996
+ function vt() {
2997
+ z.visiblePage.value < z.pages.length - 1 && z.scrollToPage(z.visiblePage.value + 1, { behavior: "smooth" });
2998
+ }
2999
+ function yt(e) {
3000
+ z.scrollToPage(e, { behavior: "smooth" });
3001
+ }
3002
+ function bt(e) {
3003
+ if (!(e.ctrlKey || e.metaKey)) return;
3004
+ e.preventDefault();
3005
+ let t = M.value;
3006
+ if (!t) return;
3007
+ let n = e.deltaY < 0 ? 1.1 : 1 / 1.1, r = A.value, i = Be(r * n);
3008
+ if (i === r) return;
3009
+ let a = z.visiblePage.value, o = z.pages[a], s = 0;
3010
+ if (o?.wrapper) {
3011
+ let e = o.wrapper.offsetTop - t.offsetTop;
3012
+ s = Math.max(0, Math.min(1, (t.scrollTop - e) / Math.max(1, o.displayHeight)));
3013
+ }
3014
+ let c = t.getBoundingClientRect(), l = e.clientX - c.left, u = t.scrollLeft + l;
3015
+ A.value = Ve(i);
3016
+ let f = i / r;
3017
+ d(() => {
3018
+ let e = M.value;
3019
+ if (!e) return;
3020
+ let t = e.style.scrollBehavior;
3021
+ e.style.scrollBehavior = "auto", e.scrollLeft = u * f - l;
3022
+ let n = z.pages[a];
3023
+ n?.wrapper && (e.scrollTop = n.wrapper.offsetTop - e.offsetTop + s * n.displayHeight), e.style.scrollBehavior = t;
3024
+ });
3025
+ }
3026
+ return O(() => te.value, (e) => {
3027
+ e != null && E("error", {
3028
+ error: e,
3029
+ src: $e.value
3030
+ });
3031
+ }), l({
3032
+ reload: R,
3033
+ destroy: ne,
3034
+ scrollToPage: z.scrollToPage
3035
+ }), (n, l) => (g(), a("div", {
3036
+ ref_key: "viewerRoot",
3037
+ ref: Ee,
3038
+ class: f(["coar-pdf-viewer", { "coar-pdf-viewer--resizing": Te.value !== null }]),
3039
+ "data-status": T(F)
3040
+ }, [
3041
+ W.value && T(F) === "ready" && (t.showThumbnails || t.showOutline) ? (g(), r(lt, {
3042
+ key: 0,
3043
+ doc: T(I),
3044
+ "page-providers": T(L),
3045
+ "page-count": B.value,
3046
+ "visible-page": T(z).visiblePage.value,
3047
+ "show-thumbnails": t.showThumbnails,
3048
+ "show-outline": t.showOutline,
3049
+ labels: k.value,
3050
+ style: p({
3051
+ width: K.value + "px",
3052
+ flexBasis: K.value + "px"
3053
+ }),
3054
+ onJump: je,
3055
+ onClose: l[0] ||= (e) => W.value = !1
3056
+ }, null, 8, [
3057
+ "doc",
3058
+ "page-providers",
3059
+ "page-count",
3060
+ "visible-page",
3061
+ "show-thumbnails",
3062
+ "show-outline",
3063
+ "labels",
3064
+ "style"
3065
+ ])) : i("", !0),
3066
+ W.value && T(F) === "ready" && (t.showThumbnails || t.showOutline) ? (g(), a("div", {
3067
+ key: 1,
3068
+ class: "coar-pdf-viewer__divider",
3069
+ role: "separator",
3070
+ "aria-orientation": "vertical",
3071
+ onPointerdown: l[1] ||= (e) => De("sidebar", e)
3072
+ }, null, 32)) : i("", !0),
3073
+ o("div", on, [
3074
+ t.showToolbar && (T(F) === "ready" || T(F) === "loading") && t.toolbarPosition === "top" ? (g(), r(Ge, u({ key: 0 }, gt.value, w($)), null, 16)) : i("", !0),
3075
+ ye.value && T(F) === "ready" ? (g(), r(Ze, {
3076
+ key: 1,
3077
+ query: T(U).query.value,
3078
+ "match-count": T(U).matches.value.length,
3079
+ "current-index": T(U).currentIndex.value,
3080
+ searching: T(U).searching.value,
3081
+ labels: k.value,
3082
+ "onUpdate:query": Re,
3083
+ onNext: T(U).next,
3084
+ onPrev: T(U).prev,
3085
+ onClose: Le
3086
+ }, null, 8, [
3087
+ "query",
3088
+ "match-count",
3089
+ "current-index",
3090
+ "searching",
3091
+ "labels",
3092
+ "onNext",
3093
+ "onPrev"
3094
+ ])) : i("", !0),
3095
+ o("div", sn, [
3096
+ t.showToolbar && (T(F) === "ready" || T(F) === "loading") && t.toolbarPosition === "left" ? (g(), r(Ge, u({ key: 0 }, gt.value, w($)), null, 16)) : i("", !0),
3097
+ o("div", {
3098
+ ref_key: "scrollContainer",
3099
+ ref: M,
3100
+ class: f(["coar-pdf-viewer__scroll", {
3101
+ "coar-pdf-viewer__scroll--pan": N.value === "pan",
3102
+ "coar-pdf-viewer__scroll--panning": P.value,
3103
+ "coar-pdf-viewer__scroll--annotate-comment": t.annotationMode === "comment",
3104
+ "coar-pdf-viewer__scroll--annotate-ink": t.annotationMode === "ink",
3105
+ "coar-pdf-viewer__scroll--annotate-marker": t.annotationMode === "marker",
3106
+ "coar-pdf-viewer__scroll--annotate-freetext": t.annotationMode === "freetext",
3107
+ "coar-pdf-viewer__scroll--annotate-select": t.annotationMode === "select",
3108
+ "coar-pdf-viewer__scroll--annotate-eraser": t.annotationMode === "eraser"
3109
+ }]),
3110
+ role: "document",
3111
+ onWheel: bt,
3112
+ onMousedown: pt
3113
+ }, [
3114
+ T(F) === "ready" || T(F) === "loading" ? (g(), a("div", cn, [(g(!0), a(e, null, v(T(z).pages, (t) => (g(), a("div", {
3115
+ key: t.index,
3116
+ ref_for: !0,
3117
+ ref: ze(t.index),
3118
+ class: "coar-pdf-page",
3119
+ style: p({
3120
+ width: t.displayWidth + "px",
3121
+ height: t.displayHeight + "px"
3122
+ }),
3123
+ "data-page-index": t.index,
3124
+ "aria-label": `Page ${t.index + 1} of ${B.value}`
3125
+ }, [c(Xt, {
3126
+ annotations: ie(t.index),
3127
+ "display-width": J(t.intrinsicWidth, t.intrinsicHeight).w,
3128
+ "display-height": J(t.intrinsicWidth, t.intrinsicHeight).h,
3129
+ rotation: j.value,
3130
+ onAnnotationClick: se
3131
+ }, null, 8, [
3132
+ "annotations",
3133
+ "display-width",
3134
+ "display-height",
3135
+ "rotation"
3136
+ ]), Ne(t.index).length > 0 ? (g(), a("div", {
3137
+ key: 0,
3138
+ class: "coar-pdf-search-overlay",
3139
+ style: p({
3140
+ width: J(t.intrinsicWidth, t.intrinsicHeight).w + "px",
3141
+ height: J(t.intrinsicWidth, t.intrinsicHeight).h + "px",
3142
+ transform: Pe.value(J(t.intrinsicWidth, t.intrinsicHeight).w, J(t.intrinsicWidth, t.intrinsicHeight).h)
3143
+ })
3144
+ }, [(g(!0), a(e, null, v(Ne(t.index), (n, r) => (g(), a(e, { key: r }, [(g(!0), a(e, null, v(n.rects, (e, i) => (g(), a("div", {
3145
+ key: `${r}-${i}`,
3146
+ class: f(["coar-pdf-search-rect", { "coar-pdf-search-rect--current": Fe(n) }]),
3147
+ style: p({
3148
+ left: e.x * J(t.intrinsicWidth, t.intrinsicHeight).w + "px",
3149
+ top: e.y * J(t.intrinsicWidth, t.intrinsicHeight).h + "px",
3150
+ width: e.w * J(t.intrinsicWidth, t.intrinsicHeight).w + "px",
3151
+ height: e.h * J(t.intrinsicWidth, t.intrinsicHeight).h + "px"
3152
+ })
3153
+ }, null, 6))), 128))], 64))), 128))], 4)) : i("", !0)], 12, ln))), 128))])) : i("", !0),
3154
+ T(F) === "loading" ? (g(), a("div", un, [y(n.$slots, "loading", {}, () => [s(C(k.value.loading), 1)], !0)])) : i("", !0),
3155
+ T(V).selectedAnnotation.value && ae.value ? (g(), r(rn, {
3156
+ key: 2,
3157
+ anchor: ae.value,
3158
+ "initial-comment": ue.value,
3159
+ "initial-color": T(V).selectedAnnotation.value.color,
3160
+ colors: t.annotationColors,
3161
+ draft: !1,
3162
+ labels: k.value,
3163
+ onSave: fe,
3164
+ onDelete: me,
3165
+ onClose: he
3166
+ }, null, 8, [
3167
+ "anchor",
3168
+ "initial-comment",
3169
+ "initial-color",
3170
+ "colors",
3171
+ "labels"
3172
+ ])) : i("", !0),
3173
+ T(V).draftPin.value ? (g(), r(rn, {
3174
+ key: 3,
3175
+ anchor: T(V).draftPin.value.viewportRect,
3176
+ "initial-comment": "",
3177
+ "initial-color": T(V).draftPin.value.color,
3178
+ colors: t.annotationColors,
3179
+ draft: !0,
3180
+ labels: k.value,
3181
+ onSave: ge,
3182
+ onClose: T(V).cancelDraftPin
3183
+ }, null, 8, [
3184
+ "anchor",
3185
+ "initial-color",
3186
+ "colors",
3187
+ "labels",
3188
+ "onClose"
3189
+ ])) : i("", !0),
3190
+ T(V).draftFreetext.value ? (g(), r(rn, {
3191
+ key: 4,
3192
+ anchor: T(V).draftFreetext.value.viewportRect,
3193
+ "initial-comment": "",
3194
+ "initial-color": T(V).draftFreetext.value.color,
3195
+ colors: t.annotationColors,
3196
+ draft: !0,
3197
+ labels: k.value,
3198
+ onSave: ve,
3199
+ onClose: T(V).cancelDraftFreetext
3200
+ }, null, 8, [
3201
+ "anchor",
3202
+ "initial-color",
3203
+ "colors",
3204
+ "labels",
3205
+ "onClose"
3206
+ ])) : i("", !0),
3207
+ T(F) === "error" ? (g(), a("div", dn, [y(n.$slots, "error", {
3208
+ error: T(te),
3209
+ retry: T(R)
3210
+ }, () => [o("div", fn, [o("p", pn, C(k.value.errorTitle), 1), o("button", {
3211
+ type: "button",
3212
+ class: "coar-pdf-viewer__error-retry",
3213
+ onClick: l[2] ||= (...e) => T(R) && T(R)(...e)
3214
+ }, C(k.value.errorRetry), 1)])], !0)])) : i("", !0)
3215
+ ], 34),
3216
+ t.showToolbar && (T(F) === "ready" || T(F) === "loading") && t.toolbarPosition === "right" ? (g(), r(Ge, u({ key: 1 }, gt.value, w($)), null, 16)) : i("", !0)
3217
+ ]),
3218
+ t.showToolbar && (T(F) === "ready" || T(F) === "loading") && t.toolbarPosition === "bottom" ? (g(), r(Ge, u({ key: 2 }, gt.value, w($)), null, 16)) : i("", !0)
3219
+ ]),
3220
+ G.value && T(F) === "ready" && t.showAnnotationsPanel ? (g(), a("div", {
3221
+ key: 2,
3222
+ class: "coar-pdf-viewer__divider",
3223
+ role: "separator",
3224
+ "aria-orientation": "vertical",
3225
+ onPointerdown: l[3] ||= (e) => De("panel", e)
3226
+ }, null, 32)) : i("", !0),
3227
+ G.value && T(F) === "ready" && t.showAnnotationsPanel ? (g(), r(Bt, {
3228
+ key: 3,
3229
+ annotations: t.annotations,
3230
+ "selected-id": T(V).selectedAnnotationId.value,
3231
+ info: t.showInfoSection ? T(ee) : null,
3232
+ "current-page-info": t.showInfoSection ? Qe.value : null,
3233
+ labels: k.value,
3234
+ style: p({
3235
+ width: q.value + "px",
3236
+ flexBasis: q.value + "px"
3237
+ }),
3238
+ onSelect: ke,
3239
+ onDelete: Ae,
3240
+ onClose: l[4] ||= (e) => G.value = !1
3241
+ }, null, 8, [
3242
+ "annotations",
3243
+ "selected-id",
3244
+ "info",
3245
+ "current-page-info",
3246
+ "labels",
3247
+ "style"
3248
+ ])) : i("", !0)
3249
+ ], 10, an));
3250
+ }
3251
+ }), [["__scopeId", "data-v-485161c5"]]);
3252
+ //#endregion
3253
+ //#region src/sources/image.ts
3254
+ function xn(e) {
3255
+ let t = {
3256
+ kind: "image",
3257
+ url: e.url,
3258
+ capabilities: Object.freeze({
3259
+ multiPage: !1,
3260
+ textLayer: !1,
3261
+ search: !1,
3262
+ outline: !1,
3263
+ print: !0
3264
+ })
3265
+ };
3266
+ return Object.freeze(t);
3267
+ }
3268
+ function Sn(e) {
3269
+ let t = {
3270
+ kind: "image-gallery",
3271
+ urls: Object.freeze([...e.urls]),
3272
+ capabilities: Object.freeze({
3273
+ multiPage: !0,
3274
+ textLayer: !1,
3275
+ search: !1,
3276
+ outline: !1,
3277
+ print: !0
3278
+ })
3279
+ };
3280
+ return Object.freeze(t);
3281
+ }
3282
+ //#endregion
3283
+ export { ke as COAR_DOCUMENT_VIEWER_ALL_TOOLS, bn as CoarDocumentViewer, Sn as imageGallerySource, xn as imageSource };