@pdf-viewer/react 1.9.0-beta.6 → 1.9.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/SearchCloseButton-cbf182aa.js +33 -0
  2. package/dist/ToolbarLayout.module-201969d2.js +3453 -0
  3. package/dist/assets/ToolbarLayout.css +1 -1
  4. package/dist/components/RPController.js +8 -8
  5. package/dist/components/RPDropFileZone.js +23 -21
  6. package/dist/components/RPPages.js +17 -18
  7. package/dist/components/RPProvider.js +14 -15
  8. package/dist/components/layout/Container.js +11 -10
  9. package/dist/components/layout/LayoutContainer.js +15 -16
  10. package/dist/components/layout/RPDefaultLayout.js +14 -76
  11. package/dist/components/layout/RPLayout.js +22 -22
  12. package/dist/components/layout/WrapperLayout.js +8 -7
  13. package/dist/components/layout/sidebar/RPSidebar.js +12 -51
  14. package/dist/components/layout/sidebar/RPSplitter.js +9 -7
  15. package/dist/components/layout/sidebar/Thumbnail.js +15 -16
  16. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  17. package/dist/components/layout/toolbar/DocumentDialog.js +24 -305
  18. package/dist/components/layout/toolbar/FileDownloadTool.js +13 -23
  19. package/dist/components/layout/toolbar/MenuItem.js +7 -6
  20. package/dist/components/layout/toolbar/MenuSeparator.js +5 -4
  21. package/dist/components/layout/toolbar/MostPageTool.js +25 -50
  22. package/dist/components/layout/toolbar/OtherTool.js +22 -115
  23. package/dist/components/layout/toolbar/Paginate.js +17 -99
  24. package/dist/components/layout/toolbar/PrintTool.js +13 -43
  25. package/dist/components/layout/toolbar/PropertyItem.js +8 -5
  26. package/dist/components/layout/toolbar/RPToolbar.js +7 -28
  27. package/dist/components/layout/toolbar/RPToolbarEnd.js +7 -22
  28. package/dist/components/layout/toolbar/RotateTool.js +21 -20
  29. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  30. package/dist/components/layout/toolbar/SearchCloseButton.js +7 -19
  31. package/dist/components/layout/toolbar/SearchResultNavigator.js +8 -42
  32. package/dist/components/layout/toolbar/SearchTool.js +30 -197
  33. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  34. package/dist/components/layout/toolbar/ThumbnailTool.js +3 -3
  35. package/dist/components/layout/toolbar/ToolbarCustom.js +22 -24
  36. package/dist/components/layout/toolbar/ToolbarDefault.js +19 -24
  37. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  38. package/dist/components/layout/toolbar/ZoomTool.js +28 -140
  39. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +1 -1
  40. package/dist/components/layout/toolbar/tools/InputPageTool.js +5 -5
  41. package/dist/components/layout/toolbar/tools/NextPageTool.js +17 -18
  42. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
  43. package/dist/components/layout/toolbar/tools/PrintTool.js +3 -3
  44. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
  45. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +7 -7
  46. package/dist/components/layout/toolbar/tools/defaults/RPHorizontalBar.js +20 -26
  47. package/dist/components/page/AnnotationLayer.js +16 -17
  48. package/dist/components/page/CanvasLayer.js +16 -17
  49. package/dist/components/page/DualPage.js +1 -1
  50. package/dist/components/page/RPPage.js +16 -17
  51. package/dist/components/page/SinglePage.js +1 -1
  52. package/dist/components/page/TextHighlightLayer.js +16 -17
  53. package/dist/components/page/TextLayer.js +16 -17
  54. package/dist/components/ui/Checkbox.js +51 -49
  55. package/dist/components/ui/DropDown.js +19 -13
  56. package/dist/components/ui/LoadingIndicator.js +5 -22
  57. package/dist/components/ui/RPTooltip.js +33 -33
  58. package/dist/contexts/PaginationContext.js +1 -1
  59. package/dist/contexts/PrintContext.js +1 -1
  60. package/dist/contexts/RenderQueueProvider.js +1 -1
  61. package/dist/contexts/SearchContext.js +3 -3
  62. package/dist/contexts/ThumbnailsContext.js +1 -1
  63. package/dist/{index-492f99d0.js → index-18b0454c.js} +1 -1
  64. package/dist/{index-2160dd99.js → index-5908484b.js} +11 -11
  65. package/dist/index-f4a9ae4d.js +1664 -0
  66. package/dist/main.js +48 -50
  67. package/dist/types/components/layout/RPDefaultLayout.d.ts +1 -2
  68. package/dist/types/components/layout/toolbar/RPToolbar.d.ts +3 -2
  69. package/dist/utils/hooks/useFileDownload.js +16 -17
  70. package/dist/utils/hooks/useLicense.js +1 -1
  71. package/dist/utils/hooks/usePaginate.js +16 -17
  72. package/dist/utils/hooks/usePresentPage.js +16 -17
  73. package/dist/utils/hooks/usePrint.js +16 -17
  74. package/dist/utils/hooks/useScrollToPage.js +16 -17
  75. package/dist/utils/hooks/useSearch.js +16 -17
  76. package/dist/utils/hooks/useThumbnail.js +16 -17
  77. package/dist/utils/hooks/useVirtualReactWindow.js +16 -17
  78. package/package.json +1 -1
  79. package/dist/Checkbox.module-3edaacbb.js +0 -7
  80. package/dist/Combination-9a0a3e65.js +0 -693
  81. package/dist/Container.module-f8b5c306.js +0 -6
  82. package/dist/DropDown.module-a78567cb.js +0 -11
  83. package/dist/MenuItem.module-bc11d0d3.js +0 -6
  84. package/dist/MenuSeparator.module-89b2ff7f.js +0 -6
  85. package/dist/PropertyItem.module-db0150cc.js +0 -8
  86. package/dist/RPSplitter.module-13d612c4.js +0 -7
  87. package/dist/RPTheme.module-bd9038da.js +0 -8
  88. package/dist/RotateTool.module-03987eba.js +0 -6
  89. package/dist/SearchTool.module-016f3a8d.js +0 -16
  90. package/dist/ToolbarLayout.module-88476995.js +0 -2464
  91. package/dist/WrapperLayout.module-147bc943.js +0 -6
  92. package/dist/index-49b9a615.js +0 -978
  93. /package/dist/assets/{RPTheme.css → RPDropFileZone.css} +0 -0
  94. /package/dist/assets/{SearchTool.css → SearchCloseButton.css} +0 -0
