pdf-h5-react 0.0.0-stage → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +455 -2
  3. package/dist/components/AnnotationLayer.d.ts +26 -0
  4. package/dist/components/LinkLayer.d.ts +17 -0
  5. package/dist/components/OutlinePanel.d.ts +8 -0
  6. package/dist/components/PageCanvas.d.ts +41 -0
  7. package/dist/components/PageThumbnail.d.ts +23 -0
  8. package/dist/components/PdfH5Reader.d.ts +101 -0
  9. package/dist/components/SearchPanel.d.ts +18 -0
  10. package/dist/components/StatusOverlay.d.ts +15 -0
  11. package/dist/components/TextLayer.d.ts +26 -0
  12. package/dist/components/ThumbnailPanel.d.ts +18 -0
  13. package/dist/components/Toolbar.d.ts +36 -0
  14. package/dist/core/annotations.d.ts +91 -0
  15. package/dist/core/cache.d.ts +96 -0
  16. package/dist/core/errors.d.ts +12 -0
  17. package/dist/core/eventEmitter.d.ts +43 -0
  18. package/dist/core/gestures.d.ts +71 -0
  19. package/dist/core/layout.d.ts +109 -0
  20. package/dist/core/layoutAdapter.d.ts +36 -0
  21. package/dist/core/lru.d.ts +57 -0
  22. package/dist/core/metrics.d.ts +22 -0
  23. package/dist/core/pdfjs.d.ts +51 -0
  24. package/dist/core/readerEvents.d.ts +116 -0
  25. package/dist/core/renderQueue.d.ts +45 -0
  26. package/dist/core/throttle.d.ts +40 -0
  27. package/dist/core/zoomAnimation.d.ts +33 -0
  28. package/dist/hooks/useElementSize.d.ts +18 -0
  29. package/dist/hooks/usePageMetrics.d.ts +27 -0
  30. package/dist/hooks/usePdfDocument.d.ts +19 -0
  31. package/dist/hooks/usePinchGesture.d.ts +41 -0
  32. package/dist/hooks/useVirtualPages.d.ts +48 -0
  33. package/dist/index.d.ts +46 -0
  34. package/dist/index.js +3226 -0
  35. package/dist/lib/highlight.d.ts +9 -0
  36. package/dist/lib/outline.d.ts +35 -0
  37. package/dist/lib/search.d.ts +38 -0
  38. package/dist/lib/text.d.ts +40 -0
  39. package/dist/lib/thumbnail.d.ts +18 -0
  40. package/dist/pdf-h5-react.css +1 -0
  41. package/dist/types.d.ts +145 -0
  42. package/package.json +84 -4
  43. package/scripts/copy-pdfjs-assets.mjs +100 -0