@@ -1,2464 +0,0 @@
1
- import { jsx as z, Fragment as mt, jsxs as Ve } from "react/jsx-runtime";
2
- import { useRef as W, useEffect as A, useCallback as F, useState as q, useMemo as H, createContext as we, useContext as be, useImperativeHandle as _t, createElement as Se, PureComponent as Wt, Component as kt, memo as vt } from "react";
3
- import { c as he } from "./clsx-0c6e471a.js";
4
- import { LoaderIcon as wt } from "./components/icons/LoaderIcon.js";
5
- import { ViewMode as ge, ScrollMode as K, AnnotationSubType as Ye, SelectionMode as Dt } from "./utils/types.js";
6
- import { useScrollModeContext as me } from "./contexts/ScrollModeContext.js";
7
- import { useDocumentContext as Y } from "./contexts/RPDocumentContext.js";
8
- import { useDocumentPasswordContext as Ht } from "./contexts/DocumentPasswordContext.js";
9
- import { useDarkModeContext as $t } from "./contexts/DarkModeContext.js";
10
- import "./contexts/RotationContext.js";
11
- import { useLayerContext as qt } from "./contexts/LayerContext.js";
12
- import { useZoomContext as je } from "./contexts/ZoomContext.js";
13
- import { useViewModeContext as Ce } from "./contexts/ViewModeContext.js";
14
- import { useVirtualScrollContext as Re } from "./contexts/VirtualScrollContext.js";
15
- import { useVirtualGridContext as bt } from "./contexts/VirtualGridContext.js";
16
- import { useSelectionModeContext as Gt } from "./contexts/SelectionModeContext.js";
17
- import { useInitialStateContext as Ut } from "./contexts/InitialStateContext.js";
18
- import { useFullScreenContext as Vt } from "./contexts/FullScreenContext.js";
19
- import "./contexts/FileInputContext.js";
20
- import "./contexts/DropFileZoneContext.js";
21
- import { findMatches as jt, resetDivs as Bt, highlightMatches as Zt, isMatchEntireWord as Xt } from "./utils/highlight.js";
22
- import { useLayoutContainer as Ie } from "./contexts/LayoutContainerContext.js";
23
- import { useDimensionPagesContext as xe } from "./contexts/DimensionPagesContext.js";
24
- import "./contexts/LocalizationContext.js";
25
- import { useHighlightContext as Kt } from "./contexts/HighlightContext.js";
26
- import "./contexts/LicenseContext.js";
27
- import { useDownloadContext as Qt } from "./contexts/DownloadContext.js";
28
- import { useSmoothScrollContext as Ct } from "./contexts/SmoothScrollContext.js";
29
- import "./contexts/ElementPageContext.js";
30
- import { usePagesRotateContext as Le } from "./contexts/PagesRotateContext.js";
31
- import { Queue as Yt } from "./utils/Queue.js";
32
- import { renderPage as Jt } from "./utils/renderPage.js";
33
- import { useLoaderContext as en } from "./contexts/LoaderContext.js";
34
- import "./contexts/ToolComponentContext.js";
35
- import "./contexts/IconToolContext.js";
36
- import "./contexts/OtherToolContext.js";
37
- import { useThemeContext as tn } from "./contexts/ThemeContext.js";
38
- import "./components/RPConfig.js";
39
- import "./components/ui/Button.js";
40
- import "./components/ui/Input.js";
41
- import "./contexts/IconContext.js";
42
- import "./contexts/ToolbarComponentContext.js";
43
- import "./contexts/ViewportContext.js";
44
- import "./components/ui/RPTooltip.js";
45
- import "./MenuItem.module-bc11d0d3.js";
46
- import "./DropDown.module-a78567cb.js";
47
- import "./utils/dateFormatter.js";
48
- import "./PropertyItem.module-db0150cc.js";
49
- import "./MenuSeparator.module-89b2ff7f.js";
50
- import "./RotateTool.module-03987eba.js";
51
- import "./SearchTool.module-016f3a8d.js";
52
- import "./Checkbox.module-3edaacbb.js";
53
- import { useInfiniteScroll as nn } from "./utils/hooks/useInfiniteScroll.js";
54
- import { withRef as Be } from "./utils/withRef.js";
55
- import "./RPSplitter.module-13d612c4.js";
56
- import "./Container.module-f8b5c306.js";
57
- import "./WrapperLayout.module-147bc943.js";
58
- import "./RPTheme.module-bd9038da.js";
59
- import * as rn from "pdfjs-dist";
60
- import { PixelsPerInch as on, AnnotationMode as sn, RenderingCancelledException as an, AnnotationLayer as cn } from "pdfjs-dist";
61
- import { SimpleLinkService as ln } from "./utils/link_service.js";
62
- import { annotationsEvents as un, annotationEventsHandler as dn, handleClick as Je, handleAnnotationWidget as pn, handleAnnotationLink as hn, bindLayerEvents as fn, unbindLayerEvents as et } from "./utils/annotations.js";
63
- import { normalizeSingleKeyword as gn, sortHighlightPosition as mn, unwrap as _n } from "./components/page/searchHighlight.js";
64
- import { CustomElement as vn } from "./components/page/CustomElement.js";
65
- import { useMousePressed as wn } from "./utils/hooks/useMousePressed.js";
66
- import { useGrabScroll as bn } from "./utils/hooks/useGrabScroll.js";
67
- import { usePinch as Cn } from "./utils/hooks/usePinch.js";
68
- import { useDebounce as Ze } from "./utils/hooks/useDebounce.js";
69
- import xn from "./components/ui/PasswordModal.js";
70
- import { getPositionFromPage as Sn, getPageFromPosition as yn } from "./utils/calculatePage.js";
71
- import { getScrollDistance as fe } from "./utils/getScrollDistance.js";
72
- import { getWordPositionInPage as Pn } from "./utils/getWordPositionInPage.js";
73
- import { getThumbnailViewport as Tn } from "./utils/getThumbnailViewport.js";
74
- import { smoothScrollTo as Ne } from "./utils/smoothScrollTo.js";
75
- import { appConsole as Rn } from "./utils/appConsole.js";
76
- import './assets/ToolbarLayout.css';const xt = () => {
77
- const { viewMode: n } = Ce(), { scrollMode: e } = me(), { virtualScrollRef: t, virtualScrollableElementRef: o, pageScrollElementRef: s } = Re(), { setFocusedPage: i } = ne(), a = W(), { columnCount: c } = bt(), { widths: l, heights: f } = xe(), g = W(e), x = W(n), d = W(c), { targetScrollPage: w } = Ct();
78
- A(() => {
79
- t != null && t.scrollToItem && (a.current = t);
80
- }, [t]), A(() => {
81
- g.current = e, x.current = n;
82
- }, [e, n]);
83
- const C = F(
84
- (v, S) => {
85
- if (!s)
86
- return;
87
- const h = Math.ceil(v / 2) * 2 - 1;
88
- if (v === h + 1) {
89
- const p = {
90
- left: l[h],
91
- top: 0
92
- };
93
- return new Promise(
94
- (r) => Ne(s, p, r)
95
- );
96
- }
97
- const u = {
98
- left: 0,
99
- top: 0
100
- };
101
- return s == null ? void 0 : s.scrollTo({
102
- ...u,
103
- behavior: S
104
- });
105
- },
106
- [s, l, Ne]
107
- );
108
- return A(() => {
109
- g.current = e, x.current = n;
110
- }, [e, n]), A(() => {
111
- d.current = c;
112
- }, [c]), { scrollToPage: F(
113
- (v, S = "smooth") => {
114
- console.log("scrollToPage", v), i(v);
115
- const h = v - 1;
116
- let u = h, p = 0;
117
- if (x.current === ge.DUAL_PAGE && g.current === K.PAGE_SCROLLING) {
118
- C(v, S);
119
- return;
120
- }
121
- if (g.current === K.PAGE_SCROLLING) {
122
- i(v);
123
- return;
124
- }
125
- if (!a.current || !o)
126
- return;
127
- const r = o;
128
- if (S === "smooth" && (w.current = v), g.current === K.HORIZONTAL_SCROLLING) {
129
- p = h;
130
- const b = {
131
- left: fe(l, p),
132
- top: 0
133
- };
134
- return r.scrollTo({
135
- ...b,
136
- behavior: S
137
- });
138
- }
139
- if (x.current === ge.DUAL_PAGE) {
140
- p = h % 2, u = Math.floor(h / 2);
141
- const b = {
142
- left: fe(l, p),
143
- top: fe(f, u)
144
- };
145
- return r.scrollTo({
146
- ...b,
147
- behavior: S
148
- });
149
- }
150
- const _ = {
151
- left: 0,
152
- top: fe(f, u)
153
- };
154
- return r.scrollTo({
155
- ..._,
156
- behavior: S
157
- });
158
- },
159
- [
160
- o,
161
- c,
162
- C,
163
- i,
164
- Ne,
165
- f,
166
- l
167
- ]
168
- ) };
169
- }, In = (n = 1) => {
170
- const [e, t] = q(n), [o, s] = q(0), { scrollToPage: i } = xt(), a = W(1), { viewMode: c } = Ce(), { scrollMode: l } = me(), { widths: f } = xe(), { pagesRef: g } = Ie(), x = Ze(e, 100), d = F(
171
- (u) => {
172
- if (!/^[0-9]*$/g.test(u.toString()) || !u)
173
- return { success: !1, currentPage: a.current };
174
- const r = +u;
175
- return r < 0 || r > o ? { success: !1, currentPage: a.current } : (t(r), a.current = r, { success: !0, currentPage: +u });
176
- },
177
- [o]
178
- ), w = F(d, [d]), C = F(
179
- (u) => {
180
- const p = d(u);
181
- return p.success && i(p.currentPage), p;
182
- },
183
- [d, i]
184
- ), P = F((u) => {
185
- const p = u % 2 === 1;
186
- if (!g || p)
187
- return !1;
188
- const r = p ? f[u] : f[u - 1], _ = p ? f[u + 1] : f[u];
189
- return c === ge.DUAL_PAGE && r + _ < g.clientWidth;
190
- }, [c, f, g, o]), v = F(() => {
191
- let u = e - 1;
192
- P(u) && (u = e - 2), C(u);
193
- }, [C, e, c, l, P]), S = H(() => c === ge.DUAL_PAGE && l === K.PAGE_SCROLLING ? e === o - 1 : e === o, [e, o, c, l]), h = F(() => {
194
- if (S)
195
- return;
196
- let u = e + 1;
197
- P(u) && (u = e + 2), C(u);
198
- }, [C, e, P, c, l, S]);
199
- return {
200
- focusedPage: x,
201
- totalPages: o,
202
- setFocusedPage: w,
203
- setTotalPages: s,
204
- nextPage: h,
205
- prevPage: v,
206
- goToPage: C
207
- };
208
- }, St = we({
209
- focusedPage: 0,
210
- setFocusedPage: (n) => {
211
- },
212
- goToPage: (n) => ({ success: !!n, currentPage: +n }),
213
- totalPages: 0,
214
- setTotalPages: (n) => {
215
- },
216
- prevPage: () => {
217
- },
218
- nextPage: () => {
219
- }
220
- }), ne = () => {
221
- const n = be(St);
222
- return typeof (n == null ? void 0 : n.focusedPage) > "u" && Rn.error("Please use this hooks inside children component of RPProvider"), n;
223
- }, qo = ({ children: n }) => {
224
- const { pdf: e } = Y(), { focusedPage: t, totalPages: o, setFocusedPage: s, setTotalPages: i, goToPage: a, nextPage: c, prevPage: l } = In();
225
- return A(() => {
226
- e != null && e.numPages && (i(e.numPages), s(1));
227
- }, [e, i, s]), /* @__PURE__ */ z(
228
- St.Provider,
229
- {
230
- value: {
231
- focusedPage: t,
232
- totalPages: o,
233
- setFocusedPage: s,
234
- setTotalPages: i,
235
- nextPage: c,
236
- prevPage: l,
237
- goToPage: a
238
- },
239
- children: n
240
- }
241
- );
242
- };
243
- const Ln = () => {
244
- const { pdf: n, pages: e } = Y(), [t, o] = q({
245
- loadedPages: 0,
246
- totalPages: 0,
247
- percentage: 0
248
- }), [s, i] = q(!1), [a, c] = q(!1), [l, f] = q(null), g = W(!1);
249
- A(() => {
250
- g.current;
251
- }, [g]);
252
- const x = F(() => {
253
- document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
254
- const u = document.querySelector(".rp-print-zone");
255
- u && u.remove();
256
- }, []), d = F(() => {
257
- g.current = !1, i(!1), c(!1), f(null), o({
258
- loadedPages: 0,
259
- totalPages: 0,
260
- percentage: 0
261
- });
262
- }, []), w = () => {
263
- g.current = !0;
264
- }, C = async ({
265
- scratchCanvas: u,
266
- pdfDocument: p,
267
- pageNumber: r,
268
- viewerPdfPage: _,
269
- printResolution: m,
270
- optionalContentConfigPromise: b,
271
- printAnnotationStoragePromise: I
272
- }) => {
273
- if (g.current) {
274
- d();
275
- return;
276
- }
277
- const y = m / on.PDF;
278
- u.width = Math.floor(_.width * y), u.height = Math.floor(_.height * y);
279
- const T = u.getContext("2d");
280
- T.save(), T.fillStyle = "rgb(255, 255, 255)", T.fillRect(0, 0, u.width, u.height), T.restore();
281
- const [E, O] = await Promise.all([
282
- p.getPage(r),
283
- I
284
- ]);
285
- if (g.current) {
286
- d();
287
- return;
288
- }
289
- const N = {
290
- canvasContext: T,
291
- transform: [y, 0, 0, y, 0, 0],
292
- viewport: E.getViewport({ scale: 1, rotation: _.rotation }),
293
- intent: "print",
294
- annotationMode: sn.ENABLE_STORAGE,
295
- optionalContentConfigPromise: b,
296
- printAnnotationStorage: O
297
- };
298
- try {
299
- return E.render(N).promise;
300
- } catch (R) {
301
- throw R instanceof an || console.error(R), R;
302
- }
303
- }, P = F(() => {
304
- const u = window.print;
305
- return new Promise((p) => {
306
- const r = (b) => {
307
- setTimeout(() => {
308
- u.call(window), setTimeout(() => b(), 20);
309
- }, 0);
310
- };
311
- if (document.querySelector(".rp-print-zone")) {
312
- r(p);
313
- return;
314
- }
315
- const m = new MutationObserver(() => {
316
- document.querySelector(".rp-print-zone") && (r(p), m.disconnect());
317
- });
318
- m.observe(document.body, { childList: !0, subtree: !0 });
319
- });
320
- }, []), v = async (u) => {
321
- const p = document.createElement("img"), r = document.createElement("div");
322
- return r.classList.add("rp-print-page"), await new Promise((_, m) => {
323
- u.toBlob((b) => {
324
- b ? (p.src = URL.createObjectURL(b), p.onload = () => {
325
- URL.revokeObjectURL(p.src), _();
326
- }, p.onerror = m) : m(new Error("Failed to create blob"));
327
- });
328
- }).catch(() => {
329
- }), r.appendChild(p), r;
330
- }, S = (u, p) => {
331
- const r = document.createElement("div");
332
- r.classList.add("rp-print-zone");
333
- const _ = document.createElement("style"), m = p.get(1);
334
- if (m) {
335
- const { width: b, height: I } = m == null ? void 0 : m.page.getViewport({ scale: 1 });
336
- _.innerHTML = `@page { size: ${b}px ${I}px }`;
337
- }
338
- return r.appendChild(_), r.append(...u), r;
339
- }, h = F(async () => {
340
- if (!n)
341
- return;
342
- d();
343
- const u = document.createElement("canvas"), p = [];
344
- try {
345
- n.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
346
- const _ = n.getOptionalContentConfig({ intent: "print" }), m = Promise.resolve(
347
- n.annotationStorage.print ?? void 0
348
- ), b = e.size;
349
- for (const [y, T] of e) {
350
- if (g.current) {
351
- d();
352
- return;
353
- }
354
- const E = T.page.getViewport({ scale: 1 });
355
- if (await C({
356
- scratchCanvas: u,
357
- pdfDocument: n,
358
- pageNumber: y,
359
- viewerPdfPage: E,
360
- printResolution: 150,
361
- optionalContentConfigPromise: _,
362
- printAnnotationStoragePromise: m
363
- }), g.current) {
364
- d();
365
- return;
366
- }
367
- const O = await v(u);
368
- p.push(O);
369
- const N = parseFloat((p.length / b * 100).toFixed(2));
370
- o({
371
- loadedPages: y,
372
- totalPages: b,
373
- percentage: N
374
- });
375
- }
376
- if (g.current) {
377
- d();
378
- return;
379
- }
380
- const I = S(p, e);
381
- document.body.appendChild(I), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), i(!0), await P();
382
- } catch (r) {
383
- c(!0), r instanceof Error && f(r);
384
- } finally {
385
- u.height = 0, u.width = 0;
386
- }
387
- }, [n, e, g]);
388
- return A(() => {
389
- const u = () => {
390
- d(), x();
391
- };
392
- return window.addEventListener("afterprint", u, !0), () => {
393
- window.removeEventListener("afterprint", u, !0);
394
- };
395
- }, [x, d]), {
396
- print: h,
397
- cancel: w,
398
- progress: t,
399
- isComplete: s,
400
- isError: a,
401
- error: l
402
- };
403
- }, yt = we({
404
- print: () => {
405
- },
406
- cancel: () => {
407
- },
408
- setOnProgress: (n) => {
409
- },
410
- progress: {},
411
- setOnComplete: (n) => n(),
412
- setOnError: (n) => {
413
- try {
414
- const e = new Error("Print error occurred");
415
- n(e);
416
- } catch (e) {
417
- console.error("Error in setOnError callback:", e);
418
- }
419
- }
420
- }), Go = ({ children: n }) => {
421
- const [e, t] = q(null), [o, s] = q(null), { print: i, cancel: a, progress: c, isComplete: l, isError: f, error: g } = Ln(), x = F((v) => {
422
- v && typeof v == "function" && s(() => v);
423
- }, []), d = (v) => {
424
- g && v(g);
425
- }, w = F(
426
- (v) => {
427
- t(() => v);
428
- },
429
- [c, e]
430
- );
431
- A(() => {
432
- l && o && C();
433
- }, [l, o]), A(() => {
434
- f && d((v) => {
435
- console.error(v);
436
- });
437
- }, [f]), A(() => {
438
- c && e && e(c);
439
- }, [c, e]);
440
- const C = () => {
441
- o && (o(), s(null));
442
- }, P = {
443
- print: i,
444
- cancel: a,
445
- setOnProgress: w,
446
- setOnComplete: x,
447
- setOnError: d,
448
- progress: c
449
- };
450
- return /* @__PURE__ */ z(yt.Provider, { value: P, children: n });
451
- }, En = () => {
452
- const n = be(yt);
453
- if (!n)
454
- throw new Error("usePrintContext must be used within a PrintProvider");
455
- return n;
456
- }, Mn = () => {
457
- const [n, e] = q({}), { pages: t } = Y(), o = H(() => Object.keys(n).length, [n]), s = F(
458
- (a) => {
459
- if (!t.size)
460
- return;
461
- const c = a > t.size ? t.size : a, f = Array.from(t.values()).slice(0, c).map((g) => {
462
- const { thumbnailViewport: x, scale: d } = Tn(g.page, g.defaultRotation);
463
- return {
464
- scale: d,
465
- page: g.page,
466
- loading: !0,
467
- viewport: x,
468
- defaultRotation: g.defaultRotation
469
- };
470
- }).reduce((g, x) => (g[x.page.pageNumber] = x, g), {});
471
- e(f);
472
- },
473
- [t]
474
- );
475
- A(() => {
476
- s(10);
477
- }, [s]);
478
- const i = F(
479
- (a) => {
480
- if (!t)
481
- return;
482
- const c = t.get(a);
483
- c && e((l) => ({
484
- ...l,
485
- [a]: {
486
- loading: !0,
487
- page: c.page,
488
- viewport: c.thumbnailViewport,
489
- scale: c.thumbnailScale,
490
- defaultRotation: c.defaultRotation
491
- }
492
- }));
493
- },
494
- [t]
495
- );
496
- return { thumbnailPages: n, addPage: i, addToPage: s, thumbnailLength: o };
497
- }, Pt = we({
498
- thumbnailPages: {},
499
- addPage: (n) => {
500
- },
501
- addToPage: (n) => {
502
- },
503
- thumbnailLength: 0,
504
- setActive: (n) => {
505
- },
506
- active: !1
507
- }), zn = () => be(Pt), Uo = ({
508
- children: n,
509
- initialThumbnailsVisible: e
510
- }) => {
511
- const { thumbnailPages: t, addPage: o, addToPage: s, thumbnailLength: i } = Mn(), [a, c] = q(e);
512
- return /* @__PURE__ */ z(
513
- Pt.Provider,
514
- {
515
- value: { thumbnailPages: t, addPage: o, addToPage: s, thumbnailLength: i, active: a, setActive: c },
516
- children: n
517
- }
518
- );
519
- }, On = (n = {}, e = "") => {
520
- const [t, o] = q(e), [s, i] = q(!1), { pdf: a, pages: c } = Y(), { widths: l, heights: f } = xe(), g = W(!t), { currentZoom: x } = je(), [d, w] = q([]), { setFocusedPage: C } = ne(), { columnCount: P } = Ce(), { pageRotate: v } = Le(), [S, h] = q(0), { pageScrollElementRef: u, virtualScrollableElementRef: p } = Re(), { scrollMode: r } = me(), { pagesRef: _ } = Ie(), [m, b] = q(null), I = W({}), y = H(() => S === 0 ? null : d[S - 1], [S, d]), T = H(() => d.length, [d]);
521
- A(() => {
522
- if (!y || !c)
523
- return;
524
- const R = p || u;
525
- if (!R || !_)
526
- return;
527
- const L = c.get(y.page);
528
- if (r === K.PAGE_SCROLLING && C(y.page), !L)
529
- return;
530
- let M = 0, k = 0;
531
- if (r === K.VERTICAL_SCROLLING) {
532
- const ee = y.page - 1, Z = P, _e = ee % Z, ie = Math.floor(ee / Z);
533
- M = fe(f, ie), k = fe(l, _e);
534
- }
535
- r === K.HORIZONTAL_SCROLLING && (k = l.slice(0, y.page - 1).reduce((ee, Z) => ee + Z, 0));
536
- const D = {
537
- height: f[y.page - 1],
538
- width: l[y.page - 1]
539
- }, V = {
540
- top: D.height / 2,
541
- left: D.width / 2
542
- }, j = v[y.page], { leftInPage: U, topInPage: X } = Pn(
543
- D,
544
- V,
545
- y.rect,
546
- x,
547
- j
548
- ), B = k + U, J = M + X, se = {
549
- left: Math.max(B, 0),
550
- top: Math.max(J, 0)
551
- };
552
- R.scrollTo({
553
- ...se,
554
- behavior: "smooth"
555
- });
556
- }, [
557
- c,
558
- C,
559
- l,
560
- f,
561
- y,
562
- r,
563
- p,
564
- u,
565
- _
566
- ]);
567
- const E = F(() => {
568
- h((R) => T ? R + 1 > T ? 1 : R + 1 : 0);
569
- }, [T]), O = F(() => {
570
- h((R) => T ? R - 1 <= 0 ? T : R - 1 : 0);
571
- }, [T]), N = F(async (R) => {
572
- if (!R)
573
- return {};
574
- const L = R.numPages, M = {};
575
- for (let k = 1; k <= L; k++) {
576
- if (g.current)
577
- throw "close pop over";
578
- const D = await R.getPage(k);
579
- M[k.toString()] = await D.getTextContent();
580
- }
581
- return M;
582
- }, []);
583
- return A(() => {
584
- if (!t) {
585
- g.current = !0, w([]), h(0);
586
- return;
587
- }
588
- g.current = !1, i(!0), w([]), h(0), N(a).then((R) => {
589
- I.current = R;
590
- const M = Object.keys(R).reduce((k, D) => {
591
- const V = jt(
592
- [t],
593
- R[D],
594
- Number(D) - 1,
595
- n
596
- ).map((j, U) => ({ ...j, page: Number(D), pageMatchIdx: U }));
597
- return [...k, ...V];
598
- }, []);
599
- w(M), h(M.length ? 1 : 0);
600
- }).catch(() => {
601
- w([]), h(0);
602
- }).finally(() => i(!1));
603
- }, [t, N, a, n]), {
604
- search: t,
605
- setSearch: o,
606
- loading: s,
607
- matches: d,
608
- totalMatches: T,
609
- currentMatchPosition: S,
610
- currentMatch: y,
611
- nextMatch: E,
612
- prevMatch: O,
613
- currentMatchElement: m,
614
- setCurrentMatchElement: b
615
- };
616
- }, Tt = we({
617
- search: "",
618
- setSearch: (n) => {
619
- },
620
- loading: !1,
621
- matches: [],
622
- totalMatches: 0,
623
- currentMatchPosition: 0,
624
- currentMatch: null,
625
- nextMatch: () => {
626
- },
627
- prevMatch: () => {
628
- },
629
- searchOptions: {},
630
- setSearchOptions: (n) => n,
631
- currentMatchElement: null,
632
- setCurrentMatchElement: (n) => {
633
- }
634
- }), Vo = ({
635
- children: n,
636
- initialSearch: e
637
- }) => {
638
- const [t, o] = q({}), {
639
- loading: s,
640
- setSearch: i,
641
- totalMatches: a,
642
- currentMatchPosition: c,
643
- currentMatch: l,
644
- search: f,
645
- matches: g,
646
- nextMatch: x,
647
- prevMatch: d,
648
- currentMatchElement: w,
649
- setCurrentMatchElement: C
650
- } = On(t, e);
651
- return /* @__PURE__ */ z(
652
- Tt.Provider,
653
- {
654
- value: {
655
- searchOptions: t,
656
- setSearchOptions: o,
657
- loading: s,
658
- setSearch: i,
659
- totalMatches: a,
660
- currentMatchPosition: c,
661
- currentMatch: l,
662
- nextMatch: x,
663
- prevMatch: d,
664
- search: f,
665
- matches: g,
666
- currentMatchElement: w,
667
- setCurrentMatchElement: C
668
- },
669
- children: n
670
- }
671
- );
672
- }, Nn = () => be(Tt), Rt = we(null), jo = ({ children: n }) => {
673
- const e = W(!1), [t, o] = q([]), s = F((l) => {
674
- o((f) => [...f, { id: l.page.pageNumber.toString(), data: l, priority: 0 }]);
675
- }, []), i = H(() => new Yt(s), [s]), { focusedPage: a } = ne(), c = F((l) => (e.current = !0, Jt(
676
- l.data.page,
677
- l.data.canvasElem,
678
- l.data.options
679
- ).promise.then(() => {
680
- l.data.canvasElem.hidden = !1;
681
- }).finally(() => {
682
- l.data.onLoaded && l.data.onLoaded();
683
- })), []);
684
- return A(() => {
685
- a && (i.changePagePriority(`^page-${a}`, 0), i.changePagePriority(`^thumbnail-${a}`, 1));
686
- }, [a]), A(() => {
687
- if (i.isEmpty() || e.current)
688
- return;
689
- const l = () => {
690
- const f = i.dequeue();
691
- f ? c(f).finally(() => {
692
- l();
693
- }) : (e.current = !1, o(i.peekAll()));
694
- };
695
- l();
696
- }, [i, c, t]), /* @__PURE__ */ z(Rt.Provider, { value: i, children: n });
697
- }, It = () => {
698
- const n = be(Rt);
699
- if (!n)
700
- throw new Error("RenderQueue not found");
701
- return n;
702
- }, Ae = {
703
- "rp-layout": "_rp-layout_1q08v_1",
704
- "rp-content": "_rp-content_1q08v_5",
705
- "rp-pages": "_rp-pages_1q08v_11",
706
- "rp-container": "_rp-container_1q08v_16",
707
- "rp-loader": "_rp-loader_1q08v_20",
708
- "rp-theme-variables": "_rp-theme-variables_1q08v_24",
709
- "rp-dark-mode": "_rp-dark-mode_1q08v_135"
710
- }, An = Be((n, e) => {
711
- const { children: t, toolbarRef: o, style: s, className: i, ...a } = n, { customVariables: c, customDarkVariables: l } = tn(), { darkMode: f } = $t();
712
- return /* @__PURE__ */ z(
713
- "div",
714
- {
715
- ref: e,
716
- ...a,
717
- className: he(
718
- Ae["rp-theme-variables"],
719
- Ae["rp-container"],
720
- f ? Ae["rp-dark-mode"] : "",
721
- i
722
- ),
723
- style: {
724
- "--rp-toolbar-height": `${(o == null ? void 0 : o.clientHeight) || 48}px`,
725
- ...c,
726
- ...f ? l : {},
727
- ...s
728
- },
729
- children: t
730
- }
731
- );
732
- }), te = {
733
- "rp-pages": "_rp-pages_6vux6_1",
734
- "rp-pages-horizontal-scroll": "_rp-pages-horizontal-scroll_6vux6_6",
735
- "rp-pages-container": "_rp-pages-container_6vux6_10",
736
- "rp-page-scrolling-wrapper": "_rp-page-scrolling-wrapper_6vux6_47",
737
- "rp-viewer": "_rp-viewer_6vux6_52",
738
- "rp-cursor-grab": "_rp-cursor-grab_6vux6_57",
739
- "rp-cursor-grabbing": "_rp-cursor-grabbing_6vux6_65",
740
- "rp-loader": "_rp-loader_6vux6_73"
741
- }, Fe = {
742
- "rp-page-wrapper": "_rp-page-wrapper_14ohm_1",
743
- "rp-page": "_rp-page_14ohm_1",
744
- "rp-loader-wrapper": "_rp-loader-wrapper_14ohm_15"
745
- }, Fn = (n) => {
746
- const { pageNumber: e, onLoaded: t, onLoading: o } = n, s = W(null), { pages: i } = Y(), { pageRotate: a } = Le(), c = W(), { currentZoom: l } = je(), f = It(), g = W(`page-${e}`);
747
- return A(() => {
748
- if (!i || l === 0)
749
- return;
750
- const x = i.get(e);
751
- if (s.current && x) {
752
- const d = s.current;
753
- d.hidden = !0;
754
- const w = c.current;
755
- w && w.cancel(), o && o(), f.enqueue(
756
- g.current,
757
- {
758
- page: x.page,
759
- canvasElem: d,
760
- options: {
761
- scale: l,
762
- rotate: a[e],
763
- renderForms: !0
764
- },
765
- onLoaded: t
766
- },
767
- 3
768
- );
769
- }
770
- return () => {
771
- f.removeQueue(g.current);
772
- };
773
- }, [i, e, a, l, o, t, f]), /* @__PURE__ */ z("canvas", { "data-rp": `page-${e}-canvas`, ref: s });
774
- }, Wn = "_selecting_usdup_9", re = {
775
- "rp-text-layer": "_rp-text-layer_usdup_1",
776
- selecting: Wn,
777
- "rp-text-layer-text": "_rp-text-layer-text_usdup_39"
778
- }, kn = (n) => {
779
- const { pageNumber: e } = n, { pages: t } = Y(), o = W(null), { matches: s, currentMatch: i, setCurrentMatchElement: a } = Nn(), [c, l] = q(
780
- []
781
- ), f = W(), g = W(), x = W([]), d = H(() => s.filter((u) => u.pageIndex === e - 1), [s, e]), w = F(
782
- (u, p, r = !1) => {
783
- if (r && Bt(u, p), !d.length) {
784
- x.current = [], l([]);
785
- return;
786
- }
787
- const _ = Zt(d, u, p);
788
- l(_);
789
- },
790
- [d]
791
- ), C = W(), P = W(!1), v = F(() => Array.from(document.querySelectorAll('[data-rp$="-textLayer"]')), []);
792
- A(() => ((() => {
793
- if (C.current)
794
- return;
795
- C.current = new AbortController();
796
- const { signal: p } = C.current, r = () => {
797
- v().forEach((m) => {
798
- const b = m.querySelector(".endOfContent");
799
- b && (m.appendChild(b), b.style.width = "", b.style.height = "", m.classList.remove(re.selecting));
800
- });
801
- };
802
- document.addEventListener(
803
- "pointerdown",
804
- () => {
805
- P.current = !0;
806
- },
807
- { signal: p }
808
- ), document.addEventListener(
809
- "pointerup",
810
- () => {
811
- P.current = !1, r();
812
- },
813
- { signal: p }
814
- ), window.addEventListener(
815
- "blur",
816
- () => {
817
- P.current = !1, r();
818
- },
819
- { signal: p }
820
- ), document.addEventListener(
821
- "keyup",
822
- () => {
823
- P.current || r();
824
- },
825
- { signal: p }
826
- );
827
- let _ = null;
828
- document.addEventListener(
829
- "selectionchange",
830
- () => {
831
- var N, R;
832
- const m = document.getSelection();
833
- if (!m)
834
- return;
835
- if (m.rangeCount === 0) {
836
- r();
837
- return;
838
- }
839
- const b = /* @__PURE__ */ new Set();
840
- for (let L = 0; L < m.rangeCount; L++) {
841
- const M = m.getRangeAt(L);
842
- v().forEach((k) => {
843
- M.intersectsNode(k) && !b.has(k) && b.add(k);
844
- });
845
- }
846
- v().forEach((L) => {
847
- if (b.has(L))
848
- L.classList.add(re.selecting);
849
- else {
850
- const M = L.querySelector(".endOfContent");
851
- M && (L.appendChild(M), M.style.width = "", M.style.height = "", L.classList.remove(re.selecting));
852
- }
853
- });
854
- const I = m.getRangeAt(0);
855
- let T = _ && (I.compareBoundaryPoints(Range.END_TO_END, _) === 0 || I.compareBoundaryPoints(Range.START_TO_END, _) === 0) ? I.startContainer : I.endContainer;
856
- T.nodeType === Node.TEXT_NODE && (T = T.parentNode);
857
- const E = (N = T.parentElement) == null ? void 0 : N.closest(
858
- re["rp-text-layer"]
859
- ), O = E == null ? void 0 : E.querySelector(".endOfContent");
860
- O && E && (O.style.width = E.style.width, O.style.height = E.style.height, (R = T.parentElement) == null || R.insertBefore(O, T.nextSibling)), _ = I.cloneRange();
861
- },
862
- { signal: p }
863
- );
864
- })(), () => {
865
- var p;
866
- (p = C.current) == null || p.abort(), C.current = void 0;
867
- }), [v]);
868
- const S = F(() => {
869
- o.current && o.current.classList.add(re.selecting);
870
- }, []), h = F(() => {
871
- o.current && o.current.classList.remove(re.selecting);
872
- }, []);
873
- return A(() => {
874
- if (x.current.forEach((r) => {
875
- r.classList.remove("selected");
876
- }), !c.length || !i || i.pageIndex !== e - 1)
877
- return;
878
- const u = d.findIndex(
879
- (r) => JSON.stringify(r) === JSON.stringify(i)
880
- );
881
- if (u === -1)
882
- return;
883
- const p = c.filter((r) => r.index === u);
884
- p.length && (x.current = p.map((r) => r.element), a(p[0].element), p.forEach((r) => {
885
- r.element.classList.add("selected");
886
- }));
887
- }, [i, c, d]), A(() => {
888
- const u = t.get(e);
889
- if (!u || !o.current)
890
- return;
891
- const p = o.current;
892
- return f.current && f.current.cancel(), u.page.getTextContent().then((r) => {
893
- const _ = u.page.getViewport({ scale: 1 });
894
- return f.current = new rn.TextLayer({
895
- viewport: _,
896
- textContentSource: r,
897
- container: p
898
- }), g.current = r, p && (p.innerText = ""), f.current.render();
899
- }).then(() => {
900
- var b, I;
901
- [].slice.call(p.children).forEach((y) => {
902
- y.classList.add(re["rp-text-layer-text"]), y.setAttribute("data-rp", "rp-text-layer-text");
903
- });
904
- const _ = (b = f.current) == null ? void 0 : b.textDivs;
905
- _ && g.current && w(g.current, _);
906
- const m = document.createElement("div");
907
- m.className = "endOfContent", (I = o.current) == null || I.appendChild(m);
908
- }).catch(() => {
909
- }), () => {
910
- var r;
911
- (r = f.current) == null || r.cancel();
912
- };
913
- }, [t, e]), A(() => {
914
- var r;
915
- [].slice.call(o.current.children).forEach((_) => {
916
- _.classList.add(re["rp-text-layer-text"]);
917
- });
918
- const p = (r = f.current) == null ? void 0 : r.textDivs;
919
- p && g.current && w(g.current, p, !0);
920
- }, [w]), /* @__PURE__ */ z(
921
- "div",
922
- {
923
- "data-rp": `page-${e}-textLayer`,
924
- className: re["rp-text-layer"],
925
- ref: o,
926
- onMouseDown: S,
927
- onMouseUp: h
928
- }
929
- );
930
- }, Dn = {
931
- "rp-annotation-layer": "_rp-annotation-layer_1udza_1"
932
- };
933
- let Hn = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/";
934
- const $n = (n) => {
935
- const { pageNumber: e } = n, t = W(null), { pages: o, pdf: s } = Y(), i = W(), [a, c] = q(), { setFocusedPage: l, goToPage: f } = ne(), { scrollMode: g } = me(), { print: x } = En(), { download: d } = fr(), w = H(() => o.get(e), [o, e]), C = H(() => w == null ? void 0 : w.page.getViewport(), [w]);
936
- A(() => {
937
- i.current && (i.current.div.replaceChildren(), i.current = void 0);
938
- }, [s]), A(() => {
939
- w && w.page.getAnnotations().then((v) => {
940
- i.current = void 0, c(v), t.current && (t.current.innerText = "");
941
- });
942
- }, [w]);
943
- const P = F(
944
- (v) => {
945
- !a || !s || (un(v), dn(v, s, a).then((S) => {
946
- var h, u;
947
- ((h = S == null ? void 0 : S.data) == null ? void 0 : h.action) === "Print" ? x() : ((u = S == null ? void 0 : S.data) == null ? void 0 : u.action) === "SaveAs" && d();
948
- }), g === K.PAGE_SCROLLING ? Je(v, a, s, (S) => l(S.pageIndex + 1)) : Je(v, a, s, (S) => f(S.pageIndex + 1)));
949
- },
950
- [s, a, f, l, g, x, d]
951
- );
952
- return A(() => {
953
- if (!w || !a)
954
- return;
955
- const v = w.page.getViewport();
956
- if (i.current) {
957
- i.current.update({
958
- viewport: v.clone({ dontFlip: !0 })
959
- });
960
- return;
961
- }
962
- const S = /* @__PURE__ */ new Map([]);
963
- for (const p of a) {
964
- const { annotationType: r } = p;
965
- switch (r) {
966
- case Ye.Link:
967
- hn(p);
968
- break;
969
- case Ye.Widget:
970
- pn(p, v, S);
971
- break;
972
- }
973
- }
974
- const h = new AbortController();
975
- return (async () => {
976
- var _;
977
- i.current && (i.current.div.replaceChildren(), i.current = void 0), t.current && (t.current.innerText = ""), i.current = new cn({
978
- div: t.current,
979
- accessibilityManager: void 0,
980
- annotationCanvasMap: void 0,
981
- annotationEditorUIManager: void 0,
982
- structTreeLayer: null,
983
- page: w.page,
984
- viewport: v.clone({ dontFlip: !0 })
985
- }), t.current && et(t.current, P);
986
- const p = await (s == null ? void 0 : s.hasJSActions()), r = await (s == null ? void 0 : s.getFieldObjects());
987
- if (h.signal.aborted)
988
- throw "abort";
989
- return (_ = i.current) == null ? void 0 : _.render({
990
- annotations: a,
991
- annotationStorage: s == null ? void 0 : s.annotationStorage,
992
- hasJSActions: p,
993
- fieldObjects: r,
994
- div: t.current,
995
- viewport: v.clone({ dontFlip: !0 }),
996
- page: w.page,
997
- imageResourcesPath: Hn,
998
- renderForms: !0,
999
- linkService: new ln(),
1000
- downloadManager: null,
1001
- enableScripting: !1
1002
- });
1003
- })().then(() => {
1004
- t.current && fn(t.current, P);
1005
- }).catch((p) => {
1006
- if (p !== "abort")
1007
- throw p;
1008
- }), () => {
1009
- h.abort("clear"), t.current && et(t.current, P);
1010
- };
1011
- }, [s, a, P]), /* @__PURE__ */ z(
1012
- "div",
1013
- {
1014
- "data-rp": `page-${e}-annotationLayer`,
1015
- style: { width: `${C == null ? void 0 : C.width}px`, height: `${C == null ? void 0 : C.height}px` },
1016
- className: Dn["rp-annotation-layer"],
1017
- ref: t
1018
- }
1019
- );
1020
- }, qn = {
1021
- "rp-text-highlight": "_rp-text-highlight_jdkf8_1"
1022
- }, Gn = ({ pageNumber: n, viewport: e }) => {
1023
- const [t, o] = q(), { pages: s } = Y(), { highlightKeywords: i } = Kt(), a = !0, c = W(null), [l, f] = q(null), [g, x] = q([]);
1024
- A(() => {
1025
- c.current && f(c.current.parentElement);
1026
- }, [c]), A(() => {
1027
- (async () => {
1028
- const u = s.get(n);
1029
- if (!u || !c.current)
1030
- return;
1031
- const p = await u.page.getTextContent();
1032
- o(p);
1033
- })();
1034
- }, [s, n]);
1035
- const d = H(() => i ? i.map((h) => {
1036
- var u, p;
1037
- return {
1038
- ...gn(h.keyword, (u = h.options) == null ? void 0 : u.matchCase, (p = h.options) == null ? void 0 : p.wholeWords),
1039
- color: h.highlightColor
1040
- };
1041
- }) : [], [i]);
1042
- function w(h, u) {
1043
- if (!h)
1044
- return;
1045
- const p = `[data-rp="page-${u}-textLayer"]`;
1046
- return new Promise((r) => {
1047
- const _ = h.querySelector(p);
1048
- if (_) {
1049
- r(_);
1050
- return;
1051
- }
1052
- new MutationObserver((b, I) => {
1053
- const y = h.querySelector(p);
1054
- y && (r(y), I.disconnect());
1055
- }).observe(h, { childList: !0, subtree: !0 });
1056
- });
1057
- }
1058
- function C(h) {
1059
- return new Promise((u) => {
1060
- const p = h.querySelectorAll(
1061
- '[data-rp="rp-text-layer-text"]'
1062
- );
1063
- if (p.length) {
1064
- u(Array.from(p));
1065
- return;
1066
- }
1067
- new MutationObserver((_, m) => {
1068
- const b = h.querySelectorAll(
1069
- ".rp-text-layer-text"
1070
- );
1071
- b.length && (u(Array.from(b)), m.disconnect());
1072
- }).observe(h, { childList: !0, subtree: !0 });
1073
- });
1074
- }
1075
- const P = (h, u, p, r) => {
1076
- var V;
1077
- const _ = document.createRange(), m = p.firstChild;
1078
- if (!m || m.nodeType !== Node.TEXT_NODE)
1079
- return null;
1080
- const b = ((V = m.textContent) == null ? void 0 : V.length) ?? 0, I = r[0].charIdxInSpan, y = r.length === 1 ? I : r[r.length - 1].charIdxInSpan;
1081
- if (I > b || y + 1 > b)
1082
- return null;
1083
- _.setStart(m, I), _.setEnd(m, y + 1);
1084
- const T = document.createElement("span");
1085
- T.style.width = "auto", _.surroundContents(T);
1086
- const E = T.getBoundingClientRect(), O = h.getBoundingClientRect(), N = O.height, R = O.width, L = 100 * (E.left - O.left) / R, M = 100 * (E.top - O.top) / N, k = 100 * E.height / N, D = 100 * E.width / R;
1087
- return _n(T), {
1088
- keywordStr: u,
1089
- left: L,
1090
- top: M,
1091
- height: k,
1092
- width: D,
1093
- pageHeight: N,
1094
- pageWidth: R
1095
- };
1096
- };
1097
- async function v(h, u) {
1098
- const p = await w(l, h);
1099
- if (!p)
1100
- return;
1101
- const r = await C(p);
1102
- if (r.length) {
1103
- const _ = r.map((b) => b.tagName === "BR" ? " " : b.textContent).reduce(
1104
- (b, I, y) => b.concat(
1105
- I.split("").map((T, E) => ({
1106
- char: T,
1107
- charIdxInSpan: E,
1108
- spanIdx: y
1109
- }))
1110
- ),
1111
- [
1112
- {
1113
- char: "",
1114
- charIdxInSpan: 0,
1115
- spanIdx: 0
1116
- }
1117
- ]
1118
- ).slice(1), m = S(p, u, r, _);
1119
- x(m);
1120
- }
1121
- }
1122
- const S = (h, u, p, r) => {
1123
- const _ = u.length;
1124
- if (!r.length || !_)
1125
- return [];
1126
- const m = [], b = r.map((I) => I.char).join("");
1127
- return d.forEach((I) => {
1128
- const { keyword: y, regExp: T, wholeWords: E, color: O } = I, N = y;
1129
- if (!N.trim())
1130
- return;
1131
- const R = T.flags.indexOf("g") === -1 ? new RegExp(T, `${T.flags}g`) : T;
1132
- let L;
1133
- const M = [];
1134
- for (; (L = R.exec(b)) !== null; )
1135
- E && !Xt(b, L.index, L[0].length) || M.push({
1136
- keyword: R,
1137
- startIndex: L.index,
1138
- endIndex: R.lastIndex
1139
- });
1140
- const k = M.map((D) => ({
1141
- keyword: D.keyword,
1142
- indexes: r.slice(D.startIndex, D.endIndex),
1143
- color: O
1144
- }));
1145
- for (const D of k) {
1146
- const V = D.indexes.reduce(
1147
- (j, U) => (j[U.spanIdx] = (j[U.spanIdx] || []).concat([U]), j),
1148
- {}
1149
- );
1150
- for (const j of Object.values(V))
1151
- if (j.length !== 1 || j[0].char.trim() !== "") {
1152
- const U = j, X = p[U[0].spanIdx], B = P(
1153
- h,
1154
- N,
1155
- X,
1156
- U
1157
- );
1158
- if (B) {
1159
- const { left: J, top: se } = B;
1160
- if (m.find((Z) => Z.left === J && Z.top === se))
1161
- continue;
1162
- m.push({ ...B, highlightColor: D.color });
1163
- }
1164
- }
1165
- }
1166
- }), m.sort(mn), m;
1167
- };
1168
- return A(() => {
1169
- (async () => {
1170
- if (!(!i || i.length === 0))
1171
- try {
1172
- await v(n, i);
1173
- } catch (u) {
1174
- console.error(u);
1175
- }
1176
- })();
1177
- }, [a, i, n, t, e]), /* @__PURE__ */ z(mt, { children: /* @__PURE__ */ z("div", { ref: c, "data-rp": `page-${n}-textHighlightLayer`, children: g.map((h, u) => /* @__PURE__ */ z(
1178
- "div",
1179
- {
1180
- className: qn["rp-text-highlight"],
1181
- style: {
1182
- top: `${h.top}%`,
1183
- left: `${h.left}%`,
1184
- width: `${h.width}%`,
1185
- height: `${h.height}%`,
1186
- backgroundColor: h.highlightColor
1187
- }
1188
- },
1189
- u
1190
- )) }) });
1191
- }, Xe = Be((n, e) => {
1192
- const { pageNumber: t, style: o, ...s } = n, { pages: i } = Y(), { pageRotate: a } = Le(), { textLayer: c } = qt(), { currentZoom: l } = je(), f = W(i.get(t)), [g, x] = q(!1), d = W(null), [w, C] = q({
1193
- width: 0,
1194
- height: 0
1195
- });
1196
- _t(e, () => d.current);
1197
- const P = H(() => f.current ? a[t] : 0, [t, a]);
1198
- A(() => {
1199
- if (i && (f.current = i.get(t), f.current)) {
1200
- const u = f.current.page.getViewport({
1201
- scale: l,
1202
- rotation: P
1203
- });
1204
- C(u);
1205
- }
1206
- }, [i, t, P, l]);
1207
- const v = H(() => {
1208
- switch (P) {
1209
- case 90:
1210
- return `${w.width / 2}px ${w.width / 2}px`;
1211
- case -90:
1212
- case 270:
1213
- return `${w.height / 2}px ${w.height / 2}px`;
1214
- default:
1215
- return "center";
1216
- }
1217
- }, [P, w]), S = F(() => {
1218
- x(!0);
1219
- }, []), h = F(() => {
1220
- x(!1);
1221
- }, []);
1222
- return /* @__PURE__ */ z(
1223
- "div",
1224
- {
1225
- ref: d,
1226
- id: `page-${t}`,
1227
- "data-rp": `page-${t}`,
1228
- ...s,
1229
- style: {
1230
- ...o,
1231
- "--rp-rotate": `${P}deg`,
1232
- "--rp-page-rotate-translate": `${v}`,
1233
- "--scale-factor": l
1234
- },
1235
- className: Fe["rp-page-wrapper"],
1236
- children: /* @__PURE__ */ Ve(
1237
- "div",
1238
- {
1239
- style: {
1240
- width: `${w.width}px`,
1241
- height: `${w.height}px`
1242
- },
1243
- className: Fe["rp-page"],
1244
- children: [
1245
- /* @__PURE__ */ z(Fn, { onLoading: S, onLoaded: h, pageNumber: t }),
1246
- g && /* @__PURE__ */ z("div", { className: Fe["rp-loader-wrapper"], children: /* @__PURE__ */ z(wt, {}) }),
1247
- /* @__PURE__ */ z(vn, { pageNumber: t }),
1248
- c && /* @__PURE__ */ z(kn, { pageNumber: t }),
1249
- /* @__PURE__ */ z(Gn, { pageNumber: t, viewport: w }),
1250
- /* @__PURE__ */ z($n, { pageNumber: t })
1251
- ]
1252
- }
1253
- )
1254
- }
1255
- );
1256
- });
1257
- function $e() {
1258
- return $e = Object.assign ? Object.assign.bind() : function(n) {
1259
- for (var e = 1; e < arguments.length; e++) {
1260
- var t = arguments[e];
1261
- for (var o in t)
1262
- ({}).hasOwnProperty.call(t, o) && (n[o] = t[o]);
1263
- }
1264
- return n;
1265
- }, $e.apply(null, arguments);
1266
- }
1267
- function tt(n) {
1268
- if (n === void 0)
1269
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1270
- return n;
1271
- }
1272
- function qe(n, e) {
1273
- return qe = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t, o) {
1274
- return t.__proto__ = o, t;
1275
- }, qe(n, e);
1276
- }
1277
- function Un(n, e) {
1278
- n.prototype = Object.create(e.prototype), n.prototype.constructor = n, qe(n, e);
1279
- }
1280
- var nt = Number.isNaN || function(e) {
1281
- return typeof e == "number" && e !== e;
1282
- };
1283
- function Vn(n, e) {
1284
- return !!(n === e || nt(n) && nt(e));
1285
- }
1286
- function jn(n, e) {
1287
- if (n.length !== e.length)
1288
- return !1;
1289
- for (var t = 0; t < n.length; t++)
1290
- if (!Vn(n[t], e[t]))
1291
- return !1;
1292
- return !0;
1293
- }
1294
- function We(n, e) {
1295
- e === void 0 && (e = jn);
1296
- var t, o = [], s, i = !1;
1297
- function a() {
1298
- for (var c = [], l = 0; l < arguments.length; l++)
1299
- c[l] = arguments[l];
1300
- return i && t === this && e(c, o) || (s = n.apply(this, c), i = !0, t = this, o = c), s;
1301
- }
1302
- return a;
1303
- }
1304
- function rt(n, e) {
1305
- if (n == null)
1306
- return {};
1307
- var t = {};
1308
- for (var o in n)
1309
- if ({}.hasOwnProperty.call(n, o)) {
1310
- if (e.indexOf(o) !== -1)
1311
- continue;
1312
- t[o] = n[o];
1313
- }
1314
- return t;
1315
- }
1316
- var Bn = typeof performance == "object" && typeof performance.now == "function", ot = Bn ? function() {
1317
- return performance.now();
1318
- } : function() {
1319
- return Date.now();
1320
- };
1321
- function st(n) {
1322
- cancelAnimationFrame(n.id);
1323
- }
1324
- function Zn(n, e) {
1325
- var t = ot();
1326
- function o() {
1327
- ot() - t >= e ? n.call(null) : s.id = requestAnimationFrame(o);
1328
- }
1329
- var s = {
1330
- id: requestAnimationFrame(o)
1331
- };
1332
- return s;
1333
- }
1334
- var ke = -1;
1335
- function Xn(n) {
1336
- if (n === void 0 && (n = !1), ke === -1 || n) {
1337
- var e = document.createElement("div"), t = e.style;
1338
- t.width = "50px", t.height = "50px", t.overflow = "scroll", document.body.appendChild(e), ke = e.offsetWidth - e.clientWidth, document.body.removeChild(e);
1339
- }
1340
- return ke;
1341
- }
1342
- var pe = null;
1343
- function it(n) {
1344
- if (n === void 0 && (n = !1), pe === null || n) {
1345
- var e = document.createElement("div"), t = e.style;
1346
- t.width = "50px", t.height = "50px", t.overflow = "scroll", t.direction = "rtl";
1347
- var o = document.createElement("div"), s = o.style;
1348
- return s.width = "100px", s.height = "100px", e.appendChild(o), document.body.appendChild(e), e.scrollLeft > 0 ? pe = "positive-descending" : (e.scrollLeft = 1, e.scrollLeft === 0 ? pe = "negative" : pe = "positive-ascending"), document.body.removeChild(e), pe;
1349
- }
1350
- return pe;
1351
- }
1352
- var Kn = 150, Qn = function(e) {
1353
- var t = e.columnIndex;
1354
- e.data;
1355
- var o = e.rowIndex;
1356
- return o + ":" + t;
1357
- }, ye = null, Pe = null, Te = null;
1358
- process.env.NODE_ENV !== "production" && typeof window < "u" && typeof window.WeakSet < "u" && (ye = /* @__PURE__ */ new WeakSet(), Pe = /* @__PURE__ */ new WeakSet(), Te = /* @__PURE__ */ new WeakSet());
1359
- function Yn(n) {
1360
- var e, t = n.getColumnOffset, o = n.getColumnStartIndexForOffset, s = n.getColumnStopIndexForStartIndex, i = n.getColumnWidth, a = n.getEstimatedTotalHeight, c = n.getEstimatedTotalWidth, l = n.getOffsetForColumnAndAlignment, f = n.getOffsetForRowAndAlignment, g = n.getRowHeight, x = n.getRowOffset, d = n.getRowStartIndexForOffset, w = n.getRowStopIndexForStartIndex, C = n.initInstanceProps, P = n.shouldResetStyleCacheOnItemSizeChange, v = n.validateProps;
1361
- return e = /* @__PURE__ */ function(S) {
1362
- Un(h, S);
1363
- function h(p) {
1364
- var r;
1365
- return r = S.call(this, p) || this, r._instanceProps = C(r.props, tt(r)), r._resetIsScrollingTimeoutId = null, r._outerRef = void 0, r.state = {
1366
- instance: tt(r),
1367
- isScrolling: !1,
1368
- horizontalScrollDirection: "forward",
1369
- scrollLeft: typeof r.props.initialScrollLeft == "number" ? r.props.initialScrollLeft : 0,
1370
- scrollTop: typeof r.props.initialScrollTop == "number" ? r.props.initialScrollTop : 0,
1371
- scrollUpdateWasRequested: !1,
1372
- verticalScrollDirection: "forward"
1373
- }, r._callOnItemsRendered = void 0, r._callOnItemsRendered = We(function(_, m, b, I, y, T, E, O) {
1374
- return r.props.onItemsRendered({
1375
- overscanColumnStartIndex: _,
1376
- overscanColumnStopIndex: m,
1377
- overscanRowStartIndex: b,
1378
- overscanRowStopIndex: I,
1379
- visibleColumnStartIndex: y,
1380
- visibleColumnStopIndex: T,
1381
- visibleRowStartIndex: E,
1382
- visibleRowStopIndex: O
1383
- });
1384
- }), r._callOnScroll = void 0, r._callOnScroll = We(function(_, m, b, I, y) {
1385
- return r.props.onScroll({
1386
- horizontalScrollDirection: b,
1387
- scrollLeft: _,
1388
- scrollTop: m,
1389
- verticalScrollDirection: I,
1390
- scrollUpdateWasRequested: y
1391
- });
1392
- }), r._getItemStyle = void 0, r._getItemStyle = function(_, m) {
1393
- var b = r.props, I = b.columnWidth, y = b.direction, T = b.rowHeight, E = r._getItemStyleCache(P && I, P && y, P && T), O = _ + ":" + m, N;
1394
- if (E.hasOwnProperty(O))
1395
- N = E[O];
1396
- else {
1397
- var R = t(r.props, m, r._instanceProps), L = y === "rtl";
1398
- E[O] = N = {
1399
- position: "absolute",
1400
- left: L ? void 0 : R,
1401
- right: L ? R : void 0,
1402
- top: x(r.props, _, r._instanceProps),
1403
- height: g(r.props, _, r._instanceProps),
1404
- width: i(r.props, m, r._instanceProps)
1405
- };
1406
- }
1407
- return N;
1408
- }, r._getItemStyleCache = void 0, r._getItemStyleCache = We(function(_, m, b) {
1409
- return {};
1410
- }), r._onScroll = function(_) {
1411
- var m = _.currentTarget, b = m.clientHeight, I = m.clientWidth, y = m.scrollLeft, T = m.scrollTop, E = m.scrollHeight, O = m.scrollWidth;
1412
- r.setState(function(N) {
1413
- if (N.scrollLeft === y && N.scrollTop === T)
1414
- return null;
1415
- var R = r.props.direction, L = y;
1416
- if (R === "rtl")
1417
- switch (it()) {
1418
- case "negative":
1419
- L = -y;
1420
- break;
1421
- case "positive-descending":
1422
- L = O - I - y;
1423
- break;
1424
- }
1425
- L = Math.max(0, Math.min(L, O - I));
1426
- var M = Math.max(0, Math.min(T, E - b));
1427
- return {
1428
- isScrolling: !0,
1429
- horizontalScrollDirection: N.scrollLeft < y ? "forward" : "backward",
1430
- scrollLeft: L,
1431
- scrollTop: M,
1432
- verticalScrollDirection: N.scrollTop < T ? "forward" : "backward",
1433
- scrollUpdateWasRequested: !1
1434
- };
1435
- }, r._resetIsScrollingDebounced);
1436
- }, r._outerRefSetter = function(_) {
1437
- var m = r.props.outerRef;
1438
- r._outerRef = _, typeof m == "function" ? m(_) : m != null && typeof m == "object" && m.hasOwnProperty("current") && (m.current = _);
1439
- }, r._resetIsScrollingDebounced = function() {
1440
- r._resetIsScrollingTimeoutId !== null && st(r._resetIsScrollingTimeoutId), r._resetIsScrollingTimeoutId = Zn(r._resetIsScrolling, Kn);
1441
- }, r._resetIsScrolling = function() {
1442
- r._resetIsScrollingTimeoutId = null, r.setState({
1443
- isScrolling: !1
1444
- }, function() {
1445
- r._getItemStyleCache(-1);
1446
- });
1447
- }, r;
1448
- }
1449
- h.getDerivedStateFromProps = function(r, _) {
1450
- return Jn(r, _), v(r), null;
1451
- };
1452
- var u = h.prototype;
1453
- return u.scrollTo = function(r) {
1454
- var _ = r.scrollLeft, m = r.scrollTop;
1455
- _ !== void 0 && (_ = Math.max(0, _)), m !== void 0 && (m = Math.max(0, m)), this.setState(function(b) {
1456
- return _ === void 0 && (_ = b.scrollLeft), m === void 0 && (m = b.scrollTop), b.scrollLeft === _ && b.scrollTop === m ? null : {
1457
- horizontalScrollDirection: b.scrollLeft < _ ? "forward" : "backward",
1458
- scrollLeft: _,
1459
- scrollTop: m,
1460
- scrollUpdateWasRequested: !0,
1461
- verticalScrollDirection: b.scrollTop < m ? "forward" : "backward"
1462
- };
1463
- }, this._resetIsScrollingDebounced);
1464
- }, u.scrollToItem = function(r) {
1465
- var _ = r.align, m = _ === void 0 ? "auto" : _, b = r.columnIndex, I = r.rowIndex, y = this.props, T = y.columnCount, E = y.height, O = y.rowCount, N = y.width, R = this.state, L = R.scrollLeft, M = R.scrollTop, k = Xn();
1466
- b !== void 0 && (b = Math.max(0, Math.min(b, T - 1))), I !== void 0 && (I = Math.max(0, Math.min(I, O - 1)));
1467
- var D = a(this.props, this._instanceProps), V = c(this.props, this._instanceProps), j = V > N ? k : 0, U = D > E ? k : 0;
1468
- this.scrollTo({
1469
- scrollLeft: b !== void 0 ? l(this.props, b, m, L, this._instanceProps, U) : L,
1470
- scrollTop: I !== void 0 ? f(this.props, I, m, M, this._instanceProps, j) : M
1471
- });
1472
- }, u.componentDidMount = function() {
1473
- var r = this.props, _ = r.initialScrollLeft, m = r.initialScrollTop;
1474
- if (this._outerRef != null) {
1475
- var b = this._outerRef;
1476
- typeof _ == "number" && (b.scrollLeft = _), typeof m == "number" && (b.scrollTop = m);
1477
- }
1478
- this._callPropsCallbacks();
1479
- }, u.componentDidUpdate = function() {
1480
- var r = this.props.direction, _ = this.state, m = _.scrollLeft, b = _.scrollTop, I = _.scrollUpdateWasRequested;
1481
- if (I && this._outerRef != null) {
1482
- var y = this._outerRef;
1483
- if (r === "rtl")
1484
- switch (it()) {
1485
- case "negative":
1486
- y.scrollLeft = -m;
1487
- break;
1488
- case "positive-ascending":
1489
- y.scrollLeft = m;
1490
- break;
1491
- default:
1492
- var T = y.clientWidth, E = y.scrollWidth;
1493
- y.scrollLeft = E - T - m;
1494
- break;
1495
- }
1496
- else
1497
- y.scrollLeft = Math.max(0, m);
1498
- y.scrollTop = Math.max(0, b);
1499
- }
1500
- this._callPropsCallbacks();
1501
- }, u.componentWillUnmount = function() {
1502
- this._resetIsScrollingTimeoutId !== null && st(this._resetIsScrollingTimeoutId);
1503
- }, u.render = function() {
1504
- var r = this.props, _ = r.children, m = r.className, b = r.columnCount, I = r.direction, y = r.height, T = r.innerRef, E = r.innerElementType, O = r.innerTagName, N = r.itemData, R = r.itemKey, L = R === void 0 ? Qn : R, M = r.outerElementType, k = r.outerTagName, D = r.rowCount, V = r.style, j = r.useIsScrolling, U = r.width, X = this.state.isScrolling, B = this._getHorizontalRangeToRender(), J = B[0], se = B[1], ee = this._getVerticalRangeToRender(), Z = ee[0], _e = ee[1], ie = [];
1505
- if (b > 0 && D)
1506
- for (var ce = Z; ce <= _e; ce++)
1507
- for (var ae = J; ae <= se; ae++)
1508
- ie.push(Se(_, {
1509
- columnIndex: ae,
1510
- data: N,
1511
- isScrolling: j ? X : void 0,
1512
- key: L({
1513
- columnIndex: ae,
1514
- data: N,
1515
- rowIndex: ce
1516
- }),
1517
- rowIndex: ce,
1518
- style: this._getItemStyle(ce, ae)
1519
- }));
1520
- var Ee = a(this.props, this._instanceProps), Me = c(this.props, this._instanceProps);
1521
- return Se(M || k || "div", {
1522
- className: m,
1523
- onScroll: this._onScroll,
1524
- ref: this._outerRefSetter,
1525
- style: $e({
1526
- position: "relative",
1527
- height: y,
1528
- width: U,
1529
- overflow: "auto",
1530
- WebkitOverflowScrolling: "touch",
1531
- willChange: "transform",
1532
- direction: I
1533
- }, V)
1534
- }, Se(E || O || "div", {
1535
- children: ie,
1536
- ref: T,
1537
- style: {
1538
- height: Ee,
1539
- pointerEvents: X ? "none" : void 0,
1540
- width: Me
1541
- }
1542
- }));
1543
- }, u._callPropsCallbacks = function() {
1544
- var r = this.props, _ = r.columnCount, m = r.onItemsRendered, b = r.onScroll, I = r.rowCount;
1545
- if (typeof m == "function" && _ > 0 && I > 0) {
1546
- var y = this._getHorizontalRangeToRender(), T = y[0], E = y[1], O = y[2], N = y[3], R = this._getVerticalRangeToRender(), L = R[0], M = R[1], k = R[2], D = R[3];
1547
- this._callOnItemsRendered(T, E, L, M, O, N, k, D);
1548
- }
1549
- if (typeof b == "function") {
1550
- var V = this.state, j = V.horizontalScrollDirection, U = V.scrollLeft, X = V.scrollTop, B = V.scrollUpdateWasRequested, J = V.verticalScrollDirection;
1551
- this._callOnScroll(U, X, j, J, B);
1552
- }
1553
- }, u._getHorizontalRangeToRender = function() {
1554
- var r = this.props, _ = r.columnCount, m = r.overscanColumnCount, b = r.overscanColumnsCount, I = r.overscanCount, y = r.rowCount, T = this.state, E = T.horizontalScrollDirection, O = T.isScrolling, N = T.scrollLeft, R = m || b || I || 1;
1555
- if (_ === 0 || y === 0)
1556
- return [0, 0, 0, 0];
1557
- var L = o(this.props, N, this._instanceProps), M = s(this.props, L, N, this._instanceProps), k = !O || E === "backward" ? Math.max(1, R) : 1, D = !O || E === "forward" ? Math.max(1, R) : 1;
1558
- return [Math.max(0, L - k), Math.max(0, Math.min(_ - 1, M + D)), L, M];
1559
- }, u._getVerticalRangeToRender = function() {
1560
- var r = this.props, _ = r.columnCount, m = r.overscanCount, b = r.overscanRowCount, I = r.overscanRowsCount, y = r.rowCount, T = this.state, E = T.isScrolling, O = T.verticalScrollDirection, N = T.scrollTop, R = b || I || m || 1;
1561
- if (_ === 0 || y === 0)
1562
- return [0, 0, 0, 0];
1563
- var L = d(this.props, N, this._instanceProps), M = w(this.props, L, N, this._instanceProps), k = !E || O === "backward" ? Math.max(1, R) : 1, D = !E || O === "forward" ? Math.max(1, R) : 1;
1564
- return [Math.max(0, L - k), Math.max(0, Math.min(y - 1, M + D)), L, M];
1565
- }, h;
1566
- }(Wt), e.defaultProps = {
1567
- direction: "ltr",
1568
- itemData: void 0,
1569
- useIsScrolling: !1
1570
- }, e;
1571
- }
1572
- var Jn = function(e, t) {
1573
- var o = e.children, s = e.direction, i = e.height, a = e.innerTagName, c = e.outerTagName, l = e.overscanColumnsCount, f = e.overscanCount, g = e.overscanRowsCount, x = e.width, d = t.instance;
1574
- if (process.env.NODE_ENV !== "production") {
1575
- if (typeof f == "number" && ye && !ye.has(d) && (ye.add(d), console.warn("The overscanCount prop has been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (typeof l == "number" || typeof g == "number") && Pe && !Pe.has(d) && (Pe.add(d), console.warn("The overscanColumnsCount and overscanRowsCount props have been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (a != null || c != null) && Te && !Te.has(d) && (Te.add(d), console.warn("The innerTagName and outerTagName props have been deprecated. Please use the innerElementType and outerElementType props instead.")), o == null)
1576
- throw Error('An invalid "children" prop has been specified. Value should be a React component. ' + ('"' + (o === null ? "null" : typeof o) + '" was specified.'));
1577
- switch (s) {
1578
- case "ltr":
1579
- case "rtl":
1580
- break;
1581
- default:
1582
- throw Error('An invalid "direction" prop has been specified. Value should be either "ltr" or "rtl". ' + ('"' + s + '" was specified.'));
1583
- }
1584
- if (typeof x != "number")
1585
- throw Error('An invalid "width" prop has been specified. Grids must specify a number for width. ' + ('"' + (x === null ? "null" : typeof x) + '" was specified.'));
1586
- if (typeof i != "number")
1587
- throw Error('An invalid "height" prop has been specified. Grids must specify a number for height. ' + ('"' + (i === null ? "null" : typeof i) + '" was specified.'));
1588
- }
1589
- }, at = 50, Lt = function(e, t) {
1590
- var o = e.rowCount, s = t.rowMetadataMap, i = t.estimatedRowHeight, a = t.lastMeasuredRowIndex, c = 0;
1591
- if (a >= o && (a = o - 1), a >= 0) {
1592
- var l = s[a];
1593
- c = l.offset + l.size;
1594
- }
1595
- var f = o - a - 1, g = f * i;
1596
- return c + g;
1597
- }, Et = function(e, t) {
1598
- var o = e.columnCount, s = t.columnMetadataMap, i = t.estimatedColumnWidth, a = t.lastMeasuredColumnIndex, c = 0;
1599
- if (a >= o && (a = o - 1), a >= 0) {
1600
- var l = s[a];
1601
- c = l.offset + l.size;
1602
- }
1603
- var f = o - a - 1, g = f * i;
1604
- return c + g;
1605
- }, oe = function(e, t, o, s) {
1606
- var i, a, c;
1607
- if (e === "column" ? (i = s.columnMetadataMap, a = t.columnWidth, c = s.lastMeasuredColumnIndex) : (i = s.rowMetadataMap, a = t.rowHeight, c = s.lastMeasuredRowIndex), o > c) {
1608
- var l = 0;
1609
- if (c >= 0) {
1610
- var f = i[c];
1611
- l = f.offset + f.size;
1612
- }
1613
- for (var g = c + 1; g <= o; g++) {
1614
- var x = a(g);
1615
- i[g] = {
1616
- offset: l,
1617
- size: x
1618
- }, l += x;
1619
- }
1620
- e === "column" ? s.lastMeasuredColumnIndex = o : s.lastMeasuredRowIndex = o;
1621
- }
1622
- return i[o];
1623
- }, ct = function(e, t, o, s) {
1624
- var i, a;
1625
- e === "column" ? (i = o.columnMetadataMap, a = o.lastMeasuredColumnIndex) : (i = o.rowMetadataMap, a = o.lastMeasuredRowIndex);
1626
- var c = a > 0 ? i[a].offset : 0;
1627
- return c >= s ? Mt(e, t, o, a, 0, s) : er(e, t, o, Math.max(0, a), s);
1628
- }, Mt = function(e, t, o, s, i, a) {
1629
- for (; i <= s; ) {
1630
- var c = i + Math.floor((s - i) / 2), l = oe(e, t, c, o).offset;
1631
- if (l === a)
1632
- return c;
1633
- l < a ? i = c + 1 : l > a && (s = c - 1);
1634
- }
1635
- return i > 0 ? i - 1 : 0;
1636
- }, er = function(e, t, o, s, i) {
1637
- for (var a = e === "column" ? t.columnCount : t.rowCount, c = 1; s < a && oe(e, t, s, o).offset < i; )
1638
- s += c, c *= 2;
1639
- return Mt(e, t, o, Math.min(s, a - 1), Math.floor(s / 2), i);
1640
- }, lt = function(e, t, o, s, i, a, c) {
1641
- var l = e === "column" ? t.width : t.height, f = oe(e, t, o, a), g = e === "column" ? Et(t, a) : Lt(t, a), x = Math.max(0, Math.min(g - l, f.offset)), d = Math.max(0, f.offset - l + c + f.size);
1642
- switch (s === "smart" && (i >= d - l && i <= x + l ? s = "auto" : s = "center"), s) {
1643
- case "start":
1644
- return x;
1645
- case "end":
1646
- return d;
1647
- case "center":
1648
- return Math.round(d + (x - d) / 2);
1649
- case "auto":
1650
- default:
1651
- return i >= d && i <= x ? i : d > x || i < d ? d : x;
1652
- }
1653
- }, tr = /* @__PURE__ */ Yn({
1654
- getColumnOffset: function(e, t, o) {
1655
- return oe("column", e, t, o).offset;
1656
- },
1657
- getColumnStartIndexForOffset: function(e, t, o) {
1658
- return ct("column", e, o, t);
1659
- },
1660
- getColumnStopIndexForStartIndex: function(e, t, o, s) {
1661
- for (var i = e.columnCount, a = e.width, c = oe("column", e, t, s), l = o + a, f = c.offset + c.size, g = t; g < i - 1 && f < l; )
1662
- g++, f += oe("column", e, g, s).size;
1663
- return g;
1664
- },
1665
- getColumnWidth: function(e, t, o) {
1666
- return o.columnMetadataMap[t].size;
1667
- },
1668
- getEstimatedTotalHeight: Lt,
1669
- getEstimatedTotalWidth: Et,
1670
- getOffsetForColumnAndAlignment: function(e, t, o, s, i, a) {
1671
- return lt("column", e, t, o, s, i, a);
1672
- },
1673
- getOffsetForRowAndAlignment: function(e, t, o, s, i, a) {
1674
- return lt("row", e, t, o, s, i, a);
1675
- },
1676
- getRowOffset: function(e, t, o) {
1677
- return oe("row", e, t, o).offset;
1678
- },
1679
- getRowHeight: function(e, t, o) {
1680
- return o.rowMetadataMap[t].size;
1681
- },
1682
- getRowStartIndexForOffset: function(e, t, o) {
1683
- return ct("row", e, o, t);
1684
- },
1685
- getRowStopIndexForStartIndex: function(e, t, o, s) {
1686
- for (var i = e.rowCount, a = e.height, c = oe("row", e, t, s), l = o + a, f = c.offset + c.size, g = t; g < i - 1 && f < l; )
1687
- g++, f += oe("row", e, g, s).size;
1688
- return g;
1689
- },
1690
- initInstanceProps: function(e, t) {
1691
- var o = e, s = o.estimatedColumnWidth, i = o.estimatedRowHeight, a = {
1692
- columnMetadataMap: {},
1693
- estimatedColumnWidth: s || at,
1694
- estimatedRowHeight: i || at,
1695
- lastMeasuredColumnIndex: -1,
1696
- lastMeasuredRowIndex: -1,
1697
- rowMetadataMap: {}
1698
- };
1699
- return t.resetAfterColumnIndex = function(c, l) {
1700
- l === void 0 && (l = !0), t.resetAfterIndices({
1701
- columnIndex: c,
1702
- shouldForceUpdate: l
1703
- });
1704
- }, t.resetAfterRowIndex = function(c, l) {
1705
- l === void 0 && (l = !0), t.resetAfterIndices({
1706
- rowIndex: c,
1707
- shouldForceUpdate: l
1708
- });
1709
- }, t.resetAfterIndices = function(c) {
1710
- var l = c.columnIndex, f = c.rowIndex, g = c.shouldForceUpdate, x = g === void 0 ? !0 : g;
1711
- typeof l == "number" && (a.lastMeasuredColumnIndex = Math.min(a.lastMeasuredColumnIndex, l - 1)), typeof f == "number" && (a.lastMeasuredRowIndex = Math.min(a.lastMeasuredRowIndex, f - 1)), t._getItemStyleCache(-1), x && t.forceUpdate();
1712
- }, a;
1713
- },
1714
- shouldResetStyleCacheOnItemSizeChange: !1,
1715
- validateProps: function(e) {
1716
- var t = e.columnWidth, o = e.rowHeight;
1717
- if (process.env.NODE_ENV !== "production") {
1718
- if (typeof t != "function")
1719
- throw Error('An invalid "columnWidth" prop has been specified. Value should be a function. ' + ('"' + (t === null ? "null" : typeof t) + '" was specified.'));
1720
- if (typeof o != "function")
1721
- throw Error('An invalid "rowHeight" prop has been specified. Value should be a function. ' + ('"' + (o === null ? "null" : typeof o) + '" was specified.'));
1722
- }
1723
- }
1724
- });
1725
- process.env.NODE_ENV;
1726
- function ut(n, e) {
1727
- for (var t in n)
1728
- if (!(t in e))
1729
- return !0;
1730
- for (var o in e)
1731
- if (n[o] !== e[o])
1732
- return !0;
1733
- return !1;
1734
- }
1735
- var nr = ["style"], rr = ["style"];
1736
- function or(n, e) {
1737
- var t = n.style, o = rt(n, nr), s = e.style, i = rt(e, rr);
1738
- return !ut(t, s) && !ut(o, i);
1739
- }
1740
- const sr = () => {
1741
- const { viewMode: n } = Ce(), { scrollMode: e } = me(), { setColumnCount: t } = bt(), { virtualScrollableElementRef: o } = Re(), s = xe(), i = H(() => s.heights.length, [s.heights]), a = H(() => e === K.HORIZONTAL_SCROLLING ? i : n === ge.DUAL_PAGE ? 2 : 1, [n, e, e, i, o]), c = H(() => s.widths.reduce((C, P, v) => {
1742
- const S = v % a;
1743
- return (!C[S] || P > C[S]) && (C[S] = P), C;
1744
- }, []), [s.widths, a]), l = F(
1745
- (w) => {
1746
- const C = w % c.length;
1747
- return c[C] || 0;
1748
- },
1749
- [c]
1750
- ), f = F(
1751
- (w) => {
1752
- const C = Array.from({ length: a }, (P, v) => {
1753
- const S = w * a + v;
1754
- return s.heights[S] || 0;
1755
- });
1756
- return Math.max(...C);
1757
- },
1758
- [s.heights, a]
1759
- );
1760
- A(() => {
1761
- t(a);
1762
- }, [a, t]);
1763
- const g = H(() => e === K.HORIZONTAL_SCROLLING || e === K.PAGE_SCROLLING ? 1 : Math.round(i / a), [a, i, e]), x = H(() => s.heights.reduce((w, C) => w + C, 0) / s.heights.length || 0, [s]), d = H(() => s.widths.reduce((w, C) => w + C, 0) / s.heights.length || 0, [s]);
1764
- return {
1765
- rowCount: g,
1766
- rowHeight: f,
1767
- columnCount: a,
1768
- columnWidth: l,
1769
- pageDimension: s,
1770
- estimatedRowHeight: x,
1771
- estimatedColumnWidth: d
1772
- };
1773
- };
1774
- let Q;
1775
- typeof window < "u" ? Q = window : typeof self < "u" ? Q = self : Q = global;
1776
- let Ge = null, Ue = null;
1777
- const dt = 20, De = Q.clearTimeout, pt = Q.setTimeout, He = Q.cancelAnimationFrame || Q.mozCancelAnimationFrame || Q.webkitCancelAnimationFrame, ht = Q.requestAnimationFrame || Q.mozRequestAnimationFrame || Q.webkitRequestAnimationFrame;
1778
- He == null || ht == null ? (Ge = De, Ue = function(e) {
1779
- return pt(e, dt);
1780
- }) : (Ge = function([e, t]) {
1781
- He(e), De(t);
1782
- }, Ue = function(e) {
1783
- const t = ht(function() {
1784
- De(o), e();
1785
- }), o = pt(function() {
1786
- He(t), e();
1787
- }, dt);
1788
- return [t, o];
1789
- });
1790
- function ir(n) {
1791
- let e, t, o, s, i, a, c;
1792
- const l = typeof document < "u" && document.attachEvent;
1793
- if (!l) {
1794
- a = function(S) {
1795
- const h = S.__resizeTriggers__, u = h.firstElementChild, p = h.lastElementChild, r = u.firstElementChild;
1796
- p.scrollLeft = p.scrollWidth, p.scrollTop = p.scrollHeight, r.style.width = u.offsetWidth + 1 + "px", r.style.height = u.offsetHeight + 1 + "px", u.scrollLeft = u.scrollWidth, u.scrollTop = u.scrollHeight;
1797
- }, i = function(S) {
1798
- return S.offsetWidth !== S.__resizeLast__.width || S.offsetHeight !== S.__resizeLast__.height;
1799
- }, c = function(S) {
1800
- if (S.target.className && typeof S.target.className.indexOf == "function" && S.target.className.indexOf("contract-trigger") < 0 && S.target.className.indexOf("expand-trigger") < 0)
1801
- return;
1802
- const h = this;
1803
- a(this), this.__resizeRAF__ && Ge(this.__resizeRAF__), this.__resizeRAF__ = Ue(function() {
1804
- i(h) && (h.__resizeLast__.width = h.offsetWidth, h.__resizeLast__.height = h.offsetHeight, h.__resizeListeners__.forEach(function(r) {
1805
- r.call(h, S);
1806
- }));
1807
- });
1808
- };
1809
- let d = !1, w = "";
1810
- o = "animationstart";
1811
- const C = "Webkit Moz O ms".split(" ");
1812
- let P = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), v = "";
1813
- {
1814
- const S = document.createElement("fakeelement");
1815
- if (S.style.animationName !== void 0 && (d = !0), d === !1) {
1816
- for (let h = 0; h < C.length; h++)
1817
- if (S.style[C[h] + "AnimationName"] !== void 0) {
1818
- v = C[h], w = "-" + v.toLowerCase() + "-", o = P[h], d = !0;
1819
- break;
1820
- }
1821
- }
1822
- }
1823
- t = "resizeanim", e = "@" + w + "keyframes " + t + " { from { opacity: 0; } to { opacity: 0; } } ", s = w + "animation: 1ms " + t + "; ";
1824
- }
1825
- const f = function(d) {
1826
- if (!d.getElementById("detectElementResize")) {
1827
- const w = (e || "") + ".resize-triggers { " + (s || "") + 'visibility: hidden; opacity: 0; } .resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }', C = d.head || d.getElementsByTagName("head")[0], P = d.createElement("style");
1828
- P.id = "detectElementResize", P.type = "text/css", n != null && P.setAttribute("nonce", n), P.styleSheet ? P.styleSheet.cssText = w : P.appendChild(d.createTextNode(w)), C.appendChild(P);
1829
- }
1830
- };
1831
- return {
1832
- addResizeListener: function(d, w) {
1833
- if (l)
1834
- d.attachEvent("onresize", w);
1835
- else {
1836
- if (!d.__resizeTriggers__) {
1837
- const C = d.ownerDocument, P = Q.getComputedStyle(d);
1838
- P && P.position === "static" && (d.style.position = "relative"), f(C), d.__resizeLast__ = {}, d.__resizeListeners__ = [], (d.__resizeTriggers__ = C.createElement("div")).className = "resize-triggers";
1839
- const v = C.createElement("div");
1840
- v.className = "expand-trigger", v.appendChild(C.createElement("div"));
1841
- const S = C.createElement("div");
1842
- S.className = "contract-trigger", d.__resizeTriggers__.appendChild(v), d.__resizeTriggers__.appendChild(S), d.appendChild(d.__resizeTriggers__), a(d), d.addEventListener("scroll", c, !0), o && (d.__resizeTriggers__.__animationListener__ = function(u) {
1843
- u.animationName === t && a(d);
1844
- }, d.__resizeTriggers__.addEventListener(o, d.__resizeTriggers__.__animationListener__));
1845
- }
1846
- d.__resizeListeners__.push(w);
1847
- }
1848
- },
1849
- removeResizeListener: function(d, w) {
1850
- if (l)
1851
- d.detachEvent("onresize", w);
1852
- else if (d.__resizeListeners__.splice(d.__resizeListeners__.indexOf(w), 1), !d.__resizeListeners__.length) {
1853
- d.removeEventListener("scroll", c, !0), d.__resizeTriggers__.__animationListener__ && (d.__resizeTriggers__.removeEventListener(o, d.__resizeTriggers__.__animationListener__), d.__resizeTriggers__.__animationListener__ = null);
1854
- try {
1855
- d.__resizeTriggers__ = !d.removeChild(d.__resizeTriggers__);
1856
- } catch {
1857
- }
1858
- }
1859
- }
1860
- };
1861
- }
1862
- class ar extends kt {
1863
- constructor(...e) {
1864
- super(...e), this.state = {
1865
- height: this.props.defaultHeight || 0,
1866
- scaledHeight: this.props.defaultHeight || 0,
1867
- scaledWidth: this.props.defaultWidth || 0,
1868
- width: this.props.defaultWidth || 0
1869
- }, this._autoSizer = null, this._detectElementResize = null, this._parentNode = null, this._resizeObserver = null, this._timeoutId = null, this._onResize = () => {
1870
- this._timeoutId = null;
1871
- const {
1872
- disableHeight: t,
1873
- disableWidth: o,
1874
- onResize: s
1875
- } = this.props;
1876
- if (this._parentNode) {
1877
- const i = window.getComputedStyle(this._parentNode) || {}, a = parseFloat(i.paddingLeft || "0"), c = parseFloat(i.paddingRight || "0"), l = parseFloat(i.paddingTop || "0"), f = parseFloat(i.paddingBottom || "0"), g = this._parentNode.getBoundingClientRect(), x = g.height - l - f, d = g.width - a - c, w = this._parentNode.offsetHeight - l - f, C = this._parentNode.offsetWidth - a - c;
1878
- (!t && (this.state.height !== w || this.state.scaledHeight !== x) || !o && (this.state.width !== C || this.state.scaledWidth !== d)) && (this.setState({
1879
- height: w,
1880
- width: C,
1881
- scaledHeight: x,
1882
- scaledWidth: d
1883
- }), typeof s == "function" && s({
1884
- height: w,
1885
- scaledHeight: x,
1886
- scaledWidth: d,
1887
- width: C
1888
- }));
1889
- }
1890
- }, this._setRef = (t) => {
1891
- this._autoSizer = t;
1892
- };
1893
- }
1894
- componentDidMount() {
1895
- const {
1896
- nonce: e
1897
- } = this.props, t = this._autoSizer ? this._autoSizer.parentNode : null;
1898
- if (t != null && t.ownerDocument && t.ownerDocument.defaultView && t instanceof t.ownerDocument.defaultView.HTMLElement) {
1899
- this._parentNode = t;
1900
- const o = t.ownerDocument.defaultView.ResizeObserver;
1901
- o != null ? (this._resizeObserver = new o(() => {
1902
- this._timeoutId = setTimeout(this._onResize, 0);
1903
- }), this._resizeObserver.observe(t)) : (this._detectElementResize = ir(e), this._detectElementResize.addResizeListener(t, this._onResize)), this._onResize();
1904
- }
1905
- }
1906
- componentWillUnmount() {
1907
- this._parentNode && (this._detectElementResize && this._detectElementResize.removeResizeListener(this._parentNode, this._onResize), this._timeoutId !== null && clearTimeout(this._timeoutId), this._resizeObserver && this._resizeObserver.disconnect());
1908
- }
1909
- render() {
1910
- const {
1911
- children: e,
1912
- defaultHeight: t,
1913
- defaultWidth: o,
1914
- disableHeight: s = !1,
1915
- disableWidth: i = !1,
1916
- doNotBailOutOnEmptyChildren: a = !1,
1917
- nonce: c,
1918
- onResize: l,
1919
- style: f = {},
1920
- tagName: g = "div",
1921
- ...x
1922
- } = this.props, {
1923
- height: d,
1924
- scaledHeight: w,
1925
- scaledWidth: C,
1926
- width: P
1927
- } = this.state, v = {
1928
- overflow: "visible"
1929
- }, S = {};
1930
- let h = !1;
1931
- return s || (d === 0 && (h = !0), v.height = 0, S.height = d, S.scaledHeight = w), i || (P === 0 && (h = !0), v.width = 0, S.width = P, S.scaledWidth = C), a && (h = !1), Se(g, {
1932
- ref: this._setRef,
1933
- style: {
1934
- ...v,
1935
- ...f
1936
- },
1937
- ...x
1938
- }, !h && e(S));
1939
- }
1940
- }
1941
- const cr = vt(({ widths: n, heights: e }) => {
1942
- const { focusedPage: t, totalPages: o } = ne(), s = H(() => {
1943
- const c = [], l = Math.ceil(t / 2) * 2 - 1;
1944
- if (c.push(l), l + 1 <= o) {
1945
- const f = l + 1;
1946
- c.push(f);
1947
- }
1948
- return c;
1949
- }, [t, o]), i = H(() => {
1950
- const c = t % 2 === 1 ? t - 1 : t - 2, l = Math.floor(c / 2), f = e(l), g = n(c), x = n(c + 1);
1951
- return [
1952
- {
1953
- position: "absolute",
1954
- left: 0,
1955
- width: g,
1956
- height: f
1957
- },
1958
- {
1959
- position: "absolute",
1960
- left: g,
1961
- width: x,
1962
- height: f
1963
- }
1964
- ];
1965
- }, [n, e, s]), a = H(() => i.reduce((c, l) => c + Number(l.width || 0), 0), [i]);
1966
- return /* @__PURE__ */ z("div", { style: { width: a, position: "relative" }, children: s.map((c, l) => /* @__PURE__ */ z(Xe, { style: i[l], pageNumber: c }, c)) });
1967
- }), lr = ({ widths: n, heights: e }) => {
1968
- const { focusedPage: t } = ne(), o = H(() => ({
1969
- position: "absolute",
1970
- width: n(t - 1),
1971
- height: e(t - 1)
1972
- }), [n, e, t]), s = H(() => n(t - 1), [n]);
1973
- return /* @__PURE__ */ z(
1974
- "div",
1975
- {
1976
- style: {
1977
- width: s,
1978
- position: "relative"
1979
- },
1980
- children: /* @__PURE__ */ z(Xe, { style: o, pageNumber: t }, t)
1981
- }
1982
- );
1983
- }, ur = (n, e, t) => {
1984
- const o = W(), { contentRef: s } = Ie(), { heights: i, widths: a } = xe(), { setFocusedPage: c } = ne(), [l, f] = q([]), { targetScrollPage: g } = Ct(), x = Ze(l, 0, 500), d = H(() => i.map((C, P) => {
1985
- const v = a[P], S = Sn(P + 1, n), h = v * S.columnIndex, u = C * S.rowIndex, p = h + v, r = u + C;
1986
- return {
1987
- pageNumber: P + 1,
1988
- ...S,
1989
- width: v,
1990
- height: C,
1991
- startX: h,
1992
- startY: u,
1993
- endX: p,
1994
- endY: r
1995
- };
1996
- }), [i, a, n, e]);
1997
- A(() => {
1998
- var P;
1999
- x.length > 0 && !g.current && c(x[0].pageNumber), ((P = x[0]) == null ? void 0 : P.ratio) && x.some((v) => v.pageNumber === g.current) && setTimeout(() => {
2000
- g.current = void 0;
2001
- }, 500);
2002
- }, [x, c]);
2003
- const w = F(
2004
- (C) => {
2005
- o.current && cancelAnimationFrame(o.current), o.current = requestAnimationFrame(() => {
2006
- const P = C.target, v = {
2007
- startTop: P.scrollTop,
2008
- startLeft: P.scrollLeft,
2009
- endTop: P.scrollTop + P.clientHeight,
2010
- endLeft: P.scrollLeft + P.clientWidth
2011
- }, S = d.filter((h) => {
2012
- const u = h.endX >= v.startLeft && h.endY >= v.startTop, p = h.startX <= v.endLeft && h.startY <= v.endTop;
2013
- return u && p;
2014
- }).map((h) => {
2015
- const u = v.startLeft > h.startX ? v.startLeft : h.startX, p = v.startTop > h.startY ? v.startTop : h.startY, r = v.endLeft < h.endX ? v.endLeft : h.endX, _ = v.endTop < h.endY ? v.endTop : h.endY, m = r - u, b = _ - p, y = +(m * b / (h.width * h.height) * 100).toFixed(2);
2016
- return {
2017
- pageNumber: h.pageNumber,
2018
- ratio: y
2019
- };
2020
- }).sort((h, u) => u.ratio - h.ratio);
2021
- f(S);
2022
- });
2023
- },
2024
- [s, d]
2025
- );
2026
- A(() => {
2027
- if (t)
2028
- return t == null || t.addEventListener("scroll", w), () => {
2029
- t == null || t.removeEventListener("scroll", w);
2030
- };
2031
- }, [t, w]);
2032
- }, dr = vt(({ columnIndex: n, rowIndex: e, data: t, style: o }) => {
2033
- const s = yn(e, n, t.columnCount);
2034
- return /* @__PURE__ */ z(Xe, { style: o, pageNumber: s }, s);
2035
- }, or), Bo = () => {
2036
- const { initialPage: n = 1, initialScrollMode: e, instanceId: t } = Ut(), { pagesRef: o, setPagesRef: s } = Ie(), { scrollToPage: i } = xt(), {
2037
- virtualScrollRef: a,
2038
- getVirtualScrollRef: c,
2039
- getPageScrollElementRef: l,
2040
- getVirtualScrollableElementRef: f,
2041
- setTotalInnerDimensions: g,
2042
- virtualScrollableElementRef: x,
2043
- totalInnerDimensions: d,
2044
- pageScrollElementRef: w
2045
- } = Re(), C = W(!0), { nextPage: P, prevPage: v, setFocusedPage: S, focusedPage: h } = ne(), { scrollMode: u } = me(), { viewMode: p } = Ce(), r = W(null), { loading: _ } = Y(), { passwordRequired: m } = Ht(), { LoaderImageComponent: b } = en(), I = W(
2046
- d
2047
- ), y = W({
2048
- viewMode: p,
2049
- scrollMode: u
2050
- }), T = W(!1), E = W(), { isFullScreen: O } = Vt(), {
2051
- pageDimension: N,
2052
- rowCount: R,
2053
- rowHeight: L,
2054
- columnCount: M,
2055
- columnWidth: k,
2056
- estimatedColumnWidth: D,
2057
- estimatedRowHeight: V
2058
- } = sr(), j = Ze(d, 100), U = W();
2059
- ur(M, R, x);
2060
- const X = W({
2061
- scrollTop: 0,
2062
- scrollLeft: 0
2063
- });
2064
- Cn(o);
2065
- const { isPressed: B } = wn(), { selectionMode: J } = Gt(), { initializeGrabScroll: se, resetGrabState: ee } = bn({
2066
- isPressed: B
2067
- }), Z = H(() => J === Dt.HAND, [J]), _e = H(() => ({
2068
- columnCount: M
2069
- }), [M]), ie = F(
2070
- ($) => {
2071
- const G = document.activeElement !== o;
2072
- !O && G || (["ArrowUp", "ArrowLeft"].includes($.key) ? ($.preventDefault(), v()) : ["ArrowDown", "ArrowRight"].includes($.key) && ($.preventDefault(), P()));
2073
- },
2074
- [P, v, O, u]
2075
- );
2076
- A(() => (window.addEventListener("keydown", ie), () => {
2077
- window.removeEventListener("keydown", ie);
2078
- }), [ie]), A(() => {
2079
- if (r.current && (r.current.style.position = "relative"), !!a)
2080
- for (let $ = 0; $ < R; $++)
2081
- for (let G = 0; G < M; G++)
2082
- a.resetAfterIndices({
2083
- columnIndex: G,
2084
- rowIndex: $,
2085
- shouldForceUpdate: !0
2086
- });
2087
- }, [R, M, N, a]);
2088
- const ce = F(
2089
- ($, G) => {
2090
- if (!x)
2091
- return { scrollTop: 0, scrollLeft: 0 };
2092
- const le = X.current.scrollTop > G, ue = X.current.scrollLeft > $;
2093
- return le || ue ? X.current : {
2094
- scrollTop: x.scrollTop,
2095
- scrollLeft: x.scrollLeft
2096
- };
2097
- },
2098
- [x]
2099
- ), ae = F(
2100
- ($, G) => {
2101
- if (y.current.viewMode !== p || y.current.scrollMode !== u) {
2102
- U.current && clearTimeout(U.current), T.current = !0, i(h, "auto"), U.current = setTimeout(() => {
2103
- requestAnimationFrame(() => {
2104
- y.current = { viewMode: p, scrollMode: u };
2105
- });
2106
- }, 100);
2107
- return;
2108
- }
2109
- const ue = $.scrollTop, ze = $.scrollLeft;
2110
- if (!G.height || !G.width)
2111
- return;
2112
- T.current = !0;
2113
- const { height: de, width: Oe } = G, { height: Ke, width: Qe } = I.current;
2114
- if (Ke === de && Qe === Oe)
2115
- return;
2116
- const Ot = ue / Ke * de, Nt = ze / Qe * Oe, At = Math.round(Math.min(Ot, de)) || 0, Ft = Math.round(Math.min(Nt, Oe)) || 0;
2117
- E.current = setTimeout(() => {
2118
- requestAnimationFrame(() => {
2119
- a == null || a.scrollTo({
2120
- scrollTop: At,
2121
- scrollLeft: Ft
2122
- });
2123
- });
2124
- }, 0), I.current = {
2125
- height: G.height,
2126
- width: G.width
2127
- };
2128
- },
2129
- [a, p, u, i]
2130
- );
2131
- A(() => {
2132
- clearTimeout(E.current);
2133
- const $ = Array.from({ length: R }).reduce(
2134
- (ue, ze, de) => ue + L(de),
2135
- 0
2136
- ), G = Array.from({ length: M }).reduce(
2137
- (ue, ze, de) => ue + k(de),
2138
- 0
2139
- ), le = ce(G, $);
2140
- X.current = le, ae(le, { height: $, width: G }), g({
2141
- height: $,
2142
- width: G
2143
- });
2144
- }, [N, R, M, ae]);
2145
- const Ee = F(
2146
- ($) => {
2147
- X.current = {
2148
- scrollTop: $.scrollTop,
2149
- scrollLeft: $.scrollLeft
2150
- };
2151
- },
2152
- [x]
2153
- );
2154
- A(() => () => {
2155
- U.current && clearTimeout(U.current);
2156
- }, []);
2157
- const Me = H(() => he(te["rp-pages-container"], {
2158
- [te["rp-cursor-grab"]]: Z && !B,
2159
- [te["rp-cursor-grabbing"]]: Z && B
2160
- }), [Z, B]), zt = F(
2161
- ($) => {
2162
- if (Z && $) {
2163
- const G = he(te["rp-pages"]), le = document.querySelector(`.${G}`);
2164
- se(le);
2165
- }
2166
- },
2167
- [Z, se, te]
2168
- );
2169
- return A(() => {
2170
- _ && ee();
2171
- }, [_]), A(() => {
2172
- if (!(j.height === 0 || !C.current)) {
2173
- if (e === K.PAGE_SCROLLING) {
2174
- n !== h && w && S(n), C.current = !1;
2175
- return;
2176
- }
2177
- i(n, "auto"), S(n), C.current = !1;
2178
- }
2179
- }, [
2180
- i,
2181
- e,
2182
- w,
2183
- S,
2184
- j
2185
- ]), /* @__PURE__ */ Ve(mt, { children: [
2186
- /* @__PURE__ */ z(An, { id: t, ref: s, tabIndex: -1, className: Me, children: /* @__PURE__ */ z(ar, { style: { minHeight: "50px" }, children: ({ width: $, height: G }) => /* @__PURE__ */ z("div", { "data-rp": "pages", ref: zt, style: { width: $, height: G }, children: u === K.PAGE_SCROLLING ? /* @__PURE__ */ z(
2187
- "div",
2188
- {
2189
- ref: l,
2190
- style: { width: $, height: G },
2191
- className: he(te["rp-pages"], te["rp-page-scrolling-wrapper"]),
2192
- children: p === ge.DUAL_PAGE ? /* @__PURE__ */ z(cr, { widths: k, heights: L }) : /* @__PURE__ */ z(lr, { widths: k, heights: L })
2193
- }
2194
- ) : D ? /* @__PURE__ */ z(
2195
- tr,
2196
- {
2197
- ref: c,
2198
- itemData: _e,
2199
- outerRef: f,
2200
- innerRef: r,
2201
- onScroll: Ee,
2202
- columnCount: M,
2203
- columnWidth: k,
2204
- rowHeight: L,
2205
- height: G,
2206
- width: $,
2207
- estimatedColumnWidth: D,
2208
- estimatedRowHeight: V,
2209
- rowCount: R,
2210
- className: he(
2211
- te["rp-pages"],
2212
- u === K.HORIZONTAL_SCROLLING ? te["rp-pages-horizontal-scroll"] : ""
2213
- ),
2214
- children: dr
2215
- }
2216
- ) : _ ? null : /* @__PURE__ */ z(
2217
- "div",
2218
- {
2219
- className: te["rp-loader"],
2220
- style: {
2221
- display: "flex",
2222
- justifyContent: "center",
2223
- alignItems: "center",
2224
- height: "100%",
2225
- width: "100%"
2226
- },
2227
- children: b && /* @__PURE__ */ z(b, {})
2228
- }
2229
- ) }) }) }),
2230
- m && /* @__PURE__ */ z(xn, {})
2231
- ] });
2232
- }, Zo = {
2233
- "rp-toolbar-content": "_rp-toolbar-content_sz31z_1",
2234
- "rp-toolbar-wrapper": "_rp-toolbar-wrapper_sz31z_10",
2235
- "rp-toolbar-start": "_rp-toolbar-start_sz31z_33",
2236
- "rp-toolbar-middle": "_rp-toolbar-middle_sz31z_39",
2237
- "rp-toolbar-end": "_rp-toolbar-end_sz31z_46"
2238
- }, Xo = {
2239
- "rp-paginate": "_rp-paginate_1gck0_1",
2240
- "rp-page-input": "_rp-page-input_1gck0_6",
2241
- "rp-total-page": "_rp-total-page_1gck0_18"
2242
- }, Ko = {
2243
- "rp-dialog-wrapper": "_rp-dialog-wrapper_slqo7_1",
2244
- "rp-dialog-overlay": "_rp-dialog-overlay_slqo7_7",
2245
- "rp-document-dialog": "_rp-document-dialog_slqo7_13",
2246
- "rp-document-properties": "_rp-document-properties_slqo7_35",
2247
- "rp-dialog-title": "_rp-dialog-title_slqo7_39",
2248
- "rp-dialog-close": "_rp-dialog-close_slqo7_47",
2249
- "rp-properties-divider": "_rp-properties-divider_slqo7_55"
2250
- }, Qo = {
2251
- "rp-other-tool-content": "_rp-other-tool-content_su718_1"
2252
- }, ft = ".pdf", pr = (n) => URL.createObjectURL(n), hr = async (n) => {
2253
- const t = await (await fetch(n)).blob();
2254
- return pr(t);
2255
- }, fr = () => {
2256
- const { filename: n, pdfSrc: e } = Y(), { downloadFilename: t } = Qt(), o = (i) => {
2257
- const a = t || i;
2258
- return a.endsWith(ft) ? a : `${a}${ft}`;
2259
- };
2260
- return { download: F(async () => {
2261
- if (!n || !e)
2262
- throw new Error("There is no PDF source to download");
2263
- const i = document.createElement("a");
2264
- i.href = await hr(e), i.download = o(n), document.body.appendChild(i), i.click(), document.body.removeChild(i);
2265
- }, [n, e]) };
2266
- }, Yo = {
2267
- "rp-go-to-Top": "_rp-go-to-Top_4e0yd_1"
2268
- }, gr = "_active_1yldl_11", Jo = {
2269
- "rp-zoom-wrapper": "_rp-zoom-wrapper_1yldl_1",
2270
- "rp-current-zoom-wrapper": "_rp-current-zoom-wrapper_1yldl_6",
2271
- active: gr,
2272
- "rp-current-zoom-icon": "_rp-current-zoom-icon_1yldl_15",
2273
- "rp-zoom-level-icon": "_rp-zoom-level-icon_1yldl_20",
2274
- "rp-current-zoom-text": "_rp-current-zoom-text_1yldl_24",
2275
- "rp-zoom-dropdown-content": "_rp-zoom-dropdown-content_1yldl_28"
2276
- }, mr = "_loading_wazy2_1", es = {
2277
- "rp-loading-overlay": "_rp-loading-overlay_wazy2_1",
2278
- "rp-loading-modal": "_rp-loading-modal_wazy2_14",
2279
- "rp-loading-title": "_rp-loading-title_wazy2_27",
2280
- "rp-loading-progress-bar": "_rp-loading-progress-bar_wazy2_35",
2281
- "rp-loading-progress": "_rp-loading-progress_wazy2_35",
2282
- "rp-loading-cancel-button": "_rp-loading-cancel-button_wazy2_55",
2283
- loading: mr
2284
- }, ts = {
2285
- "rp-sidebar-content-wrapper": "_rp-sidebar-content-wrapper_1sdl6_1",
2286
- "rp-sidebar-content": "_rp-sidebar-content_1sdl6_1",
2287
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_1sdl6_16",
2288
- "rp-thumbnail-dragging": "_rp-thumbnail-dragging_1sdl6_21"
2289
- }, ve = {
2290
- "rp-thumbnail-wrapper": "_rp-thumbnail-wrapper_3fenb_1",
2291
- "rp-thumbnail-text": "_rp-thumbnail-text_3fenb_10",
2292
- "rp-thumbnail": "_rp-thumbnail_3fenb_1",
2293
- "rp-thumbnail-active": "_rp-thumbnail-active_3fenb_22",
2294
- "rp-thumbnail-loader": "_rp-thumbnail-loader_3fenb_31"
2295
- }, _r = (n) => {
2296
- const { pageNumber: e, isFocused: t, viewport: o } = n, { goToPage: s } = ne(), { pageRotate: i } = Le(), a = W(null), c = It(), { pages: l } = Y(), [f, g] = q(null), x = W(!1), d = W(), w = H(() => t ? ve["rp-thumbnail-active"] : "", [t]), C = H(() => ({
2297
- width: Math.round(o.width),
2298
- height: Math.round(o.height)
2299
- }), [o]), P = F(() => {
2300
- e && s(e);
2301
- }, [s, e]);
2302
- return A(() => {
2303
- const v = l.get(e);
2304
- d.current === v || (g(null), d.current = v);
2305
- }, [l, e]), A(() => {
2306
- const v = l.get(e);
2307
- if (!a.current || !e || !v || f)
2308
- return;
2309
- const S = new IntersectionObserver((h) => {
2310
- h.forEach((u) => {
2311
- if (x.current) {
2312
- x.current = !1, c.removeQueue(`thumbnail-${e}`);
2313
- return;
2314
- }
2315
- if (u.isIntersecting) {
2316
- const p = document.createElement("canvas");
2317
- x.current = !0, c.enqueue(
2318
- `thumbnail-${e}`,
2319
- {
2320
- page: v.page,
2321
- canvasElem: p,
2322
- options: {
2323
- scale: 1
2324
- },
2325
- onLoaded: () => {
2326
- p.toBlob((r) => {
2327
- if (!r)
2328
- return;
2329
- const _ = URL.createObjectURL(r);
2330
- g(_);
2331
- });
2332
- }
2333
- },
2334
- 2
2335
- );
2336
- }
2337
- });
2338
- });
2339
- return a.current && S.observe(a.current), () => {
2340
- S.disconnect(), c.removeQueue(`thumbnail-${e}`);
2341
- };
2342
- }, [c, e, l, f]), /* @__PURE__ */ Ve(
2343
- "div",
2344
- {
2345
- onClick: P,
2346
- id: `page-${e}`,
2347
- className: ve["rp-thumbnail-wrapper"],
2348
- ref: a,
2349
- children: [
2350
- /* @__PURE__ */ z(
2351
- "div",
2352
- {
2353
- style: {
2354
- transform: `rotate(${i[e || 0]}deg)`
2355
- },
2356
- className: he(w, ve["rp-thumbnail"]),
2357
- children: f ? /* @__PURE__ */ z(
2358
- "img",
2359
- {
2360
- src: f,
2361
- width: C.width,
2362
- height: C.height,
2363
- alt: "thumbnail"
2364
- }
2365
- ) : /* @__PURE__ */ z(
2366
- "div",
2367
- {
2368
- className: ve["rp-thumbnail-loader"],
2369
- style: {
2370
- width: `${C.width}px`,
2371
- height: `${C.height}px`
2372
- },
2373
- children: /* @__PURE__ */ z(wt, {})
2374
- }
2375
- )
2376
- }
2377
- ),
2378
- /* @__PURE__ */ z("div", { className: ve["rp-thumbnail-text"], children: e })
2379
- ]
2380
- }
2381
- );
2382
- }, gt = {
2383
- "rp-thumbnails-container": "_rp-thumbnails-container_16vqr_1",
2384
- "rp-thumbnails": "_rp-thumbnails_16vqr_1"
2385
- }, vr = 16, wr = (n, e) => {
2386
- const t = n == null ? void 0 : n.querySelector(`#page-${e}`);
2387
- n && (t != null && t.offsetTop) && (n.scrollTop = (t == null ? void 0 : t.offsetTop) - vr);
2388
- }, ns = Be((n, e) => {
2389
- const { show: t } = n, { focusedPage: o, totalPages: s } = ne(), { thumbnailPages: i, addPage: a, thumbnailLength: c, addToPage: l } = zn(), f = W(null), g = W(1);
2390
- _t(e, () => f.current);
2391
- const x = H(() => Object.values(i), [i]), d = F(() => {
2392
- const w = c + 1;
2393
- w <= s && a(w);
2394
- }, [a, s, c]);
2395
- return A(() => {
2396
- o > c ? l(o) : t && g.current !== o && (wr(f.current, o), g.current = o);
2397
- }, [o, c, l, t, x]), nn(f.current, d), /* @__PURE__ */ z("div", { ref: f, className: gt["rp-thumbnails-container"], children: /* @__PURE__ */ z("div", { className: gt["rp-thumbnails"], children: t ? x.map((w, C) => {
2398
- var P, v;
2399
- return /* @__PURE__ */ z(
2400
- _r,
2401
- {
2402
- isFocused: o === ((P = w.page) == null ? void 0 : P.pageNumber),
2403
- pageNumber: (v = w.page) == null ? void 0 : v.pageNumber,
2404
- loading: w.loading,
2405
- viewport: w.viewport,
2406
- defaultRotation: w.defaultRotation
2407
- },
2408
- C
2409
- );
2410
- }) : null }) });
2411
- }), rs = {
2412
- "rp-toolbar-layout": "_rp-toolbar-layout_vwobs_1",
2413
- "rp-content": "_rp-content_vwobs_7",
2414
- "rp-topbar-content": "_rp-topbar-content_vwobs_13",
2415
- "rp-sidebar-content": "_rp-sidebar-content_vwobs_22",
2416
- "rp-pages": "_rp-pages_vwobs_32",
2417
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_vwobs_37"
2418
- };
2419
- export {
2420
- Tt as A,
2421
- Rt as B,
2422
- It as C,
2423
- Fn as D,
2424
- kn as E,
2425
- $n as F,
2426
- Gn as G,
2427
- Xe as H,
2428
- sr as I,
2429
- cr as J,
2430
- lr as K,
2431
- An as L,
2432
- ur as M,
2433
- _r as N,
2434
- qo as P,
2435
- Bo as R,
2436
- Vo as S,
2437
- Uo as T,
2438
- fr as a,
2439
- En as b,
2440
- Nn as c,
2441
- Ae as d,
2442
- jo as e,
2443
- Go as f,
2444
- zn as g,
2445
- Xo as h,
2446
- Jo as i,
2447
- Zo as j,
2448
- ts as k,
2449
- ns as l,
2450
- es as m,
2451
- rs as n,
2452
- Qo as o,
2453
- Yo as p,
2454
- Ko as q,
2455
- xt as r,
2456
- In as s,
2457
- St as t,
2458
- ne as u,
2459
- Ln as v,
2460
- yt as w,
2461
- Mn as x,
2462
- Pt as y,
2463
- On as z
2464
- };