package/dist/index.js ADDED
@@ -0,0 +1,3226 @@
1
+ import { useState as B, useRef as A, useMemo as rt, useEffect as S, useCallback as I, forwardRef as Bn, useImperativeHandle as Hn } from "react";
2
+ import { jsx as p, jsxs as L, Fragment as In } from "react/jsx-runtime";
3
+ import * as Ht from "pdfjs-dist";
4
+ const Fn = Ht.version, Dt = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${Fn}/`;
5
+ let dt = {
6
+ workerSrc: `${Dt}build/pdf.worker.min.mjs`,
7
+ cMapUrl: `${Dt}cmaps/`,
8
+ standardFontDataUrl: `${Dt}standard_fonts/`,
9
+ wasmUrl: `${Dt}wasm/`,
10
+ iccUrl: `${Dt}iccs/`
11
+ }, ye = !1;
12
+ function rn() {
13
+ if (ye) return;
14
+ const e = dt.workerSrc;
15
+ e && (Ht.GlobalWorkerOptions.workerSrc = e, ye = !0);
16
+ }
17
+ function Jr(e) {
18
+ dt = { ...dt, ...e }, e.workerSrc && e.workerSrc !== Ht.GlobalWorkerOptions.workerSrc && (ye = !1), rn();
19
+ }
20
+ function Qr() {
21
+ return dt;
22
+ }
23
+ function On(e) {
24
+ return e instanceof ArrayBuffer || typeof ArrayBuffer < "u" && ArrayBuffer.isView(e) || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer;
25
+ }
26
+ function Zn(e, t) {
27
+ const n = {};
28
+ if (typeof e == "string")
29
+ n.url = e;
30
+ else if (e instanceof URL)
31
+ n.url = e.href;
32
+ else if (On(e)) {
33
+ const r = e instanceof Uint8Array ? e.slice() : new Uint8Array(e.slice(0));
34
+ n.data = r;
35
+ } else e && typeof e == "object" && (e.url && (n.url = String(e.url)), e.data && (n.data = e.data instanceof Uint8Array ? e.data.slice() : e.data.slice(0)), e.httpHeaders && (n.httpHeaders = e.httpHeaders), e.withCredentials && (n.withCredentials = e.withCredentials), e.password && (n.password = e.password), e.range && (n.range = e.range));
36
+ return rn(), {
37
+ cMapUrl: dt.cMapUrl,
38
+ cMapPacked: !0,
39
+ standardFontDataUrl: dt.standardFontDataUrl,
40
+ wasmUrl: dt.wasmUrl,
41
+ iccUrl: dt.iccUrl,
42
+ ...dt.verbosity != null ? { verbosity: dt.verbosity } : null,
43
+ ...n,
44
+ ...t
45
+ };
46
+ }
47
+ function sn(e, t = {}) {
48
+ const n = Ht.getDocument(
49
+ Zn(e, {
50
+ ...t.password ? { password: t.password } : null,
51
+ ...t.stopAtErrors != null ? { stopAtErrors: t.stopAtErrors } : null,
52
+ ...t.disableOffscreenCanvas ? { isOffscreenCanvasSupported: !1 } : null
53
+ })
54
+ );
55
+ return t.onProgress && (n.onProgress = ({ loaded: r, total: s }) => {
56
+ t.onProgress(r, s);
57
+ }), t.onPassword && (n.onPassword = (r, s) => {
58
+ t.onPassword(s);
59
+ }), { doc: null, task: n };
60
+ }
61
+ async function ts(e, t = {}) {
62
+ const { task: n } = sn(e, t);
63
+ return n.promise;
64
+ }
65
+ const on = typeof requestAnimationFrame == "function" ? (e) => requestAnimationFrame(() => e()) : (e) => setTimeout(e, 16), Yt = typeof cancelAnimationFrame == "function" ? (e) => cancelAnimationFrame(e) : (e) => clearTimeout(e);
66
+ function pe(e) {
67
+ let t = 0, n = null, r = null;
68
+ const s = () => {
69
+ if (t = 0, n === null) return;
70
+ const c = n;
71
+ n = null, e.apply(r, c);
72
+ }, i = function(...c) {
73
+ n = c, r = this, !t && (t = on(s));
74
+ };
75
+ return i.cancel = () => {
76
+ t && Yt(t), t = 0, n = null;
77
+ }, i.flush = () => {
78
+ t && (Yt(t), s());
79
+ }, i.pending = () => t !== 0, i;
80
+ }
81
+ function be(e, t = 100, n = {}) {
82
+ const r = n.leading ?? !0, s = n.trailing ?? !0;
83
+ let i = null, c = 0, a = null, l = null;
84
+ const d = () => {
85
+ c = Date.now();
86
+ const f = a;
87
+ a = null, f && e.apply(l, f);
88
+ }, m = () => {
89
+ i = null, s && a && d();
90
+ }, u = function(...f) {
91
+ const y = Date.now();
92
+ !c && !r && (c = y);
93
+ const b = t - (y - c);
94
+ if (a = f, l = this, b <= 0 || b > t) {
95
+ i && (clearTimeout(i), i = null), d();
96
+ return;
97
+ }
98
+ !i && s && (i = setTimeout(m, b));
99
+ };
100
+ return u.cancel = () => {
101
+ i && clearTimeout(i), i = null, a = null, c = 0;
102
+ }, u.flush = () => {
103
+ i && (clearTimeout(i), i = null), a && d();
104
+ }, u.pending = () => i !== null, u;
105
+ }
106
+ function cn(e, t = 200) {
107
+ let n = null, r = null, s = null;
108
+ const i = function(...c) {
109
+ r = c, s = this, n && clearTimeout(n), n = setTimeout(() => {
110
+ n = null;
111
+ const a = r;
112
+ r = null, a && e.apply(s, a);
113
+ }, t);
114
+ };
115
+ return i.cancel = () => {
116
+ n && clearTimeout(n), n = null, r = null;
117
+ }, i.flush = () => {
118
+ if (n && (clearTimeout(n), n = null), r) {
119
+ const c = r;
120
+ r = null, e.apply(s, c);
121
+ }
122
+ }, i.pending = () => n !== null, i;
123
+ }
124
+ function jn(e, t = 64) {
125
+ let n = [], r = 0;
126
+ const s = () => {
127
+ if (r = 0, n.length === 0) return;
128
+ const i = n;
129
+ n = [], e(i);
130
+ };
131
+ return {
132
+ push(i) {
133
+ if (n.push(i), n.length >= t) {
134
+ r && Yt(r), s();
135
+ return;
136
+ }
137
+ r || (r = on(s));
138
+ },
139
+ cancel() {
140
+ r && Yt(r), r = 0, n = [];
141
+ }
142
+ };
143
+ }
144
+ function Un(e) {
145
+ if (typeof e == "string") return `url:${e}`;
146
+ if (e instanceof URL) return `url:${e.href}`;
147
+ if (e instanceof ArrayBuffer) return `bin:${e.byteLength}:${e.slice(0, 32).toString()}`;
148
+ if (ArrayBuffer.isView(e)) return `bin:${e.byteLength}:${e.buffer.slice(0, 32).toString()}`;
149
+ if (e && typeof e == "object") {
150
+ if (e.url) return `url:${String(e.url)}`;
151
+ if (e.data) return `bin:${e.data.byteLength ?? 0}`;
152
+ }
153
+ return "unknown";
154
+ }
155
+ function Wn(e, t = !0) {
156
+ const [n, r] = B(null), [s, i] = B(!!e && t), [c, a] = B(null), [l, d] = B(null), [m, u] = B(!1), [f, y] = B(0), b = A(null), g = A(null), x = rt(() => e ? Un(e) : "", [e]);
157
+ S(() => {
158
+ if (!e || !t || !x) {
159
+ i(!1);
160
+ return;
161
+ }
162
+ let M = !1;
163
+ i(!0), d(null), r(null), a(null), u(!1);
164
+ const P = be((z, $) => {
165
+ M || a({ loaded: z, total: $ });
166
+ }, 120), { task: D } = sn(e, {
167
+ onProgress: (z, $) => P(z, $)
168
+ });
169
+ return g.current = D, D.onPassword = (z, $) => {
170
+ M || (b.current = z, y($), u(!0), i(!0));
171
+ }, D.promise.then((z) => {
172
+ M || (r(z), i(!1), u(!1), a(null));
173
+ }).catch((z) => {
174
+ M || z.name === "PasswordException" || (d(z instanceof Error ? z : new Error(String(z))), i(!1));
175
+ }), () => {
176
+ M = !0, P.cancel(), b.current = null, D.destroy().catch(() => {
177
+ }), g.current === D && (g.current = null);
178
+ };
179
+ }, [e, x, t]);
180
+ const k = I((M) => {
181
+ const P = b.current;
182
+ P && (b.current = null, u(!1), P(M));
183
+ }, []), C = I(() => {
184
+ u(!1), i(!1), d(new Error("已取消输入密码"));
185
+ }, []);
186
+ return {
187
+ doc: n,
188
+ numPages: n?.numPages ?? 0,
189
+ loading: s,
190
+ progress: c,
191
+ error: l,
192
+ needPassword: m,
193
+ passwordReason: f,
194
+ submitPassword: k,
195
+ cancelPassword: C
196
+ };
197
+ }
198
+ class Xt {
199
+ map = /* @__PURE__ */ new Map();
200
+ maxBytes;
201
+ maxEntries;
202
+ sizeOf;
203
+ onEvict;
204
+ name;
205
+ bytes = 0;
206
+ hits = 0;
207
+ misses = 0;
208
+ evictions = 0;
209
+ constructor(t = {}) {
210
+ this.maxBytes = t.maxBytes ?? Number.POSITIVE_INFINITY, this.maxEntries = t.maxEntries ?? Number.POSITIVE_INFINITY, this.sizeOf = t.sizeOf ?? (() => 1), this.onEvict = t.onEvict, this.name = t.name ?? "lru";
211
+ }
212
+ get size() {
213
+ return this.map.size;
214
+ }
215
+ get byteSize() {
216
+ return this.bytes;
217
+ }
218
+ /** 读取并提升为最近使用 */
219
+ get(t) {
220
+ const n = this.map.get(t);
221
+ if (n === void 0) {
222
+ this.misses += 1;
223
+ return;
224
+ }
225
+ return this.hits += 1, this.map.delete(t), this.map.set(t, n), n.value;
226
+ }
227
+ /** 读取但不改变活跃度(用于「有多少可用」的探测) */
228
+ peek(t) {
229
+ return this.map.get(t)?.value;
230
+ }
231
+ has(t) {
232
+ return this.map.has(t);
233
+ }
234
+ set(t, n) {
235
+ const r = this.map.get(t);
236
+ r !== void 0 && (this.bytes -= r.size, this.map.delete(t), this.onEvict?.(r.value, t, "replace"));
237
+ const s = Math.max(0, this.sizeOf(n, t));
238
+ return this.map.set(t, { value: n, size: s }), this.bytes += s, this.trim(t), this;
239
+ }
240
+ delete(t) {
241
+ const n = this.map.get(t);
242
+ return n === void 0 ? !1 : (this.map.delete(t), this.bytes -= n.size, this.onEvict?.(n.value, t, "delete"), !0);
243
+ }
244
+ clear() {
245
+ for (const [t, n] of this.map)
246
+ this.onEvict?.(n.value, t, "clear");
247
+ this.map.clear(), this.bytes = 0;
248
+ }
249
+ /** 按最近使用顺序返回键(最旧 → 最新) */
250
+ keys() {
251
+ return [...this.map.keys()];
252
+ }
253
+ stats() {
254
+ return {
255
+ name: this.name,
256
+ entries: this.map.size,
257
+ bytes: this.bytes,
258
+ maxBytes: this.maxBytes,
259
+ maxEntries: this.maxEntries,
260
+ hits: this.hits,
261
+ misses: this.misses,
262
+ evictions: this.evictions
263
+ };
264
+ }
265
+ resetStats() {
266
+ this.hits = 0, this.misses = 0, this.evictions = 0;
267
+ }
268
+ trim(t) {
269
+ const n = () => this.map.size > this.maxEntries, r = () => this.bytes > this.maxBytes;
270
+ for (; n() || r(); ) {
271
+ const s = this.map.keys().next();
272
+ if (s.done || this.map.size === 1 && s.value === t) return;
273
+ const i = s.value, c = this.map.get(i), a = r() ? "bytes" : "entries";
274
+ this.map.delete(i), this.bytes -= c.size, this.evictions += 1, this.onEvict?.(c.value, i, a);
275
+ }
276
+ }
277
+ }
278
+ function Ve(e, t) {
279
+ return ((e.rotate + t) % 360 + 360) % 360 % 180 === 0 ? { width: e.width, height: e.height } : { width: e.height, height: e.width };
280
+ }
281
+ function qn(e, t, n) {
282
+ if (n === "none" || e.width <= 0 || e.height <= 0) return 1;
283
+ const r = t.width / e.width;
284
+ return n === "width" ? r : Math.min(r, t.height / e.height);
285
+ }
286
+ function _n(e) {
287
+ const { mode: t, metrics: n, fallback: r, scale: s, zoom: i, containerWidth: c, containerHeight: a, rotation: l, fitMode: d } = e, m = Math.max(0, e.gap * i), u = Math.max(0, e.padding * i);
288
+ if (t === "page") {
289
+ const P = [];
290
+ for (let D = 0; D < n.length; D += 1) {
291
+ const z = n[D], $ = z ? Ve(z, l) : { width: r.width, height: r.height }, W = d === "none" ? s : qn($, { width: c, height: a }, d) * i, O = $.width * W, _ = $.height * W;
292
+ P.push({
293
+ pageNumber: D + 1,
294
+ // 超出容器时顶部对齐,否则垂直居中
295
+ top: _ >= a ? 0 : (a - _) / 2,
296
+ left: D * c + (c - O) / 2,
297
+ width: O,
298
+ height: _,
299
+ scale: W
300
+ });
301
+ }
302
+ return {
303
+ boxes: P,
304
+ contentWidth: Math.max(c, n.length * c),
305
+ contentHeight: a,
306
+ widest: c,
307
+ mode: t
308
+ };
309
+ }
310
+ const f = n.map(
311
+ (P) => P ? Ve(P, l) : { width: r.width, height: r.height }
312
+ ), y = Math.max(0, e.padding), b = Math.max(1, c - y * 2), g = [];
313
+ let x = u, k = 0;
314
+ for (let P = 0; P < f.length; P += 1) {
315
+ const D = f[P], z = d === "none" ? s * i : D.width > 0 ? b / D.width * i : s * i, $ = D.width * z, W = D.height * z;
316
+ k = Math.max(k, $), g.push({ pageNumber: P + 1, top: x, left: 0, width: $, height: W, scale: z }), x += W + m;
317
+ }
318
+ const C = Math.max(c, c * i);
319
+ for (const P of g)
320
+ P.left = (C - P.width) / 2;
321
+ const M = Math.max(a, x - (f.length ? m : 0) + u);
322
+ return { boxes: g, contentWidth: C, contentHeight: M, widest: k, mode: t };
323
+ }
324
+ function Kn(e, t, n = "y") {
325
+ if (e.length === 0) return 1;
326
+ const r = (u) => n === "y" ? u.top : u.left, s = (u) => n === "y" ? u.height : u.width;
327
+ let i = 0, c = e.length - 1;
328
+ for (; i <= c; ) {
329
+ const u = i + c >> 1, f = e[u], y = r(f), b = y + s(f);
330
+ if (t < y) c = u - 1;
331
+ else if (t >= b) i = u + 1;
332
+ else return f.pageNumber;
333
+ }
334
+ const a = e[Math.min(i, e.length - 1)], l = e[Math.max(c, 0)], d = Math.abs(r(a) - t), m = Math.abs(t - (r(l) + s(l)));
335
+ return d < m ? a.pageNumber : l.pageNumber;
336
+ }
337
+ function Vn(e, t, n = "y", r = "start") {
338
+ const s = e.boxes[t - 1];
339
+ return s ? n === "x" ? r === "center" ? s.left + s.width / 2 : s.left : s.top : 0;
340
+ }
341
+ const Yn = [
342
+ 0.25,
343
+ 0.35,
344
+ 0.5,
345
+ 0.7,
346
+ 0.85,
347
+ 1,
348
+ 1.25,
349
+ 1.5,
350
+ 1.75,
351
+ 2,
352
+ 2.5,
353
+ 3,
354
+ 3.5,
355
+ 4,
356
+ 5,
357
+ 6,
358
+ 8,
359
+ 10,
360
+ 12,
361
+ 16
362
+ ];
363
+ function es(e, t = Yn) {
364
+ if (!(e > 0)) return 1;
365
+ for (const n of t)
366
+ if (n >= e) return n;
367
+ return Math.max(t[t.length - 1], e);
368
+ }
369
+ function Gn(e, t = 3) {
370
+ const n = Math.min(Math.max(e || 1, 1), t), r = [
371
+ 1,
372
+ 1.1,
373
+ 1.25,
374
+ 1.4,
375
+ 1.5,
376
+ 1.6,
377
+ 1.75,
378
+ 2,
379
+ 2.25,
380
+ 2.5,
381
+ 2.75,
382
+ 3
383
+ ];
384
+ let s = r[0], i = Math.abs(r[0] - n);
385
+ for (const c of r) {
386
+ if (c > t) break;
387
+ const a = Math.abs(c - n);
388
+ a < i && (i = a, s = c);
389
+ }
390
+ return Math.abs(s - n) / n > 0.06 ? n : s;
391
+ }
392
+ function Xn(e, t, n, r = {}) {
393
+ const s = r.maxPixels ?? 16777216, i = r.maxDimension ?? 8192, c = Math.max(1, e), a = Math.max(1, t);
394
+ let l = n > 0 ? n : 1;
395
+ const d = Math.min(i / c, i / a), m = Math.sqrt(s / (c * a)), u = Math.min(d, m);
396
+ let f = !1;
397
+ return u < l && (l = u, f = !0), {
398
+ width: Math.max(1, Math.floor(c * l)),
399
+ height: Math.max(1, Math.floor(a * l)),
400
+ scale: l,
401
+ clamped: f
402
+ };
403
+ }
404
+ function Jn(e, t, n) {
405
+ return !(e > 0) || !(t > 0) ? n : e / t * n;
406
+ }
407
+ function Qn(e, t) {
408
+ return Math.max(0, Math.floor(e)) * Math.max(0, Math.floor(t)) * 4;
409
+ }
410
+ function tr(e, t) {
411
+ const n = document.createElement("canvas");
412
+ return n.width = Math.max(1, Math.floor(e)), n.height = Math.max(1, Math.floor(t)), n;
413
+ }
414
+ function er(e) {
415
+ if (e)
416
+ try {
417
+ e.width = 0, e.height = 0;
418
+ } catch {
419
+ }
420
+ }
421
+ class an {
422
+ lru;
423
+ pinned = /* @__PURE__ */ new Set();
424
+ constructor(t) {
425
+ this.lru = t;
426
+ }
427
+ get size() {
428
+ return this.lru.size;
429
+ }
430
+ get byteSize() {
431
+ return this.lru.byteSize;
432
+ }
433
+ get(t) {
434
+ return this.lru.get(t);
435
+ }
436
+ has(t) {
437
+ return this.lru.has(t);
438
+ }
439
+ set(t, n) {
440
+ this.lru.set(t, n);
441
+ }
442
+ pin(t) {
443
+ this.pinned.add(t);
444
+ }
445
+ unpin(t) {
446
+ this.pinned.delete(t);
447
+ }
448
+ isPinned(t) {
449
+ return this.pinned.has(t);
450
+ }
451
+ delete(t) {
452
+ this.pinned.delete(t), this.lru.delete(t);
453
+ }
454
+ clear() {
455
+ this.pinned.clear(), this.lru.clear();
456
+ }
457
+ stats() {
458
+ return this.lru.stats();
459
+ }
460
+ }
461
+ class Bt {
462
+ cache;
463
+ constructor(t = {}) {
464
+ const n = t.onEvict;
465
+ this.cache = new an(
466
+ new Xt({
467
+ name: "bitmap",
468
+ // 默认 96MB:约等于 6 页 A4 @2x,足够覆盖可见区 + 前后各一页
469
+ maxBytes: t.maxBytes ?? 96 * 1024 * 1024,
470
+ sizeOf: (r) => r.bytes,
471
+ onEvict: (r, s, i) => {
472
+ n?.(r), i !== "replace" && er(r.canvas);
473
+ }
474
+ })
475
+ );
476
+ }
477
+ static key(t, n) {
478
+ return `${t}@${n.toFixed(3)}`;
479
+ }
480
+ get(t, n) {
481
+ return this.cache.get(Bt.key(t, n));
482
+ }
483
+ take(t, n) {
484
+ const r = this.get(t, n);
485
+ return r && this.cache.pin(r.key), r;
486
+ }
487
+ release(t) {
488
+ t && this.cache.unpin(t.key);
489
+ }
490
+ put(t, n, r) {
491
+ const s = r.width, i = r.height, c = {
492
+ key: Bt.key(t, n),
493
+ pageNumber: t,
494
+ scale: n,
495
+ canvas: r,
496
+ width: s,
497
+ height: i,
498
+ bytes: Qn(s, i)
499
+ };
500
+ return this.cache.set(c.key, c), c;
501
+ }
502
+ has(t, n) {
503
+ return this.cache.has(Bt.key(t, n));
504
+ }
505
+ /** 丢掉某一页的所有档位(例如页面被移出远区) */
506
+ dropPage(t) {
507
+ for (const n of this.cache.lru.keys()) {
508
+ const r = this.cache.get(n);
509
+ r && r.pageNumber === t && this.cache.delete(n);
510
+ }
511
+ }
512
+ clear() {
513
+ this.cache.clear();
514
+ }
515
+ stats() {
516
+ return this.cache.stats();
517
+ }
518
+ }
519
+ class nr {
520
+ cache;
521
+ constructor(t = {}) {
522
+ this.cache = new an(
523
+ new Xt({
524
+ name: "text",
525
+ maxEntries: t.maxEntries ?? 24,
526
+ maxBytes: t.maxBytes ?? 24 * 1024 * 1024,
527
+ sizeOf: (n) => n.bytes,
528
+ onEvict: (n, r, s) => {
529
+ s !== "replace" && n.destroy();
530
+ }
531
+ })
532
+ );
533
+ }
534
+ get(t) {
535
+ return this.cache.get(t);
536
+ }
537
+ take(t) {
538
+ const n = this.cache.get(t);
539
+ return n && this.cache.pin(t), n;
540
+ }
541
+ release(t) {
542
+ this.cache.unpin(t);
543
+ }
544
+ put(t) {
545
+ this.cache.set(t.pageNumber, t);
546
+ }
547
+ delete(t) {
548
+ this.cache.delete(t);
549
+ }
550
+ clear() {
551
+ this.cache.clear();
552
+ }
553
+ stats() {
554
+ return this.cache.stats();
555
+ }
556
+ }
557
+ class rr {
558
+ cache;
559
+ inflight = /* @__PURE__ */ new Map();
560
+ doc = null;
561
+ constructor(t, n = 48) {
562
+ this.doc = t, this.cache = new Xt({
563
+ name: "page",
564
+ maxEntries: n,
565
+ sizeOf: () => 1
566
+ });
567
+ }
568
+ /** 同步读取(命中即返回,不发起请求) */
569
+ peek(t) {
570
+ return this.cache.get(t);
571
+ }
572
+ async get(t) {
573
+ const n = this.cache.get(t);
574
+ if (n) return n;
575
+ const r = this.inflight.get(t);
576
+ if (r) return r;
577
+ const s = this.doc;
578
+ if (!s) throw new Error("document not ready");
579
+ const i = s.getPage(t).then((c) => (this.cache.set(t, c), this.inflight.delete(t), c));
580
+ return i.catch(() => this.inflight.delete(t)), this.inflight.set(t, i), i;
581
+ }
582
+ clear() {
583
+ this.cache.clear(), this.inflight.clear();
584
+ }
585
+ stats() {
586
+ return this.cache.stats();
587
+ }
588
+ }
589
+ class sr {
590
+ cache;
591
+ constructor(t = 120) {
592
+ this.cache = new Xt({
593
+ name: "thumbnail",
594
+ maxEntries: t,
595
+ sizeOf: (n) => n.bytes
596
+ });
597
+ }
598
+ get(t) {
599
+ return this.cache.get(t);
600
+ }
601
+ put(t, n) {
602
+ this.cache.set(t, { pageNumber: t, dataUrl: n, bytes: n.length * 2 });
603
+ }
604
+ clear() {
605
+ this.cache.clear();
606
+ }
607
+ stats() {
608
+ return this.cache.stats();
609
+ }
610
+ }
611
+ function or(e, t = {}) {
612
+ const n = Math.max(1, t.initialPages ?? 4), [r, s] = B([]), [i, c] = B(0), a = A(null), l = A(/* @__PURE__ */ new Set()), d = A(/* @__PURE__ */ new Set()), m = A(null);
613
+ S(() => {
614
+ if (!e) {
615
+ a.current = null, s([]), c(0);
616
+ return;
617
+ }
618
+ const g = new rr(e, 64);
619
+ a.current = g, l.current.clear(), d.current.clear(), s(new Array(e.numPages).fill(void 0)), c(0);
620
+ const x = jn((k) => {
621
+ s((C) => {
622
+ const M = C.slice();
623
+ for (const { pageNumber: P, metric: D } of k) M[P - 1] = D;
624
+ return M;
625
+ }), c(d.current.size);
626
+ }, 16);
627
+ return m.current = x, () => {
628
+ x.cancel(), m.current = null, a.current = null;
629
+ };
630
+ }, [e]);
631
+ const u = I(async (g) => {
632
+ const x = a.current;
633
+ if (x && !(d.current.has(g) || l.current.has(g))) {
634
+ l.current.add(g);
635
+ try {
636
+ const k = await x.get(g), C = k.getViewport({ scale: 1 });
637
+ d.current.add(g), m.current?.push({
638
+ pageNumber: g,
639
+ metric: {
640
+ pageNumber: g,
641
+ width: C.width / C.userUnit,
642
+ height: C.height / C.userUnit,
643
+ rotate: k.rotate,
644
+ userUnit: C.userUnit
645
+ }
646
+ });
647
+ } catch {
648
+ } finally {
649
+ l.current.delete(g);
650
+ }
651
+ }
652
+ }, []), f = I(
653
+ (g) => {
654
+ u(g);
655
+ },
656
+ [u]
657
+ );
658
+ S(() => {
659
+ if (!e) return;
660
+ let g = !1;
661
+ return (async () => {
662
+ const k = Math.min(n, e.numPages), C = [];
663
+ for (let M = 1; M <= k; M += 1)
664
+ C.push(u(M));
665
+ await Promise.all(C);
666
+ })(), () => {
667
+ g = !0;
668
+ };
669
+ }, [e, n, u]);
670
+ const y = I(async (g) => {
671
+ const x = a.current;
672
+ if (!x) throw new Error("document not ready");
673
+ return x.get(g);
674
+ }, []), b = I((g) => a.current?.peek(g), []);
675
+ return { metrics: r, resolved: i, getPage: y, peekPage: b, ensurePage: f };
676
+ }
677
+ function ir(e, t) {
678
+ const { boxes: n, mode: r, viewportWidth: s, viewportHeight: i } = t, c = t.prefetchScreens ?? 1.2, a = t.mountScreens ?? 2.5, [l, d] = B(() => ({
679
+ mounted: n.slice(0, 3).map((u) => u.pageNumber),
680
+ visible: n.slice(0, 1).map((u) => u.pageNumber),
681
+ prefetch: n.slice(0, 2).map((u) => u.pageNumber),
682
+ current: 1
683
+ })), m = A({ boxes: n, mode: r, viewportWidth: s, viewportHeight: i, prefetchScreens: c, mountScreens: a });
684
+ return m.current = { boxes: n, mode: r, viewportWidth: s, viewportHeight: i, prefetchScreens: c, mountScreens: a }, S(() => {
685
+ const u = e.current;
686
+ if (!u || n.length === 0) return;
687
+ let f = 0, y = "";
688
+ const b = () => {
689
+ f = 0;
690
+ const { boxes: x, mode: k, viewportWidth: C, viewportHeight: M } = m.current;
691
+ if (x.length === 0) return;
692
+ const P = k === "page", D = P ? u.scrollLeft : u.scrollTop, z = P ? C || u.clientWidth : M || u.clientHeight, $ = D, W = D + z, O = [], _ = [], K = [], Z = z * m.current.prefetchScreens, N = z * m.current.mountScreens;
693
+ for (const T of x) {
694
+ const E = P ? T.left : T.top, V = E + (P ? T.width : T.height);
695
+ V > $ && E < W && O.push(T.pageNumber), V > $ - Z && E < W + Z && _.push(T.pageNumber), V > $ - N && E < W + N && K.push(T.pageNumber);
696
+ }
697
+ if (K.length === 0) {
698
+ const T = Math.max(1, Math.round(D / Math.max(1, z)) + 1);
699
+ for (let E = T; E < T + 3 && E <= x.length; E += 1) K.push(E);
700
+ }
701
+ O.length === 0 && O.push(K[0] ?? 1), _.length === 0 && _.push(...K);
702
+ const F = P ? O[0] : (() => {
703
+ const T = ($ + W) / 2;
704
+ let E = O[0], V = Number.POSITIVE_INFINITY;
705
+ for (const X of O) {
706
+ const J = x[X - 1];
707
+ if (!J) continue;
708
+ const lt = J.top + J.height / 2, ut = Math.abs(lt - T);
709
+ ut < V && (V = ut, E = X);
710
+ }
711
+ return E;
712
+ })(), w = `${K.join(",")}|${O.join(",")}|${F}`;
713
+ w !== y && (y = w, d({ mounted: K, visible: O, prefetch: _, current: F }));
714
+ }, g = () => {
715
+ f || (f = requestAnimationFrame(b));
716
+ };
717
+ return b(), u.addEventListener("scroll", g, { passive: !0 }), globalThis.window.addEventListener("resize", g), () => {
718
+ f && cancelAnimationFrame(f), u.removeEventListener("scroll", g), globalThis.window.removeEventListener("resize", g);
719
+ };
720
+ }, [e, n]), l;
721
+ }
722
+ const Mt = {
723
+ scrollEvents: 0,
724
+ scrollHandled: 0,
725
+ sizeEvents: 0,
726
+ sizeHandled: 0,
727
+ gestureEvents: 0,
728
+ gestureHandled: 0
729
+ };
730
+ function we(e) {
731
+ e === "scroll" ? Mt.scrollEvents += 1 : e === "size" ? Mt.sizeEvents += 1 : Mt.gestureEvents += 1;
732
+ }
733
+ function ve(e) {
734
+ e === "scroll" ? Mt.scrollHandled += 1 : e === "size" ? Mt.sizeHandled += 1 : Mt.gestureHandled += 1;
735
+ }
736
+ function cr() {
737
+ return { ...Mt };
738
+ }
739
+ function ar() {
740
+ const [e, t] = B(null), [n, r] = B({ width: 0, height: 0 }), s = A(0), i = I((c) => t(c), []);
741
+ return S(() => {
742
+ if (!e) return;
743
+ const c = (d, m) => {
744
+ r((u) => u.width === d && u.height === m ? u : { width: d, height: m });
745
+ }, a = () => c(e.clientWidth, e.clientHeight);
746
+ if (a(), typeof ResizeObserver > "u") {
747
+ const d = () => {
748
+ we("size"), a(), ve("size");
749
+ };
750
+ return window.addEventListener("resize", d), () => window.removeEventListener("resize", d);
751
+ }
752
+ const l = new ResizeObserver((d) => {
753
+ const m = d[d.length - 1];
754
+ if (!m) return;
755
+ const { width: u, height: f } = m.contentRect;
756
+ we("size"), !s.current && (s.current = requestAnimationFrame(() => {
757
+ s.current = 0, ve("size"), c(Math.round(u), Math.round(f));
758
+ }));
759
+ });
760
+ return l.observe(e), () => {
761
+ s.current && cancelAnimationFrame(s.current), s.current = 0, l.disconnect();
762
+ };
763
+ }, [e]), { ref: i, width: n.width, height: n.height };
764
+ }
765
+ function lr(e, t, n, r) {
766
+ const s = e.x - n.left + n.scrollLeft, i = e.y - n.top + n.scrollTop, c = t.x - n.left, a = t.y - n.top;
767
+ return {
768
+ k: r,
769
+ tx: c + n.scrollLeft - r * s,
770
+ ty: a + n.scrollTop - r * i
771
+ };
772
+ }
773
+ function Vt(e, t, n, r, s) {
774
+ const i = it(s.baseZoom * r, s.minZoom, s.maxZoom), c = i / s.baseZoom, a = e.x - n.left + n.scrollLeft, l = e.y - n.top + n.scrollTop, d = t.x - n.left, m = t.y - n.top;
775
+ return {
776
+ zoom: i,
777
+ scrollLeft: it(a * c - d, 0, Math.max(0, s.maxScrollLeft)),
778
+ scrollTop: it(l * c - m, 0, Math.max(0, s.maxScrollTop))
779
+ };
780
+ }
781
+ function ur(e, t) {
782
+ const n = it(t.targetZoom, t.minZoom, t.maxZoom);
783
+ return e > n * 0.98 ? 1 : n;
784
+ }
785
+ function ns(e, t, n, r) {
786
+ return Vt(e, e, t, n, r);
787
+ }
788
+ function it(e, t, n) {
789
+ return Number.isNaN(e) ? t : Math.min(n, Math.max(t, e));
790
+ }
791
+ function Ye(e, t) {
792
+ return { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 };
793
+ }
794
+ function hr(e) {
795
+ const { scrollRef: t, contentRef: n, enabled: r } = e, [s, i] = B(!1), [c, a] = B(null), l = A(e);
796
+ l.current = e;
797
+ const d = A(e.zoom);
798
+ return d.current = e.zoom, S(() => {
799
+ const m = t.current;
800
+ if (!m || !r) return;
801
+ const u = /* @__PURE__ */ new Map();
802
+ let f = 0, y = { left: 0, top: 0, scrollLeft: 0, scrollTop: 0 }, b = { x: 0, y: 0 }, g = !1, x = 0, k = null, C = 1, M = 0, P = { x: 0, y: 0 };
803
+ const D = () => {
804
+ if (x = 0, !g || !k) return;
805
+ const w = lr(b, k, y, C), T = n.current;
806
+ T && (T.style.transformOrigin = "0 0", T.style.transform = `translate3d(${w.tx}px, ${w.ty}px, 0) scale(${w.k})`, T.style.willChange = "transform"), a(w);
807
+ }, z = (w, T) => {
808
+ k = w, C = T, !x && (x = requestAnimationFrame(D));
809
+ }, $ = () => {
810
+ const w = n.current;
811
+ w && (w.style.transform = "", w.style.transformOrigin = "", w.style.willChange = ""), a(null);
812
+ }, W = () => {
813
+ if (g) return;
814
+ g = !0, i(!0), l.current.onGestureStart?.();
815
+ const w = m.getBoundingClientRect();
816
+ y = {
817
+ left: w.left,
818
+ top: w.top,
819
+ scrollLeft: m.scrollLeft,
820
+ scrollTop: m.scrollTop
821
+ }, m.style.overflowAnchor = "none";
822
+ }, O = (w) => {
823
+ if (!g || (g = !1, i(!1), $(), m.style.overflowAnchor = "", l.current.onGestureEnd?.(), !w || k === null)) return;
824
+ const T = C;
825
+ if (Math.abs(T - 1) < 0.01) return;
826
+ const { left: E, top: V } = l.current.maxScroll(), X = Vt(b, k, y, T, {
827
+ minZoom: l.current.minZoom,
828
+ maxZoom: l.current.maxZoom,
829
+ baseZoom: d.current,
830
+ maxScrollLeft: E,
831
+ maxScrollTop: V
832
+ });
833
+ l.current.onCommit(X.zoom, X.scrollLeft, X.scrollTop), k = null, C = 1;
834
+ }, _ = (w) => {
835
+ if (!(w.pointerType === "mouse" && w.button !== 0)) {
836
+ if (u.set(w.pointerId, { x: w.clientX, y: w.clientY }), u.size === 2) {
837
+ const [T, E] = [...u.values()];
838
+ f = Math.hypot(T.x - E.x, T.y - E.y), b = Ye(T, E), k = b, C = 1, W();
839
+ return;
840
+ }
841
+ if (u.size === 1 && w.pointerType !== "mouse") {
842
+ const T = Date.now(), E = { x: w.clientX, y: w.clientY }, V = T - M < 300 && Math.hypot(E.x - P.x, E.y - P.y) < 30;
843
+ if (M = T, P = E, V) {
844
+ M = 0;
845
+ const X = m.getBoundingClientRect(), J = {
846
+ left: X.left,
847
+ top: X.top,
848
+ scrollLeft: m.scrollLeft,
849
+ scrollTop: m.scrollTop
850
+ }, lt = ur(d.current, {
851
+ targetZoom: l.current.doubleTapZoom,
852
+ minZoom: l.current.minZoom,
853
+ maxZoom: l.current.maxZoom
854
+ }), { left: ut, top: It } = l.current.maxScroll(), yt = Vt(E, E, J, lt / d.current, {
855
+ minZoom: l.current.minZoom,
856
+ maxZoom: l.current.maxZoom,
857
+ baseZoom: d.current,
858
+ maxScrollLeft: ut,
859
+ maxScrollTop: It
860
+ });
861
+ l.current.onDoubleTap ? l.current.onDoubleTap(yt.zoom, yt.scrollLeft, yt.scrollTop) : l.current.onCommit(yt.zoom, yt.scrollLeft, yt.scrollTop);
862
+ }
863
+ }
864
+ }
865
+ }, K = (w) => {
866
+ if (!u.has(w.pointerId) || (u.set(w.pointerId, { x: w.clientX, y: w.clientY }), u.size !== 2 || !g)) return;
867
+ const [T, E] = [...u.values()], V = Math.hypot(T.x - E.x, T.y - E.y), X = Ye(T, E);
868
+ if (f <= 0) return;
869
+ const J = it(V / f, 0.2, 8);
870
+ z(X, J), w.cancelable && w.preventDefault();
871
+ }, Z = (w) => {
872
+ u.delete(w.pointerId), u.size < 2 && g && O(!0), u.size === 0 && (k = null);
873
+ }, N = (w) => {
874
+ u.delete(w.pointerId), u.size < 2 && g && O(!1);
875
+ }, F = (w) => {
876
+ if (!w.ctrlKey && !w.metaKey) return;
877
+ w.preventDefault();
878
+ const T = m.getBoundingClientRect(), E = {
879
+ left: T.left,
880
+ top: T.top,
881
+ scrollLeft: m.scrollLeft,
882
+ scrollTop: m.scrollTop
883
+ }, V = Math.exp(-w.deltaY / 200), { left: X, top: J } = l.current.maxScroll(), lt = Vt(
884
+ { x: w.clientX, y: w.clientY },
885
+ { x: w.clientX, y: w.clientY },
886
+ E,
887
+ V,
888
+ {
889
+ minZoom: l.current.minZoom,
890
+ maxZoom: l.current.maxZoom,
891
+ baseZoom: d.current,
892
+ maxScrollLeft: X,
893
+ maxScrollTop: J
894
+ }
895
+ );
896
+ l.current.onCommit(lt.zoom, lt.scrollLeft, lt.scrollTop);
897
+ };
898
+ return m.addEventListener("pointerdown", _, { passive: !0 }), m.addEventListener("pointermove", K, { passive: !1 }), m.addEventListener("pointerup", Z, { passive: !0 }), m.addEventListener("pointercancel", N, { passive: !0 }), m.addEventListener("wheel", F, { passive: !1 }), () => {
899
+ x && cancelAnimationFrame(x), m.removeEventListener("pointerdown", _), m.removeEventListener("pointermove", K), m.removeEventListener("pointerup", Z), m.removeEventListener("pointercancel", N), m.removeEventListener("wheel", F), $();
900
+ };
901
+ }, [t, n, r]), { active: s, preview: c };
902
+ }
903
+ class gt extends Error {
904
+ name = "RenderCancelledError";
905
+ constructor(t = "render cancelled") {
906
+ super(t);
907
+ }
908
+ }
909
+ function dr(e) {
910
+ if (e instanceof gt) return !0;
911
+ if (!e || typeof e != "object") return !1;
912
+ const t = e.name;
913
+ return t === "RenderingCancelledException" || t === "AbortException" || t === "RenderCancelledError";
914
+ }
915
+ function fr() {
916
+ let e, t;
917
+ const n = new Promise((r, s) => {
918
+ e = r, t = s;
919
+ });
920
+ return n.catch(() => {
921
+ }), { promise: n, resolve: e, reject: t };
922
+ }
923
+ class ln {
924
+ jobs = [];
925
+ running = /* @__PURE__ */ new Map();
926
+ visibleRunning = 0;
927
+ prefetchRunning = 0;
928
+ visibleConcurrency;
929
+ prefetchConcurrency;
930
+ yieldDelay;
931
+ pumping = !1;
932
+ stats = { started: 0, completed: 0, cancelled: 0 };
933
+ constructor(t = {}) {
934
+ this.visibleConcurrency = Math.max(1, t.visibleConcurrency ?? 2), this.prefetchConcurrency = Math.max(0, t.prefetchConcurrency ?? 1), this.yieldDelay = t.yieldDelay ?? 0;
935
+ }
936
+ /** 提交任务;同 key 已在排队或执行中则复用其 Promise(引用计数 +1) */
937
+ enqueue(t, n, r) {
938
+ const s = this.running.get(t);
939
+ if (s)
940
+ return s.refs += 1, s.deferred.promise;
941
+ const i = this.jobs.find((a) => a.key === t);
942
+ if (i)
943
+ return i.refs += 1, n === "visible" && i.priority !== 0 && (i.priority = 0, this.pump()), i.deferred.promise;
944
+ const c = {
945
+ key: t,
946
+ priority: n === "visible" ? 0 : 1,
947
+ run: r,
948
+ deferred: fr(),
949
+ abort: new AbortController(),
950
+ refs: 1
951
+ };
952
+ return this.jobs.push(c), this.pump(), c.deferred.promise;
953
+ }
954
+ /**
955
+ * 归还一次使用权(引用计数 -1),归零时才真正取消。
956
+ *
957
+ * 为什么不能直接 cancel:任务在多个调用方之间共享(同一 page@scale 可能被
958
+ * 可见区与预取区同时需要;React 严格模式下 effect 也会挂载两次)。
959
+ * 「谁先卸载谁就 cancel」会把别人仍需的任务杀掉 —— 表现为页面一直空白:
960
+ * 任务被 abort → Promise reject → 没有重试者。
961
+ */
962
+ release(t, n = new Error("released")) {
963
+ const r = this.jobs.find((i) => i.key === t);
964
+ if (r) {
965
+ r.refs -= 1, r.refs <= 0 && this.cancel(t, n);
966
+ return;
967
+ }
968
+ const s = this.running.get(t);
969
+ s && (s.refs -= 1, s.refs <= 0 && (s.abort.abort(n), this.stats.cancelled += 1));
970
+ }
971
+ /** 取消某个 key(排队中直接丢弃,执行中触发 abort) */
972
+ cancel(t, n = new Error("cancelled")) {
973
+ const r = this.jobs.findIndex((i) => i.key === t);
974
+ if (r >= 0) {
975
+ const [i] = this.jobs.splice(r, 1);
976
+ i.abort.abort(n), i.deferred.reject(n), this.stats.cancelled += 1;
977
+ return;
978
+ }
979
+ const s = this.running.get(t);
980
+ s && (s.abort.abort(n), this.stats.cancelled += 1);
981
+ }
982
+ /** 丢弃所有未开始的预取任务,返回丢弃数量 */
983
+ dropPendingPrefetch(t = () => !1) {
984
+ let n = 0;
985
+ for (let r = this.jobs.length - 1; r >= 0; r -= 1) {
986
+ const s = this.jobs[r];
987
+ if (s.priority > 0 && !t(s.key)) {
988
+ this.jobs.splice(r, 1);
989
+ const i = new Error("preempted");
990
+ s.abort.abort(i), s.deferred.reject(i), n += 1;
991
+ }
992
+ }
993
+ return n;
994
+ }
995
+ get pending() {
996
+ return this.jobs.length;
997
+ }
998
+ get active() {
999
+ return this.running.size;
1000
+ }
1001
+ getStats() {
1002
+ return { ...this.stats };
1003
+ }
1004
+ cancelAll(t = new Error("cancelled all")) {
1005
+ const n = this.jobs;
1006
+ this.jobs = [];
1007
+ for (const r of n)
1008
+ r.abort.abort(t), r.deferred.reject(t);
1009
+ for (const r of this.running.values()) r.abort.abort(t);
1010
+ }
1011
+ canStart(t) {
1012
+ return t === 0 ? this.visibleRunning < this.visibleConcurrency : this.prefetchRunning < this.prefetchConcurrency;
1013
+ }
1014
+ pump() {
1015
+ if (!this.pumping) {
1016
+ this.pumping = !0;
1017
+ try {
1018
+ this.jobs.sort((t, n) => t.priority - n.priority);
1019
+ for (let t = 0; t < this.jobs.length; ) {
1020
+ const n = this.jobs[t];
1021
+ if (!this.canStart(n.priority)) {
1022
+ t += 1;
1023
+ continue;
1024
+ }
1025
+ this.jobs.splice(t, 1), this.start(n);
1026
+ }
1027
+ } finally {
1028
+ this.pumping = !1;
1029
+ }
1030
+ }
1031
+ }
1032
+ start(t) {
1033
+ this.running.set(t.key, t), t.priority === 0 ? this.visibleRunning += 1 : this.prefetchRunning += 1, this.stats.started += 1;
1034
+ const n = () => {
1035
+ this.running.delete(t.key), t.priority === 0 ? this.visibleRunning = Math.max(0, this.visibleRunning - 1) : this.prefetchRunning = Math.max(0, this.prefetchRunning - 1), this.yieldDelay > 0 ? setTimeout(() => this.pump(), this.yieldDelay) : queueMicrotask(() => this.pump());
1036
+ };
1037
+ t.run(t.abort.signal).then((r) => {
1038
+ n(), this.stats.completed += 1, t.deferred.resolve(r);
1039
+ }).catch((r) => {
1040
+ n(), dr(r) && (this.stats.cancelled += 1), t.deferred.reject(r);
1041
+ });
1042
+ }
1043
+ }
1044
+ function mr(e) {
1045
+ const t = new Array(e.pageCount);
1046
+ for (let n = 0; n < e.pageCount; n += 1) t[n] = e.metrics[n];
1047
+ return _n({
1048
+ mode: e.mode,
1049
+ metrics: t,
1050
+ fallback: e.fallback,
1051
+ scale: e.scale,
1052
+ zoom: e.zoom,
1053
+ containerWidth: e.containerWidth,
1054
+ containerHeight: e.containerHeight,
1055
+ gap: e.gap,
1056
+ padding: e.padding,
1057
+ rotation: e.rotation,
1058
+ fitMode: e.fitMode
1059
+ });
1060
+ }
1061
+ function pr(e) {
1062
+ let t = 0, n = 0, r = 0;
1063
+ for (const s of e)
1064
+ s && (t += s.width, n += s.height, r += 1);
1065
+ return r === 0 ? { width: 595.28, height: 841.89 } : { width: t / r, height: n / r };
1066
+ }
1067
+ function gr({
1068
+ page: e,
1069
+ pageNumber: t,
1070
+ width: n,
1071
+ height: r,
1072
+ displayScale: s,
1073
+ devicePixelRatio: i,
1074
+ rotation: c,
1075
+ bitmapCache: a,
1076
+ renderQueue: l,
1077
+ priority: d,
1078
+ shouldRender: m,
1079
+ maxCanvasPixels: u,
1080
+ maxCanvasDimension: f,
1081
+ onRendered: y
1082
+ }) {
1083
+ const b = A(null), g = A(y);
1084
+ g.current = y;
1085
+ const x = A(""), k = A(0);
1086
+ return S(() => {
1087
+ const C = b.current;
1088
+ if (!C) return;
1089
+ const M = Gn(i), P = Xn(n, r, M, {
1090
+ maxPixels: u,
1091
+ maxDimension: f
1092
+ }), D = n / (s || 1), z = Jn(n, D, P.scale), $ = document.createElement("canvas");
1093
+ P.width > 0 && P.height > 0 && ($.width = P.width, $.height = P.height), $.style.width = "100%", $.style.height = "100%", $.style.display = "block", C.replaceChildren($), C.removeAttribute("data-painted");
1094
+ const W = (T, E, V, X) => {
1095
+ $.width !== E && ($.width = E), $.height !== V && ($.height = V);
1096
+ const J = $.getContext("2d");
1097
+ J && (J.clearRect(0, 0, E, V), J.drawImage(T, 0, 0, E, V), x.current = X, C.setAttribute("data-painted", "1"));
1098
+ }, O = a.get(t, z);
1099
+ if (O) {
1100
+ W(O.canvas, O.width, O.height, `cached:${O.scale}`);
1101
+ return;
1102
+ }
1103
+ if (!e || !m || n <= 0 || r <= 0) return;
1104
+ const _ = `${t}@${z.toFixed(3)}`, K = a.get(t, z);
1105
+ if (K) {
1106
+ W(K.canvas, K.width, K.height, _);
1107
+ return;
1108
+ }
1109
+ let Z = !1, N = null;
1110
+ const F = e.getViewport({ scale: z, rotation: e.rotate + c }), w = () => {
1111
+ if (Z) return;
1112
+ const T = tr(P.width, P.height);
1113
+ l.enqueue(_, d, async (E) => {
1114
+ if (E.aborted) throw new gt();
1115
+ const V = e.render({ canvas: T, canvasContext: T.getContext("2d"), viewport: F }), X = () => V.cancel();
1116
+ E.addEventListener("abort", X, { once: !0 });
1117
+ try {
1118
+ await V.promise;
1119
+ } catch (J) {
1120
+ throw E.aborted ? new gt() : J;
1121
+ } finally {
1122
+ E.removeEventListener("abort", X);
1123
+ }
1124
+ return { canvas: T, width: P.width, height: P.height };
1125
+ }).then((E) => {
1126
+ a.put(t, z, E.canvas), !Z && (W(E.canvas, E.width, E.height, _), g.current?.(t));
1127
+ }).catch((E) => {
1128
+ Z || E instanceof gt && k.current < 4 && (k.current += 1, N = setTimeout(w, 60));
1129
+ });
1130
+ };
1131
+ return w(), () => {
1132
+ Z = !0, N && clearTimeout(N), C.removeAttribute("data-painted");
1133
+ };
1134
+ }, [
1135
+ e,
1136
+ t,
1137
+ n,
1138
+ r,
1139
+ s,
1140
+ i,
1141
+ c,
1142
+ a,
1143
+ l,
1144
+ d,
1145
+ m,
1146
+ u,
1147
+ f
1148
+ ]), /* @__PURE__ */ p("div", { ref: b, className: "pdfh5-canvas", style: { width: n, height: r }, "aria-hidden": "true" });
1149
+ }
1150
+ function yr({
1151
+ page: e,
1152
+ pageNumber: t,
1153
+ width: n,
1154
+ height: r,
1155
+ displayScale: s,
1156
+ rotation: i,
1157
+ textLayerCache: c,
1158
+ renderQueue: a,
1159
+ enabled: l,
1160
+ shouldBuild: d
1161
+ }) {
1162
+ const m = A(null), u = e ? e.getViewport({ scale: s, rotation: e.rotate + i }).scale : s, f = e?.userUnit ?? 1;
1163
+ return S(() => {
1164
+ const y = m.current;
1165
+ if (!y) return;
1166
+ y.style.setProperty("--scale-factor", String(u)), f !== 1 ? y.style.setProperty("--user-unit", String(f)) : y.style.removeProperty("--user-unit");
1167
+ const b = c.get(t);
1168
+ if (b && e && Math.abs(b.scale - s) > 1e-3) {
1169
+ const g = e.getViewport({ scale: s, rotation: e.rotate + i });
1170
+ b.update(g), b.scale = s, b.viewportScale = g.scale;
1171
+ }
1172
+ }, [u, f, e, t, s, i, c]), S(() => {
1173
+ const y = m.current;
1174
+ if (!y || (y.replaceChildren(), !l)) return;
1175
+ const b = c.get(t);
1176
+ if (b)
1177
+ return y.appendChild(b.node), () => {
1178
+ b.node.parentNode === y && y.removeChild(b.node);
1179
+ };
1180
+ if (!e || !d || n <= 0 || r <= 0) return;
1181
+ let g = !1;
1182
+ const x = e.getViewport({ scale: s, rotation: e.rotate + i }), k = `text:${t}@${s.toFixed(3)}`;
1183
+ return a.enqueue(k, "prefetch", async (C) => {
1184
+ if (C.aborted) throw new gt();
1185
+ const M = document.createElement("div");
1186
+ M.className = "textLayer";
1187
+ const P = new Ht.TextLayer({
1188
+ textContentSource: e.streamTextContent({ includeMarkedContent: !0 }),
1189
+ container: M,
1190
+ viewport: x
1191
+ });
1192
+ if (await P.render(), C.aborted) throw new gt();
1193
+ return { container: M, textLayer: P };
1194
+ }).then(({ container: C, textLayer: M }) => {
1195
+ if (g) {
1196
+ try {
1197
+ M.cancel();
1198
+ } catch {
1199
+ }
1200
+ return;
1201
+ }
1202
+ const P = {
1203
+ pageNumber: t,
1204
+ node: C,
1205
+ scale: s,
1206
+ viewportScale: x.scale,
1207
+ bytes: M.textDivs.length * 220,
1208
+ update: (D) => M.update({ viewport: D }),
1209
+ destroy: () => {
1210
+ try {
1211
+ M.cancel();
1212
+ } catch {
1213
+ }
1214
+ C.replaceChildren();
1215
+ }
1216
+ };
1217
+ c.put(P), y.appendChild(C);
1218
+ }).catch(() => {
1219
+ }), () => {
1220
+ g = !0, a.release(k, new gt());
1221
+ };
1222
+ }, [e, t, n, r, s, i, c, a, l, d]), /* @__PURE__ */ p("div", { ref: m, className: "pdfh5-textLayerHost", style: { width: n, height: r } });
1223
+ }
1224
+ function br({
1225
+ page: e,
1226
+ pageNumber: t,
1227
+ width: n,
1228
+ height: r,
1229
+ displayScale: s,
1230
+ rotation: i,
1231
+ enabled: c,
1232
+ onInternalLink: a,
1233
+ onExternalLink: l
1234
+ }) {
1235
+ const [d, m] = B([]), u = A(!0);
1236
+ return S(() => (u.current = !0, () => {
1237
+ u.current = !1;
1238
+ }), []), S(() => {
1239
+ if (!e || !c) {
1240
+ m([]);
1241
+ return;
1242
+ }
1243
+ let f = !1;
1244
+ return e.getAnnotations({ intent: "display" }).then((y) => {
1245
+ if (f || !u.current) return;
1246
+ const b = e.getViewport({ scale: s, rotation: e.rotate + i }), g = [];
1247
+ y.forEach((x, k) => {
1248
+ if (x.subtype !== "Link") return;
1249
+ const C = x.rect;
1250
+ if (!C) return;
1251
+ const [M, P, D, z] = wr(b, C), $ = Math.min(M, D), W = Math.min(P, z);
1252
+ g.push({
1253
+ key: `${t}-${k}`,
1254
+ left: $,
1255
+ top: W,
1256
+ width: Math.abs(D - M),
1257
+ height: Math.abs(z - P),
1258
+ url: typeof x.url == "string" ? x.url : void 0,
1259
+ dest: x.dest ?? null,
1260
+ title: x.title || x.url || "链接"
1261
+ });
1262
+ }), m(g);
1263
+ }).catch(() => {
1264
+ f || m([]);
1265
+ }), () => {
1266
+ f = !0;
1267
+ };
1268
+ }, [e, t, s, i, c, n, r]), !c || d.length === 0 ? null : /* @__PURE__ */ p("div", { className: "pdfh5-linkLayer", style: { width: n, height: r }, children: d.map(
1269
+ (f) => f.url ? /* @__PURE__ */ p(
1270
+ "a",
1271
+ {
1272
+ className: "pdfh5-link",
1273
+ style: { left: f.left, top: f.top, width: f.width, height: f.height },
1274
+ href: f.url,
1275
+ target: "_blank",
1276
+ rel: "noreferrer noopener",
1277
+ onClick: (y) => {
1278
+ l && (y.preventDefault(), l(f.url));
1279
+ },
1280
+ title: f.title
1281
+ },
1282
+ f.key
1283
+ ) : /* @__PURE__ */ p(
1284
+ "button",
1285
+ {
1286
+ type: "button",
1287
+ className: "pdfh5-link",
1288
+ style: { left: f.left, top: f.top, width: f.width, height: f.height },
1289
+ onClick: () => a?.(f.dest ?? null),
1290
+ title: f.title
1291
+ },
1292
+ f.key
1293
+ )
1294
+ ) });
1295
+ }
1296
+ function wr(e, t) {
1297
+ const n = e.convertToViewportPoint(t[0], t[1]), r = e.convertToViewportPoint(t[2], t[3]);
1298
+ return [n[0], n[1], r[0], r[1]];
1299
+ }
1300
+ function vr({
1301
+ mode: e,
1302
+ page: t,
1303
+ total: n,
1304
+ zoom: r,
1305
+ minZoom: s,
1306
+ maxZoom: i,
1307
+ panel: c,
1308
+ panelSupported: a,
1309
+ annotation: l = !1,
1310
+ annotationMode: d = "none",
1311
+ annotationCount: m = 0,
1312
+ onPrev: u,
1313
+ onNext: f,
1314
+ onJump: y,
1315
+ onZoomIn: b,
1316
+ onZoomOut: g,
1317
+ onResetZoom: x,
1318
+ onTogglePanel: k,
1319
+ onLocate: C,
1320
+ onToggleAnnotation: M,
1321
+ onClearAnnotations: P
1322
+ }) {
1323
+ const [D, z] = B(String(t)), [$, W] = B(!1), [O, _] = B(!1);
1324
+ S(() => {
1325
+ $ || z(String(t));
1326
+ }, [t, $]), S(() => {
1327
+ _(!1);
1328
+ }, [d]);
1329
+ const K = () => {
1330
+ const Z = Number.parseInt(D, 10);
1331
+ Number.isFinite(Z) && Z >= 1 && Z <= n ? y(Z) : z(String(t)), W(!1);
1332
+ };
1333
+ return /* @__PURE__ */ L("nav", { className: "pdfh5-toolbar", "aria-label": "阅读器工具栏", children: [
1334
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-icon-btn", onClick: u, disabled: t <= 1, "aria-label": "上一页", children: "‹" }),
1335
+ /* @__PURE__ */ L("div", { className: "pdfh5-page-jump", children: [
1336
+ /* @__PURE__ */ p(
1337
+ "input",
1338
+ {
1339
+ className: "pdfh5-page-input",
1340
+ value: D,
1341
+ inputMode: "numeric",
1342
+ pattern: "[0-9]*",
1343
+ "aria-label": "页码",
1344
+ onFocus: (Z) => {
1345
+ W(!0), Z.currentTarget.select();
1346
+ },
1347
+ onChange: (Z) => z(Z.target.value.replace(/[^\d]/g, "")),
1348
+ onBlur: K,
1349
+ onKeyDown: (Z) => {
1350
+ Z.key === "Enter" && Z.currentTarget.blur();
1351
+ }
1352
+ }
1353
+ ),
1354
+ /* @__PURE__ */ L("span", { className: "pdfh5-page-total", children: [
1355
+ "/ ",
1356
+ n
1357
+ ] })
1358
+ ] }),
1359
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-icon-btn", onClick: f, disabled: t >= n, "aria-label": "下一页", children: "›" }),
1360
+ /* @__PURE__ */ p("span", { className: "pdfh5-divider", "aria-hidden": "true" }),
1361
+ /* @__PURE__ */ p(
1362
+ "button",
1363
+ {
1364
+ type: "button",
1365
+ className: "pdfh5-icon-btn",
1366
+ onClick: g,
1367
+ disabled: r <= s + 1e-3,
1368
+ "aria-label": "缩小",
1369
+ children: "−"
1370
+ }
1371
+ ),
1372
+ /* @__PURE__ */ L("button", { type: "button", className: "pdfh5-zoom-label", onClick: x, "aria-label": "恢复适配大小", children: [
1373
+ Math.round(r * 100),
1374
+ "%"
1375
+ ] }),
1376
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-icon-btn", onClick: b, disabled: r >= i - 1e-3, "aria-label": "放大", children: "+" }),
1377
+ /* @__PURE__ */ p("span", { className: "pdfh5-divider", "aria-hidden": "true" }),
1378
+ /* @__PURE__ */ p(
1379
+ "button",
1380
+ {
1381
+ type: "button",
1382
+ className: `pdfh5-icon-btn ${c === "outline" ? "is-active" : ""}`,
1383
+ onClick: () => k(c === "outline" ? null : "outline"),
1384
+ disabled: !a.outline,
1385
+ "aria-label": "目录",
1386
+ "aria-pressed": c === "outline",
1387
+ children: "☰"
1388
+ }
1389
+ ),
1390
+ /* @__PURE__ */ p(
1391
+ "button",
1392
+ {
1393
+ type: "button",
1394
+ className: `pdfh5-icon-btn ${c === "thumbnails" ? "is-active" : ""}`,
1395
+ onClick: () => k(c === "thumbnails" ? null : "thumbnails"),
1396
+ disabled: !a.thumbnails,
1397
+ "aria-label": "缩略图",
1398
+ "aria-pressed": c === "thumbnails",
1399
+ children: "▦"
1400
+ }
1401
+ ),
1402
+ /* @__PURE__ */ p(
1403
+ "button",
1404
+ {
1405
+ type: "button",
1406
+ className: `pdfh5-icon-btn ${c === "search" ? "is-active" : ""}`,
1407
+ onClick: () => k(c === "search" ? null : "search"),
1408
+ "aria-label": "搜索",
1409
+ "aria-pressed": c === "search",
1410
+ children: "⌕"
1411
+ }
1412
+ ),
1413
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-icon-btn", onClick: C, "aria-label": "回到适配大小", children: "⤢" }),
1414
+ l ? /* @__PURE__ */ L("div", { className: "pdfh5-anno-menu-wrap", children: [
1415
+ /* @__PURE__ */ L(
1416
+ "button",
1417
+ {
1418
+ type: "button",
1419
+ className: `pdfh5-icon-btn ${d !== "none" ? "is-active" : ""}`,
1420
+ onClick: () => {
1421
+ if (d !== "none") {
1422
+ M?.("highlight"), _(!1);
1423
+ return;
1424
+ }
1425
+ _((Z) => !Z);
1426
+ },
1427
+ "aria-label": "批注",
1428
+ "aria-pressed": d !== "none",
1429
+ "aria-expanded": O,
1430
+ children: [
1431
+ "✎",
1432
+ m > 0 ? /* @__PURE__ */ p("span", { className: "pdfh5-anno-badge", children: m }) : null
1433
+ ]
1434
+ }
1435
+ ),
1436
+ O && d === "none" ? /* @__PURE__ */ L("div", { className: "pdfh5-anno-menu", role: "menu", children: [
1437
+ /* @__PURE__ */ L("button", { type: "button", role: "menuitem", onClick: () => M?.("highlight"), children: [
1438
+ /* @__PURE__ */ p("span", { className: "pdfh5-anno-swatch", style: { background: "var(--pdfh5-anno-hl, #ffd400)" } }),
1439
+ "高亮"
1440
+ ] }),
1441
+ /* @__PURE__ */ L("button", { type: "button", role: "menuitem", onClick: () => M?.("freetext"), children: [
1442
+ /* @__PURE__ */ p("span", { className: "pdfh5-anno-swatch pdfh5-anno-swatch-text", children: "A" }),
1443
+ "文字批注"
1444
+ ] }),
1445
+ /* @__PURE__ */ L("button", { type: "button", role: "menuitem", onClick: () => M?.("ink"), children: [
1446
+ /* @__PURE__ */ p("span", { className: "pdfh5-anno-swatch", style: { background: "var(--pdfh5-anno-ink, #e5484d)" } }),
1447
+ "手写"
1448
+ ] }),
1449
+ m > 0 ? /* @__PURE__ */ p(
1450
+ "button",
1451
+ {
1452
+ type: "button",
1453
+ role: "menuitem",
1454
+ className: "pdfh5-anno-menu-danger",
1455
+ onClick: () => {
1456
+ P?.(), _(!1);
1457
+ },
1458
+ children: "清空全部批注"
1459
+ }
1460
+ ) : null
1461
+ ] }) : null
1462
+ ] }) : null,
1463
+ /* @__PURE__ */ p("span", { className: "pdfh5-mode-tag", "aria-hidden": "true", children: e === "page" ? "翻页" : "滚动" })
1464
+ ] });
1465
+ }
1466
+ async function xr(e) {
1467
+ let t;
1468
+ try {
1469
+ t = await e.getOutline();
1470
+ } catch {
1471
+ return [];
1472
+ }
1473
+ if (!t || t.length === 0) return [];
1474
+ const n = [];
1475
+ let r = 0;
1476
+ const s = async (c) => {
1477
+ try {
1478
+ let a = c;
1479
+ if (typeof a == "string" && (a = await e.getDestination(a)), !Array.isArray(a) || a.length === 0) return null;
1480
+ const l = a[0];
1481
+ if (typeof l == "number") return l + 1;
1482
+ if (l && typeof l == "object" && "num" in l)
1483
+ return await e.getPageIndex(l) + 1;
1484
+ } catch {
1485
+ }
1486
+ return null;
1487
+ }, i = async (c, a) => {
1488
+ for (const l of c) {
1489
+ const d = l.dest ? await s(l.dest) : null;
1490
+ n.push({
1491
+ title: l.title || "(无标题)",
1492
+ bold: !!l.bold,
1493
+ italic: !!l.italic,
1494
+ pageNumber: d,
1495
+ url: l.url ?? null,
1496
+ depth: a,
1497
+ key: `outline-${r++}`
1498
+ }), l.items && l.items.length > 0 && await i(l.items, a + 1);
1499
+ }
1500
+ };
1501
+ return await i(t, 0), n;
1502
+ }
1503
+ function kr(e) {
1504
+ const [t, n] = B([]), [r, s] = B(!1), i = A(/* @__PURE__ */ new WeakMap());
1505
+ return S(() => {
1506
+ if (!e) {
1507
+ n([]);
1508
+ return;
1509
+ }
1510
+ const c = i.current.get(e);
1511
+ if (c) {
1512
+ n(c);
1513
+ return;
1514
+ }
1515
+ let a = !1;
1516
+ return s(!0), xr(e).then((l) => {
1517
+ a || (i.current.set(e, l), n(l));
1518
+ }).finally(() => {
1519
+ a || s(!1);
1520
+ }), () => {
1521
+ a = !0;
1522
+ };
1523
+ }, [e]), { entries: t, loading: r };
1524
+ }
1525
+ function Pe(e) {
1526
+ const t = A(e);
1527
+ return t.current = e, S(() => {
1528
+ const r = (s) => {
1529
+ s.key === "Escape" && t.current();
1530
+ };
1531
+ return window.addEventListener("keydown", r), () => window.removeEventListener("keydown", r);
1532
+ }, []), { onBackdrop: I(
1533
+ (r) => {
1534
+ r.target === r.currentTarget && t.current();
1535
+ },
1536
+ []
1537
+ ) };
1538
+ }
1539
+ function Pr({ doc: e, onNavigate: t, onClose: n }) {
1540
+ const { entries: r, loading: s } = kr(e), { onBackdrop: i } = Pe(n);
1541
+ return /* @__PURE__ */ p("div", { className: "pdfh5-panel-backdrop", onClick: i, role: "presentation", children: /* @__PURE__ */ L("aside", { className: "pdfh5-panel pdfh5-panel-outline", role: "dialog", "aria-label": "目录", children: [
1542
+ /* @__PURE__ */ L("header", { className: "pdfh5-panel-head", children: [
1543
+ /* @__PURE__ */ p("h2", { children: "目录" }),
1544
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-icon-btn", onClick: n, "aria-label": "关闭", children: "✕" })
1545
+ ] }),
1546
+ /* @__PURE__ */ L("div", { className: "pdfh5-outline-list", children: [
1547
+ s ? /* @__PURE__ */ p("p", { className: "pdfh5-empty", children: "正在读取目录…" }) : null,
1548
+ !s && r.length === 0 ? /* @__PURE__ */ p("p", { className: "pdfh5-empty", children: "此文档没有目录" }) : null,
1549
+ r.map((c) => /* @__PURE__ */ L(
1550
+ "button",
1551
+ {
1552
+ type: "button",
1553
+ className: "pdfh5-outline-item",
1554
+ style: { paddingLeft: 16 + c.depth * 14 },
1555
+ onClick: () => {
1556
+ c.pageNumber ? t(c.pageNumber) : c.url && window.open(c.url, "_blank", "noopener");
1557
+ },
1558
+ disabled: !c.pageNumber && !c.url,
1559
+ children: [
1560
+ /* @__PURE__ */ p(
1561
+ "span",
1562
+ {
1563
+ className: "pdfh5-outline-title",
1564
+ style: { fontWeight: c.bold ? 600 : 400, fontStyle: c.italic ? "italic" : "normal" },
1565
+ children: c.title
1566
+ }
1567
+ ),
1568
+ c.pageNumber ? /* @__PURE__ */ p("span", { className: "pdfh5-outline-page", children: c.pageNumber }) : null
1569
+ ]
1570
+ },
1571
+ c.key
1572
+ ))
1573
+ ] })
1574
+ ] }) });
1575
+ }
1576
+ async function Cr(e, t, n = {}, r) {
1577
+ const s = n.targetWidth ?? 120, i = n.rotation ?? 0, c = n.quality ?? 0.72, a = async (l) => {
1578
+ const d = await e.getPage(t), m = d.getViewport({ scale: 1, rotation: d.rotate + i }), u = s / m.width, f = d.getViewport({ scale: u, rotation: d.rotate + i }), y = document.createElement("canvas");
1579
+ y.width = Math.max(1, Math.round(f.width)), y.height = Math.max(1, Math.round(f.height));
1580
+ const b = y.getContext("2d");
1581
+ if (!b) throw new Error("无法创建 2D 上下文");
1582
+ if (l?.aborted) throw new gt();
1583
+ const g = d.render({ canvas: y, canvasContext: b, viewport: f, background: "#ffffff" }), x = () => g.cancel();
1584
+ l?.addEventListener("abort", x, { once: !0 });
1585
+ try {
1586
+ await g.promise;
1587
+ } catch (C) {
1588
+ throw l?.aborted ? new gt() : C;
1589
+ } finally {
1590
+ l?.removeEventListener("abort", x);
1591
+ }
1592
+ const k = y.toDataURL("image/jpeg", c);
1593
+ return y.width = 0, y.height = 0, { dataUrl: k, width: Math.round(f.width), height: Math.round(f.height) };
1594
+ };
1595
+ return r ? r.enqueue(`thumb:${t}@${s}`, "prefetch", (l) => a(l)) : a();
1596
+ }
1597
+ function Mr({
1598
+ doc: e,
1599
+ pageNumber: t,
1600
+ width: n,
1601
+ cache: r,
1602
+ queue: s,
1603
+ active: i,
1604
+ rotation: c,
1605
+ onSelect: a,
1606
+ current: l
1607
+ }) {
1608
+ const [d, m] = B(() => r.get(t)?.dataUrl ?? null), [u, f] = B(Math.round(n * 1.414));
1609
+ return S(() => {
1610
+ const y = r.get(t);
1611
+ if (y) {
1612
+ m(y.dataUrl);
1613
+ return;
1614
+ }
1615
+ if (!i) return;
1616
+ let b = !1;
1617
+ return Cr(e, t, { targetWidth: n, rotation: c }, s).then((g) => {
1618
+ b || (f(g.height), r.put(t, g.dataUrl), m(g.dataUrl));
1619
+ }).catch(() => {
1620
+ }), () => {
1621
+ b = !0;
1622
+ };
1623
+ }, [e, t, n, c, r, s, i]), /* @__PURE__ */ L(
1624
+ "button",
1625
+ {
1626
+ type: "button",
1627
+ className: `pdfh5-thumb ${l ? "is-current" : ""}`,
1628
+ style: { width: n, height: u },
1629
+ onClick: () => a(t),
1630
+ "aria-label": `第 ${t} 页`,
1631
+ "aria-current": l || void 0,
1632
+ children: [
1633
+ d ? /* @__PURE__ */ p("img", { src: d, alt: "", width: n, height: u, decoding: "async", loading: "lazy" }) : /* @__PURE__ */ p("span", { className: "pdfh5-thumb-skeleton" }),
1634
+ /* @__PURE__ */ p("span", { className: "pdfh5-thumb-label", children: t })
1635
+ ]
1636
+ }
1637
+ );
1638
+ }
1639
+ const Kt = 2, $t = 178, Ge = 118;
1640
+ function Nr({ doc: e, cache: t, currentPage: n, rotation: r, onSelect: s, onClose: i }) {
1641
+ const { onBackdrop: c } = Pe(i), a = A(null), [l, d] = B({ start: 0, end: 12 }), m = e.numPages, u = rt(() => new ln({ visibleConcurrency: 3, prefetchConcurrency: 2 }), []);
1642
+ return S(() => {
1643
+ const f = a.current;
1644
+ if (!f) return;
1645
+ let y = 0;
1646
+ const b = () => {
1647
+ y = 0;
1648
+ const x = f.clientHeight || 600, k = f.scrollTop, C = $t * 2, M = Math.max(0, Math.floor((k - C) / $t) * Kt), P = Math.min(m, Math.ceil((k + x + C) / $t) * Kt);
1649
+ d((D) => D.start === M && D.end === P ? D : { start: M, end: P });
1650
+ }, g = () => {
1651
+ y || (y = requestAnimationFrame(b));
1652
+ };
1653
+ return b(), f.addEventListener("scroll", g, { passive: !0 }), window.addEventListener("resize", g), () => {
1654
+ y && cancelAnimationFrame(y), f.removeEventListener("scroll", g), window.removeEventListener("resize", g);
1655
+ };
1656
+ }, [m]), S(() => {
1657
+ const f = a.current;
1658
+ if (!f) return;
1659
+ const y = Math.floor((n - 1) / Kt);
1660
+ f.scrollTop = Math.max(0, y * $t - f.clientHeight / 2 + $t / 2);
1661
+ }, [n]), /* @__PURE__ */ p("div", { className: "pdfh5-panel-backdrop", onClick: c, role: "presentation", children: /* @__PURE__ */ L("aside", { className: "pdfh5-panel pdfh5-panel-thumbs", role: "dialog", "aria-label": "页面缩略图", children: [
1662
+ /* @__PURE__ */ L("header", { className: "pdfh5-panel-head", children: [
1663
+ /* @__PURE__ */ p("h2", { children: "页面缩略图" }),
1664
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-icon-btn", onClick: i, "aria-label": "关闭", children: "✕" })
1665
+ ] }),
1666
+ /* @__PURE__ */ p("div", { className: "pdfh5-thumb-grid", ref: a, style: { gridTemplateColumns: `repeat(${Kt}, ${Ge}px)` }, children: Array.from({ length: m }, (f, y) => {
1667
+ const b = y + 1, g = y >= l.start && y < l.end;
1668
+ return /* @__PURE__ */ p(
1669
+ Mr,
1670
+ {
1671
+ doc: e,
1672
+ pageNumber: b,
1673
+ width: Ge,
1674
+ cache: t,
1675
+ queue: u,
1676
+ active: g,
1677
+ rotation: r,
1678
+ current: b === n,
1679
+ onSelect: s
1680
+ },
1681
+ b
1682
+ );
1683
+ }) })
1684
+ ] }) });
1685
+ }
1686
+ function un(e, t, n, r = 24) {
1687
+ const s = Math.max(0, t - r), i = Math.min(e.length, n + r), c = e.slice(s, t), a = e.slice(t, n), l = e.slice(n, i);
1688
+ return `${s > 0 ? "…" : ""}${c}\0${a}\0${l}${i < e.length ? "…" : ""}`;
1689
+ }
1690
+ function Tr(e) {
1691
+ return e.split("\0").map((n, r) => ({ text: n, hit: r % 2 === 1 })).filter((n) => n.text.length > 0);
1692
+ }
1693
+ function Er(e, t, n, r, s = 50) {
1694
+ const i = [];
1695
+ if (!r) return i;
1696
+ const c = r.toLocaleLowerCase(), a = n.toLocaleLowerCase();
1697
+ let l = 0;
1698
+ for (; i.length < s; ) {
1699
+ const d = a.indexOf(c, l);
1700
+ if (d < 0) break;
1701
+ let m = 0;
1702
+ for (let u = t.length - 1; u >= 0; u -= 1)
1703
+ if (t[u].start <= d) {
1704
+ m = u;
1705
+ break;
1706
+ }
1707
+ i.push({
1708
+ pageNumber: e,
1709
+ text: n.slice(d, d + r.length),
1710
+ itemIndex: m,
1711
+ start: d,
1712
+ end: d + r.length,
1713
+ snippet: un(n, d, d + r.length)
1714
+ }), l = d + Math.max(1, c.length);
1715
+ }
1716
+ return i;
1717
+ }
1718
+ const Sr = 260;
1719
+ function Lr({ hits: e, index: t, onSearch: n, onSelect: r, onClose: s, stats: i, onClearCaches: c }) {
1720
+ const { onBackdrop: a } = Pe(s), [l, d] = B(""), [m, u] = B(!1), f = A(null);
1721
+ S(() => {
1722
+ f.current?.focus();
1723
+ }, []);
1724
+ const y = rt(
1725
+ () => cn(async (g) => {
1726
+ if (!g.trim()) {
1727
+ await n(""), u(!1);
1728
+ return;
1729
+ }
1730
+ u(!0);
1731
+ try {
1732
+ await n(g);
1733
+ } finally {
1734
+ u(!1);
1735
+ }
1736
+ }, Sr),
1737
+ [n]
1738
+ );
1739
+ S(() => () => y.cancel(), [y]);
1740
+ const b = (g) => {
1741
+ d(g), u(!!g.trim()), y(g);
1742
+ };
1743
+ return /* @__PURE__ */ p("div", { className: "pdfh5-panel-backdrop", onClick: a, role: "presentation", children: /* @__PURE__ */ L("aside", { className: "pdfh5-panel pdfh5-panel-search", role: "dialog", "aria-label": "搜索", children: [
1744
+ /* @__PURE__ */ L("header", { className: "pdfh5-panel-head", children: [
1745
+ /* @__PURE__ */ p("h2", { children: "搜索" }),
1746
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-icon-btn", onClick: s, "aria-label": "关闭", children: "✕" })
1747
+ ] }),
1748
+ /* @__PURE__ */ L("div", { className: "pdfh5-search-bar", children: [
1749
+ /* @__PURE__ */ p(
1750
+ "input",
1751
+ {
1752
+ ref: f,
1753
+ className: "pdfh5-search-input",
1754
+ value: l,
1755
+ onChange: (g) => b(g.target.value),
1756
+ placeholder: "输入关键词…",
1757
+ enterKeyHint: "search",
1758
+ autoComplete: "off",
1759
+ autoCorrect: "off",
1760
+ spellCheck: !1
1761
+ }
1762
+ ),
1763
+ l ? /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-icon-btn", onClick: () => b(""), "aria-label": "清空", children: "✕" }) : null
1764
+ ] }),
1765
+ /* @__PURE__ */ p("p", { className: "pdfh5-search-summary", children: m ? "搜索中…" : l ? `共 ${e.length} 条结果` : "输入关键词以搜索全文" }),
1766
+ /* @__PURE__ */ L("div", { className: "pdfh5-search-list", children: [
1767
+ e.map((g, x) => /* @__PURE__ */ L(
1768
+ "button",
1769
+ {
1770
+ type: "button",
1771
+ className: `pdfh5-search-item ${x === t ? "is-active" : ""}`,
1772
+ onClick: () => r(x),
1773
+ children: [
1774
+ /* @__PURE__ */ L("span", { className: "pdfh5-search-page", children: [
1775
+ "第 ",
1776
+ g.pageNumber,
1777
+ " 页"
1778
+ ] }),
1779
+ /* @__PURE__ */ p("span", { className: "pdfh5-search-snippet", children: Tr(g.snippet).map(
1780
+ (k, C) => k.hit ? /* @__PURE__ */ p("mark", { children: k.text }, C) : /* @__PURE__ */ p("span", { children: k.text }, C)
1781
+ ) })
1782
+ ]
1783
+ },
1784
+ `${g.pageNumber}-${g.start}-${x}`
1785
+ )),
1786
+ !m && l && e.length === 0 ? /* @__PURE__ */ p("p", { className: "pdfh5-empty", children: "没有找到匹配内容" }) : null
1787
+ ] }),
1788
+ i ? /* @__PURE__ */ L("section", { className: "pdfh5-perf", children: [
1789
+ /* @__PURE__ */ p("h3", { children: "运行状态" }),
1790
+ /* @__PURE__ */ L("dl", { children: [
1791
+ /* @__PURE__ */ L("div", { children: [
1792
+ /* @__PURE__ */ p("dt", { children: "位图缓存" }),
1793
+ /* @__PURE__ */ L("dd", { children: [
1794
+ i.bitmap.entries,
1795
+ " 张 / ",
1796
+ (i.bitmap.bytes / 1024 / 1024).toFixed(1),
1797
+ " MB"
1798
+ ] })
1799
+ ] }),
1800
+ /* @__PURE__ */ L("div", { children: [
1801
+ /* @__PURE__ */ p("dt", { children: "文本层缓存" }),
1802
+ /* @__PURE__ */ L("dd", { children: [
1803
+ i.text.entries,
1804
+ " 页"
1805
+ ] })
1806
+ ] }),
1807
+ /* @__PURE__ */ L("div", { children: [
1808
+ /* @__PURE__ */ p("dt", { children: "缩略图缓存" }),
1809
+ /* @__PURE__ */ L("dd", { children: [
1810
+ i.thumbnail.entries,
1811
+ " 张"
1812
+ ] })
1813
+ ] }),
1814
+ /* @__PURE__ */ L("div", { children: [
1815
+ /* @__PURE__ */ p("dt", { children: "渲染任务" }),
1816
+ /* @__PURE__ */ L("dd", { children: [
1817
+ "完成 ",
1818
+ i.renders.completed,
1819
+ " / 取消 ",
1820
+ i.renders.cancelled
1821
+ ] })
1822
+ ] }),
1823
+ /* @__PURE__ */ L("div", { children: [
1824
+ /* @__PURE__ */ p("dt", { children: "缓存命中" }),
1825
+ /* @__PURE__ */ L("dd", { children: [
1826
+ i.renders.cacheHits,
1827
+ " 次 / 淘汰 ",
1828
+ i.bitmap.evictions,
1829
+ " 次"
1830
+ ] })
1831
+ ] })
1832
+ ] }),
1833
+ c ? /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-btn", onClick: c, children: "清空所有缓存" }) : null
1834
+ ] }) : null
1835
+ ] }) });
1836
+ }
1837
+ function zr({
1838
+ loading: e,
1839
+ needPassword: t,
1840
+ passwordReason: n,
1841
+ error: r,
1842
+ progress: s,
1843
+ onSubmitPassword: i,
1844
+ onCancelPassword: c,
1845
+ renderError: a
1846
+ }) {
1847
+ const [l, d] = B("");
1848
+ if (S(() => {
1849
+ d("");
1850
+ }, [t, n]), t)
1851
+ return /* @__PURE__ */ p("div", { className: "pdfh5-status", role: "dialog", "aria-label": "需要密码", children: /* @__PURE__ */ L(
1852
+ "form",
1853
+ {
1854
+ className: "pdfh5-password",
1855
+ onSubmit: (m) => {
1856
+ m.preventDefault(), l && i(l);
1857
+ },
1858
+ children: [
1859
+ /* @__PURE__ */ p("h2", { children: n === 2 ? "密码错误,请重试" : "该文档需要密码" }),
1860
+ /* @__PURE__ */ p(
1861
+ "input",
1862
+ {
1863
+ type: "password",
1864
+ value: l,
1865
+ onChange: (m) => d(m.target.value),
1866
+ placeholder: "请输入打开密码",
1867
+ autoFocus: !0,
1868
+ inputMode: "text",
1869
+ enterKeyHint: "done"
1870
+ }
1871
+ ),
1872
+ /* @__PURE__ */ L("div", { className: "pdfh5-password-actions", children: [
1873
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-btn pdfh5-btn-ghost", onClick: c, children: "取消" }),
1874
+ /* @__PURE__ */ p("button", { type: "submit", className: "pdfh5-btn pdfh5-btn-primary", disabled: !l, children: "打开" })
1875
+ ] })
1876
+ ]
1877
+ }
1878
+ ) });
1879
+ if (r)
1880
+ return a ? /* @__PURE__ */ p(In, { children: a(r, () => window.location.reload()) }) : /* @__PURE__ */ L("div", { className: "pdfh5-status", role: "alert", children: [
1881
+ /* @__PURE__ */ p("p", { className: "pdfh5-status-title", children: "文档加载失败" }),
1882
+ /* @__PURE__ */ p("p", { className: "pdfh5-status-detail", children: r.message }),
1883
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-btn pdfh5-btn-primary", onClick: () => window.location.reload(), children: "重新加载" })
1884
+ ] });
1885
+ if (e) {
1886
+ const m = s && s.total > 0 ? s.loaded / s.total : null;
1887
+ return /* @__PURE__ */ L("div", { className: "pdfh5-status", role: "status", "aria-live": "polite", children: [
1888
+ /* @__PURE__ */ p("div", { className: "pdfh5-spinner" }),
1889
+ /* @__PURE__ */ p("p", { className: "pdfh5-status-title", children: "正在加载文档…" }),
1890
+ m !== null ? /* @__PURE__ */ p("div", { className: "pdfh5-progress", "aria-hidden": "true", children: /* @__PURE__ */ p("span", { style: { width: `${Math.min(100, Math.round(m * 100))}%` } }) }) : null
1891
+ ] });
1892
+ }
1893
+ return null;
1894
+ }
1895
+ function Ar(e, t, n) {
1896
+ for (const i of e.querySelectorAll("mark.pdfh5-hit")) {
1897
+ const c = i.parentNode;
1898
+ c && (c.replaceChild(document.createTextNode(i.textContent ?? ""), i), c.normalize());
1899
+ }
1900
+ if (t.length === 0) return;
1901
+ const r = /* @__PURE__ */ new Map();
1902
+ for (const i of t) {
1903
+ const c = r.get(i.pageNumber);
1904
+ c ? c.push(i) : r.set(i.pageNumber, [i]);
1905
+ }
1906
+ e.querySelectorAll(".pdfh5-page").forEach((i) => {
1907
+ const c = Number(i.dataset.pageNumber), a = r.get(c);
1908
+ if (!a || a.length === 0) return;
1909
+ const l = i.querySelector(".pdfh5-textLayerHost");
1910
+ if (!l) return;
1911
+ const d = Array.from(l.querySelectorAll(".textLayer span"));
1912
+ if (d.length === 0) return;
1913
+ const m = [];
1914
+ let u = 0;
1915
+ for (const f of d)
1916
+ m.push(u), u += (f.textContent ?? "").length;
1917
+ for (const f of a) {
1918
+ const y = Rr(m, d, f.start), b = d[y];
1919
+ if (!b) continue;
1920
+ const g = Math.max(0, f.start - m[y]), x = b.textContent ?? "", k = Math.min(x.length, g + (f.end - f.start));
1921
+ k <= g || Dr(b, g, k, f === t[n]);
1922
+ }
1923
+ });
1924
+ }
1925
+ function Rr(e, t, n) {
1926
+ for (let r = t.length - 1; r >= 0; r -= 1)
1927
+ if (e[r] <= n) return r;
1928
+ return 0;
1929
+ }
1930
+ function Dr(e, t, n, r) {
1931
+ const s = e.textContent ?? "";
1932
+ if (t >= s.length) return;
1933
+ const i = s.slice(0, t), c = s.slice(t, Math.min(n, s.length)), a = s.slice(Math.min(n, s.length));
1934
+ if (!c) return;
1935
+ const l = document.createElement("mark");
1936
+ l.className = r ? "pdfh5-hit pdfh5-hit-active" : "pdfh5-hit", l.textContent = c, e.textContent = "", i && e.appendChild(document.createTextNode(i)), e.appendChild(l), a && e.appendChild(document.createTextNode(a));
1937
+ }
1938
+ async function $r(e, t) {
1939
+ const r = await (await e.getPage(t)).getTextContent(), s = [];
1940
+ let i = "";
1941
+ for (const c of r.items)
1942
+ !("str" in c) || typeof c.str != "string" || (s.push({ str: c.str, start: i.length }), i += c.str, c.hasEOL && (i += " "));
1943
+ return { pageNumber: t, text: i, items: s };
1944
+ }
1945
+ const xe = /* @__PURE__ */ new Map();
1946
+ async function Br(e, t, n = {}) {
1947
+ const r = n.perPageLimit ?? 20, s = n.totalLimit ?? 300, i = n.yieldMs ?? 0, c = t.toLocaleLowerCase();
1948
+ if (!c) return [];
1949
+ const a = [], l = e.numPages, d = e.fingerprints?.[0] ?? `doc-${l}`;
1950
+ for (let m = 1; m <= l; m += 1) {
1951
+ if (n.signal?.aborted) return a;
1952
+ let u = xe.get(`${d}:${m}`);
1953
+ if (!u)
1954
+ try {
1955
+ u = await $r(e, m), xe.set(`${d}:${m}`, u);
1956
+ } catch {
1957
+ continue;
1958
+ }
1959
+ if (u.text.toLocaleLowerCase().includes(c)) {
1960
+ const f = Er(m, u.items, u.text, t, r);
1961
+ for (const y of f)
1962
+ if (a.push({ ...y, snippet: un(u.text, y.start, y.end) }), a.length >= s) return a;
1963
+ }
1964
+ n.onProgress?.(m, l), i > 0 && await new Promise((f) => setTimeout(f, i));
1965
+ }
1966
+ return a;
1967
+ }
1968
+ function rs() {
1969
+ xe.clear();
1970
+ }
1971
+ class Hr {
1972
+ listeners = /* @__PURE__ */ new Map();
1973
+ /** 注册监听,返回取消订阅函数 */
1974
+ on(t, n) {
1975
+ let r = this.listeners.get(t);
1976
+ return r || (r = /* @__PURE__ */ new Set(), this.listeners.set(t, r)), r.add(n), () => this.off(t, n);
1977
+ }
1978
+ /** 只触发一次 */
1979
+ once(t, n) {
1980
+ const r = (s) => {
1981
+ this.off(t, r), n(s);
1982
+ };
1983
+ return this.on(t, r);
1984
+ }
1985
+ /**
1986
+ * 移除监听。
1987
+ * 不传 listener 时清空该事件的全部监听(兼容 pdfh5 的用法)。
1988
+ */
1989
+ off(t, n) {
1990
+ if (!n) {
1991
+ this.listeners.delete(t);
1992
+ return;
1993
+ }
1994
+ const r = this.listeners.get(t);
1995
+ r && (r.delete(n), r.size === 0 && this.listeners.delete(t));
1996
+ }
1997
+ /**
1998
+ * 触发事件。
1999
+ *
2000
+ * 对数组做快照再遍历:回调内部调用 `off` 不会影响本轮分发(否则会漏发后续监听者)。
2001
+ * 单个监听器抛错时打印告警并继续 —— 避免一个写错的回调导致别的功能静默失效。
2002
+ */
2003
+ emit(t, n) {
2004
+ const r = this.listeners.get(t);
2005
+ if (!r || r.size === 0) return;
2006
+ const s = [...r];
2007
+ for (const i of s)
2008
+ try {
2009
+ i(n);
2010
+ } catch (c) {
2011
+ console.error(`[pdf-h5-react] 事件 "${String(t)}" 的监听器抛出异常:`, c);
2012
+ }
2013
+ }
2014
+ /** 某个事件当前的监听数量(调试用) */
2015
+ listenerCount(t) {
2016
+ return this.listeners.get(t)?.size ?? 0;
2017
+ }
2018
+ /** 清空全部监听(组件卸载时调用) */
2019
+ clear() {
2020
+ this.listeners.clear();
2021
+ }
2022
+ }
2023
+ const Ir = (e) => 1 - Math.pow(1 - e, 3), Xe = (e) => typeof requestAnimationFrame == "function" ? requestAnimationFrame(e) : setTimeout(e, 16), Fr = (e) => {
2024
+ typeof cancelAnimationFrame == "function" ? cancelAnimationFrame(e) : clearTimeout(e);
2025
+ }, Je = () => typeof performance < "u" ? performance.now() : Date.now();
2026
+ function Or() {
2027
+ if (typeof window > "u" || !window.matchMedia) return !1;
2028
+ try {
2029
+ return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2030
+ } catch {
2031
+ return !1;
2032
+ }
2033
+ }
2034
+ function Zr(e) {
2035
+ const { from: t, to: n, onUpdate: r, onDone: s } = e, i = e.easing ?? Ir, c = Math.max(0, e.duration), a = c === 0 || Or();
2036
+ let l = 0, d = !1, m = !1;
2037
+ const u = () => {
2038
+ m = !0, s?.();
2039
+ };
2040
+ if (a)
2041
+ return r(n, 1), u(), {
2042
+ cancel() {
2043
+ },
2044
+ get finished() {
2045
+ return !0;
2046
+ }
2047
+ };
2048
+ const f = Je(), y = () => {
2049
+ if (d) return;
2050
+ const b = Je() - f, g = Math.min(1, b / c), x = i(g), k = t + (n - t) * x;
2051
+ if (r(k, g), g >= 1) {
2052
+ u();
2053
+ return;
2054
+ }
2055
+ l = Xe(y);
2056
+ };
2057
+ return l = Xe(y), {
2058
+ cancel() {
2059
+ d || m || (d = !0, l && Fr(l), l = 0, r(n, 1), u());
2060
+ },
2061
+ get finished() {
2062
+ return m;
2063
+ }
2064
+ };
2065
+ }
2066
+ const jr = {
2067
+ highlightColor: "#ffd400",
2068
+ highlightOpacity: 0.38,
2069
+ textColor: "#1f2329",
2070
+ inkColor: "#e5484d",
2071
+ fontSize: 0.022,
2072
+ thickness: 28e-4
2073
+ };
2074
+ function Ur(e, t, n, r) {
2075
+ return {
2076
+ x: n > 0 ? tn(e / n) : 0,
2077
+ y: r > 0 ? tn(t / r) : 0
2078
+ };
2079
+ }
2080
+ function ke(e, t, n) {
2081
+ return { x: e.x * t, y: e.y * n };
2082
+ }
2083
+ function hn(e, t, n) {
2084
+ return {
2085
+ x: e.x * t,
2086
+ y: e.y * n,
2087
+ width: e.width * t,
2088
+ height: e.height * n
2089
+ };
2090
+ }
2091
+ function Qe(e, t) {
2092
+ const n = Math.min(e.x, t.x), r = Math.min(e.y, t.y);
2093
+ return {
2094
+ x: n,
2095
+ y: r,
2096
+ width: Math.abs(e.x - t.x),
2097
+ height: Math.abs(e.y - t.y)
2098
+ };
2099
+ }
2100
+ function tn(e) {
2101
+ return Number.isFinite(e) ? Math.min(1, Math.max(0, e)) : 0;
2102
+ }
2103
+ let en = 0;
2104
+ function ge(e = "anno") {
2105
+ return en += 1, `${e}-${Date.now().toString(36)}-${en.toString(36)}`;
2106
+ }
2107
+ function Gt(e) {
2108
+ switch (e.kind) {
2109
+ case "highlight":
2110
+ return e.rects.some((t) => t.width * t.height > 4e-5);
2111
+ case "freetext":
2112
+ return e.text.trim().length > 0;
2113
+ case "ink":
2114
+ return e.points.length >= 2;
2115
+ default:
2116
+ return !1;
2117
+ }
2118
+ }
2119
+ function ss(e, t = 0.02) {
2120
+ return e.x >= -t && e.x <= 1 + t && e.y >= -t && e.y <= 1 + t;
2121
+ }
2122
+ function Wr(e) {
2123
+ const t = /* @__PURE__ */ new Map();
2124
+ for (const n of e) {
2125
+ const r = t.get(n.pageNumber);
2126
+ r ? r.push(n) : t.set(n.pageNumber, [n]);
2127
+ }
2128
+ return t;
2129
+ }
2130
+ function qr({
2131
+ pageNumber: e,
2132
+ width: t,
2133
+ height: n,
2134
+ mode: r,
2135
+ style: s,
2136
+ annotations: i,
2137
+ enabled: c,
2138
+ onAdd: a,
2139
+ onSelect: l,
2140
+ onActiveChange: d
2141
+ }) {
2142
+ const m = A(null), [u, f] = B(null), [y, b] = B(null), [g, x] = B(""), k = A(!1), C = A(null), M = c && r !== "none";
2143
+ S(() => {
2144
+ d?.(!!y || !!u);
2145
+ }, [y, u, d]), S(() => {
2146
+ y && requestAnimationFrame(() => C.current?.focus());
2147
+ }, [y]);
2148
+ const P = I(
2149
+ (N) => {
2150
+ const F = m.current;
2151
+ if (!F) return null;
2152
+ const w = F.getBoundingClientRect();
2153
+ return w.width <= 0 || w.height <= 0 ? null : Ur(N.clientX - w.left, N.clientY - w.top, w.width, w.height);
2154
+ },
2155
+ []
2156
+ ), D = I(
2157
+ (N, F) => {
2158
+ const w = Qe(N, F), T = {
2159
+ id: ge("hl"),
2160
+ kind: "highlight",
2161
+ pageNumber: e,
2162
+ createdAt: Date.now(),
2163
+ rects: [w],
2164
+ color: s.highlightColor,
2165
+ opacity: s.highlightOpacity
2166
+ };
2167
+ Gt(T) && a(T), f(null);
2168
+ },
2169
+ [e, s.highlightColor, s.highlightOpacity, a]
2170
+ ), z = I(
2171
+ (N) => {
2172
+ const F = {
2173
+ id: ge("ink"),
2174
+ kind: "ink",
2175
+ pageNumber: e,
2176
+ createdAt: Date.now(),
2177
+ points: N,
2178
+ thickness: s.thickness,
2179
+ color: s.inkColor
2180
+ };
2181
+ Gt(F) && a(F), f(null);
2182
+ },
2183
+ [e, s.thickness, s.inkColor, a]
2184
+ ), $ = I(() => {
2185
+ const N = y, F = g.trim();
2186
+ if (b(null), x(""), !N || !F) return;
2187
+ const w = {
2188
+ id: ge("ft"),
2189
+ kind: "freetext",
2190
+ pageNumber: e,
2191
+ createdAt: Date.now(),
2192
+ anchor: N,
2193
+ text: F,
2194
+ fontSize: s.fontSize,
2195
+ color: s.textColor
2196
+ };
2197
+ a(w);
2198
+ }, [y, g, e, s.fontSize, s.textColor, a]), W = I(
2199
+ (N) => {
2200
+ if (!M || N.pointerType === "mouse" && N.button !== 0) return;
2201
+ const F = P(N);
2202
+ if (F) {
2203
+ if (r === "freetext") {
2204
+ N.preventDefault(), N.stopPropagation(), b(F), x("");
2205
+ return;
2206
+ }
2207
+ N.preventDefault(), N.stopPropagation(), N.target.setPointerCapture?.(N.pointerId), k.current = !0, f(
2208
+ r === "highlight" ? { kind: "highlight", start: F, current: F } : { kind: "ink", points: [F] }
2209
+ );
2210
+ }
2211
+ },
2212
+ [M, r, P]
2213
+ ), O = I(
2214
+ (N) => {
2215
+ if (!M || !k.current) return;
2216
+ const F = P(N);
2217
+ F && (N.preventDefault(), f((w) => {
2218
+ if (!w) return w;
2219
+ if (w.kind === "highlight") return { ...w, current: F };
2220
+ const T = w.points[w.points.length - 1];
2221
+ return Math.hypot(F.x - T.x, F.y - T.y) < 15e-4 ? w : { kind: "ink", points: [...w.points, F] };
2222
+ }));
2223
+ },
2224
+ [M, P]
2225
+ ), _ = I(
2226
+ (N) => {
2227
+ k.current && (k.current = !1, N.target.releasePointerCapture?.(N.pointerId), f((F) => F ? (queueMicrotask(() => {
2228
+ F.kind === "highlight" ? D(F.start, F.current) : z(F.points);
2229
+ }), F) : null));
2230
+ },
2231
+ [D, z]
2232
+ ), K = I(() => {
2233
+ k.current = !1, f(null);
2234
+ }, []), Z = I((N) => {
2235
+ N.stopPropagation();
2236
+ }, []);
2237
+ return /* @__PURE__ */ L(
2238
+ "div",
2239
+ {
2240
+ ref: m,
2241
+ className: "pdfh5-anno",
2242
+ "data-mode": r,
2243
+ "data-interactive": M || void 0,
2244
+ style: { width: t, height: n },
2245
+ children: [
2246
+ /* @__PURE__ */ L("div", { className: "pdfh5-anno-view", "aria-hidden": "true", children: [
2247
+ i.map((N) => /* @__PURE__ */ p(
2248
+ _r,
2249
+ {
2250
+ annotation: N,
2251
+ width: t,
2252
+ height: n,
2253
+ onSelect: l
2254
+ },
2255
+ N.id
2256
+ )),
2257
+ u?.kind === "highlight" ? /* @__PURE__ */ p(Kr, { rect: Qe(u.start, u.current), width: t, height: n, color: s.highlightColor, opacity: s.highlightOpacity }) : null,
2258
+ u?.kind === "ink" ? /* @__PURE__ */ p(Vr, { points: u.points, width: t, height: n, color: s.inkColor, thickness: s.thickness }) : null
2259
+ ] }),
2260
+ M ? /* @__PURE__ */ p(
2261
+ "div",
2262
+ {
2263
+ className: "pdfh5-anno-capture",
2264
+ onPointerDown: W,
2265
+ onPointerMove: O,
2266
+ onPointerUp: _,
2267
+ onPointerCancel: K
2268
+ }
2269
+ ) : null,
2270
+ y ? /* @__PURE__ */ L(
2271
+ "div",
2272
+ {
2273
+ className: "pdfh5-anno-editor",
2274
+ style: {
2275
+ left: y.x * t,
2276
+ top: y.y * n
2277
+ },
2278
+ onPointerDown: Z,
2279
+ onClick: Z,
2280
+ children: [
2281
+ /* @__PURE__ */ p(
2282
+ "textarea",
2283
+ {
2284
+ ref: C,
2285
+ className: "pdfh5-anno-input",
2286
+ value: g,
2287
+ placeholder: "输入批注…",
2288
+ onChange: (N) => x(N.target.value),
2289
+ onKeyDown: (N) => {
2290
+ N.stopPropagation(), N.key === "Escape" && (b(null), x("")), N.key === "Enter" && (N.metaKey || N.ctrlKey) && (N.preventDefault(), $());
2291
+ },
2292
+ rows: 2
2293
+ }
2294
+ ),
2295
+ /* @__PURE__ */ L("div", { className: "pdfh5-anno-actions", children: [
2296
+ /* @__PURE__ */ p(
2297
+ "button",
2298
+ {
2299
+ type: "button",
2300
+ className: "pdfh5-anno-btn",
2301
+ onClick: () => {
2302
+ b(null), x("");
2303
+ },
2304
+ children: "取消"
2305
+ }
2306
+ ),
2307
+ /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-anno-btn pdfh5-anno-btn-primary", onClick: $, children: "添加" })
2308
+ ] })
2309
+ ]
2310
+ }
2311
+ ) : null
2312
+ ]
2313
+ }
2314
+ );
2315
+ }
2316
+ function _r({
2317
+ annotation: e,
2318
+ width: t,
2319
+ height: n,
2320
+ onSelect: r
2321
+ }) {
2322
+ const s = (a) => {
2323
+ a.stopPropagation(), r?.(e);
2324
+ };
2325
+ if (e.kind === "highlight")
2326
+ return /* @__PURE__ */ p("div", { className: "pdfh5-anno-hit", onClick: s, role: "presentation", children: e.rects.map((a, l) => {
2327
+ const d = hn(a, t, n);
2328
+ return /* @__PURE__ */ p(
2329
+ "span",
2330
+ {
2331
+ className: "pdfh5-anno-hl",
2332
+ style: {
2333
+ left: d.x,
2334
+ top: d.y,
2335
+ width: d.width,
2336
+ height: d.height,
2337
+ background: e.color,
2338
+ opacity: e.opacity
2339
+ }
2340
+ },
2341
+ l
2342
+ );
2343
+ }) });
2344
+ if (e.kind === "freetext") {
2345
+ const a = ke(e.anchor, t, n);
2346
+ return /* @__PURE__ */ p(
2347
+ "div",
2348
+ {
2349
+ className: "pdfh5-anno-text",
2350
+ style: {
2351
+ left: a.x,
2352
+ top: a.y,
2353
+ fontSize: Math.max(9, e.fontSize * t),
2354
+ color: e.color
2355
+ },
2356
+ onClick: s,
2357
+ role: "presentation",
2358
+ children: e.text
2359
+ }
2360
+ );
2361
+ }
2362
+ const i = e.points.map((a) => ke(a, t, n));
2363
+ if (i.length < 2) return null;
2364
+ const c = i.map((a, l) => `${l === 0 ? "M" : "L"}${a.x.toFixed(2)},${a.y.toFixed(2)}`).join(" ");
2365
+ return /* @__PURE__ */ p("svg", { className: "pdfh5-anno-ink", width: t, height: n, onClick: s, children: /* @__PURE__ */ p(
2366
+ "path",
2367
+ {
2368
+ d: c,
2369
+ fill: "none",
2370
+ stroke: e.color,
2371
+ strokeWidth: Math.max(1, e.thickness * t),
2372
+ strokeLinecap: "round",
2373
+ strokeLinejoin: "round"
2374
+ }
2375
+ ) });
2376
+ }
2377
+ function Kr({
2378
+ rect: e,
2379
+ width: t,
2380
+ height: n,
2381
+ color: r,
2382
+ opacity: s
2383
+ }) {
2384
+ const i = hn(e, t, n);
2385
+ return /* @__PURE__ */ p(
2386
+ "span",
2387
+ {
2388
+ className: "pdfh5-anno-hl pdfh5-anno-hl-draft",
2389
+ style: { left: i.x, top: i.y, width: i.width, height: i.height, background: r, opacity: s * 0.7 }
2390
+ }
2391
+ );
2392
+ }
2393
+ function Vr({
2394
+ points: e,
2395
+ width: t,
2396
+ height: n,
2397
+ color: r,
2398
+ thickness: s
2399
+ }) {
2400
+ const i = e.map((a) => ke(a, t, n));
2401
+ if (i.length < 2) return null;
2402
+ const c = i.map((a, l) => `${l === 0 ? "M" : "L"}${a.x.toFixed(2)},${a.y.toFixed(2)}`).join(" ");
2403
+ return /* @__PURE__ */ p("svg", { className: "pdfh5-anno-ink", width: t, height: n, children: /* @__PURE__ */ p("path", { d: c, fill: "none", stroke: r, strokeWidth: Math.max(1, s * t), strokeLinecap: "round", strokeLinejoin: "round" }) });
2404
+ }
2405
+ const nn = {
2406
+ light: "light",
2407
+ dark: "dark"
2408
+ };
2409
+ function Yr(e) {
2410
+ const [t, n] = B(
2411
+ () => typeof window < "u" && window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)").matches : !1
2412
+ );
2413
+ return S(() => {
2414
+ if (e !== "auto" || typeof window > "u" || !window.matchMedia) return;
2415
+ const r = window.matchMedia("(prefers-color-scheme: dark)"), s = (i) => n(i.matches);
2416
+ return r.addEventListener("change", s), () => r.removeEventListener("change", s);
2417
+ }, [e]), e === "auto" ? t ? "dark" : "light" : e;
2418
+ }
2419
+ const os = Bn(function(t, n) {
2420
+ const {
2421
+ src: r,
2422
+ mode: s = "scroll",
2423
+ fitMode: i = "width",
2424
+ initialPage: c = 1,
2425
+ initialZoom: a = 1,
2426
+ minZoom: l = 0.5,
2427
+ maxZoom: d = 5,
2428
+ doubleTapZoom: m = 2.5,
2429
+ animationDuration: u = 300,
2430
+ zoomEnable: f = !0,
2431
+ scrollEnable: y = !0,
2432
+ rotation: b = 0,
2433
+ theme: g = "auto",
2434
+ gap: x = 12,
2435
+ padding: k = 12,
2436
+ textLayer: C = !0,
2437
+ links: M = !0,
2438
+ toolbar: P = !0,
2439
+ showControls: D = !0,
2440
+ backTop: z = !0,
2441
+ loadingBar: $ = !0,
2442
+ annotation: W = !1,
2443
+ annotations: O,
2444
+ annotationStyle: _,
2445
+ onAnnotationsChange: K,
2446
+ bitmapCacheBytes: Z,
2447
+ textLayerCacheEntries: N,
2448
+ maxCanvasPixels: F,
2449
+ maxCanvasDimension: w,
2450
+ className: T,
2451
+ style: E,
2452
+ onDocumentLoad: V,
2453
+ onPageChange: X,
2454
+ onProgress: J,
2455
+ onError: lt,
2456
+ onZoomChange: ut,
2457
+ onInternalLink: It,
2458
+ onExternalLink: yt,
2459
+ renderError: dn,
2460
+ onReady: fn,
2461
+ onRender: Ce,
2462
+ onScroll: Me,
2463
+ onZoomEnd: Ne,
2464
+ onComplete: Te
2465
+ } = t, Ft = Yr(g), { ref: mn, width: Y, height: Q } = ar(), nt = A(null), Ee = A(null), U = Wn(r), { doc: H } = U, ft = rt(
2466
+ () => new Bt({ maxBytes: Z ?? 96 * 1024 * 1024 }),
2467
+ [Z]
2468
+ ), wt = rt(
2469
+ () => new nr({ maxEntries: N ?? 24 }),
2470
+ [N]
2471
+ ), vt = rt(() => new sr(), []), Lt = rt(() => new ln({ visibleConcurrency: 2, prefetchConcurrency: 1 }), []), [xt, Ot] = B(a), ct = A(xt);
2472
+ ct.current = xt;
2473
+ const [ht, Jt] = B(c), at = A(ht);
2474
+ at.current = ht;
2475
+ const [kt, Pt] = B(null), [pn, Se] = B([]), Nt = O ?? pn, Le = A(Nt);
2476
+ Le.current = Nt;
2477
+ const [Tt, Qt] = B("none"), te = A(Tt);
2478
+ te.current = Tt;
2479
+ const gn = rt(
2480
+ () => ({ ...jr, ..._ }),
2481
+ [_]
2482
+ ), yn = rt(() => Wr(Nt), [Nt]), [bn, wn] = B(!1), bt = I(
2483
+ (o) => {
2484
+ if (typeof o == "function") {
2485
+ O === void 0 ? Se((h) => {
2486
+ const v = o(h);
2487
+ return K?.(v), v;
2488
+ }) : K?.(o(O));
2489
+ return;
2490
+ }
2491
+ O === void 0 && Se(o), K?.(o);
2492
+ },
2493
+ [O, K]
2494
+ ), vn = I(
2495
+ (o) => {
2496
+ Gt(o) && (bt((h) => [...h, o]), Qt("none"));
2497
+ },
2498
+ [bt]
2499
+ ), ze = I(
2500
+ (o) => {
2501
+ bt((h) => h.filter((v) => v.id !== o));
2502
+ },
2503
+ [bt]
2504
+ ), ee = I(() => {
2505
+ bt([]);
2506
+ }, [bt]), [zt, Zt] = B([]), [ne, re] = B(0), [xn, Ae] = B({}), [kn, se] = B(null), [Pn, oe] = B(0), { metrics: Ct, resolved: At, getPage: Re, peekPage: De, ensurePage: $e } = or(H, { initialPages: 6 }), [Cn, Mn] = B(() => typeof window > "u" ? 1 : Math.min(window.devicePixelRatio || 1, 3));
2507
+ S(() => {
2508
+ if (typeof window > "u") return;
2509
+ const o = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`), h = () => Mn(Math.min(window.devicePixelRatio || 1, 3));
2510
+ return o.addEventListener?.("change", h), () => o.removeEventListener?.("change", h);
2511
+ }, []);
2512
+ const ie = rt(() => pr(Ct), [Ct]), Be = rt(() => {
2513
+ if (i === "none" || Y <= 0) return 1;
2514
+ const o = Ct[0], h = Math.max(1, Y - k * 2);
2515
+ if (!o) return 1;
2516
+ const v = b % 180 === 0 ? o.width : o.height, R = b % 180 === 0 ? o.height : o.width, j = h / v;
2517
+ return i === "width" ? j : Math.min(j, (Q - k * 2) / R);
2518
+ }, [i, Ct, Y, Q, k, b]), tt = rt(
2519
+ () => mr({
2520
+ mode: s,
2521
+ metrics: Ct,
2522
+ fallback: ie,
2523
+ scale: Be,
2524
+ zoom: xt,
2525
+ containerWidth: Y,
2526
+ containerHeight: Q,
2527
+ gap: x,
2528
+ padding: k,
2529
+ rotation: b,
2530
+ fitMode: i,
2531
+ pageCount: H?.numPages ?? 0
2532
+ }),
2533
+ [s, Ct, ie, Be, xt, Y, Q, x, k, b, i, H?.numPages]
2534
+ ), mt = ir(nt, {
2535
+ boxes: tt.boxes,
2536
+ mode: s,
2537
+ viewportWidth: Y,
2538
+ viewportHeight: Q
2539
+ }), Nn = A({ left: 0, top: 0 }), jt = A({ left: 0, top: 0 });
2540
+ S(() => {
2541
+ jt.current = {
2542
+ left: Math.max(0, tt.contentWidth - Y),
2543
+ top: Math.max(0, tt.contentHeight - Q)
2544
+ };
2545
+ }, [tt.contentWidth, tt.contentHeight, Y, Q]), S(() => {
2546
+ const o = nt.current;
2547
+ if (!o) return;
2548
+ const h = pe(() => {
2549
+ ve("scroll"), Nn.current = { left: o.scrollLeft, top: o.scrollTop };
2550
+ const R = s === "page", j = R ? o.scrollLeft : o.scrollTop, q = R ? Y : Q, ot = R ? Math.round(j / Math.max(1, q)) + 1 : Kn(tt.boxes, j + q * 0.5, "y"), pt = it(ot, 1, H?.numPages ?? 1);
2551
+ pt !== at.current && Jt(pt);
2552
+ }), v = () => {
2553
+ we("scroll"), h();
2554
+ };
2555
+ return o.addEventListener("scroll", v, { passive: !0 }), () => {
2556
+ o.removeEventListener("scroll", v), h.cancel();
2557
+ };
2558
+ }, [s, Y, Q, tt.boxes, H?.numPages]);
2559
+ const He = A($e);
2560
+ He.current = $e, S(() => {
2561
+ for (const o of mt.prefetch) He.current(o);
2562
+ }, [mt.prefetch]), S(() => {
2563
+ let o = !1;
2564
+ const h = new Set(mt.mounted);
2565
+ return (async () => {
2566
+ const v = {};
2567
+ await Promise.all(
2568
+ mt.mounted.map(async (R) => {
2569
+ const j = De(R);
2570
+ if (j) {
2571
+ v[R] = j;
2572
+ return;
2573
+ }
2574
+ try {
2575
+ v[R] = await Re(R);
2576
+ } catch {
2577
+ }
2578
+ })
2579
+ ), !o && Ae((R) => {
2580
+ const j = {};
2581
+ for (const q of h) {
2582
+ const ot = v[q] ?? R[q];
2583
+ ot && (j[q] = ot);
2584
+ }
2585
+ return j;
2586
+ });
2587
+ })(), () => {
2588
+ o = !0;
2589
+ };
2590
+ }, [mt.mounted, Re, De]), S(() => {
2591
+ H && (Lt.cancelAll(), ft.clear(), wt.clear(), vt.clear(), Ae({}), Zt([]), V?.(H));
2592
+ }, [H]), S(() => {
2593
+ U.error && lt?.(U.error);
2594
+ }, [U.error, lt]);
2595
+ const Ut = rt(() => be((o, h) => J?.(o, h), 150), [J]);
2596
+ S(() => {
2597
+ U.progress && Ut(U.progress.loaded, U.progress.total ?? 0);
2598
+ }, [U.progress, Ut]), S(() => () => Ut.cancel(), [Ut]);
2599
+ const G = A(new Hr()), Wt = A(null), qt = A(null), ce = rt(
2600
+ () => be((o, h) => G.current.emit("zoom", { zoom: o, source: h }), 80),
2601
+ []
2602
+ ), Ie = I((o) => {
2603
+ qt.current || (qt.current = { zoom: ct.current, time: Date.now(), source: o }, G.current.emit("zoomStart", { zoom: ct.current, source: o }));
2604
+ }, []), Fe = A(Ne);
2605
+ Fe.current = Ne;
2606
+ const ae = I((o) => {
2607
+ const h = qt.current;
2608
+ if (qt.current = null, !h) return;
2609
+ const v = {
2610
+ zoom: o,
2611
+ scaleChange: h.zoom > 0 ? o / h.zoom : 1,
2612
+ startZoom: h.zoom,
2613
+ duration: Date.now() - h.time,
2614
+ source: h.source
2615
+ };
2616
+ G.current.emit("zoomEnd", v), Fe.current?.(v);
2617
+ }, []), st = I(
2618
+ (o, h, v, R = {}) => {
2619
+ const j = nt.current, q = it(o, l, d), ot = R.source ?? "api", pt = ct.current;
2620
+ Wt.current?.cancel(), Wt.current = null, Ie(ot);
2621
+ const Rt = (St) => {
2622
+ if (!j || h === void 0 || v === void 0) return;
2623
+ const Ke = pt > 0 ? St / pt : 1;
2624
+ requestAnimationFrame(() => {
2625
+ j.scrollLeft = it(h * Ke, 0, jt.current.left), j.scrollTop = it(v * Ke, 0, jt.current.top);
2626
+ });
2627
+ };
2628
+ if (R.animate && Math.abs(q - pt) > 1e-3) {
2629
+ Wt.current = Zr({
2630
+ from: pt,
2631
+ to: q,
2632
+ duration: u,
2633
+ onUpdate: (St) => {
2634
+ Ot(St), ut?.(St), ce(St, ot), Rt(St);
2635
+ },
2636
+ onDone: () => {
2637
+ Wt.current = null, Ot(q), ut?.(q), ae(q);
2638
+ }
2639
+ });
2640
+ return;
2641
+ }
2642
+ Ot(q), ut?.(q), ce(q, ot), Rt(q), requestAnimationFrame(() => ae(q));
2643
+ },
2644
+ [l, d, ut, Ie, ae, ce, u]
2645
+ ), Tn = A(G);
2646
+ Tn.current = G;
2647
+ const le = A(Date.now());
2648
+ S(() => {
2649
+ le.current = Date.now(), G.current.emit("init", { src: r });
2650
+ }, [r]), S(() => {
2651
+ if (!H) return;
2652
+ const o = Date.now() - le.current;
2653
+ G.current.emit("ready", { doc: H, total: H.numPages }), G.current.emit("success", { message: `已加载 ${H.numPages} 页`, time: o }), G.current.emit("complete", { status: "success", message: "ok", time: o }), fn?.({ doc: H, total: H.numPages }), Te?.({ status: "success", message: "ok", time: o });
2654
+ }, [H]), S(() => {
2655
+ if (!U.error) return;
2656
+ const o = Date.now() - le.current, h = U.error.message || "加载失败";
2657
+ G.current.emit("error", { error: U.error, message: h, time: o }), G.current.emit("complete", { status: "error", message: h, time: o }), Te?.({ status: "error", message: h, time: o });
2658
+ }, [U.error]), S(() => {
2659
+ const o = nt.current;
2660
+ if (!o) return;
2661
+ const h = pe(() => {
2662
+ const v = s === "page", R = H?.numPages ?? 0, j = o.scrollTop, q = o.scrollLeft, ot = Math.max(1, tt.contentHeight - Q), pt = v ? Y > 0 && R > 0 ? q / Math.max(1, (R - 1) * Y) : 0 : it(j / ot, 0, 1), Rt = { scrollTop: j, scrollLeft: q, currentPage: at.current, progress: pt };
2663
+ G.current.emit("scroll", Rt), Me?.(Rt);
2664
+ });
2665
+ return o.addEventListener("scroll", h, { passive: !0 }), () => {
2666
+ o.removeEventListener("scroll", h), h.cancel();
2667
+ };
2668
+ }, [s, H?.numPages, tt.contentHeight, Q, Y, Me]);
2669
+ const Oe = A(0), Ze = A(X);
2670
+ Ze.current = X, S(() => {
2671
+ if (ht === Oe.current) return;
2672
+ Oe.current = ht;
2673
+ const o = H?.numPages ?? 0;
2674
+ G.current.emit("pageChange", { page: ht, total: o }), Ze.current?.(ht, o);
2675
+ }, [ht, H?.numPages]), S(() => {
2676
+ G.current.emit("zoomEnabled", { enabled: f });
2677
+ }, [f]), S(() => {
2678
+ G.current.emit("scrollEnabled", { enabled: y });
2679
+ }, [y]), S(() => {
2680
+ const o = G.current;
2681
+ return () => {
2682
+ try {
2683
+ o.emit("destroy", {});
2684
+ } finally {
2685
+ o.clear();
2686
+ }
2687
+ };
2688
+ }, []);
2689
+ const je = I(() => {
2690
+ const o = nt.current;
2691
+ let h = 0;
2692
+ return o && (h = o.querySelectorAll(".pdfh5-page").length), {
2693
+ ready: !!H,
2694
+ loading: U.loading,
2695
+ total: H?.numPages ?? 0,
2696
+ page: at.current,
2697
+ zoom: ct.current,
2698
+ measured: At,
2699
+ cacheBytes: ft.stats().bytes,
2700
+ mountedPages: h,
2701
+ error: U.error?.message ?? null,
2702
+ zoomEnabled: f,
2703
+ scrollEnabled: y
2704
+ };
2705
+ }, [H, U.loading, U.error, At, ft, f, y]), En = A(Date.now()), Ue = A(/* @__PURE__ */ new Map()), We = I(
2706
+ (o) => {
2707
+ const h = Ue.current.get(o) ?? Date.now();
2708
+ Ue.current.delete(o);
2709
+ const v = {
2710
+ pageNumber: o,
2711
+ pageTime: Date.now() - h,
2712
+ totalTime: Date.now() - En.current
2713
+ };
2714
+ G.current.emit("render", v), Ce?.(v);
2715
+ },
2716
+ [Ce]
2717
+ ), qe = A(s);
2718
+ S(() => {
2719
+ if (qe.current === s) return;
2720
+ qe.current = s, Ot(1), ut?.(1);
2721
+ const o = nt.current;
2722
+ o && (o.scrollLeft = 0, o.scrollTop = 0);
2723
+ }, [s]);
2724
+ const et = I(
2725
+ (o, h = !1) => {
2726
+ const v = it(Math.round(o), 1, H?.numPages ?? 1), R = nt.current;
2727
+ if (!R) return;
2728
+ const j = s === "page", q = Vn(tt, v, j ? "x" : "y");
2729
+ h ? R.scrollTo({ [j ? "left" : "top"]: q, behavior: "smooth" }) : j ? R.scrollLeft = q : R.scrollTop = q, Jt(v);
2730
+ },
2731
+ [H?.numPages, tt, s]
2732
+ ), ue = A(!1);
2733
+ S(() => {
2734
+ ue.current || !H || tt.boxes.length === 0 || Y <= 0 || (ue.current = !0, c > 1 && requestAnimationFrame(() => et(c)));
2735
+ }, [H, tt.boxes.length, Y, c, et]), S(() => {
2736
+ ue.current = !1;
2737
+ }, [r]);
2738
+ const Sn = I(
2739
+ async (o) => {
2740
+ if (!(!H || !o))
2741
+ try {
2742
+ let h = o;
2743
+ if (typeof o == "string" && (h = await H.getDestination(o)), !Array.isArray(h) || h.length === 0) return;
2744
+ const v = h[0];
2745
+ let R = null;
2746
+ typeof v == "number" ? R = v + 1 : v && typeof v == "object" && "num" in v && (R = await H.getPageIndex(v) + 1), R && et(R, !0), It?.(o);
2747
+ } catch {
2748
+ }
2749
+ },
2750
+ [H, et, It]
2751
+ ), he = I(
2752
+ async (o) => {
2753
+ if (!H || !o.trim())
2754
+ return Zt([]), [];
2755
+ const h = await Br(H, o.trim());
2756
+ return Zt(h), re(0), h.length > 0 && et(h[0].pageNumber, !0), h;
2757
+ },
2758
+ [H, et]
2759
+ ), de = I(() => {
2760
+ Zt([]), re(0);
2761
+ const o = nt.current;
2762
+ if (o)
2763
+ for (const h of o.querySelectorAll(".pdfh5-textLayerHost mark")) {
2764
+ const v = h.parentNode;
2765
+ v && (v.replaceChild(document.createTextNode(h.textContent ?? ""), h), v.normalize());
2766
+ }
2767
+ }, []);
2768
+ S(() => {
2769
+ const o = nt.current;
2770
+ o && zt.length !== 0 && Ar(o, zt, ne);
2771
+ }, [zt, ne, Pn, mt.mounted]);
2772
+ const Et = I(() => {
2773
+ const o = ft.stats(), h = wt.stats(), v = vt.stats(), R = Lt.getStats();
2774
+ return {
2775
+ bitmap: {
2776
+ entries: o.entries,
2777
+ bytes: o.bytes,
2778
+ maxBytes: o.maxBytes,
2779
+ hits: o.hits,
2780
+ misses: o.misses,
2781
+ evictions: o.evictions
2782
+ },
2783
+ text: {
2784
+ entries: h.entries,
2785
+ bytes: h.bytes,
2786
+ maxBytes: h.maxBytes,
2787
+ hits: h.hits,
2788
+ misses: h.misses,
2789
+ evictions: h.evictions
2790
+ },
2791
+ page: { entries: 0, bytes: 0, maxBytes: 0, hits: 0, misses: 0, evictions: 0 },
2792
+ thumbnail: {
2793
+ entries: v.entries,
2794
+ bytes: v.bytes,
2795
+ maxBytes: v.maxBytes,
2796
+ hits: v.hits,
2797
+ misses: v.misses,
2798
+ evictions: v.evictions
2799
+ },
2800
+ metrics: { entries: At },
2801
+ renders: {
2802
+ started: R.started,
2803
+ completed: R.completed,
2804
+ cancelled: R.cancelled,
2805
+ cacheHits: o.hits,
2806
+ cacheMisses: o.misses
2807
+ },
2808
+ throttle: cr()
2809
+ };
2810
+ }, [ft, wt, vt, Lt, At]);
2811
+ S(() => {
2812
+ if (kt !== "search") return;
2813
+ const o = setInterval(() => se(Et()), 1e3);
2814
+ return se(Et()), () => clearInterval(o);
2815
+ }, [kt, Et]), Hn(
2816
+ n,
2817
+ () => ({
2818
+ getDocument: () => H,
2819
+ getCurrentPage: () => at.current,
2820
+ goToPage: (o, h) => et(o, h?.smooth),
2821
+ nextPage: () => et(at.current + 1, !0),
2822
+ prevPage: () => et(at.current - 1, !0),
2823
+ setZoom: (o, h) => {
2824
+ if (!h) {
2825
+ st(o);
2826
+ return;
2827
+ }
2828
+ const v = nt.current;
2829
+ if (!v) return;
2830
+ const R = v.getBoundingClientRect(), j = it(o, l, d) / ct.current, q = h.x - R.left + v.scrollLeft, ot = h.y - R.top + v.scrollTop;
2831
+ st(o, q * j - (h.x - R.left), ot * j - (h.y - R.top));
2832
+ },
2833
+ zoomIn: (o = 1.25) => st(ct.current * o),
2834
+ zoomOut: (o = 1.25) => st(ct.current / o),
2835
+ resetZoom: () => st(1),
2836
+ search: he,
2837
+ clearSearch: de,
2838
+ getCacheStats: Et,
2839
+ clearCaches: () => {
2840
+ ft.clear(), wt.clear(), vt.clear(), oe((o) => o + 1);
2841
+ },
2842
+ openPanel: (o) => Pt(o),
2843
+ on: (o, h) => G.current.on(o, h),
2844
+ once: (o, h) => G.current.once(o, h),
2845
+ off: (o, h) => G.current.off(o, h),
2846
+ trigger: (o, h) => G.current.emit(o, h),
2847
+ getStatus: je,
2848
+ getAnnotations: () => Le.current,
2849
+ addAnnotation: (o) => {
2850
+ Gt(o) && bt((h) => [...h, o]);
2851
+ },
2852
+ removeAnnotation: ze,
2853
+ clearAnnotations: ee,
2854
+ setAnnotationMode: (o) => {
2855
+ Qt(o), te.current = o;
2856
+ },
2857
+ getAnnotationMode: () => te.current
2858
+ }),
2859
+ [
2860
+ H,
2861
+ et,
2862
+ st,
2863
+ l,
2864
+ d,
2865
+ he,
2866
+ de,
2867
+ Et,
2868
+ ft,
2869
+ wt,
2870
+ vt,
2871
+ je,
2872
+ Nt,
2873
+ bt,
2874
+ ze,
2875
+ ee,
2876
+ Tt
2877
+ ]
2878
+ );
2879
+ const Ln = hr({
2880
+ scrollRef: nt,
2881
+ contentRef: Ee,
2882
+ // zoomEnable=false 时禁用手势与双击,但按钮 / API 缩放仍然可用。
2883
+ // 批注模式(或在输入批注)时也禁用手势:否则单指拖拽会同时触发绘制和滚动。
2884
+ enabled: !!H && !kt && f && Tt === "none" && !bn,
2885
+ zoom: xt,
2886
+ minZoom: l,
2887
+ maxZoom: d,
2888
+ doubleTapZoom: m,
2889
+ maxScroll: () => jt.current,
2890
+ // 手势缩放:走 transform 预演 + 松手提交,不需要动画(否则会「跟不上手」)
2891
+ onCommit: (o, h, v) => st(o, h, v, { source: "gesture" }),
2892
+ // 双击:带动画,保留空间连续性
2893
+ onDoubleTap: (o, h, v) => st(o, h, v, { animate: !0, source: "doubleTap" })
2894
+ }), zn = rt(() => {
2895
+ const o = U.progress;
2896
+ return !o || o.total <= 0 ? "35%" : `${Math.min(100, Math.max(4, Math.round(o.loaded / o.total * 100)))}%`;
2897
+ }, [U.progress]), [An, _e] = B(!1);
2898
+ S(() => {
2899
+ const o = nt.current;
2900
+ if (!o || !z) {
2901
+ _e(!1);
2902
+ return;
2903
+ }
2904
+ const h = pe(() => {
2905
+ const v = s === "page" ? o.scrollLeft : o.scrollTop;
2906
+ _e(v > (s === "page" ? Y : Q) * 0.8);
2907
+ });
2908
+ return o.addEventListener("scroll", h, { passive: !0 }), h(), () => {
2909
+ o.removeEventListener("scroll", h), h.cancel();
2910
+ };
2911
+ }, [z, s, Y, Q, tt.contentWidth, tt.contentHeight]);
2912
+ const Rn = I(() => {
2913
+ const o = nt.current;
2914
+ if (!o) return;
2915
+ const h = at.current;
2916
+ G.current.emit("backTop", { from: h }), s === "page" ? (o.scrollTo({ left: 0, behavior: "smooth" }), Jt(1)) : o.scrollTo({ top: 0, behavior: "smooth" });
2917
+ }, [s]), Dn = I(
2918
+ (o) => {
2919
+ oe((h) => h + 1), We(o);
2920
+ },
2921
+ [We]
2922
+ ), fe = A({ width: Y, height: Q }), _t = rt(
2923
+ () => cn((o) => {
2924
+ et(o);
2925
+ }, 120),
2926
+ [et]
2927
+ );
2928
+ S(() => {
2929
+ const o = fe.current;
2930
+ if (o.width === 0 || o.height === 0) {
2931
+ fe.current = { width: Y, height: Q };
2932
+ return;
2933
+ }
2934
+ (o.width !== Y || o.height !== Q) && (fe.current = { width: Y, height: Q }, _t(at.current));
2935
+ }, [Y, Q, _t]), S(() => () => _t.cancel(), [_t]);
2936
+ const me = H?.numPages ?? 0, $n = I(() => {
2937
+ const o = nt.current;
2938
+ if (!o) return;
2939
+ const h = o.getBoundingClientRect();
2940
+ return { x: h.left + h.width / 2, y: h.top + h.height / 2 };
2941
+ }, []);
2942
+ return U.loading || U.needPassword || U.error || !H ? /* @__PURE__ */ p(
2943
+ "div",
2944
+ {
2945
+ className: `pdfh5-root pdfh5-theme-${Ft} ${T ?? ""}`,
2946
+ style: E,
2947
+ "data-pdfh5-theme": nn[Ft],
2948
+ children: /* @__PURE__ */ p(
2949
+ zr,
2950
+ {
2951
+ loading: U.loading,
2952
+ needPassword: U.needPassword,
2953
+ passwordReason: U.passwordReason,
2954
+ error: U.error,
2955
+ progress: U.progress,
2956
+ onSubmitPassword: U.submitPassword,
2957
+ onCancelPassword: U.cancelPassword,
2958
+ renderError: dn
2959
+ }
2960
+ )
2961
+ }
2962
+ ) : /* @__PURE__ */ L(
2963
+ "div",
2964
+ {
2965
+ className: `pdfh5-root pdfh5-theme-${Ft} ${T ?? ""}`,
2966
+ style: E,
2967
+ "data-mode": s,
2968
+ "data-pdfh5-theme": nn[Ft],
2969
+ children: [
2970
+ $ && U.loading ? /* @__PURE__ */ p("div", { className: "pdfh5-loadingbar", "aria-hidden": "true", children: /* @__PURE__ */ p("span", { style: { width: zn } }) }) : null,
2971
+ /* @__PURE__ */ p(
2972
+ "div",
2973
+ {
2974
+ className: "pdfh5-viewport",
2975
+ "data-scroll-locked": y ? void 0 : "true",
2976
+ ref: (o) => {
2977
+ nt.current = o, mn(o);
2978
+ },
2979
+ children: /* @__PURE__ */ p(
2980
+ "div",
2981
+ {
2982
+ className: "pdfh5-content",
2983
+ ref: Ee,
2984
+ style: { width: tt.contentWidth, height: tt.contentHeight },
2985
+ children: tt.boxes.filter((o) => mt.mounted.includes(o.pageNumber)).map((o) => {
2986
+ const h = xn[o.pageNumber] ?? null, v = mt.visible.includes(o.pageNumber), R = !v && mt.prefetch.includes(o.pageNumber), j = o.width / (Ct[o.pageNumber - 1]?.width ?? ie.width);
2987
+ return /* @__PURE__ */ L(
2988
+ "div",
2989
+ {
2990
+ className: "pdfh5-page",
2991
+ "data-page-number": o.pageNumber,
2992
+ "data-visible": v || void 0,
2993
+ style: {
2994
+ transform: `translate3d(${o.left}px, ${o.top}px, 0)`,
2995
+ width: o.width,
2996
+ height: o.height
2997
+ },
2998
+ children: [
2999
+ /* @__PURE__ */ p(
3000
+ gr,
3001
+ {
3002
+ page: h,
3003
+ pageNumber: o.pageNumber,
3004
+ width: o.width,
3005
+ height: o.height,
3006
+ displayScale: j,
3007
+ devicePixelRatio: Cn,
3008
+ rotation: b,
3009
+ bitmapCache: ft,
3010
+ renderQueue: Lt,
3011
+ priority: v ? "visible" : "prefetch",
3012
+ shouldRender: v || R,
3013
+ maxCanvasPixels: F,
3014
+ maxCanvasDimension: w,
3015
+ onRendered: Dn
3016
+ }
3017
+ ),
3018
+ C ? /* @__PURE__ */ p(
3019
+ yr,
3020
+ {
3021
+ page: h,
3022
+ pageNumber: o.pageNumber,
3023
+ width: o.width,
3024
+ height: o.height,
3025
+ displayScale: j,
3026
+ rotation: b,
3027
+ textLayerCache: wt,
3028
+ renderQueue: Lt,
3029
+ enabled: C,
3030
+ shouldBuild: v || R
3031
+ }
3032
+ ) : null,
3033
+ M ? /* @__PURE__ */ p(
3034
+ br,
3035
+ {
3036
+ page: h,
3037
+ pageNumber: o.pageNumber,
3038
+ width: o.width,
3039
+ height: o.height,
3040
+ displayScale: j,
3041
+ rotation: b,
3042
+ enabled: M,
3043
+ onInternalLink: Sn,
3044
+ onExternalLink: yt
3045
+ }
3046
+ ) : null,
3047
+ W ? /* @__PURE__ */ p(
3048
+ qr,
3049
+ {
3050
+ pageNumber: o.pageNumber,
3051
+ width: o.width,
3052
+ height: o.height,
3053
+ mode: Tt,
3054
+ style: gn,
3055
+ annotations: yn.get(o.pageNumber) ?? [],
3056
+ enabled: v,
3057
+ onAdd: vn,
3058
+ onActiveChange: wn
3059
+ }
3060
+ ) : null,
3061
+ /* @__PURE__ */ p("div", { className: "pdfh5-pageNumber", children: o.pageNumber })
3062
+ ]
3063
+ },
3064
+ o.pageNumber
3065
+ );
3066
+ })
3067
+ }
3068
+ )
3069
+ }
3070
+ ),
3071
+ D ? /* @__PURE__ */ L("div", { className: "pdfh5-hud", "data-gesture": Ln.active || void 0, children: [
3072
+ /* @__PURE__ */ L("span", { className: "pdfh5-hud-page", children: [
3073
+ ht,
3074
+ " / ",
3075
+ me,
3076
+ At < me ? /* @__PURE__ */ p("span", { className: "pdfh5-hud-resolving", children: " · 解析中" }) : null
3077
+ ] }),
3078
+ /* @__PURE__ */ L("span", { className: "pdfh5-hud-zoom", children: [
3079
+ Math.round(xt * 100),
3080
+ "%"
3081
+ ] })
3082
+ ] }) : null,
3083
+ z && An ? /* @__PURE__ */ p("button", { type: "button", className: "pdfh5-backtop", onClick: Rn, "aria-label": "回到顶部", children: /* @__PURE__ */ p("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ p("path", { d: "M12 19V5M5 12l7-7 7 7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }) : null,
3084
+ P ? /* @__PURE__ */ p(
3085
+ vr,
3086
+ {
3087
+ mode: s,
3088
+ page: ht,
3089
+ total: me,
3090
+ zoom: xt,
3091
+ minZoom: l,
3092
+ maxZoom: d,
3093
+ panel: kt,
3094
+ panelSupported: { search: !0, outline: !0, thumbnails: !0 },
3095
+ annotation: W,
3096
+ annotationMode: Tt,
3097
+ annotationCount: Nt.length,
3098
+ onToggleAnnotation: (o) => {
3099
+ Qt((h) => h === o ? "none" : o);
3100
+ },
3101
+ onClearAnnotations: ee,
3102
+ onPrev: () => et(at.current - 1, !0),
3103
+ onNext: () => et(at.current + 1, !0),
3104
+ onJump: (o) => et(o),
3105
+ onZoomIn: () => st(ct.current * 1.25, void 0, void 0, { animate: !0, source: "button" }),
3106
+ onZoomOut: () => st(ct.current / 1.25, void 0, void 0, { animate: !0, source: "button" }),
3107
+ onResetZoom: () => st(1, void 0, void 0, { animate: !0, source: "reset" }),
3108
+ onTogglePanel: (o) => Pt(o),
3109
+ onLocate: () => {
3110
+ const o = $n();
3111
+ if (o) {
3112
+ const h = nt.current;
3113
+ if (!h) return;
3114
+ const v = h.getBoundingClientRect(), R = 1 / ct.current;
3115
+ st(
3116
+ 1,
3117
+ (o.x - v.left + h.scrollLeft) * R - (o.x - v.left),
3118
+ (o.y - v.top + h.scrollTop) * R - (o.y - v.top)
3119
+ );
3120
+ }
3121
+ }
3122
+ }
3123
+ ) : null,
3124
+ kt === "outline" ? /* @__PURE__ */ p(Pr, { doc: H, onClose: () => Pt(null), onNavigate: (o) => {
3125
+ Pt(null), et(o, !0);
3126
+ } }) : null,
3127
+ kt === "thumbnails" ? /* @__PURE__ */ p(
3128
+ Nr,
3129
+ {
3130
+ doc: H,
3131
+ cache: vt,
3132
+ currentPage: ht,
3133
+ rotation: b,
3134
+ onClose: () => Pt(null),
3135
+ onSelect: (o) => {
3136
+ Pt(null), et(o);
3137
+ }
3138
+ }
3139
+ ) : null,
3140
+ kt === "search" ? /* @__PURE__ */ p(
3141
+ Lr,
3142
+ {
3143
+ hits: zt,
3144
+ index: ne,
3145
+ onSearch: he,
3146
+ onSelect: (o) => {
3147
+ re(o);
3148
+ const h = zt[o];
3149
+ h && et(h.pageNumber, !0);
3150
+ },
3151
+ onClose: () => {
3152
+ de(), Pt(null);
3153
+ },
3154
+ stats: kn,
3155
+ onClearCaches: () => {
3156
+ ft.clear(), wt.clear(), vt.clear(), oe((o) => o + 1), se(Et());
3157
+ }
3158
+ }
3159
+ ) : null
3160
+ ]
3161
+ }
3162
+ );
3163
+ });
3164
+ function is(e) {
3165
+ const t = I(() => e.current?.nextPage(), [e]), n = I(() => e.current?.prevPage(), [e]), r = I((a) => e.current?.goToPage(a), [e]), s = I(() => e.current?.zoomIn(), [e]), i = I(() => e.current?.zoomOut(), [e]), c = I(() => e.current?.resetZoom(), [e]);
3166
+ return { next: t, prev: n, goTo: r, zoomIn: s, zoomOut: i, resetZoom: c };
3167
+ }
3168
+ export {
3169
+ qr as AnnotationLayer,
3170
+ Bt as BitmapCache,
3171
+ jr as DEFAULT_ANNOTATION_STYLE,
3172
+ Hr as EventEmitter,
3173
+ Xt as LruCache,
3174
+ rr as PageProxyCache,
3175
+ os as PdfH5Reader,
3176
+ ln as RenderQueue,
3177
+ nr as TextLayerCache,
3178
+ sr as ThumbnailCache,
3179
+ Zr as animateZoom,
3180
+ Qn as bitmapBytes,
3181
+ Xn as clampCanvasSize,
3182
+ rs as clearSearchCache,
3183
+ _n as computeLayout,
3184
+ Jr as configurePdfjs,
3185
+ ge as createAnnotationId,
3186
+ Cr as createThumbnailCanvas,
3187
+ cn as debounce,
3188
+ ur as doubleTapTarget,
3189
+ $r as extractPageText,
3190
+ Er as findInPage,
3191
+ xr as flattenOutline,
3192
+ Qr as getPdfjsRuntimeOptions,
3193
+ Wr as groupByPage,
3194
+ Ar as highlightTextNodes,
3195
+ Gt as isAnnotationValid,
3196
+ ss as isPointInPage,
3197
+ sn as loadPdf,
3198
+ ts as loadPdfDocument,
3199
+ un as makeSnippet,
3200
+ Vn as offsetForPage,
3201
+ Kn as pageAtOffset,
3202
+ Ht as pdfjsLib,
3203
+ Vt as pinchCommit,
3204
+ lr as pinchTransform,
3205
+ Gn as quantizePixelRatio,
3206
+ es as quantizeScale,
3207
+ jn as rafBatch,
3208
+ pe as rafThrottle,
3209
+ Qe as rectFromPoints,
3210
+ hn as rectToPixel,
3211
+ Br as searchDocument,
3212
+ Or as shouldReduceMotion,
3213
+ Tr as splitSnippet,
3214
+ be as throttle,
3215
+ Ur as toNormalized,
3216
+ ke as toPixel,
3217
+ ar as useElementSize,
3218
+ or as usePageMetrics,
3219
+ Wn as usePdfDocument,
3220
+ is as usePdfH5ReaderActions,
3221
+ hr as usePinchGesture,
3222
+ ir as useVirtualPages,
3223
+ Jn as viewportScaleFor,
3224
+ ns as zoomAtPoint
3225
+ };
3226
+ //# sourceMappingURL=index.js.map