@pdf-viewer/react 1.9.0-beta.0 → 1.9.0-beta.2

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 (78) hide show
  1. package/dist/RPLayout-81cd4970.js +3393 -0
  2. package/dist/components/RPController.js +1 -1
  3. package/dist/components/RPDropFileZone.js +27 -26
  4. package/dist/components/RPPages.js +8 -2
  5. package/dist/components/layout/LayoutContainer.js +8 -2
  6. package/dist/components/layout/RPDefaultLayout.js +1 -1
  7. package/dist/components/layout/RPLayout.js +8 -3
  8. package/dist/components/layout/WrapperLayout.js +8 -7
  9. package/dist/components/layout/sidebar/RPSidebar.js +3 -2
  10. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  11. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  12. package/dist/components/layout/toolbar/DarkModeTool.js +20 -18
  13. package/dist/components/layout/toolbar/DocumentDialog.js +6 -3
  14. package/dist/components/layout/toolbar/DocumentProperties.js +19 -17
  15. package/dist/components/layout/toolbar/FileDownloadTool.js +4 -2
  16. package/dist/components/layout/toolbar/FileUploadTool.js +21 -19
  17. package/dist/components/layout/toolbar/FullScreenTool.js +45 -36
  18. package/dist/components/layout/toolbar/MostPageTool.js +8 -2
  19. package/dist/components/layout/toolbar/OtherTool.js +3 -2
  20. package/dist/components/layout/toolbar/Paginate.js +4 -2
  21. package/dist/components/layout/toolbar/PrintTool.js +4 -2
  22. package/dist/components/layout/toolbar/RPToolbar.js +3 -2
  23. package/dist/components/layout/toolbar/RPToolbarEnd.js +1 -1
  24. package/dist/components/layout/toolbar/RotateTool.js +27 -25
  25. package/dist/components/layout/toolbar/ScrollModeTool.js +43 -41
  26. package/dist/components/layout/toolbar/SearchResultNavigator.js +1 -1
  27. package/dist/components/layout/toolbar/SearchTool.js +9 -3
  28. package/dist/components/layout/toolbar/SelectionModeTool.js +32 -30
  29. package/dist/components/layout/toolbar/ThumbnailTool.js +17 -0
  30. package/dist/components/layout/toolbar/ToolbarCustom.js +8 -2
  31. package/dist/components/layout/toolbar/ViewModeTool.js +33 -24
  32. package/dist/components/layout/toolbar/ZoomTool.js +4 -2
  33. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +9 -13
  34. package/dist/components/layout/toolbar/tools/FileUploadTool.js +10 -14
  35. package/dist/components/layout/toolbar/tools/FullScreenTool.js +13 -17
  36. package/dist/components/layout/toolbar/tools/InputPageTool.js +1 -1
  37. package/dist/components/layout/toolbar/tools/NextPageTool.js +9 -3
  38. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +1 -1
  39. package/dist/components/layout/toolbar/tools/PrintTool.js +8 -12
  40. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +1 -1
  41. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +55 -56
  42. package/dist/components/layout/toolbar/tools/defaults/LeftSidebarDefaultTools.js +16 -0
  43. package/dist/components/layout/toolbar/tools/defaults/TopbarDefaultTools.js +59 -0
  44. package/dist/components/page/AnnotationLayer.js +8 -2
  45. package/dist/components/page/CanvasLayer.js +8 -2
  46. package/dist/components/page/DualPage.js +1 -1
  47. package/dist/components/page/RPPage.js +8 -2
  48. package/dist/components/page/SinglePage.js +1 -1
  49. package/dist/components/page/TextHighlightLayer.js +8 -2
  50. package/dist/components/page/TextLayer.js +8 -2
  51. package/dist/components/ui/LoadingIndicator.js +1 -1
  52. package/dist/contexts/DropFileZoneContext.js +28 -29
  53. package/dist/contexts/IconToolContext.js +13 -0
  54. package/dist/contexts/PaginationContext.js +3 -3
  55. package/dist/contexts/PrintContext.js +1 -1
  56. package/dist/contexts/SearchContext.js +1 -1
  57. package/dist/contexts/ThumbnailsContext.js +1 -1
  58. package/dist/contexts/ToolComponentContext.js +52 -0
  59. package/dist/contexts/ToolbarComponentContext.js +6 -3
  60. package/dist/main.js +23 -19
  61. package/dist/types/components/layout/toolbar/ThumbnailTool.d.ts +2 -0
  62. package/dist/types/components/layout/toolbar/tools/defaults/LeftSidebarDefaultTools.d.ts +3 -0
  63. package/dist/types/components/layout/toolbar/tools/defaults/TopbarDefaultTools.d.ts +3 -0
  64. package/dist/types/contexts/IconToolContext.d.ts +9 -0
  65. package/dist/types/contexts/ToolComponentContext.d.ts +12 -0
  66. package/dist/types/main.d.ts +3 -1
  67. package/dist/types/utils/types.d.ts +69 -46
  68. package/dist/utils/hooks/useFileDownload.js +8 -2
  69. package/dist/utils/hooks/useLicense.js +1 -1
  70. package/dist/utils/hooks/usePaginate.js +8 -2
  71. package/dist/utils/hooks/usePresentPage.js +8 -2
  72. package/dist/utils/hooks/usePrint.js +8 -2
  73. package/dist/utils/hooks/useScrollToPage.js +8 -2
  74. package/dist/utils/hooks/useSearch.js +8 -2
  75. package/dist/utils/hooks/useThumbnail.js +8 -2
  76. package/dist/utils/hooks/useVirtualReactWindow.js +8 -2
  77. package/package.json +1 -1
  78. package/dist/RPLayout-3ef4e136.js +0 -3343
@@ -1,3343 +0,0 @@
1
- import { jsx as i, Fragment as ie, jsxs as D } from "react/jsx-runtime";
2
- import * as B from "react";
3
- import { useRef as H, useEffect as W, useCallback as E, useState as G, useMemo as M, createContext as Qe, useContext as et, forwardRef as We, useImperativeHandle as pn, createElement as Ze, PureComponent as sr, Component as cr, memo as hn } from "react";
4
- import { useLayoutContainer as se } from "./contexts/LayoutContainerContext.js";
5
- import { Container as fn } from "./components/layout/Container.js";
6
- import { useViewportContext as Pe, ViewportProvider as mn } from "./contexts/ViewportContext.js";
7
- import { c as ne } from "./clsx-0c6e471a.js";
8
- import { useThemeContext as lr } from "./contexts/ThemeContext.js";
9
- import { useDocumentContext as X } from "./contexts/RPDocumentContext.js";
10
- import { useDocumentPasswordContext as dr } from "./contexts/DocumentPasswordContext.js";
11
- import { ViewMode as Re, ScrollMode as ee, AnnotationSubType as kt, SelectionMode as ur, ZoomLevel as st } from "./utils/types.js";
12
- import { useScrollModeContext as Ne } from "./contexts/ScrollModeContext.js";
13
- import { useDarkModeContext as pr } from "./contexts/DarkModeContext.js";
14
- import "./contexts/RotationContext.js";
15
- import { useLayerContext as hr } from "./contexts/LayerContext.js";
16
- import { useZoomContext as tt } from "./contexts/ZoomContext.js";
17
- import { useViewModeContext as Ee } from "./contexts/ViewModeContext.js";
18
- import { useVirtualScrollContext as nt } from "./contexts/VirtualScrollContext.js";
19
- import { useVirtualGridContext as gn } from "./contexts/VirtualGridContext.js";
20
- import { useSelectionModeContext as fr } from "./contexts/SelectionModeContext.js";
21
- import { useInitialStateContext as mr } from "./contexts/InitialStateContext.js";
22
- import { useFullScreenContext as gr } from "./contexts/FullScreenContext.js";
23
- import "./contexts/FileInputContext.js";
24
- import "./contexts/DropFileZoneContext.js";
25
- import { renderPage as wt } from "./utils/renderPage.js";
26
- import { findMatches as vr, resetDivs as wr, highlightMatches as _r, isMatchEntireWord as br } from "./utils/highlight.js";
27
- import { useDimensionPagesContext as Ue } from "./contexts/DimensionPagesContext.js";
28
- import { useLocalizationContext as ce } from "./contexts/LocalizationContext.js";
29
- import { useHighlightContext as Cr } from "./contexts/HighlightContext.js";
30
- import "./contexts/LicenseContext.js";
31
- import { useDownloadContext as Pr } from "./contexts/DownloadContext.js";
32
- import { useSmoothScrollContext as vn } from "./contexts/SmoothScrollContext.js";
33
- import "./contexts/ElementPageContext.js";
34
- import { usePagesRotateContext as Ve } from "./contexts/PagesRotateContext.js";
35
- import { useLoaderContext as Pt } from "./contexts/LoaderContext.js";
36
- import "./components/RPConfig.js";
37
- import { ChevronUpIcon as Ge } from "./components/icons/ChevronUpIcon.js";
38
- import { UIButton as re } from "./components/ui/Button.js";
39
- import { UIInput as wn } from "./components/ui/Input.js";
40
- import { useIconContext as he, IconProvider as Tr } from "./contexts/IconContext.js";
41
- import { useToolbarComponentContext as fe, ToolbarComponentProvider as yr } from "./contexts/ToolbarComponentContext.js";
42
- import K from "./components/ui/RPTooltip.js";
43
- import { FileUploadTool as _n } from "./components/layout/toolbar/FileUploadTool.js";
44
- import { DarkModeTool as Sr } from "./components/layout/toolbar/DarkModeTool.js";
45
- import { ThreeDotIcon as xr } from "./components/icons/ThreeDotIcon.js";
46
- import { UIDropDown as bn } from "./components/ui/DropDown.js";
47
- import { e as Ir, a as Tt, P as qe, c as $e, g as yt, i as Rr, k as Lr, f as Nr } from "./index-1cb41342.js";
48
- import { D as Er, u as ct } from "./index-aa2d3884.js";
49
- import { a as Or, u as zr, F as Dr, b as Ar, G as Ye } from "./index-7279fb4e.js";
50
- import { h as Fr } from "./component-1da194e8.js";
51
- import { CloseIcon as Wr } from "./components/icons/CloseIcon.js";
52
- import { dateFormatter as Mt } from "./utils/dateFormatter.js";
53
- import { LoaderIcon as St } from "./components/icons/LoaderIcon.js";
54
- import { useInfiniteScroll as kr } from "./utils/hooks/useInfiniteScroll.js";
55
- import { RPDropFileZone as Mr } from "./components/RPDropFileZone.js";
56
- import { c as Q, S as Ht } from "./SearchCloseButton-ddb9877e.js";
57
- import { UICheckbox as $t } from "./components/ui/Checkbox.js";
58
- import { _ as Hr, U as $r } from "./Popover-1faa77f6.js";
59
- import { MenuItem as Ce } from "./components/layout/toolbar/MenuItem.js";
60
- import { MenuSeparator as xt } from "./components/layout/toolbar/MenuSeparator.js";
61
- import { useOtherToolContext as Gr, OtherToolProvider as Cn } from "./contexts/OtherToolContext.js";
62
- import { WrapperLayout as Pn } from "./components/layout/WrapperLayout.js";
63
- import { PropertyItem as Ur } from "./components/layout/toolbar/PropertyItem.js";
64
- import { DocumentProperties as Vr } from "./components/layout/toolbar/DocumentProperties.js";
65
- import { RotateTool as qr } from "./components/layout/toolbar/RotateTool.js";
66
- import { ViewModeTool as Br } from "./components/layout/toolbar/ViewModeTool.js";
67
- import { ScrollModeTool as Zr } from "./components/layout/toolbar/ScrollModeTool.js";
68
- import { FileDownloadDefaultIcon as jr } from "./components/icons/FileDownloadDefaultIcon.js";
69
- import { PrintDefaultTool as Kr } from "./components/icons/PrintDefaultIcon.js";
70
- import { FullScreenTool as Tn } from "./components/layout/toolbar/FullScreenTool.js";
71
- import { GoToDownIcon as yn } from "./components/icons/GoToDownIcon.js";
72
- import { SelectionModeTool as Xr } from "./components/layout/toolbar/SelectionModeTool.js";
73
- import { ZoomInIcon as Yr } from "./components/icons/ZoomInIcon.js";
74
- import { ZoomOutIcon as Jr } from "./components/icons/ZoomOutIcon.js";
75
- import { PAGE_PADDING as Gt } from "./utils/constants.js";
76
- import { getZoomLevel as Qr } from "./utils/getZoomLevel.js";
77
- import { SearchIcon as eo } from "./components/icons/SearchIcon.js";
78
- import { ClearIcon as to } from "./components/icons/ClearIcon.js";
79
- import { InfoIcon as Ut } from "./components/icons/InfoIcon.js";
80
- import { ThumbnailIcon as no } from "./components/icons/Thumbnail.js";
81
- import { RPSplitter as ro } from "./components/layout/sidebar/RPSplitter.js";
82
- import * as oo from "pdfjs-dist";
83
- import { PixelsPerInch as io, AnnotationMode as ao, RenderingCancelledException as so, AnnotationLayer as co } from "pdfjs-dist";
84
- import { SimpleLinkService as lo } from "./utils/link_service.js";
85
- import { annotationsEvents as uo, annotationEventsHandler as po, handleClick as Vt, handleAnnotationWidget as ho, handleAnnotationLink as fo, bindLayerEvents as mo, unbindLayerEvents as qt } from "./utils/annotations.js";
86
- import { normalizeSingleKeyword as go, sortHighlightPosition as vo, unwrap as wo } from "./components/page/searchHighlight.js";
87
- import { CustomElement as _o } from "./components/page/CustomElement.js";
88
- import { useMousePressed as bo } from "./utils/hooks/useMousePressed.js";
89
- import { useGrabScroll as Co } from "./utils/hooks/useGrabScroll.js";
90
- import { usePinch as Po } from "./utils/hooks/usePinch.js";
91
- import { useDebounce as It } from "./utils/hooks/useDebounce.js";
92
- import To from "./components/ui/PasswordModal.js";
93
- import { getPositionFromPage as yo, getPageFromPosition as So } from "./utils/calculatePage.js";
94
- import { getScrollDistance as Fe } from "./utils/getScrollDistance.js";
95
- import { getWordPositionInPage as xo } from "./utils/getWordPositionInPage.js";
96
- import { getThumbnailViewport as Bt } from "./utils/getThumbnailViewport.js";
97
- import { smoothScrollTo as lt } from "./utils/smoothScrollTo.js";
98
- import { appConsole as Io } from "./utils/appConsole.js";
99
- import './assets/RPLayout.css';const Sn = () => {
100
- const { viewMode: e } = Ee(), { scrollMode: t } = Ne(), { virtualScrollRef: n, virtualScrollableElementRef: o, pageScrollElementRef: r } = nt(), { setFocusedPage: a } = ae(), l = H(), { columnCount: c } = gn(), { widths: d, heights: u } = Ue(), f = H(t), v = H(e), h = H(c), { targetScrollPage: w } = vn();
101
- W(() => {
102
- n != null && n.scrollToItem && (l.current = n);
103
- }, [n]), W(() => {
104
- f.current = t, v.current = e;
105
- }, [t, e]);
106
- const b = E(
107
- (P, T) => {
108
- if (!r)
109
- return;
110
- const m = Math.ceil(P / 2) * 2 - 1;
111
- if (P === m + 1) {
112
- const g = {
113
- left: d[m],
114
- top: 0
115
- };
116
- return new Promise(
117
- (s) => lt(r, g, s)
118
- );
119
- }
120
- const p = {
121
- left: 0,
122
- top: 0
123
- };
124
- return r == null ? void 0 : r.scrollTo({
125
- ...p,
126
- behavior: T
127
- });
128
- },
129
- [r, d, lt]
130
- );
131
- return W(() => {
132
- f.current = t, v.current = e;
133
- }, [t, e]), W(() => {
134
- h.current = c;
135
- }, [c]), { scrollToPage: E(
136
- (P, T = "smooth") => {
137
- a(P);
138
- const m = P - 1;
139
- let p = m, g = 0;
140
- if (v.current === Re.DUAL_PAGE && f.current === ee.PAGE_SCROLLING) {
141
- b(P, T);
142
- return;
143
- }
144
- if (f.current === ee.PAGE_SCROLLING) {
145
- a(P);
146
- return;
147
- }
148
- if (!l.current || !o)
149
- return;
150
- const s = o;
151
- if (w.current = P, f.current === ee.HORIZONTAL_SCROLLING) {
152
- g = m;
153
- const y = {
154
- left: Fe(d, g),
155
- top: 0
156
- };
157
- return s.scrollTo({
158
- ...y,
159
- behavior: T
160
- });
161
- }
162
- if (v.current === Re.DUAL_PAGE) {
163
- g = m % 2, p = Math.floor(m / 2);
164
- const y = {
165
- left: Fe(d, g),
166
- top: Fe(u, p)
167
- };
168
- return s.scrollTo({
169
- ...y,
170
- behavior: T
171
- });
172
- }
173
- const _ = {
174
- left: 0,
175
- top: Fe(u, p)
176
- };
177
- return s.scrollTo({
178
- ..._,
179
- behavior: T
180
- });
181
- },
182
- [
183
- o,
184
- c,
185
- b,
186
- a,
187
- lt,
188
- u,
189
- d
190
- ]
191
- ) };
192
- }, Ro = (e = 1) => {
193
- const [t, n] = G(e), [o, r] = G(0), { scrollToPage: a } = Sn(), l = H(1), { viewMode: c } = Ee(), { scrollMode: d } = Ne(), { widths: u } = Ue(), { pagesRef: f } = se(), v = It(t, 100), h = E(
194
- (p) => {
195
- if (!/^[0-9]*$/g.test(p.toString()) || !p)
196
- return { success: !1, currentPage: l.current };
197
- const s = +p;
198
- return s < 0 || s > o ? { success: !1, currentPage: l.current } : (n(s), l.current = s, { success: !0, currentPage: +p });
199
- },
200
- [o]
201
- ), w = E(h, [h]), b = E(
202
- (p) => {
203
- const g = h(p);
204
- return g.success && a(g.currentPage), g;
205
- },
206
- [h, a]
207
- ), S = E((p) => {
208
- const g = p % 2 === 1;
209
- if (!f || g)
210
- return !1;
211
- const s = g ? u[p] : u[p - 1], _ = g ? u[p + 1] : u[p];
212
- return c === Re.DUAL_PAGE && s + _ < f.clientWidth;
213
- }, [c, u, f, o]), P = E(() => {
214
- let p = t - 1;
215
- S(p) && (p = t - 2), b(p);
216
- }, [b, t, c, d, S]), T = M(() => c === Re.DUAL_PAGE && d === ee.PAGE_SCROLLING ? t === o - 1 : t === o, [t, o, c, d]), m = E(() => {
217
- if (T)
218
- return;
219
- let p = t + 1;
220
- S(p) && (p = t + 2), b(p);
221
- }, [b, t, S, c, d, T]);
222
- return {
223
- focusedPage: v,
224
- totalPages: o,
225
- setFocusedPage: w,
226
- setTotalPages: r,
227
- nextPage: m,
228
- prevPage: P,
229
- goToPage: b
230
- };
231
- }, xn = Qe({
232
- focusedPage: 0,
233
- setFocusedPage: (e) => {
234
- },
235
- goToPage: (e) => ({ success: !!e, currentPage: +e }),
236
- totalPages: 0,
237
- setTotalPages: (e) => {
238
- },
239
- prevPage: () => {
240
- },
241
- nextPage: () => {
242
- }
243
- }), ae = () => {
244
- const e = et(xn);
245
- return typeof (e == null ? void 0 : e.focusedPage) > "u" && Io.error("Please use this hooks inside children component of RPProvider"), e;
246
- }, Vs = ({ children: e }) => {
247
- const { pdf: t } = X(), { focusedPage: n, totalPages: o, setFocusedPage: r, setTotalPages: a, goToPage: l, nextPage: c, prevPage: d } = Ro();
248
- return W(() => {
249
- t != null && t.numPages && (a(t.numPages), r(1));
250
- }, [t, a, r]), /* @__PURE__ */ i(
251
- xn.Provider,
252
- {
253
- value: {
254
- focusedPage: n,
255
- totalPages: o,
256
- setFocusedPage: r,
257
- setTotalPages: a,
258
- nextPage: c,
259
- prevPage: d,
260
- goToPage: l
261
- },
262
- children: e
263
- }
264
- );
265
- };
266
- const Lo = () => {
267
- const { pdf: e, pages: t } = X(), [n, o] = G({
268
- loadedPages: 0,
269
- totalPages: 0,
270
- percentage: 0
271
- }), [r, a] = G(!1), [l, c] = G(!1), [d, u] = G(null), f = H(!1);
272
- W(() => {
273
- f.current;
274
- }, [f]);
275
- const v = E(() => {
276
- document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
277
- const p = document.querySelector(".rp-print-zone");
278
- p && p.remove();
279
- }, []), h = E(() => {
280
- f.current = !1, a(!1), c(!1), u(null), o({
281
- loadedPages: 0,
282
- totalPages: 0,
283
- percentage: 0
284
- });
285
- }, []), w = () => {
286
- f.current = !0;
287
- }, b = async ({
288
- scratchCanvas: p,
289
- pdfDocument: g,
290
- pageNumber: s,
291
- viewerPdfPage: _,
292
- printResolution: C,
293
- optionalContentConfigPromise: y,
294
- printAnnotationStoragePromise: L
295
- }) => {
296
- if (f.current) {
297
- h();
298
- return;
299
- }
300
- const x = C / io.PDF;
301
- p.width = Math.floor(_.width * x), p.height = Math.floor(_.height * x);
302
- const I = p.getContext("2d");
303
- I.save(), I.fillStyle = "rgb(255, 255, 255)", I.fillRect(0, 0, p.width, p.height), I.restore();
304
- const [z, A] = await Promise.all([
305
- g.getPage(s),
306
- L
307
- ]);
308
- if (f.current) {
309
- h();
310
- return;
311
- }
312
- const F = {
313
- canvasContext: I,
314
- transform: [x, 0, 0, x, 0, 0],
315
- viewport: z.getViewport({ scale: 1, rotation: _.rotation }),
316
- intent: "print",
317
- annotationMode: ao.ENABLE_STORAGE,
318
- optionalContentConfigPromise: y,
319
- printAnnotationStorage: A
320
- };
321
- try {
322
- return z.render(F).promise;
323
- } catch (R) {
324
- throw R instanceof so || console.error(R), R;
325
- }
326
- }, S = E(() => {
327
- const p = window.print;
328
- return new Promise((g) => {
329
- const s = (y) => {
330
- setTimeout(() => {
331
- p.call(window), setTimeout(() => y(), 20);
332
- }, 0);
333
- };
334
- if (document.querySelector(".rp-print-zone")) {
335
- s(g);
336
- return;
337
- }
338
- const C = new MutationObserver(() => {
339
- document.querySelector(".rp-print-zone") && (s(g), C.disconnect());
340
- });
341
- C.observe(document.body, { childList: !0, subtree: !0 });
342
- });
343
- }, []), P = async (p) => {
344
- const g = document.createElement("img"), s = document.createElement("div");
345
- return s.classList.add("rp-print-page"), await new Promise((_, C) => {
346
- p.toBlob((y) => {
347
- y ? (g.src = URL.createObjectURL(y), g.onload = () => {
348
- URL.revokeObjectURL(g.src), _();
349
- }, g.onerror = C) : C(new Error("Failed to create blob"));
350
- });
351
- }).catch(() => {
352
- }), s.appendChild(g), s;
353
- }, T = (p, g) => {
354
- const s = document.createElement("div");
355
- s.classList.add("rp-print-zone");
356
- const _ = document.createElement("style"), C = g.get(1);
357
- if (C) {
358
- const { width: y, height: L } = C == null ? void 0 : C.page.getViewport({ scale: 1 });
359
- _.innerHTML = `@page { size: ${y}px ${L}px }`;
360
- }
361
- return s.appendChild(_), s.append(...p), s;
362
- }, m = E(async () => {
363
- if (!e)
364
- return;
365
- h();
366
- const p = document.createElement("canvas"), g = [];
367
- try {
368
- e.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
369
- const _ = e.getOptionalContentConfig({ intent: "print" }), C = Promise.resolve(
370
- e.annotationStorage.print ?? void 0
371
- ), y = t.size;
372
- for (const [x, I] of t) {
373
- if (f.current) {
374
- h();
375
- return;
376
- }
377
- const z = I.page.getViewport({ scale: 1 });
378
- if (await b({
379
- scratchCanvas: p,
380
- pdfDocument: e,
381
- pageNumber: x,
382
- viewerPdfPage: z,
383
- printResolution: 150,
384
- optionalContentConfigPromise: _,
385
- printAnnotationStoragePromise: C
386
- }), f.current) {
387
- h();
388
- return;
389
- }
390
- const A = await P(p);
391
- g.push(A);
392
- const F = parseFloat((g.length / y * 100).toFixed(2));
393
- o({
394
- loadedPages: x,
395
- totalPages: y,
396
- percentage: F
397
- });
398
- }
399
- if (f.current) {
400
- h();
401
- return;
402
- }
403
- const L = T(g, t);
404
- document.body.appendChild(L), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), a(!0), await S();
405
- } catch (s) {
406
- c(!0), s instanceof Error && u(s);
407
- } finally {
408
- p.height = 0, p.width = 0;
409
- }
410
- }, [e, t, f]);
411
- return W(() => {
412
- const p = () => {
413
- h(), v();
414
- };
415
- return window.addEventListener("afterprint", p, !0), () => {
416
- window.removeEventListener("afterprint", p, !0);
417
- };
418
- }, [v, h]), {
419
- print: m,
420
- cancel: w,
421
- progress: n,
422
- isComplete: r,
423
- isError: l,
424
- error: d
425
- };
426
- }, In = Qe({
427
- print: () => {
428
- },
429
- cancel: () => {
430
- },
431
- setOnProgress: (e) => {
432
- },
433
- progress: {},
434
- setOnComplete: (e) => e(),
435
- setOnError: (e) => {
436
- try {
437
- const t = new Error("Print error occurred");
438
- e(t);
439
- } catch (t) {
440
- console.error("Error in setOnError callback:", t);
441
- }
442
- }
443
- }), qs = ({ children: e }) => {
444
- const [t, n] = G(null), [o, r] = G(null), { print: a, cancel: l, progress: c, isComplete: d, isError: u, error: f } = Lo(), v = E((P) => {
445
- P && typeof P == "function" && r(() => P);
446
- }, []), h = (P) => {
447
- f && P(f);
448
- }, w = E(
449
- (P) => {
450
- n(() => P);
451
- },
452
- [c, t]
453
- );
454
- W(() => {
455
- d && o && b();
456
- }, [d, o]), W(() => {
457
- u && h((P) => {
458
- console.error(P);
459
- });
460
- }, [u]), W(() => {
461
- c && t && t(c);
462
- }, [c, t]);
463
- const b = () => {
464
- o && (o(), r(null));
465
- }, S = {
466
- print: a,
467
- cancel: l,
468
- setOnProgress: w,
469
- setOnComplete: v,
470
- setOnError: h,
471
- progress: c
472
- };
473
- return /* @__PURE__ */ i(In.Provider, { value: S, children: e });
474
- }, Be = () => {
475
- const e = et(In);
476
- if (!e)
477
- throw new Error("usePrintContext must be used within a PrintProvider");
478
- return e;
479
- }, No = () => {
480
- const [e, t] = G({}), { pages: n } = X(), o = M(() => Object.keys(e).length, [e]), r = E(
481
- (l) => {
482
- if (!n.size)
483
- return;
484
- const c = l > n.size ? n.size : l, d = Array.from(n.values()).slice(0, c).map((v) => {
485
- const { thumbnailViewport: h, scale: w } = Bt(v.page, v.defaultRotation);
486
- return {
487
- scale: w,
488
- page: v.page,
489
- loading: !0,
490
- viewport: h,
491
- defaultRotation: v.defaultRotation
492
- };
493
- }), u = d.reduce((v, h) => (v[h.page.pageNumber] = h, v), {});
494
- t(u);
495
- const f = [];
496
- for (const v of d) {
497
- const h = document.createElement("canvas"), w = wt(v.page, h, {
498
- scale: v.scale,
499
- rotate: v.defaultRotation
500
- }).promise.then(() => {
501
- const b = h.toDataURL();
502
- return {
503
- ...v,
504
- thumbnailSrc: b,
505
- loading: !1,
506
- defaultRotation: v.defaultRotation
507
- };
508
- });
509
- f.push(w);
510
- }
511
- Promise.all(f).then((v) => {
512
- const h = v.reduce(
513
- (w, b) => (w[b.page.pageNumber] = b, w),
514
- {}
515
- );
516
- t((w) => ({ ...w, ...h }));
517
- }).catch(() => {
518
- });
519
- },
520
- [n]
521
- );
522
- W(() => {
523
- r(10);
524
- }, [r]);
525
- const a = E(
526
- (l) => {
527
- if (!n)
528
- return;
529
- const c = n.get(l);
530
- if (!c)
531
- return;
532
- t((u) => ({
533
- ...u,
534
- [l]: {
535
- loading: !0,
536
- page: c.page,
537
- viewport: c.thumbnailViewport,
538
- scale: c.thumbnailScale,
539
- defaultRotation: c.defaultRotation
540
- }
541
- }));
542
- const d = document.createElement("canvas");
543
- wt(c.page, d, {
544
- scale: c.thumbnailScale,
545
- rotate: c.defaultRotation
546
- }).promise.then(() => {
547
- const u = d.toDataURL(), { thumbnailViewport: f, scale: v } = Bt(c.page);
548
- return {
549
- scale: v,
550
- thumbnailSrc: u,
551
- page: c.page,
552
- loading: !1,
553
- viewport: f,
554
- defaultRotation: c.defaultRotation
555
- };
556
- }).then((u) => {
557
- t((f) => ({ ...f, [l]: u }));
558
- });
559
- },
560
- [n]
561
- );
562
- return { thumbnailPages: e, addPage: a, addToPage: r, thumbnailLength: o };
563
- }, Rn = Qe({
564
- thumbnailPages: {},
565
- addPage: (e) => {
566
- },
567
- addToPage: (e) => {
568
- },
569
- thumbnailLength: 0,
570
- setActive: (e) => {
571
- },
572
- active: !1
573
- }), Rt = () => et(Rn), Bs = ({
574
- children: e,
575
- initialThumbnailsVisible: t
576
- }) => {
577
- const { thumbnailPages: n, addPage: o, addToPage: r, thumbnailLength: a } = No(), [l, c] = G(t);
578
- return /* @__PURE__ */ i(
579
- Rn.Provider,
580
- {
581
- value: { thumbnailPages: n, addPage: o, addToPage: r, thumbnailLength: a, active: l, setActive: c },
582
- children: e
583
- }
584
- );
585
- }, Eo = (e = {}, t = "") => {
586
- const [n, o] = G(t), [r, a] = G(!1), { pdf: l, pages: c } = X(), { widths: d, heights: u } = Ue(), f = H(!n), { currentZoom: v } = tt(), [h, w] = G([]), { setFocusedPage: b } = ae(), { columnCount: S } = Ee(), { pageRotate: P } = Ve(), [T, m] = G(0), { pageScrollElementRef: p, virtualScrollableElementRef: g } = nt(), { scrollMode: s } = Ne(), { pagesRef: _ } = se(), [C, y] = G(null), L = H({}), x = M(() => T === 0 ? null : h[T - 1], [T, h]), I = M(() => h.length, [h]);
587
- W(() => {
588
- if (!x || !c)
589
- return;
590
- const R = g || p;
591
- if (!R || !_)
592
- return;
593
- const O = c.get(x.page);
594
- if (s === ee.PAGE_SCROLLING && b(x.page), !O)
595
- return;
596
- let N = 0, k = 0;
597
- if (s === ee.VERTICAL_SCROLLING) {
598
- const ue = x.page - 1, J = S, ke = ue % J, _e = Math.floor(ue / J);
599
- N = Fe(u, _e), k = Fe(d, ke);
600
- }
601
- s === ee.HORIZONTAL_SCROLLING && (k = d.slice(0, x.page - 1).reduce((ue, J) => ue + J, 0));
602
- const $ = {
603
- height: u[x.page - 1],
604
- width: d[x.page - 1]
605
- }, Z = {
606
- top: $.height / 2,
607
- left: $.width / 2
608
- }, j = P[x.page], { leftInPage: q, topInPage: te } = xo(
609
- $,
610
- Z,
611
- x.rect,
612
- v,
613
- j
614
- ), Y = k + q, de = N + te, we = {
615
- left: Math.max(Y, 0),
616
- top: Math.max(de, 0)
617
- };
618
- R.scrollTo({
619
- ...we,
620
- behavior: "smooth"
621
- });
622
- }, [
623
- c,
624
- b,
625
- d,
626
- u,
627
- x,
628
- s,
629
- g,
630
- p,
631
- _
632
- ]);
633
- const z = E(() => {
634
- m((R) => I ? R + 1 > I ? 1 : R + 1 : 0);
635
- }, [I]), A = E(() => {
636
- m((R) => I ? R - 1 <= 0 ? I : R - 1 : 0);
637
- }, [I]), F = E(async (R) => {
638
- if (!R)
639
- return {};
640
- const O = R.numPages, N = {};
641
- for (let k = 1; k <= O; k++) {
642
- if (f.current)
643
- throw "close pop over";
644
- const $ = await R.getPage(k);
645
- N[k.toString()] = await $.getTextContent();
646
- }
647
- return N;
648
- }, []);
649
- return W(() => {
650
- if (!n) {
651
- f.current = !0, w([]), m(0);
652
- return;
653
- }
654
- f.current = !1, a(!0), w([]), m(0), F(l).then((R) => {
655
- L.current = R;
656
- const N = Object.keys(R).reduce((k, $) => {
657
- const Z = vr(
658
- [n],
659
- R[$],
660
- Number($) - 1,
661
- e
662
- ).map((j, q) => ({ ...j, page: Number($), pageMatchIdx: q }));
663
- return [...k, ...Z];
664
- }, []);
665
- w(N), m(N.length ? 1 : 0);
666
- }).catch(() => {
667
- w([]), m(0);
668
- }).finally(() => a(!1));
669
- }, [n, F, l, e]), {
670
- search: n,
671
- setSearch: o,
672
- loading: r,
673
- matches: h,
674
- totalMatches: I,
675
- currentMatchPosition: T,
676
- currentMatch: x,
677
- nextMatch: z,
678
- prevMatch: A,
679
- currentMatchElement: C,
680
- setCurrentMatchElement: y
681
- };
682
- }, Ln = Qe({
683
- search: "",
684
- setSearch: (e) => {
685
- },
686
- loading: !1,
687
- matches: [],
688
- totalMatches: 0,
689
- currentMatchPosition: 0,
690
- currentMatch: null,
691
- nextMatch: () => {
692
- },
693
- prevMatch: () => {
694
- },
695
- searchOptions: {},
696
- setSearchOptions: (e) => e,
697
- currentMatchElement: null,
698
- setCurrentMatchElement: (e) => {
699
- }
700
- }), Zs = ({
701
- children: e,
702
- initialSearch: t
703
- }) => {
704
- const [n, o] = G({}), {
705
- loading: r,
706
- setSearch: a,
707
- totalMatches: l,
708
- currentMatchPosition: c,
709
- currentMatch: d,
710
- search: u,
711
- matches: f,
712
- nextMatch: v,
713
- prevMatch: h,
714
- currentMatchElement: w,
715
- setCurrentMatchElement: b
716
- } = Eo(n, t);
717
- return /* @__PURE__ */ i(
718
- Ln.Provider,
719
- {
720
- value: {
721
- searchOptions: n,
722
- setSearchOptions: o,
723
- loading: r,
724
- setSearch: a,
725
- totalMatches: l,
726
- currentMatchPosition: c,
727
- currentMatch: d,
728
- nextMatch: v,
729
- prevMatch: h,
730
- search: u,
731
- matches: f,
732
- currentMatchElement: w,
733
- setCurrentMatchElement: b
734
- },
735
- children: e
736
- }
737
- );
738
- }, Lt = () => et(Ln), pe = {
739
- "rp-pages": "_rp-pages_17t6t_1",
740
- "rp-pages-horizontal-scroll": "_rp-pages-horizontal-scroll_17t6t_7",
741
- "rp-pages-container": "_rp-pages-container_17t6t_11",
742
- "rp-page-scrolling-wrapper": "_rp-page-scrolling-wrapper_17t6t_48",
743
- "rp-viewer": "_rp-viewer_17t6t_53",
744
- "rp-cursor-grab": "_rp-cursor-grab_17t6t_58",
745
- "rp-cursor-grabbing": "_rp-cursor-grabbing_17t6t_66",
746
- "rp-loader": "_rp-loader_17t6t_74"
747
- }, dt = {
748
- "rp-page-wrapper": "_rp-page-wrapper_14ohm_1",
749
- "rp-page": "_rp-page_14ohm_1",
750
- "rp-loader-wrapper": "_rp-loader-wrapper_14ohm_15"
751
- }, Oo = (e) => {
752
- const { pageNumber: t, onLoaded: n, onLoading: o } = e, r = H(null), { pages: a } = X(), { pageRotate: l } = Ve(), c = H(), { currentZoom: d } = tt();
753
- return W(() => {
754
- if (!a || d === 0)
755
- return;
756
- const u = a.get(t);
757
- if (r.current && u) {
758
- const f = r.current;
759
- f.hidden = !0;
760
- const v = c.current;
761
- v && v.cancel(), o && o(), c.current = wt(u.page, f, {
762
- scale: d,
763
- rotate: l[t],
764
- renderForms: !0
765
- }), c.current.promise.then(() => {
766
- f.hidden = !1;
767
- }).catch(() => {
768
- }).finally(() => {
769
- n && n();
770
- });
771
- }
772
- return () => {
773
- var f;
774
- (f = c.current) == null || f.cancel();
775
- };
776
- }, [a, t, l, d, o, n]), /* @__PURE__ */ i("canvas", { "data-rp": `page-${t}-canvas`, ref: r });
777
- }, zo = "_selecting_usdup_9", me = {
778
- "rp-text-layer": "_rp-text-layer_usdup_1",
779
- selecting: zo,
780
- "rp-text-layer-text": "_rp-text-layer-text_usdup_39"
781
- }, Do = (e) => {
782
- const { pageNumber: t } = e, { pages: n } = X(), o = H(null), { matches: r, currentMatch: a, setCurrentMatchElement: l } = Lt(), [c, d] = G(
783
- []
784
- ), u = H(), f = H(), v = H([]), h = M(() => r.filter((p) => p.pageIndex === t - 1), [r, t]), w = E(
785
- (p, g, s = !1) => {
786
- if (s && wr(p, g), !h.length) {
787
- v.current = [], d([]);
788
- return;
789
- }
790
- const _ = _r(h, p, g);
791
- d(_);
792
- },
793
- [h]
794
- ), b = H(), S = H(!1), P = E(() => Array.from(document.querySelectorAll('[data-rp$="-textLayer"]')), []);
795
- W(() => ((() => {
796
- if (b.current)
797
- return;
798
- b.current = new AbortController();
799
- const { signal: g } = b.current, s = () => {
800
- P().forEach((C) => {
801
- const y = C.querySelector(".endOfContent");
802
- y && (C.appendChild(y), y.style.width = "", y.style.height = "", C.classList.remove(me.selecting));
803
- });
804
- };
805
- document.addEventListener(
806
- "pointerdown",
807
- () => {
808
- S.current = !0;
809
- },
810
- { signal: g }
811
- ), document.addEventListener(
812
- "pointerup",
813
- () => {
814
- S.current = !1, s();
815
- },
816
- { signal: g }
817
- ), window.addEventListener(
818
- "blur",
819
- () => {
820
- S.current = !1, s();
821
- },
822
- { signal: g }
823
- ), document.addEventListener(
824
- "keyup",
825
- () => {
826
- S.current || s();
827
- },
828
- { signal: g }
829
- );
830
- let _ = null;
831
- document.addEventListener(
832
- "selectionchange",
833
- () => {
834
- var F, R;
835
- const C = document.getSelection();
836
- if (!C)
837
- return;
838
- if (C.rangeCount === 0) {
839
- s();
840
- return;
841
- }
842
- const y = /* @__PURE__ */ new Set();
843
- for (let O = 0; O < C.rangeCount; O++) {
844
- const N = C.getRangeAt(O);
845
- P().forEach((k) => {
846
- N.intersectsNode(k) && !y.has(k) && y.add(k);
847
- });
848
- }
849
- P().forEach((O) => {
850
- if (y.has(O))
851
- O.classList.add(me.selecting);
852
- else {
853
- const N = O.querySelector(".endOfContent");
854
- N && (O.appendChild(N), N.style.width = "", N.style.height = "", O.classList.remove(me.selecting));
855
- }
856
- });
857
- const L = C.getRangeAt(0);
858
- let I = _ && (L.compareBoundaryPoints(Range.END_TO_END, _) === 0 || L.compareBoundaryPoints(Range.START_TO_END, _) === 0) ? L.startContainer : L.endContainer;
859
- I.nodeType === Node.TEXT_NODE && (I = I.parentNode);
860
- const z = (F = I.parentElement) == null ? void 0 : F.closest(
861
- me["rp-text-layer"]
862
- ), A = z == null ? void 0 : z.querySelector(".endOfContent");
863
- A && z && (A.style.width = z.style.width, A.style.height = z.style.height, (R = I.parentElement) == null || R.insertBefore(A, I.nextSibling)), _ = L.cloneRange();
864
- },
865
- { signal: g }
866
- );
867
- })(), () => {
868
- var g;
869
- (g = b.current) == null || g.abort(), b.current = void 0;
870
- }), [P]);
871
- const T = E(() => {
872
- o.current && o.current.classList.add(me.selecting);
873
- }, []), m = E(() => {
874
- o.current && o.current.classList.remove(me.selecting);
875
- }, []);
876
- return W(() => {
877
- if (v.current.forEach((s) => {
878
- s.classList.remove("selected");
879
- }), !c.length || !a || a.pageIndex !== t - 1)
880
- return;
881
- const p = h.findIndex(
882
- (s) => JSON.stringify(s) === JSON.stringify(a)
883
- );
884
- if (p === -1)
885
- return;
886
- const g = c.filter((s) => s.index === p);
887
- g.length && (v.current = g.map((s) => s.element), l(g[0].element), g.forEach((s) => {
888
- s.element.classList.add("selected");
889
- }));
890
- }, [a, c, h]), W(() => {
891
- const p = n.get(t);
892
- if (!p || !o.current)
893
- return;
894
- const g = o.current;
895
- return u.current && u.current.cancel(), p.page.getTextContent().then((s) => {
896
- const _ = p.page.getViewport({ scale: 1 });
897
- return u.current = new oo.TextLayer({
898
- viewport: _,
899
- textContentSource: s,
900
- container: g
901
- }), f.current = s, g && (g.innerText = ""), u.current.render();
902
- }).then(() => {
903
- var y, L;
904
- [].slice.call(g.children).forEach((x) => {
905
- x.classList.add(me["rp-text-layer-text"]), x.setAttribute("data-rp", "rp-text-layer-text");
906
- });
907
- const _ = (y = u.current) == null ? void 0 : y.textDivs;
908
- _ && f.current && w(f.current, _);
909
- const C = document.createElement("div");
910
- C.className = "endOfContent", (L = o.current) == null || L.appendChild(C);
911
- }).catch(() => {
912
- }), () => {
913
- var s;
914
- (s = u.current) == null || s.cancel();
915
- };
916
- }, [n, t]), W(() => {
917
- var s;
918
- [].slice.call(o.current.children).forEach((_) => {
919
- _.classList.add(me["rp-text-layer-text"]);
920
- });
921
- const g = (s = u.current) == null ? void 0 : s.textDivs;
922
- g && f.current && w(f.current, g, !0);
923
- }, [w]), /* @__PURE__ */ i(
924
- "div",
925
- {
926
- "data-rp": `page-${t}-textLayer`,
927
- className: me["rp-text-layer"],
928
- ref: o,
929
- onMouseDown: T,
930
- onMouseUp: m
931
- }
932
- );
933
- }, Ao = {
934
- "rp-annotation-layer": "_rp-annotation-layer_1udza_1"
935
- };
936
- let Fo = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/";
937
- const Wo = (e) => {
938
- const { pageNumber: t } = e, n = H(null), { pages: o, pdf: r } = X(), a = H(), [l, c] = G(), { setFocusedPage: d, goToPage: u } = ae(), { scrollMode: f } = Ne(), { print: v } = Be(), { download: h } = Zn(), w = M(() => o.get(t), [o, t]), b = M(() => w == null ? void 0 : w.page.getViewport(), [w]);
939
- W(() => {
940
- a.current && (a.current.div.replaceChildren(), a.current = void 0);
941
- }, [r]), W(() => {
942
- w && w.page.getAnnotations().then((P) => {
943
- a.current = void 0, c(P), n.current && (n.current.innerText = "");
944
- });
945
- }, [w]);
946
- const S = E(
947
- (P) => {
948
- !l || !r || (uo(P), po(P, r, l).then((T) => {
949
- var m, p;
950
- ((m = T == null ? void 0 : T.data) == null ? void 0 : m.action) === "Print" ? v() : ((p = T == null ? void 0 : T.data) == null ? void 0 : p.action) === "SaveAs" && h();
951
- }), f === ee.PAGE_SCROLLING ? Vt(P, l, r, (T) => d(T.pageIndex + 1)) : Vt(P, l, r, (T) => u(T.pageIndex + 1)));
952
- },
953
- [r, l, u, d, f, v, h]
954
- );
955
- return W(() => {
956
- if (!w || !l)
957
- return;
958
- const P = w.page.getViewport();
959
- if (a.current) {
960
- a.current.update({
961
- viewport: P.clone({ dontFlip: !0 })
962
- });
963
- return;
964
- }
965
- const T = /* @__PURE__ */ new Map([]);
966
- for (const g of l) {
967
- const { annotationType: s } = g;
968
- switch (s) {
969
- case kt.Link:
970
- fo(g);
971
- break;
972
- case kt.Widget:
973
- ho(g, P, T);
974
- break;
975
- }
976
- }
977
- const m = new AbortController();
978
- return (async () => {
979
- var _;
980
- a.current && (a.current.div.replaceChildren(), a.current = void 0), n.current && (n.current.innerText = ""), a.current = new co({
981
- div: n.current,
982
- accessibilityManager: void 0,
983
- annotationCanvasMap: void 0,
984
- annotationEditorUIManager: void 0,
985
- structTreeLayer: null,
986
- page: w.page,
987
- viewport: P.clone({ dontFlip: !0 })
988
- }), n.current && qt(n.current, S);
989
- const g = await (r == null ? void 0 : r.hasJSActions()), s = await (r == null ? void 0 : r.getFieldObjects());
990
- if (m.signal.aborted)
991
- throw "abort";
992
- return (_ = a.current) == null ? void 0 : _.render({
993
- annotations: l,
994
- annotationStorage: r == null ? void 0 : r.annotationStorage,
995
- hasJSActions: g,
996
- fieldObjects: s,
997
- div: n.current,
998
- viewport: P.clone({ dontFlip: !0 }),
999
- page: w.page,
1000
- imageResourcesPath: Fo,
1001
- renderForms: !0,
1002
- linkService: new lo(),
1003
- downloadManager: null,
1004
- enableScripting: !1
1005
- });
1006
- })().then(() => {
1007
- n.current && mo(n.current, S);
1008
- }).catch((g) => {
1009
- if (g !== "abort")
1010
- throw g;
1011
- }), () => {
1012
- m.abort("clear"), n.current && qt(n.current, S);
1013
- };
1014
- }, [r, l, S]), /* @__PURE__ */ i(
1015
- "div",
1016
- {
1017
- "data-rp": `page-${t}-annotationLayer`,
1018
- style: { width: `${b == null ? void 0 : b.width}px`, height: `${b == null ? void 0 : b.height}px` },
1019
- className: Ao["rp-annotation-layer"],
1020
- ref: n
1021
- }
1022
- );
1023
- }, ko = {
1024
- "rp-text-highlight": "_rp-text-highlight_jdkf8_1"
1025
- }, Mo = ({ pageNumber: e, viewport: t }) => {
1026
- const [n, o] = G(), { pages: r } = X(), { highlightKeywords: a } = Cr(), l = !0, c = H(null), [d, u] = G(null), [f, v] = G([]);
1027
- W(() => {
1028
- c.current && u(c.current.parentElement);
1029
- }, [c]), W(() => {
1030
- (async () => {
1031
- const p = r.get(e);
1032
- if (!p || !c.current)
1033
- return;
1034
- const g = await p.page.getTextContent();
1035
- o(g);
1036
- })();
1037
- }, [r, e]);
1038
- const h = M(() => a ? a.map((m) => {
1039
- var p, g;
1040
- return {
1041
- ...go(m.keyword, (p = m.options) == null ? void 0 : p.matchCase, (g = m.options) == null ? void 0 : g.wholeWords),
1042
- color: m.highlightColor
1043
- };
1044
- }) : [], [a]);
1045
- function w(m, p) {
1046
- if (!m)
1047
- return;
1048
- const g = `[data-rp="page-${p}-textLayer"]`;
1049
- return new Promise((s) => {
1050
- const _ = m.querySelector(g);
1051
- if (_) {
1052
- s(_);
1053
- return;
1054
- }
1055
- new MutationObserver((y, L) => {
1056
- const x = m.querySelector(g);
1057
- x && (s(x), L.disconnect());
1058
- }).observe(m, { childList: !0, subtree: !0 });
1059
- });
1060
- }
1061
- function b(m) {
1062
- return new Promise((p) => {
1063
- const g = m.querySelectorAll(
1064
- '[data-rp="rp-text-layer-text"]'
1065
- );
1066
- if (g.length) {
1067
- p(Array.from(g));
1068
- return;
1069
- }
1070
- new MutationObserver((_, C) => {
1071
- const y = m.querySelectorAll(
1072
- ".rp-text-layer-text"
1073
- );
1074
- y.length && (p(Array.from(y)), C.disconnect());
1075
- }).observe(m, { childList: !0, subtree: !0 });
1076
- });
1077
- }
1078
- const S = (m, p, g, s) => {
1079
- var Z;
1080
- const _ = document.createRange(), C = g.firstChild;
1081
- if (!C || C.nodeType !== Node.TEXT_NODE)
1082
- return null;
1083
- const y = ((Z = C.textContent) == null ? void 0 : Z.length) ?? 0, L = s[0].charIdxInSpan, x = s.length === 1 ? L : s[s.length - 1].charIdxInSpan;
1084
- if (L > y || x + 1 > y)
1085
- return null;
1086
- _.setStart(C, L), _.setEnd(C, x + 1);
1087
- const I = document.createElement("span");
1088
- I.style.width = "auto", _.surroundContents(I);
1089
- const z = I.getBoundingClientRect(), A = m.getBoundingClientRect(), F = A.height, R = A.width, O = 100 * (z.left - A.left) / R, N = 100 * (z.top - A.top) / F, k = 100 * z.height / F, $ = 100 * z.width / R;
1090
- return wo(I), {
1091
- keywordStr: p,
1092
- left: O,
1093
- top: N,
1094
- height: k,
1095
- width: $,
1096
- pageHeight: F,
1097
- pageWidth: R
1098
- };
1099
- };
1100
- async function P(m, p) {
1101
- const g = await w(d, m);
1102
- if (!g)
1103
- return;
1104
- const s = await b(g);
1105
- if (s.length) {
1106
- const _ = s.map((y) => y.tagName === "BR" ? " " : y.textContent).reduce(
1107
- (y, L, x) => y.concat(
1108
- L.split("").map((I, z) => ({
1109
- char: I,
1110
- charIdxInSpan: z,
1111
- spanIdx: x
1112
- }))
1113
- ),
1114
- [
1115
- {
1116
- char: "",
1117
- charIdxInSpan: 0,
1118
- spanIdx: 0
1119
- }
1120
- ]
1121
- ).slice(1), C = T(g, p, s, _);
1122
- v(C);
1123
- }
1124
- }
1125
- const T = (m, p, g, s) => {
1126
- const _ = p.length;
1127
- if (!s.length || !_)
1128
- return [];
1129
- const C = [], y = s.map((L) => L.char).join("");
1130
- return h.forEach((L) => {
1131
- const { keyword: x, regExp: I, wholeWords: z, color: A } = L, F = x;
1132
- if (!F.trim())
1133
- return;
1134
- const R = I.flags.indexOf("g") === -1 ? new RegExp(I, `${I.flags}g`) : I;
1135
- let O;
1136
- const N = [];
1137
- for (; (O = R.exec(y)) !== null; )
1138
- z && !br(y, O.index, O[0].length) || N.push({
1139
- keyword: R,
1140
- startIndex: O.index,
1141
- endIndex: R.lastIndex
1142
- });
1143
- const k = N.map(($) => ({
1144
- keyword: $.keyword,
1145
- indexes: s.slice($.startIndex, $.endIndex),
1146
- color: A
1147
- }));
1148
- for (const $ of k) {
1149
- const Z = $.indexes.reduce(
1150
- (j, q) => (j[q.spanIdx] = (j[q.spanIdx] || []).concat([q]), j),
1151
- {}
1152
- );
1153
- for (const j of Object.values(Z))
1154
- if (j.length !== 1 || j[0].char.trim() !== "") {
1155
- const q = j, te = g[q[0].spanIdx], Y = S(
1156
- m,
1157
- F,
1158
- te,
1159
- q
1160
- );
1161
- if (Y) {
1162
- const { left: de, top: we } = Y;
1163
- if (C.find((J) => J.left === de && J.top === we))
1164
- continue;
1165
- C.push({ ...Y, highlightColor: $.color });
1166
- }
1167
- }
1168
- }
1169
- }), C.sort(vo), C;
1170
- };
1171
- return W(() => {
1172
- (async () => {
1173
- if (!(!a || a.length === 0))
1174
- try {
1175
- await P(e, a);
1176
- } catch (p) {
1177
- console.error(p);
1178
- }
1179
- })();
1180
- }, [l, a, e, n, t]), /* @__PURE__ */ i(ie, { children: /* @__PURE__ */ i("div", { ref: c, "data-rp": `page-${e}-textHighlightLayer`, children: f.map((m, p) => /* @__PURE__ */ i(
1181
- "div",
1182
- {
1183
- className: ko["rp-text-highlight"],
1184
- style: {
1185
- top: `${m.top}%`,
1186
- left: `${m.left}%`,
1187
- width: `${m.width}%`,
1188
- height: `${m.height}%`,
1189
- backgroundColor: m.highlightColor
1190
- }
1191
- },
1192
- p
1193
- )) }) });
1194
- }, Nt = We((e, t) => {
1195
- const { pageNumber: n, style: o, ...r } = e, { pages: a } = X(), { pageRotate: l } = Ve(), { textLayer: c } = hr(), { currentZoom: d } = tt(), u = H(a.get(n)), [f, v] = G(!1), h = H(null), [w, b] = G({
1196
- width: 0,
1197
- height: 0
1198
- });
1199
- pn(t, () => h.current);
1200
- const S = M(() => u.current ? l[n] : 0, [n, l]);
1201
- W(() => {
1202
- if (a && (u.current = a.get(n), u.current)) {
1203
- const p = u.current.page.getViewport({
1204
- scale: d,
1205
- rotation: S
1206
- });
1207
- b(p);
1208
- }
1209
- }, [a, n, S, d]);
1210
- const P = M(() => {
1211
- switch (S) {
1212
- case 90:
1213
- return `${w.width / 2}px ${w.width / 2}px`;
1214
- case -90:
1215
- case 270:
1216
- return `${w.height / 2}px ${w.height / 2}px`;
1217
- default:
1218
- return "center";
1219
- }
1220
- }, [S, w]), T = E(() => {
1221
- v(!0);
1222
- }, []), m = E(() => {
1223
- v(!1);
1224
- }, []);
1225
- return /* @__PURE__ */ i(
1226
- "div",
1227
- {
1228
- ref: h,
1229
- id: `page-${n}`,
1230
- "data-rp": `page-${n}`,
1231
- ...r,
1232
- style: {
1233
- ...o,
1234
- "--rp-rotate": `${S}deg`,
1235
- "--rp-page-rotate-translate": `${P}`,
1236
- "--scale-factor": d
1237
- },
1238
- className: dt["rp-page-wrapper"],
1239
- children: /* @__PURE__ */ D(
1240
- "div",
1241
- {
1242
- style: {
1243
- width: `${w.width}px`,
1244
- height: `${w.height}px`
1245
- },
1246
- className: dt["rp-page"],
1247
- children: [
1248
- /* @__PURE__ */ i(Oo, { onLoading: T, onLoaded: m, pageNumber: n }),
1249
- f && /* @__PURE__ */ i("div", { className: dt["rp-loader-wrapper"], children: /* @__PURE__ */ i(St, {}) }),
1250
- /* @__PURE__ */ i(_o, { pageNumber: n }),
1251
- c && /* @__PURE__ */ i(Do, { pageNumber: n }),
1252
- /* @__PURE__ */ i(Mo, { pageNumber: n, viewport: w }),
1253
- /* @__PURE__ */ i(Wo, { pageNumber: n })
1254
- ]
1255
- }
1256
- )
1257
- }
1258
- );
1259
- });
1260
- function Zt(e) {
1261
- if (e === void 0)
1262
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1263
- return e;
1264
- }
1265
- function _t(e, t) {
1266
- return _t = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, o) {
1267
- return n.__proto__ = o, n;
1268
- }, _t(e, t);
1269
- }
1270
- function Ho(e, t) {
1271
- e.prototype = Object.create(t.prototype), e.prototype.constructor = e, _t(e, t);
1272
- }
1273
- var jt = Number.isNaN || function(t) {
1274
- return typeof t == "number" && t !== t;
1275
- };
1276
- function $o(e, t) {
1277
- return !!(e === t || jt(e) && jt(t));
1278
- }
1279
- function Go(e, t) {
1280
- if (e.length !== t.length)
1281
- return !1;
1282
- for (var n = 0; n < e.length; n++)
1283
- if (!$o(e[n], t[n]))
1284
- return !1;
1285
- return !0;
1286
- }
1287
- function ut(e, t) {
1288
- t === void 0 && (t = Go);
1289
- var n, o = [], r, a = !1;
1290
- function l() {
1291
- for (var c = [], d = 0; d < arguments.length; d++)
1292
- c[d] = arguments[d];
1293
- return a && n === this && t(c, o) || (r = e.apply(this, c), a = !0, n = this, o = c), r;
1294
- }
1295
- return l;
1296
- }
1297
- function Kt(e, t) {
1298
- if (e == null)
1299
- return {};
1300
- var n = {};
1301
- for (var o in e)
1302
- if ({}.hasOwnProperty.call(e, o)) {
1303
- if (t.indexOf(o) !== -1)
1304
- continue;
1305
- n[o] = e[o];
1306
- }
1307
- return n;
1308
- }
1309
- var Uo = typeof performance == "object" && typeof performance.now == "function", Xt = Uo ? function() {
1310
- return performance.now();
1311
- } : function() {
1312
- return Date.now();
1313
- };
1314
- function Yt(e) {
1315
- cancelAnimationFrame(e.id);
1316
- }
1317
- function Vo(e, t) {
1318
- var n = Xt();
1319
- function o() {
1320
- Xt() - n >= t ? e.call(null) : r.id = requestAnimationFrame(o);
1321
- }
1322
- var r = {
1323
- id: requestAnimationFrame(o)
1324
- };
1325
- return r;
1326
- }
1327
- var pt = -1;
1328
- function qo(e) {
1329
- if (e === void 0 && (e = !1), pt === -1 || e) {
1330
- var t = document.createElement("div"), n = t.style;
1331
- n.width = "50px", n.height = "50px", n.overflow = "scroll", document.body.appendChild(t), pt = t.offsetWidth - t.clientWidth, document.body.removeChild(t);
1332
- }
1333
- return pt;
1334
- }
1335
- var Oe = null;
1336
- function Jt(e) {
1337
- if (e === void 0 && (e = !1), Oe === null || e) {
1338
- var t = document.createElement("div"), n = t.style;
1339
- n.width = "50px", n.height = "50px", n.overflow = "scroll", n.direction = "rtl";
1340
- var o = document.createElement("div"), r = o.style;
1341
- return r.width = "100px", r.height = "100px", t.appendChild(o), document.body.appendChild(t), t.scrollLeft > 0 ? Oe = "positive-descending" : (t.scrollLeft = 1, t.scrollLeft === 0 ? Oe = "negative" : Oe = "positive-ascending"), document.body.removeChild(t), Oe;
1342
- }
1343
- return Oe;
1344
- }
1345
- var Bo = 150, Zo = function(t) {
1346
- var n = t.columnIndex;
1347
- t.data;
1348
- var o = t.rowIndex;
1349
- return o + ":" + n;
1350
- }, je = null, Ke = null, Xe = null;
1351
- process.env.NODE_ENV !== "production" && typeof window < "u" && typeof window.WeakSet < "u" && (je = /* @__PURE__ */ new WeakSet(), Ke = /* @__PURE__ */ new WeakSet(), Xe = /* @__PURE__ */ new WeakSet());
1352
- function jo(e) {
1353
- var t, n = e.getColumnOffset, o = e.getColumnStartIndexForOffset, r = e.getColumnStopIndexForStartIndex, a = e.getColumnWidth, l = e.getEstimatedTotalHeight, c = e.getEstimatedTotalWidth, d = e.getOffsetForColumnAndAlignment, u = e.getOffsetForRowAndAlignment, f = e.getRowHeight, v = e.getRowOffset, h = e.getRowStartIndexForOffset, w = e.getRowStopIndexForStartIndex, b = e.initInstanceProps, S = e.shouldResetStyleCacheOnItemSizeChange, P = e.validateProps;
1354
- return t = /* @__PURE__ */ function(T) {
1355
- Ho(m, T);
1356
- function m(g) {
1357
- var s;
1358
- return s = T.call(this, g) || this, s._instanceProps = b(s.props, Zt(s)), s._resetIsScrollingTimeoutId = null, s._outerRef = void 0, s.state = {
1359
- instance: Zt(s),
1360
- isScrolling: !1,
1361
- horizontalScrollDirection: "forward",
1362
- scrollLeft: typeof s.props.initialScrollLeft == "number" ? s.props.initialScrollLeft : 0,
1363
- scrollTop: typeof s.props.initialScrollTop == "number" ? s.props.initialScrollTop : 0,
1364
- scrollUpdateWasRequested: !1,
1365
- verticalScrollDirection: "forward"
1366
- }, s._callOnItemsRendered = void 0, s._callOnItemsRendered = ut(function(_, C, y, L, x, I, z, A) {
1367
- return s.props.onItemsRendered({
1368
- overscanColumnStartIndex: _,
1369
- overscanColumnStopIndex: C,
1370
- overscanRowStartIndex: y,
1371
- overscanRowStopIndex: L,
1372
- visibleColumnStartIndex: x,
1373
- visibleColumnStopIndex: I,
1374
- visibleRowStartIndex: z,
1375
- visibleRowStopIndex: A
1376
- });
1377
- }), s._callOnScroll = void 0, s._callOnScroll = ut(function(_, C, y, L, x) {
1378
- return s.props.onScroll({
1379
- horizontalScrollDirection: y,
1380
- scrollLeft: _,
1381
- scrollTop: C,
1382
- verticalScrollDirection: L,
1383
- scrollUpdateWasRequested: x
1384
- });
1385
- }), s._getItemStyle = void 0, s._getItemStyle = function(_, C) {
1386
- var y = s.props, L = y.columnWidth, x = y.direction, I = y.rowHeight, z = s._getItemStyleCache(S && L, S && x, S && I), A = _ + ":" + C, F;
1387
- if (z.hasOwnProperty(A))
1388
- F = z[A];
1389
- else {
1390
- var R = n(s.props, C, s._instanceProps), O = x === "rtl";
1391
- z[A] = F = {
1392
- position: "absolute",
1393
- left: O ? void 0 : R,
1394
- right: O ? R : void 0,
1395
- top: v(s.props, _, s._instanceProps),
1396
- height: f(s.props, _, s._instanceProps),
1397
- width: a(s.props, C, s._instanceProps)
1398
- };
1399
- }
1400
- return F;
1401
- }, s._getItemStyleCache = void 0, s._getItemStyleCache = ut(function(_, C, y) {
1402
- return {};
1403
- }), s._onScroll = function(_) {
1404
- var C = _.currentTarget, y = C.clientHeight, L = C.clientWidth, x = C.scrollLeft, I = C.scrollTop, z = C.scrollHeight, A = C.scrollWidth;
1405
- s.setState(function(F) {
1406
- if (F.scrollLeft === x && F.scrollTop === I)
1407
- return null;
1408
- var R = s.props.direction, O = x;
1409
- if (R === "rtl")
1410
- switch (Jt()) {
1411
- case "negative":
1412
- O = -x;
1413
- break;
1414
- case "positive-descending":
1415
- O = A - L - x;
1416
- break;
1417
- }
1418
- O = Math.max(0, Math.min(O, A - L));
1419
- var N = Math.max(0, Math.min(I, z - y));
1420
- return {
1421
- isScrolling: !0,
1422
- horizontalScrollDirection: F.scrollLeft < x ? "forward" : "backward",
1423
- scrollLeft: O,
1424
- scrollTop: N,
1425
- verticalScrollDirection: F.scrollTop < I ? "forward" : "backward",
1426
- scrollUpdateWasRequested: !1
1427
- };
1428
- }, s._resetIsScrollingDebounced);
1429
- }, s._outerRefSetter = function(_) {
1430
- var C = s.props.outerRef;
1431
- s._outerRef = _, typeof C == "function" ? C(_) : C != null && typeof C == "object" && C.hasOwnProperty("current") && (C.current = _);
1432
- }, s._resetIsScrollingDebounced = function() {
1433
- s._resetIsScrollingTimeoutId !== null && Yt(s._resetIsScrollingTimeoutId), s._resetIsScrollingTimeoutId = Vo(s._resetIsScrolling, Bo);
1434
- }, s._resetIsScrolling = function() {
1435
- s._resetIsScrollingTimeoutId = null, s.setState({
1436
- isScrolling: !1
1437
- }, function() {
1438
- s._getItemStyleCache(-1);
1439
- });
1440
- }, s;
1441
- }
1442
- m.getDerivedStateFromProps = function(s, _) {
1443
- return Ko(s, _), P(s), null;
1444
- };
1445
- var p = m.prototype;
1446
- return p.scrollTo = function(s) {
1447
- var _ = s.scrollLeft, C = s.scrollTop;
1448
- _ !== void 0 && (_ = Math.max(0, _)), C !== void 0 && (C = Math.max(0, C)), this.setState(function(y) {
1449
- return _ === void 0 && (_ = y.scrollLeft), C === void 0 && (C = y.scrollTop), y.scrollLeft === _ && y.scrollTop === C ? null : {
1450
- horizontalScrollDirection: y.scrollLeft < _ ? "forward" : "backward",
1451
- scrollLeft: _,
1452
- scrollTop: C,
1453
- scrollUpdateWasRequested: !0,
1454
- verticalScrollDirection: y.scrollTop < C ? "forward" : "backward"
1455
- };
1456
- }, this._resetIsScrollingDebounced);
1457
- }, p.scrollToItem = function(s) {
1458
- var _ = s.align, C = _ === void 0 ? "auto" : _, y = s.columnIndex, L = s.rowIndex, x = this.props, I = x.columnCount, z = x.height, A = x.rowCount, F = x.width, R = this.state, O = R.scrollLeft, N = R.scrollTop, k = qo();
1459
- y !== void 0 && (y = Math.max(0, Math.min(y, I - 1))), L !== void 0 && (L = Math.max(0, Math.min(L, A - 1)));
1460
- var $ = l(this.props, this._instanceProps), Z = c(this.props, this._instanceProps), j = Z > F ? k : 0, q = $ > z ? k : 0;
1461
- this.scrollTo({
1462
- scrollLeft: y !== void 0 ? d(this.props, y, C, O, this._instanceProps, q) : O,
1463
- scrollTop: L !== void 0 ? u(this.props, L, C, N, this._instanceProps, j) : N
1464
- });
1465
- }, p.componentDidMount = function() {
1466
- var s = this.props, _ = s.initialScrollLeft, C = s.initialScrollTop;
1467
- if (this._outerRef != null) {
1468
- var y = this._outerRef;
1469
- typeof _ == "number" && (y.scrollLeft = _), typeof C == "number" && (y.scrollTop = C);
1470
- }
1471
- this._callPropsCallbacks();
1472
- }, p.componentDidUpdate = function() {
1473
- var s = this.props.direction, _ = this.state, C = _.scrollLeft, y = _.scrollTop, L = _.scrollUpdateWasRequested;
1474
- if (L && this._outerRef != null) {
1475
- var x = this._outerRef;
1476
- if (s === "rtl")
1477
- switch (Jt()) {
1478
- case "negative":
1479
- x.scrollLeft = -C;
1480
- break;
1481
- case "positive-ascending":
1482
- x.scrollLeft = C;
1483
- break;
1484
- default:
1485
- var I = x.clientWidth, z = x.scrollWidth;
1486
- x.scrollLeft = z - I - C;
1487
- break;
1488
- }
1489
- else
1490
- x.scrollLeft = Math.max(0, C);
1491
- x.scrollTop = Math.max(0, y);
1492
- }
1493
- this._callPropsCallbacks();
1494
- }, p.componentWillUnmount = function() {
1495
- this._resetIsScrollingTimeoutId !== null && Yt(this._resetIsScrollingTimeoutId);
1496
- }, p.render = function() {
1497
- var s = this.props, _ = s.children, C = s.className, y = s.columnCount, L = s.direction, x = s.height, I = s.innerRef, z = s.innerElementType, A = s.innerTagName, F = s.itemData, R = s.itemKey, O = R === void 0 ? Zo : R, N = s.outerElementType, k = s.outerTagName, $ = s.rowCount, Z = s.style, j = s.useIsScrolling, q = s.width, te = this.state.isScrolling, Y = this._getHorizontalRangeToRender(), de = Y[0], we = Y[1], ue = this._getVerticalRangeToRender(), J = ue[0], ke = ue[1], _e = [];
1498
- if (y > 0 && $)
1499
- for (var Te = J; Te <= ke; Te++)
1500
- for (var be = de; be <= we; be++)
1501
- _e.push(Ze(_, {
1502
- columnIndex: be,
1503
- data: F,
1504
- isScrolling: j ? te : void 0,
1505
- key: O({
1506
- columnIndex: be,
1507
- data: F,
1508
- rowIndex: Te
1509
- }),
1510
- rowIndex: Te,
1511
- style: this._getItemStyle(Te, be)
1512
- }));
1513
- var rt = l(this.props, this._instanceProps), ot = c(this.props, this._instanceProps);
1514
- return Ze(N || k || "div", {
1515
- className: C,
1516
- onScroll: this._onScroll,
1517
- ref: this._outerRefSetter,
1518
- style: Hr({
1519
- position: "relative",
1520
- height: x,
1521
- width: q,
1522
- overflow: "auto",
1523
- WebkitOverflowScrolling: "touch",
1524
- willChange: "transform",
1525
- direction: L
1526
- }, Z)
1527
- }, Ze(z || A || "div", {
1528
- children: _e,
1529
- ref: I,
1530
- style: {
1531
- height: rt,
1532
- pointerEvents: te ? "none" : void 0,
1533
- width: ot
1534
- }
1535
- }));
1536
- }, p._callPropsCallbacks = function() {
1537
- var s = this.props, _ = s.columnCount, C = s.onItemsRendered, y = s.onScroll, L = s.rowCount;
1538
- if (typeof C == "function" && _ > 0 && L > 0) {
1539
- var x = this._getHorizontalRangeToRender(), I = x[0], z = x[1], A = x[2], F = x[3], R = this._getVerticalRangeToRender(), O = R[0], N = R[1], k = R[2], $ = R[3];
1540
- this._callOnItemsRendered(I, z, O, N, A, F, k, $);
1541
- }
1542
- if (typeof y == "function") {
1543
- var Z = this.state, j = Z.horizontalScrollDirection, q = Z.scrollLeft, te = Z.scrollTop, Y = Z.scrollUpdateWasRequested, de = Z.verticalScrollDirection;
1544
- this._callOnScroll(q, te, j, de, Y);
1545
- }
1546
- }, p._getHorizontalRangeToRender = function() {
1547
- var s = this.props, _ = s.columnCount, C = s.overscanColumnCount, y = s.overscanColumnsCount, L = s.overscanCount, x = s.rowCount, I = this.state, z = I.horizontalScrollDirection, A = I.isScrolling, F = I.scrollLeft, R = C || y || L || 1;
1548
- if (_ === 0 || x === 0)
1549
- return [0, 0, 0, 0];
1550
- var O = o(this.props, F, this._instanceProps), N = r(this.props, O, F, this._instanceProps), k = !A || z === "backward" ? Math.max(1, R) : 1, $ = !A || z === "forward" ? Math.max(1, R) : 1;
1551
- return [Math.max(0, O - k), Math.max(0, Math.min(_ - 1, N + $)), O, N];
1552
- }, p._getVerticalRangeToRender = function() {
1553
- var s = this.props, _ = s.columnCount, C = s.overscanCount, y = s.overscanRowCount, L = s.overscanRowsCount, x = s.rowCount, I = this.state, z = I.isScrolling, A = I.verticalScrollDirection, F = I.scrollTop, R = y || L || C || 1;
1554
- if (_ === 0 || x === 0)
1555
- return [0, 0, 0, 0];
1556
- var O = h(this.props, F, this._instanceProps), N = w(this.props, O, F, this._instanceProps), k = !z || A === "backward" ? Math.max(1, R) : 1, $ = !z || A === "forward" ? Math.max(1, R) : 1;
1557
- return [Math.max(0, O - k), Math.max(0, Math.min(x - 1, N + $)), O, N];
1558
- }, m;
1559
- }(sr), t.defaultProps = {
1560
- direction: "ltr",
1561
- itemData: void 0,
1562
- useIsScrolling: !1
1563
- }, t;
1564
- }
1565
- var Ko = function(t, n) {
1566
- var o = t.children, r = t.direction, a = t.height, l = t.innerTagName, c = t.outerTagName, d = t.overscanColumnsCount, u = t.overscanCount, f = t.overscanRowsCount, v = t.width, h = n.instance;
1567
- if (process.env.NODE_ENV !== "production") {
1568
- if (typeof u == "number" && je && !je.has(h) && (je.add(h), console.warn("The overscanCount prop has been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (typeof d == "number" || typeof f == "number") && Ke && !Ke.has(h) && (Ke.add(h), console.warn("The overscanColumnsCount and overscanRowsCount props have been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (l != null || c != null) && Xe && !Xe.has(h) && (Xe.add(h), console.warn("The innerTagName and outerTagName props have been deprecated. Please use the innerElementType and outerElementType props instead.")), o == null)
1569
- throw Error('An invalid "children" prop has been specified. Value should be a React component. ' + ('"' + (o === null ? "null" : typeof o) + '" was specified.'));
1570
- switch (r) {
1571
- case "ltr":
1572
- case "rtl":
1573
- break;
1574
- default:
1575
- throw Error('An invalid "direction" prop has been specified. Value should be either "ltr" or "rtl". ' + ('"' + r + '" was specified.'));
1576
- }
1577
- if (typeof v != "number")
1578
- throw Error('An invalid "width" prop has been specified. Grids must specify a number for width. ' + ('"' + (v === null ? "null" : typeof v) + '" was specified.'));
1579
- if (typeof a != "number")
1580
- throw Error('An invalid "height" prop has been specified. Grids must specify a number for height. ' + ('"' + (a === null ? "null" : typeof a) + '" was specified.'));
1581
- }
1582
- }, Qt = 50, Nn = function(t, n) {
1583
- var o = t.rowCount, r = n.rowMetadataMap, a = n.estimatedRowHeight, l = n.lastMeasuredRowIndex, c = 0;
1584
- if (l >= o && (l = o - 1), l >= 0) {
1585
- var d = r[l];
1586
- c = d.offset + d.size;
1587
- }
1588
- var u = o - l - 1, f = u * a;
1589
- return c + f;
1590
- }, En = function(t, n) {
1591
- var o = t.columnCount, r = n.columnMetadataMap, a = n.estimatedColumnWidth, l = n.lastMeasuredColumnIndex, c = 0;
1592
- if (l >= o && (l = o - 1), l >= 0) {
1593
- var d = r[l];
1594
- c = d.offset + d.size;
1595
- }
1596
- var u = o - l - 1, f = u * a;
1597
- return c + f;
1598
- }, ge = function(t, n, o, r) {
1599
- var a, l, c;
1600
- if (t === "column" ? (a = r.columnMetadataMap, l = n.columnWidth, c = r.lastMeasuredColumnIndex) : (a = r.rowMetadataMap, l = n.rowHeight, c = r.lastMeasuredRowIndex), o > c) {
1601
- var d = 0;
1602
- if (c >= 0) {
1603
- var u = a[c];
1604
- d = u.offset + u.size;
1605
- }
1606
- for (var f = c + 1; f <= o; f++) {
1607
- var v = l(f);
1608
- a[f] = {
1609
- offset: d,
1610
- size: v
1611
- }, d += v;
1612
- }
1613
- t === "column" ? r.lastMeasuredColumnIndex = o : r.lastMeasuredRowIndex = o;
1614
- }
1615
- return a[o];
1616
- }, en = function(t, n, o, r) {
1617
- var a, l;
1618
- t === "column" ? (a = o.columnMetadataMap, l = o.lastMeasuredColumnIndex) : (a = o.rowMetadataMap, l = o.lastMeasuredRowIndex);
1619
- var c = l > 0 ? a[l].offset : 0;
1620
- return c >= r ? On(t, n, o, l, 0, r) : Xo(t, n, o, Math.max(0, l), r);
1621
- }, On = function(t, n, o, r, a, l) {
1622
- for (; a <= r; ) {
1623
- var c = a + Math.floor((r - a) / 2), d = ge(t, n, c, o).offset;
1624
- if (d === l)
1625
- return c;
1626
- d < l ? a = c + 1 : d > l && (r = c - 1);
1627
- }
1628
- return a > 0 ? a - 1 : 0;
1629
- }, Xo = function(t, n, o, r, a) {
1630
- for (var l = t === "column" ? n.columnCount : n.rowCount, c = 1; r < l && ge(t, n, r, o).offset < a; )
1631
- r += c, c *= 2;
1632
- return On(t, n, o, Math.min(r, l - 1), Math.floor(r / 2), a);
1633
- }, tn = function(t, n, o, r, a, l, c) {
1634
- var d = t === "column" ? n.width : n.height, u = ge(t, n, o, l), f = t === "column" ? En(n, l) : Nn(n, l), v = Math.max(0, Math.min(f - d, u.offset)), h = Math.max(0, u.offset - d + c + u.size);
1635
- switch (r === "smart" && (a >= h - d && a <= v + d ? r = "auto" : r = "center"), r) {
1636
- case "start":
1637
- return v;
1638
- case "end":
1639
- return h;
1640
- case "center":
1641
- return Math.round(h + (v - h) / 2);
1642
- case "auto":
1643
- default:
1644
- return a >= h && a <= v ? a : h > v || a < h ? h : v;
1645
- }
1646
- }, Yo = /* @__PURE__ */ jo({
1647
- getColumnOffset: function(t, n, o) {
1648
- return ge("column", t, n, o).offset;
1649
- },
1650
- getColumnStartIndexForOffset: function(t, n, o) {
1651
- return en("column", t, o, n);
1652
- },
1653
- getColumnStopIndexForStartIndex: function(t, n, o, r) {
1654
- for (var a = t.columnCount, l = t.width, c = ge("column", t, n, r), d = o + l, u = c.offset + c.size, f = n; f < a - 1 && u < d; )
1655
- f++, u += ge("column", t, f, r).size;
1656
- return f;
1657
- },
1658
- getColumnWidth: function(t, n, o) {
1659
- return o.columnMetadataMap[n].size;
1660
- },
1661
- getEstimatedTotalHeight: Nn,
1662
- getEstimatedTotalWidth: En,
1663
- getOffsetForColumnAndAlignment: function(t, n, o, r, a, l) {
1664
- return tn("column", t, n, o, r, a, l);
1665
- },
1666
- getOffsetForRowAndAlignment: function(t, n, o, r, a, l) {
1667
- return tn("row", t, n, o, r, a, l);
1668
- },
1669
- getRowOffset: function(t, n, o) {
1670
- return ge("row", t, n, o).offset;
1671
- },
1672
- getRowHeight: function(t, n, o) {
1673
- return o.rowMetadataMap[n].size;
1674
- },
1675
- getRowStartIndexForOffset: function(t, n, o) {
1676
- return en("row", t, o, n);
1677
- },
1678
- getRowStopIndexForStartIndex: function(t, n, o, r) {
1679
- for (var a = t.rowCount, l = t.height, c = ge("row", t, n, r), d = o + l, u = c.offset + c.size, f = n; f < a - 1 && u < d; )
1680
- f++, u += ge("row", t, f, r).size;
1681
- return f;
1682
- },
1683
- initInstanceProps: function(t, n) {
1684
- var o = t, r = o.estimatedColumnWidth, a = o.estimatedRowHeight, l = {
1685
- columnMetadataMap: {},
1686
- estimatedColumnWidth: r || Qt,
1687
- estimatedRowHeight: a || Qt,
1688
- lastMeasuredColumnIndex: -1,
1689
- lastMeasuredRowIndex: -1,
1690
- rowMetadataMap: {}
1691
- };
1692
- return n.resetAfterColumnIndex = function(c, d) {
1693
- d === void 0 && (d = !0), n.resetAfterIndices({
1694
- columnIndex: c,
1695
- shouldForceUpdate: d
1696
- });
1697
- }, n.resetAfterRowIndex = function(c, d) {
1698
- d === void 0 && (d = !0), n.resetAfterIndices({
1699
- rowIndex: c,
1700
- shouldForceUpdate: d
1701
- });
1702
- }, n.resetAfterIndices = function(c) {
1703
- var d = c.columnIndex, u = c.rowIndex, f = c.shouldForceUpdate, v = f === void 0 ? !0 : f;
1704
- typeof d == "number" && (l.lastMeasuredColumnIndex = Math.min(l.lastMeasuredColumnIndex, d - 1)), typeof u == "number" && (l.lastMeasuredRowIndex = Math.min(l.lastMeasuredRowIndex, u - 1)), n._getItemStyleCache(-1), v && n.forceUpdate();
1705
- }, l;
1706
- },
1707
- shouldResetStyleCacheOnItemSizeChange: !1,
1708
- validateProps: function(t) {
1709
- var n = t.columnWidth, o = t.rowHeight;
1710
- if (process.env.NODE_ENV !== "production") {
1711
- if (typeof n != "function")
1712
- throw Error('An invalid "columnWidth" prop has been specified. Value should be a function. ' + ('"' + (n === null ? "null" : typeof n) + '" was specified.'));
1713
- if (typeof o != "function")
1714
- throw Error('An invalid "rowHeight" prop has been specified. Value should be a function. ' + ('"' + (o === null ? "null" : typeof o) + '" was specified.'));
1715
- }
1716
- }
1717
- });
1718
- process.env.NODE_ENV;
1719
- function nn(e, t) {
1720
- for (var n in e)
1721
- if (!(n in t))
1722
- return !0;
1723
- for (var o in t)
1724
- if (e[o] !== t[o])
1725
- return !0;
1726
- return !1;
1727
- }
1728
- var Jo = ["style"], Qo = ["style"];
1729
- function ei(e, t) {
1730
- var n = e.style, o = Kt(e, Jo), r = t.style, a = Kt(t, Qo);
1731
- return !nn(n, r) && !nn(o, a);
1732
- }
1733
- const ti = () => {
1734
- const { viewMode: e } = Ee(), { scrollMode: t } = Ne(), { setColumnCount: n } = gn(), { virtualScrollableElementRef: o } = nt(), r = Ue(), a = M(() => r.heights.length, [r.heights]), l = M(() => t === ee.HORIZONTAL_SCROLLING ? a : e === Re.DUAL_PAGE ? 2 : 1, [e, t, t, a, o]), c = M(() => r.widths.reduce((b, S, P) => {
1735
- const T = P % l;
1736
- return (!b[T] || S > b[T]) && (b[T] = S), b;
1737
- }, []), [r.widths, l]), d = E(
1738
- (w) => {
1739
- const b = w % c.length;
1740
- return c[b] || 0;
1741
- },
1742
- [c]
1743
- ), u = E(
1744
- (w) => {
1745
- const b = Array.from({ length: l }, (S, P) => {
1746
- const T = w * l + P;
1747
- return r.heights[T] || 0;
1748
- });
1749
- return Math.max(...b);
1750
- },
1751
- [r.heights, l]
1752
- );
1753
- W(() => {
1754
- n(l);
1755
- }, [l, n]);
1756
- const f = M(() => t === ee.HORIZONTAL_SCROLLING || t === ee.PAGE_SCROLLING ? 1 : Math.round(a / l), [l, a, t]), v = M(() => r.heights.reduce((w, b) => w + b, 0) / r.heights.length || 0, [r]), h = M(() => r.widths.reduce((w, b) => w + b, 0) / r.heights.length || 0, [r]);
1757
- return {
1758
- rowCount: f,
1759
- rowHeight: u,
1760
- columnCount: l,
1761
- columnWidth: d,
1762
- pageDimension: r,
1763
- estimatedRowHeight: v,
1764
- estimatedColumnWidth: h
1765
- };
1766
- };
1767
- let oe;
1768
- typeof window < "u" ? oe = window : typeof self < "u" ? oe = self : oe = global;
1769
- let bt = null, Ct = null;
1770
- const rn = 20, ht = oe.clearTimeout, on = oe.setTimeout, ft = oe.cancelAnimationFrame || oe.mozCancelAnimationFrame || oe.webkitCancelAnimationFrame, an = oe.requestAnimationFrame || oe.mozRequestAnimationFrame || oe.webkitRequestAnimationFrame;
1771
- ft == null || an == null ? (bt = ht, Ct = function(t) {
1772
- return on(t, rn);
1773
- }) : (bt = function([t, n]) {
1774
- ft(t), ht(n);
1775
- }, Ct = function(t) {
1776
- const n = an(function() {
1777
- ht(o), t();
1778
- }), o = on(function() {
1779
- ft(n), t();
1780
- }, rn);
1781
- return [n, o];
1782
- });
1783
- function ni(e) {
1784
- let t, n, o, r, a, l, c;
1785
- const d = typeof document < "u" && document.attachEvent;
1786
- if (!d) {
1787
- l = function(T) {
1788
- const m = T.__resizeTriggers__, p = m.firstElementChild, g = m.lastElementChild, s = p.firstElementChild;
1789
- g.scrollLeft = g.scrollWidth, g.scrollTop = g.scrollHeight, s.style.width = p.offsetWidth + 1 + "px", s.style.height = p.offsetHeight + 1 + "px", p.scrollLeft = p.scrollWidth, p.scrollTop = p.scrollHeight;
1790
- }, a = function(T) {
1791
- return T.offsetWidth !== T.__resizeLast__.width || T.offsetHeight !== T.__resizeLast__.height;
1792
- }, c = function(T) {
1793
- if (T.target.className && typeof T.target.className.indexOf == "function" && T.target.className.indexOf("contract-trigger") < 0 && T.target.className.indexOf("expand-trigger") < 0)
1794
- return;
1795
- const m = this;
1796
- l(this), this.__resizeRAF__ && bt(this.__resizeRAF__), this.__resizeRAF__ = Ct(function() {
1797
- a(m) && (m.__resizeLast__.width = m.offsetWidth, m.__resizeLast__.height = m.offsetHeight, m.__resizeListeners__.forEach(function(s) {
1798
- s.call(m, T);
1799
- }));
1800
- });
1801
- };
1802
- let h = !1, w = "";
1803
- o = "animationstart";
1804
- const b = "Webkit Moz O ms".split(" ");
1805
- let S = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), P = "";
1806
- {
1807
- const T = document.createElement("fakeelement");
1808
- if (T.style.animationName !== void 0 && (h = !0), h === !1) {
1809
- for (let m = 0; m < b.length; m++)
1810
- if (T.style[b[m] + "AnimationName"] !== void 0) {
1811
- P = b[m], w = "-" + P.toLowerCase() + "-", o = S[m], h = !0;
1812
- break;
1813
- }
1814
- }
1815
- }
1816
- n = "resizeanim", t = "@" + w + "keyframes " + n + " { from { opacity: 0; } to { opacity: 0; } } ", r = w + "animation: 1ms " + n + "; ";
1817
- }
1818
- const u = function(h) {
1819
- if (!h.getElementById("detectElementResize")) {
1820
- const w = (t || "") + ".resize-triggers { " + (r || "") + '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%; }', b = h.head || h.getElementsByTagName("head")[0], S = h.createElement("style");
1821
- S.id = "detectElementResize", S.type = "text/css", e != null && S.setAttribute("nonce", e), S.styleSheet ? S.styleSheet.cssText = w : S.appendChild(h.createTextNode(w)), b.appendChild(S);
1822
- }
1823
- };
1824
- return {
1825
- addResizeListener: function(h, w) {
1826
- if (d)
1827
- h.attachEvent("onresize", w);
1828
- else {
1829
- if (!h.__resizeTriggers__) {
1830
- const b = h.ownerDocument, S = oe.getComputedStyle(h);
1831
- S && S.position === "static" && (h.style.position = "relative"), u(b), h.__resizeLast__ = {}, h.__resizeListeners__ = [], (h.__resizeTriggers__ = b.createElement("div")).className = "resize-triggers";
1832
- const P = b.createElement("div");
1833
- P.className = "expand-trigger", P.appendChild(b.createElement("div"));
1834
- const T = b.createElement("div");
1835
- T.className = "contract-trigger", h.__resizeTriggers__.appendChild(P), h.__resizeTriggers__.appendChild(T), h.appendChild(h.__resizeTriggers__), l(h), h.addEventListener("scroll", c, !0), o && (h.__resizeTriggers__.__animationListener__ = function(p) {
1836
- p.animationName === n && l(h);
1837
- }, h.__resizeTriggers__.addEventListener(o, h.__resizeTriggers__.__animationListener__));
1838
- }
1839
- h.__resizeListeners__.push(w);
1840
- }
1841
- },
1842
- removeResizeListener: function(h, w) {
1843
- if (d)
1844
- h.detachEvent("onresize", w);
1845
- else if (h.__resizeListeners__.splice(h.__resizeListeners__.indexOf(w), 1), !h.__resizeListeners__.length) {
1846
- h.removeEventListener("scroll", c, !0), h.__resizeTriggers__.__animationListener__ && (h.__resizeTriggers__.removeEventListener(o, h.__resizeTriggers__.__animationListener__), h.__resizeTriggers__.__animationListener__ = null);
1847
- try {
1848
- h.__resizeTriggers__ = !h.removeChild(h.__resizeTriggers__);
1849
- } catch {
1850
- }
1851
- }
1852
- }
1853
- };
1854
- }
1855
- class ri extends cr {
1856
- constructor(...t) {
1857
- super(...t), this.state = {
1858
- height: this.props.defaultHeight || 0,
1859
- scaledHeight: this.props.defaultHeight || 0,
1860
- scaledWidth: this.props.defaultWidth || 0,
1861
- width: this.props.defaultWidth || 0
1862
- }, this._autoSizer = null, this._detectElementResize = null, this._parentNode = null, this._resizeObserver = null, this._timeoutId = null, this._onResize = () => {
1863
- this._timeoutId = null;
1864
- const {
1865
- disableHeight: n,
1866
- disableWidth: o,
1867
- onResize: r
1868
- } = this.props;
1869
- if (this._parentNode) {
1870
- const a = window.getComputedStyle(this._parentNode) || {}, l = parseFloat(a.paddingLeft || "0"), c = parseFloat(a.paddingRight || "0"), d = parseFloat(a.paddingTop || "0"), u = parseFloat(a.paddingBottom || "0"), f = this._parentNode.getBoundingClientRect(), v = f.height - d - u, h = f.width - l - c, w = this._parentNode.offsetHeight - d - u, b = this._parentNode.offsetWidth - l - c;
1871
- (!n && (this.state.height !== w || this.state.scaledHeight !== v) || !o && (this.state.width !== b || this.state.scaledWidth !== h)) && (this.setState({
1872
- height: w,
1873
- width: b,
1874
- scaledHeight: v,
1875
- scaledWidth: h
1876
- }), typeof r == "function" && r({
1877
- height: w,
1878
- scaledHeight: v,
1879
- scaledWidth: h,
1880
- width: b
1881
- }));
1882
- }
1883
- }, this._setRef = (n) => {
1884
- this._autoSizer = n;
1885
- };
1886
- }
1887
- componentDidMount() {
1888
- const {
1889
- nonce: t
1890
- } = this.props, n = this._autoSizer ? this._autoSizer.parentNode : null;
1891
- if (n != null && n.ownerDocument && n.ownerDocument.defaultView && n instanceof n.ownerDocument.defaultView.HTMLElement) {
1892
- this._parentNode = n;
1893
- const o = n.ownerDocument.defaultView.ResizeObserver;
1894
- o != null ? (this._resizeObserver = new o(() => {
1895
- this._timeoutId = setTimeout(this._onResize, 0);
1896
- }), this._resizeObserver.observe(n)) : (this._detectElementResize = ni(t), this._detectElementResize.addResizeListener(n, this._onResize)), this._onResize();
1897
- }
1898
- }
1899
- componentWillUnmount() {
1900
- this._parentNode && (this._detectElementResize && this._detectElementResize.removeResizeListener(this._parentNode, this._onResize), this._timeoutId !== null && clearTimeout(this._timeoutId), this._resizeObserver && this._resizeObserver.disconnect());
1901
- }
1902
- render() {
1903
- const {
1904
- children: t,
1905
- defaultHeight: n,
1906
- defaultWidth: o,
1907
- disableHeight: r = !1,
1908
- disableWidth: a = !1,
1909
- doNotBailOutOnEmptyChildren: l = !1,
1910
- nonce: c,
1911
- onResize: d,
1912
- style: u = {},
1913
- tagName: f = "div",
1914
- ...v
1915
- } = this.props, {
1916
- height: h,
1917
- scaledHeight: w,
1918
- scaledWidth: b,
1919
- width: S
1920
- } = this.state, P = {
1921
- overflow: "visible"
1922
- }, T = {};
1923
- let m = !1;
1924
- return r || (h === 0 && (m = !0), P.height = 0, T.height = h, T.scaledHeight = w), a || (S === 0 && (m = !0), P.width = 0, T.width = S, T.scaledWidth = b), l && (m = !1), Ze(f, {
1925
- ref: this._setRef,
1926
- style: {
1927
- ...P,
1928
- ...u
1929
- },
1930
- ...v
1931
- }, !m && t(T));
1932
- }
1933
- }
1934
- const oi = hn(({ widths: e, heights: t }) => {
1935
- const { focusedPage: n, totalPages: o } = ae(), r = M(() => {
1936
- const c = [], d = Math.ceil(n / 2) * 2 - 1;
1937
- if (c.push(d), d + 1 <= o) {
1938
- const u = d + 1;
1939
- c.push(u);
1940
- }
1941
- return c;
1942
- }, [n, o]), a = M(() => {
1943
- const c = n % 2 === 1 ? n - 1 : n - 2, d = e(c), u = t(c), f = e(c + 1), v = t(c + 1), h = u > v ? u : v, w = u < v ? u : v, b = h / 2 - w / 2;
1944
- return [
1945
- {
1946
- position: "absolute",
1947
- left: 0,
1948
- top: h === u ? 0 : b,
1949
- width: d,
1950
- height: u
1951
- },
1952
- {
1953
- position: "absolute",
1954
- left: d,
1955
- top: h === v ? 0 : b,
1956
- width: f,
1957
- height: v
1958
- }
1959
- ];
1960
- }, [e, t, r]), l = M(() => a.reduce((c, d) => c + Number(d.width || 0), 0), [a]);
1961
- return /* @__PURE__ */ i("div", { style: { width: l, position: "relative" }, children: r.map((c, d) => /* @__PURE__ */ i(Nt, { style: a[d], pageNumber: c }, c)) });
1962
- }), ii = ({ widths: e, heights: t }) => {
1963
- const { focusedPage: n } = ae(), o = M(() => ({
1964
- position: "absolute",
1965
- width: e(n - 1),
1966
- height: t(n - 1)
1967
- }), [e, t, n]), r = M(() => e(n - 1), [e]);
1968
- return /* @__PURE__ */ i(
1969
- "div",
1970
- {
1971
- style: {
1972
- width: r,
1973
- position: "relative"
1974
- },
1975
- children: /* @__PURE__ */ i(Nt, { style: o, pageNumber: n }, n)
1976
- }
1977
- );
1978
- }, ai = (e, t, n) => {
1979
- const o = H(), { contentRef: r } = se(), { heights: a, widths: l } = Ue(), { setFocusedPage: c } = ae(), [d, u] = G([]), { targetScrollPage: f } = vn(), v = It(d, 0, 500), h = M(() => a.map((b, S) => {
1980
- const P = l[S], T = yo(S + 1, e), m = P * T.columnIndex, p = b * T.rowIndex, g = m + P, s = p + b;
1981
- return {
1982
- pageNumber: S + 1,
1983
- ...T,
1984
- width: P,
1985
- height: b,
1986
- startX: m,
1987
- startY: p,
1988
- endX: g,
1989
- endY: s
1990
- };
1991
- }), [a, l, e, t]);
1992
- W(() => {
1993
- var S;
1994
- v.length > 0 && !f.current && c(v[0].pageNumber);
1995
- let b = (S = v[0]) == null ? void 0 : S.ratio;
1996
- b && v.filter((P) => Math.round(P.ratio) === Math.round(b)).some((P) => P.pageNumber === f.current) && setTimeout(() => {
1997
- f.current = void 0;
1998
- }, 500);
1999
- }, [v, c]);
2000
- const w = E(
2001
- (b) => {
2002
- o.current && cancelAnimationFrame(o.current), o.current = requestAnimationFrame(() => {
2003
- const S = b.target, P = {
2004
- startTop: S.scrollTop,
2005
- startLeft: S.scrollLeft,
2006
- endTop: S.scrollTop + S.clientHeight,
2007
- endLeft: S.scrollLeft + S.clientWidth
2008
- }, T = h.filter((m) => {
2009
- const p = m.endX >= P.startLeft && m.endY >= P.startTop, g = m.startX <= P.endLeft && m.startY <= P.endTop;
2010
- return p && g;
2011
- }).map((m) => {
2012
- const p = P.startLeft > m.startX ? P.startLeft : m.startX, g = P.startTop > m.startY ? P.startTop : m.startY, s = P.endLeft < m.endX ? P.endLeft : m.endX, _ = P.endTop < m.endY ? P.endTop : m.endY, C = s - p, y = _ - g, x = +(C * y / (m.width * m.height) * 100).toFixed(2);
2013
- return {
2014
- pageNumber: m.pageNumber,
2015
- ratio: x
2016
- };
2017
- }).sort((m, p) => p.ratio - m.ratio);
2018
- u(T);
2019
- });
2020
- },
2021
- [r, h]
2022
- );
2023
- W(() => {
2024
- if (n)
2025
- return n == null || n.addEventListener("scroll", w), () => {
2026
- n == null || n.removeEventListener("scroll", w);
2027
- };
2028
- }, [n, w]);
2029
- }, ve = {
2030
- "rp-layout": "_rp-layout_1g4ff_1",
2031
- "rp-content": "_rp-content_1g4ff_5",
2032
- "rp-pages": "_rp-pages_1g4ff_11",
2033
- "rp-container": "_rp-container_1g4ff_16",
2034
- "rp-loader": "_rp-loader_1g4ff_20",
2035
- "rp-theme-variables": "_rp-theme-variables_1g4ff_24",
2036
- "rp-dark-mode": "_rp-dark-mode_1g4ff_135"
2037
- }, Et = We(
2038
- (e, t) => {
2039
- const { children: n, toolbarRef: o, style: r, className: a, ...l } = e, { customVariables: c, customDarkVariables: d } = lr(), { darkMode: u } = pr();
2040
- return /* @__PURE__ */ i(
2041
- "div",
2042
- {
2043
- ref: t,
2044
- ...l,
2045
- className: ne(
2046
- ve["rp-theme-variables"],
2047
- ve["rp-container"],
2048
- u ? ve["rp-dark-mode"] : "",
2049
- a
2050
- ),
2051
- style: {
2052
- "--rp-toolbar-height": `${(o == null ? void 0 : o.clientHeight) || 48}px`,
2053
- ...c,
2054
- ...u ? d : {},
2055
- ...r
2056
- },
2057
- children: n
2058
- }
2059
- );
2060
- }
2061
- ), si = hn(({ columnIndex: e, rowIndex: t, data: n, style: o }) => {
2062
- const r = So(t, e, n.columnCount);
2063
- return /* @__PURE__ */ i(Nt, { style: o, pageNumber: r }, r);
2064
- }, ei), js = () => {
2065
- const { initialPage: e = 1, initialScrollMode: t, instanceId: n } = mr(), { pagesRef: o, setPagesRef: r } = se(), { scrollToPage: a } = Sn(), {
2066
- virtualScrollRef: l,
2067
- getVirtualScrollRef: c,
2068
- getPageScrollElementRef: d,
2069
- getVirtualScrollableElementRef: u,
2070
- setTotalInnerDimensions: f,
2071
- virtualScrollableElementRef: v,
2072
- totalInnerDimensions: h,
2073
- pageScrollElementRef: w
2074
- } = nt(), b = H(!0), { nextPage: S, prevPage: P, setFocusedPage: T, focusedPage: m } = ae(), { scrollMode: p } = Ne(), { viewMode: g } = Ee(), s = H(null), { loading: _ } = X(), { passwordRequired: C } = dr(), { LoaderImageComponent: y } = Pt(), L = H(
2075
- h
2076
- ), x = H({
2077
- viewMode: g,
2078
- scrollMode: p
2079
- }), I = H(!1), z = H(), { isFullScreen: A } = gr(), {
2080
- pageDimension: F,
2081
- rowCount: R,
2082
- rowHeight: O,
2083
- columnCount: N,
2084
- columnWidth: k,
2085
- estimatedColumnWidth: $,
2086
- estimatedRowHeight: Z
2087
- } = ti(), j = It(h, 100), q = H();
2088
- ai(N, R, v);
2089
- const te = H({
2090
- scrollTop: 0,
2091
- scrollLeft: 0
2092
- });
2093
- Po(o);
2094
- const { isPressed: Y } = bo(), { selectionMode: de } = fr(), { initializeGrabScroll: we, resetGrabState: ue } = Co({
2095
- isPressed: Y
2096
- }), J = M(() => de === ur.HAND, [de]), ke = M(() => ({
2097
- columnCount: N
2098
- }), [N]), _e = E(
2099
- (U) => {
2100
- const V = document.activeElement !== o;
2101
- !A && V || (["ArrowUp", "ArrowLeft"].includes(U.key) ? (U.preventDefault(), P()) : ["ArrowDown", "ArrowRight"].includes(U.key) && (U.preventDefault(), S()));
2102
- },
2103
- [S, P, A, p]
2104
- );
2105
- W(() => (window.addEventListener("keydown", _e), () => {
2106
- window.removeEventListener("keydown", _e);
2107
- }), [_e]), W(() => {
2108
- if (s.current && (s.current.style.position = "relative"), !!l)
2109
- for (let U = 0; U < R; U++)
2110
- for (let V = 0; V < N; V++)
2111
- l.resetAfterIndices({
2112
- columnIndex: V,
2113
- rowIndex: U,
2114
- shouldForceUpdate: !0
2115
- });
2116
- }, [R, N, F, l]);
2117
- const Te = E(
2118
- (U, V) => {
2119
- if (!v)
2120
- return { scrollTop: 0, scrollLeft: 0 };
2121
- const ye = te.current.scrollTop > V, Se = te.current.scrollLeft > U;
2122
- return ye || Se ? te.current : {
2123
- scrollTop: v.scrollTop,
2124
- scrollLeft: v.scrollLeft
2125
- };
2126
- },
2127
- [v]
2128
- ), be = E(
2129
- (U, V) => {
2130
- if (x.current.viewMode !== g || x.current.scrollMode !== p) {
2131
- q.current && clearTimeout(q.current), I.current = !0, a(m, "auto"), q.current = setTimeout(() => {
2132
- requestAnimationFrame(() => {
2133
- x.current = { viewMode: g, scrollMode: p };
2134
- });
2135
- }, 100);
2136
- return;
2137
- }
2138
- const Se = U.scrollTop, it = U.scrollLeft;
2139
- if (!V.height || !V.width)
2140
- return;
2141
- I.current = !0;
2142
- const { height: xe, width: at } = V, { height: Ft, width: Wt } = L.current;
2143
- if (Ft === xe && Wt === at)
2144
- return;
2145
- const rr = Se / Ft * xe, or = it / Wt * at, ir = Math.round(Math.min(rr, xe)) || 0, ar = Math.round(Math.min(or, at)) || 0;
2146
- z.current = setTimeout(() => {
2147
- requestAnimationFrame(() => {
2148
- l == null || l.scrollTo({
2149
- scrollTop: ir,
2150
- scrollLeft: ar
2151
- });
2152
- });
2153
- }, 0), L.current = {
2154
- height: V.height,
2155
- width: V.width
2156
- };
2157
- },
2158
- [l, g, p, a]
2159
- );
2160
- W(() => {
2161
- clearTimeout(z.current);
2162
- const U = Array.from({ length: R }).reduce(
2163
- (Se, it, xe) => Se + O(xe),
2164
- 0
2165
- ), V = Array.from({ length: N }).reduce(
2166
- (Se, it, xe) => Se + k(xe),
2167
- 0
2168
- ), ye = Te(V, U);
2169
- te.current = ye, be(ye, { height: U, width: V }), f({
2170
- height: U,
2171
- width: V
2172
- });
2173
- }, [F, R, N, be]);
2174
- const rt = E(
2175
- (U) => {
2176
- te.current = {
2177
- scrollTop: U.scrollTop,
2178
- scrollLeft: U.scrollLeft
2179
- };
2180
- },
2181
- [v]
2182
- );
2183
- W(() => () => {
2184
- q.current && clearTimeout(q.current);
2185
- }, []);
2186
- const ot = M(() => ne(pe["rp-pages-container"], {
2187
- [pe["rp-cursor-grab"]]: J && !Y,
2188
- [pe["rp-cursor-grabbing"]]: J && Y
2189
- }), [J, Y]), nr = E(
2190
- (U) => {
2191
- if (J && U) {
2192
- const V = ne(pe["rp-pages"]), ye = document.querySelector(`.${V}`);
2193
- we(ye);
2194
- }
2195
- },
2196
- [J, we, pe]
2197
- );
2198
- return W(() => {
2199
- _ && ue();
2200
- }, [_]), W(() => {
2201
- if (!(j.height === 0 || !b.current)) {
2202
- if (t === ee.PAGE_SCROLLING) {
2203
- e !== m && w && T(e), b.current = !1;
2204
- return;
2205
- }
2206
- a(e, "auto"), T(e), b.current = !1;
2207
- }
2208
- }, [
2209
- a,
2210
- t,
2211
- w,
2212
- T,
2213
- j
2214
- ]), /* @__PURE__ */ D(ie, { children: [
2215
- /* @__PURE__ */ i(Et, { id: n, ref: r, tabIndex: -1, className: ot, children: /* @__PURE__ */ i(ri, { style: { minHeight: "50px" }, children: ({ width: U, height: V }) => /* @__PURE__ */ i("div", { "data-rp": "pages", ref: nr, style: { width: U, height: V }, children: p === ee.PAGE_SCROLLING ? /* @__PURE__ */ i(
2216
- "div",
2217
- {
2218
- ref: d,
2219
- style: { width: U, height: V },
2220
- className: ne(pe["rp-pages"], pe["rp-page-scrolling-wrapper"]),
2221
- children: g === Re.DUAL_PAGE ? /* @__PURE__ */ i(oi, { widths: k, heights: O }) : /* @__PURE__ */ i(ii, { widths: k, heights: O })
2222
- }
2223
- ) : $ ? /* @__PURE__ */ i(
2224
- Yo,
2225
- {
2226
- ref: c,
2227
- itemData: ke,
2228
- outerRef: u,
2229
- innerRef: s,
2230
- onScroll: rt,
2231
- columnCount: N,
2232
- columnWidth: k,
2233
- rowHeight: O,
2234
- height: V,
2235
- width: U,
2236
- estimatedColumnWidth: $,
2237
- estimatedRowHeight: Z,
2238
- rowCount: R,
2239
- className: ne(
2240
- pe["rp-pages"],
2241
- p === ee.HORIZONTAL_SCROLLING ? pe["rp-pages-horizontal-scroll"] : ""
2242
- ),
2243
- children: si
2244
- }
2245
- ) : _ ? null : /* @__PURE__ */ i(
2246
- "div",
2247
- {
2248
- className: pe["rp-loader"],
2249
- style: {
2250
- display: "flex",
2251
- justifyContent: "center",
2252
- alignItems: "center",
2253
- height: "100%",
2254
- width: "100%"
2255
- },
2256
- children: y && /* @__PURE__ */ i(y, {})
2257
- }
2258
- ) }) }) }),
2259
- C && /* @__PURE__ */ i(To, {})
2260
- ] });
2261
- }, Me = {
2262
- "rp-toolbar-content": "_rp-toolbar-content_sz31z_1",
2263
- "rp-toolbar-wrapper": "_rp-toolbar-wrapper_sz31z_10",
2264
- "rp-toolbar-start": "_rp-toolbar-start_sz31z_33",
2265
- "rp-toolbar-middle": "_rp-toolbar-middle_sz31z_39",
2266
- "rp-toolbar-end": "_rp-toolbar-end_sz31z_46"
2267
- }, mt = {
2268
- "rp-paginate": "_rp-paginate_1y9vo_1",
2269
- "rp-page-input": "_rp-page-input_1y9vo_6",
2270
- "rp-total-page": "_rp-total-page_1y9vo_11"
2271
- }, ci = () => {
2272
- const { prevIcon: e } = he();
2273
- return e || /* @__PURE__ */ i(Ge, {});
2274
- }, li = () => {
2275
- const { nextIcon: e } = he();
2276
- return e || /* @__PURE__ */ i(Ge, { style: { transform: "rotate(180deg" } });
2277
- }, di = () => {
2278
- const { focusedPage: e, totalPages: t, setFocusedPage: n, nextPage: o, prevPage: r, goToPage: a } = ae(), [l, c] = G(e.toString()), { pageNavigationTool: d = !0 } = fe(), { isSmallScreen: u } = Pe(), { localeMessages: f } = ce(), { viewMode: v } = Ee(), { scrollMode: h } = Ne();
2279
- W(() => {
2280
- c(e.toString());
2281
- }, [e]);
2282
- const w = E((m) => {
2283
- const p = m.target.value;
2284
- c(p);
2285
- }, []), b = E(async () => {
2286
- const m = a(l);
2287
- m.success || c(m.currentPage.toString());
2288
- }, [a, l, t]), S = E(() => {
2289
- c(e.toString());
2290
- }, [e]), P = E(
2291
- (m) => {
2292
- m.key === "Enter" && b();
2293
- },
2294
- [b]
2295
- ), T = M(() => v === Re.DUAL_PAGE && h === ee.PAGE_SCROLLING && e === t - 1 || e === t, [e, t, v, h]);
2296
- return typeof d != "boolean" ? /* @__PURE__ */ i(
2297
- d,
2298
- {
2299
- total: t,
2300
- current: e,
2301
- nextPage: o,
2302
- prevPage: r,
2303
- goToPage: a,
2304
- changePage: n
2305
- }
2306
- ) : d ? /* @__PURE__ */ D("div", { className: mt["rp-paginate"], children: [
2307
- !u && /* @__PURE__ */ i(K, { content: f == null ? void 0 : f.previousPageTooltip, children: /* @__PURE__ */ i(
2308
- re,
2309
- {
2310
- onClick: r,
2311
- "aria-label": f == null ? void 0 : f.previousPageTooltip,
2312
- "aria-disabled": e === 1,
2313
- children: /* @__PURE__ */ i(ci, {})
2314
- }
2315
- ) }),
2316
- /* @__PURE__ */ i(K, { content: f == null ? void 0 : f.currentPageTooltip, children: /* @__PURE__ */ i(
2317
- wn,
2318
- {
2319
- onKeyDown: P,
2320
- onBlur: S,
2321
- onChange: w,
2322
- value: l,
2323
- className: mt["rp-page-input"]
2324
- }
2325
- ) }),
2326
- /* @__PURE__ */ D("span", { className: mt["rp-total-page"], children: [
2327
- "/",
2328
- t
2329
- ] }),
2330
- !u && /* @__PURE__ */ i(K, { content: f == null ? void 0 : f.nextPageTooltip, children: /* @__PURE__ */ i(
2331
- re,
2332
- {
2333
- onClick: o,
2334
- "aria-label": f == null ? void 0 : f.nextPageTooltip,
2335
- "aria-disabled": T,
2336
- children: /* @__PURE__ */ i(li, {})
2337
- }
2338
- ) })
2339
- ] }) : null;
2340
- };
2341
- var Ot = "Dialog", [zn, Ks] = Ir(Ot), [ui, le] = zn(Ot), Dn = (e) => {
2342
- const {
2343
- __scopeDialog: t,
2344
- children: n,
2345
- open: o,
2346
- defaultOpen: r,
2347
- onOpenChange: a,
2348
- modal: l = !0
2349
- } = e, c = B.useRef(null), d = B.useRef(null), [u = !1, f] = Nr({
2350
- prop: o,
2351
- defaultProp: r,
2352
- onChange: a
2353
- });
2354
- return /* @__PURE__ */ i(
2355
- ui,
2356
- {
2357
- scope: t,
2358
- triggerRef: c,
2359
- contentRef: d,
2360
- contentId: ct(),
2361
- titleId: ct(),
2362
- descriptionId: ct(),
2363
- open: u,
2364
- onOpenChange: f,
2365
- onOpenToggle: B.useCallback(() => f((v) => !v), [f]),
2366
- modal: l,
2367
- children: n
2368
- }
2369
- );
2370
- };
2371
- Dn.displayName = Ot;
2372
- var An = "DialogTrigger", pi = B.forwardRef(
2373
- (e, t) => {
2374
- const { __scopeDialog: n, ...o } = e, r = le(An, n), a = Tt(t, r.triggerRef);
2375
- return /* @__PURE__ */ i(
2376
- qe.button,
2377
- {
2378
- type: "button",
2379
- "aria-haspopup": "dialog",
2380
- "aria-expanded": r.open,
2381
- "aria-controls": r.contentId,
2382
- "data-state": At(r.open),
2383
- ...o,
2384
- ref: a,
2385
- onClick: $e(e.onClick, r.onOpenToggle)
2386
- }
2387
- );
2388
- }
2389
- );
2390
- pi.displayName = An;
2391
- var zt = "DialogPortal", [hi, Fn] = zn(zt, {
2392
- forceMount: void 0
2393
- }), Wn = (e) => {
2394
- const { __scopeDialog: t, forceMount: n, children: o, container: r } = e, a = le(zt, t);
2395
- return /* @__PURE__ */ i(hi, { scope: t, forceMount: n, children: B.Children.map(o, (l) => /* @__PURE__ */ i(yt, { present: n || a.open, children: /* @__PURE__ */ i(Ar, { asChild: !0, container: r, children: l }) })) });
2396
- };
2397
- Wn.displayName = zt;
2398
- var Je = "DialogOverlay", kn = B.forwardRef(
2399
- (e, t) => {
2400
- const n = Fn(Je, e.__scopeDialog), { forceMount: o = n.forceMount, ...r } = e, a = le(Je, e.__scopeDialog);
2401
- return a.modal ? /* @__PURE__ */ i(yt, { present: o || a.open, children: /* @__PURE__ */ i(fi, { ...r, ref: t }) }) : null;
2402
- }
2403
- );
2404
- kn.displayName = Je;
2405
- var fi = B.forwardRef(
2406
- (e, t) => {
2407
- const { __scopeDialog: n, ...o } = e, r = le(Je, n);
2408
- return (
2409
- // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
2410
- // ie. when `Overlay` and `Content` are siblings
2411
- /* @__PURE__ */ i(Or, { as: Rr, allowPinchZoom: !0, shards: [r.contentRef], children: /* @__PURE__ */ i(
2412
- qe.div,
2413
- {
2414
- "data-state": At(r.open),
2415
- ...o,
2416
- ref: t,
2417
- style: { pointerEvents: "auto", ...o.style }
2418
- }
2419
- ) })
2420
- );
2421
- }
2422
- ), Le = "DialogContent", Mn = B.forwardRef(
2423
- (e, t) => {
2424
- const n = Fn(Le, e.__scopeDialog), { forceMount: o = n.forceMount, ...r } = e, a = le(Le, e.__scopeDialog);
2425
- return /* @__PURE__ */ i(yt, { present: o || a.open, children: a.modal ? /* @__PURE__ */ i(mi, { ...r, ref: t }) : /* @__PURE__ */ i(gi, { ...r, ref: t }) });
2426
- }
2427
- );
2428
- Mn.displayName = Le;
2429
- var mi = B.forwardRef(
2430
- (e, t) => {
2431
- const n = le(Le, e.__scopeDialog), o = B.useRef(null), r = Tt(t, n.contentRef, o);
2432
- return B.useEffect(() => {
2433
- const a = o.current;
2434
- if (a)
2435
- return Fr(a);
2436
- }, []), /* @__PURE__ */ i(
2437
- Hn,
2438
- {
2439
- ...e,
2440
- ref: r,
2441
- trapFocus: n.open,
2442
- disableOutsidePointerEvents: !0,
2443
- onCloseAutoFocus: $e(e.onCloseAutoFocus, (a) => {
2444
- var l;
2445
- a.preventDefault(), (l = n.triggerRef.current) == null || l.focus();
2446
- }),
2447
- onPointerDownOutside: $e(e.onPointerDownOutside, (a) => {
2448
- const l = a.detail.originalEvent, c = l.button === 0 && l.ctrlKey === !0;
2449
- (l.button === 2 || c) && a.preventDefault();
2450
- }),
2451
- onFocusOutside: $e(
2452
- e.onFocusOutside,
2453
- (a) => a.preventDefault()
2454
- )
2455
- }
2456
- );
2457
- }
2458
- ), gi = B.forwardRef(
2459
- (e, t) => {
2460
- const n = le(Le, e.__scopeDialog), o = B.useRef(!1), r = B.useRef(!1);
2461
- return /* @__PURE__ */ i(
2462
- Hn,
2463
- {
2464
- ...e,
2465
- ref: t,
2466
- trapFocus: !1,
2467
- disableOutsidePointerEvents: !1,
2468
- onCloseAutoFocus: (a) => {
2469
- var l, c;
2470
- (l = e.onCloseAutoFocus) == null || l.call(e, a), a.defaultPrevented || (o.current || (c = n.triggerRef.current) == null || c.focus(), a.preventDefault()), o.current = !1, r.current = !1;
2471
- },
2472
- onInteractOutside: (a) => {
2473
- var d, u;
2474
- (d = e.onInteractOutside) == null || d.call(e, a), a.defaultPrevented || (o.current = !0, a.detail.originalEvent.type === "pointerdown" && (r.current = !0));
2475
- const l = a.target;
2476
- ((u = n.triggerRef.current) == null ? void 0 : u.contains(l)) && a.preventDefault(), a.detail.originalEvent.type === "focusin" && r.current && a.preventDefault();
2477
- }
2478
- }
2479
- );
2480
- }
2481
- ), Hn = B.forwardRef(
2482
- (e, t) => {
2483
- const { __scopeDialog: n, trapFocus: o, onOpenAutoFocus: r, onCloseAutoFocus: a, ...l } = e, c = le(Le, n), d = B.useRef(null), u = Tt(t, d);
2484
- return zr(), /* @__PURE__ */ D(ie, { children: [
2485
- /* @__PURE__ */ i(
2486
- Dr,
2487
- {
2488
- asChild: !0,
2489
- loop: !0,
2490
- trapped: o,
2491
- onMountAutoFocus: r,
2492
- onUnmountAutoFocus: a,
2493
- children: /* @__PURE__ */ i(
2494
- Er,
2495
- {
2496
- role: "dialog",
2497
- id: c.contentId,
2498
- "aria-describedby": c.descriptionId,
2499
- "aria-labelledby": c.titleId,
2500
- "data-state": At(c.open),
2501
- ...l,
2502
- ref: u,
2503
- onDismiss: () => c.onOpenChange(!1)
2504
- }
2505
- )
2506
- }
2507
- ),
2508
- /* @__PURE__ */ D(ie, { children: [
2509
- /* @__PURE__ */ i(wi, { titleId: c.titleId }),
2510
- /* @__PURE__ */ i(bi, { contentRef: d, descriptionId: c.descriptionId })
2511
- ] })
2512
- ] });
2513
- }
2514
- ), Dt = "DialogTitle", $n = B.forwardRef(
2515
- (e, t) => {
2516
- const { __scopeDialog: n, ...o } = e, r = le(Dt, n);
2517
- return /* @__PURE__ */ i(qe.h2, { id: r.titleId, ...o, ref: t });
2518
- }
2519
- );
2520
- $n.displayName = Dt;
2521
- var Gn = "DialogDescription", vi = B.forwardRef(
2522
- (e, t) => {
2523
- const { __scopeDialog: n, ...o } = e, r = le(Gn, n);
2524
- return /* @__PURE__ */ i(qe.p, { id: r.descriptionId, ...o, ref: t });
2525
- }
2526
- );
2527
- vi.displayName = Gn;
2528
- var Un = "DialogClose", Vn = B.forwardRef(
2529
- (e, t) => {
2530
- const { __scopeDialog: n, ...o } = e, r = le(Un, n);
2531
- return /* @__PURE__ */ i(
2532
- qe.button,
2533
- {
2534
- type: "button",
2535
- ...o,
2536
- ref: t,
2537
- onClick: $e(e.onClick, () => r.onOpenChange(!1))
2538
- }
2539
- );
2540
- }
2541
- );
2542
- Vn.displayName = Un;
2543
- function At(e) {
2544
- return e ? "open" : "closed";
2545
- }
2546
- var qn = "DialogTitleWarning", [Xs, Bn] = Lr(qn, {
2547
- contentName: Le,
2548
- titleName: Dt,
2549
- docsSlug: "dialog"
2550
- }), wi = ({ titleId: e }) => {
2551
- const t = Bn(qn), n = `\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
2552
-
2553
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
2554
-
2555
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;
2556
- return B.useEffect(() => {
2557
- e && (document.getElementById(e) || console.error(n));
2558
- }, [n, e]), null;
2559
- }, _i = "DialogDescriptionWarning", bi = ({ contentRef: e, descriptionId: t }) => {
2560
- const o = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Bn(_i).contentName}}.`;
2561
- return B.useEffect(() => {
2562
- var a;
2563
- const r = (a = e.current) == null ? void 0 : a.getAttribute("aria-describedby");
2564
- t && r && (document.getElementById(t) || console.warn(o));
2565
- }, [o, e, t]), null;
2566
- }, Ci = Dn, Pi = Wn, Ti = kn, yi = Mn, Si = $n, xi = Vn;
2567
- const Ie = {
2568
- "rp-dialog-wrapper": "_rp-dialog-wrapper_slqo7_1",
2569
- "rp-dialog-overlay": "_rp-dialog-overlay_slqo7_7",
2570
- "rp-document-dialog": "_rp-document-dialog_slqo7_13",
2571
- "rp-document-properties": "_rp-document-properties_slqo7_35",
2572
- "rp-dialog-title": "_rp-dialog-title_slqo7_39",
2573
- "rp-dialog-close": "_rp-dialog-close_slqo7_47",
2574
- "rp-properties-divider": "_rp-properties-divider_slqo7_55"
2575
- }, Ii = () => {
2576
- const { pdfProperties: e } = X(), { container: t } = se(), { activeDocumentProperties: n, setActiveDocumentProperties: o } = Gr(), { localeMessages: r } = ce(), a = M(() => {
2577
- if (!e)
2578
- return [];
2579
- const {
2580
- fileSize: l,
2581
- filename: c,
2582
- title: d,
2583
- author: u,
2584
- subject: f,
2585
- createdOn: v,
2586
- creator: h,
2587
- keywords: w,
2588
- modifiedOn: b,
2589
- pdfProducer: S,
2590
- pdfVersion: P,
2591
- pageCount: T
2592
- } = e;
2593
- return [
2594
- { label: r == null ? void 0 : r.propertiesFilenameLabel, value: c },
2595
- { label: r == null ? void 0 : r.propertiesFileSizeLabel, value: l },
2596
- { separate: !0 },
2597
- { label: r == null ? void 0 : r.propertiesTitleLabel, value: d },
2598
- { label: r == null ? void 0 : r.propertiesAuthorLabel, value: u },
2599
- { label: r == null ? void 0 : r.propertiesSubjectLabel, value: f },
2600
- { label: r == null ? void 0 : r.propertiesKeywordLabel, value: w },
2601
- { label: r == null ? void 0 : r.propertiesCreatorLabel, value: h },
2602
- {
2603
- label: r == null ? void 0 : r.propertiesCreateOnLabel,
2604
- value: v ? Mt(v) : ""
2605
- },
2606
- {
2607
- label: r == null ? void 0 : r.propertiesModifiedOnLabel,
2608
- value: b ? Mt(b) : ""
2609
- },
2610
- { separate: !0 },
2611
- { label: r == null ? void 0 : r.propertiesPDFProducerLabel, value: S },
2612
- { label: r == null ? void 0 : r.propertiesPDFVersionLabel, value: P },
2613
- { label: r == null ? void 0 : r.propertiesPageCountLabel, value: T }
2614
- ];
2615
- }, [e, r]);
2616
- return /* @__PURE__ */ i(Ci, { open: n, onOpenChange: o, children: /* @__PURE__ */ i(Pi, { container: t, children: /* @__PURE__ */ D("div", { className: Ie["rp-dialog-wrapper"], children: [
2617
- /* @__PURE__ */ i(Ti, { className: Ie["rp-dialog-overlay"] }),
2618
- /* @__PURE__ */ D(yi, { className: Ie["rp-document-dialog"], children: [
2619
- /* @__PURE__ */ i(Si, { className: Ie["rp-dialog-title"], children: r == null ? void 0 : r.documentPropertiesLabel }),
2620
- /* @__PURE__ */ i("div", { className: Ie["rp-document-properties"], children: a.map((l, c) => /* @__PURE__ */ i("div", { children: l.separate ? /* @__PURE__ */ i("div", { className: Ie["rp-properties-divider"] }) : /* @__PURE__ */ i(Ur, { label: l.label, value: l.value }) }, c)) }),
2621
- /* @__PURE__ */ i(xi, { asChild: !0, className: Ie["rp-dialog-close"], children: /* @__PURE__ */ i(Wr, {}) })
2622
- ] })
2623
- ] }) }) });
2624
- }, Ri = {
2625
- "rp-other-tool-content": "_rp-other-tool-content_su718_1"
2626
- }, sn = ".pdf", Li = (e) => URL.createObjectURL(e), Ni = async (e) => {
2627
- const n = await (await fetch(e)).blob();
2628
- return Li(n);
2629
- }, Zn = () => {
2630
- const { filename: e, pdfSrc: t } = X(), { downloadFilename: n } = Pr(), o = (a) => {
2631
- const l = n || a;
2632
- return l.endsWith(sn) ? l : `${l}${sn}`;
2633
- };
2634
- return { download: E(async () => {
2635
- if (!e || !t)
2636
- throw new Error("There is no PDF source to download");
2637
- const a = document.createElement("a");
2638
- a.href = await Ni(t), a.download = o(e), document.body.appendChild(a), a.click(), document.body.removeChild(a);
2639
- }, [e, t]) };
2640
- }, jn = () => {
2641
- const { downloadIcon: e } = he();
2642
- return e || /* @__PURE__ */ i(jr, {});
2643
- }, Kn = ({ children: e, className: t, localeMessages: n }) => /* @__PURE__ */ i(K, { className: t, content: n == null ? void 0 : n.downloadFileTooltip, children: e }), Ei = ({ download: e, localeMessages: t }) => /* @__PURE__ */ i(Kn, { localeMessages: t, children: /* @__PURE__ */ i(re, { onClick: e, "aria-label": t == null ? void 0 : t.downloadFileTooltip, children: /* @__PURE__ */ i(jn, {}) }) }), Oi = ({ download: e, localeMessages: t }) => /* @__PURE__ */ i(Ce, { onClick: e, children: /* @__PURE__ */ D(Kn, { className: "rp-menu-item", localeMessages: t, children: [
2644
- /* @__PURE__ */ i("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ i(jn, {}) }),
2645
- t == null ? void 0 : t.downloadFileLabel
2646
- ] }) }), Xn = () => {
2647
- const { download: e } = Zn(), { downloadTool: t = !0 } = fe(), { isSmallScreen: n } = Pe(), { localeMessages: o } = ce();
2648
- return t ? n ? /* @__PURE__ */ i(Oi, { download: e, localeMessages: o }) : typeof t == "function" ? /* @__PURE__ */ i(t, { download: e }) : t ? /* @__PURE__ */ i(Ei, { download: e, localeMessages: o }) : null : null;
2649
- }, Yn = () => {
2650
- const { printIcon: e } = he();
2651
- return e || /* @__PURE__ */ i(Kr, {});
2652
- }, Jn = ({ children: e, className: t, localeMessages: n }) => /* @__PURE__ */ i(K, { className: t, content: n == null ? void 0 : n.printTooltip, children: e }), zi = ({ print: e, localeMessages: t }) => /* @__PURE__ */ i(Jn, { localeMessages: t, children: /* @__PURE__ */ i(re, { onClick: e, "aria-label": t == null ? void 0 : t.printTooltip, children: /* @__PURE__ */ i(Yn, {}) }) }), Di = ({ print: e, localeMessages: t }) => /* @__PURE__ */ i(Ce, { onClick: e, children: /* @__PURE__ */ D(Jn, { className: "rp-menu-item", localeMessages: t, children: [
2653
- /* @__PURE__ */ i("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ i(Yn, {}) }),
2654
- t == null ? void 0 : t.printLabel
2655
- ] }) }), Qn = () => {
2656
- const { print: e, cancel: t, setOnProgress: n, setOnComplete: o, setOnError: r, progress: a } = Be(), { printTool: l = !0 } = fe(), { isSmallScreen: c } = Pe(), { localeMessages: d } = ce();
2657
- return l ? c ? /* @__PURE__ */ i(Di, { print: e, localeMessages: d }) : typeof l == "function" ? /* @__PURE__ */ i(
2658
- l,
2659
- {
2660
- print: e,
2661
- cancel: t,
2662
- setOnProgress: n,
2663
- setOnError: r,
2664
- setOnComplete: o,
2665
- progress: a
2666
- }
2667
- ) : l ? /* @__PURE__ */ i(zi, { print: e, localeMessages: d }) : null : null;
2668
- }, Ai = {
2669
- "rp-go-to-Top": "_rp-go-to-Top_4e0yd_1"
2670
- }, Fi = () => {
2671
- const { goToFirstPageIcon: e } = he();
2672
- return e || /* @__PURE__ */ i(yn, { className: Ai["rp-go-to-Top"] });
2673
- }, Wi = () => {
2674
- const { goToLastPageIcon: e } = he();
2675
- return e || /* @__PURE__ */ i(yn, {});
2676
- }, cn = { width: "100%" }, ki = () => {
2677
- const { goToPage: e, totalPages: t, focusedPage: n } = ae(), { jumpNavigationTool: o = !0 } = fe(), { localeMessages: r } = ce(), a = M(() => n === 1, [n]), l = M(() => n === t, [n, t]), c = E(() => {
2678
- e(1);
2679
- }, [e]), d = E(() => {
2680
- e(t);
2681
- }, [e, t]);
2682
- return o ? /* @__PURE__ */ D(Ye, { children: [
2683
- /* @__PURE__ */ i(Ce, { onClick: c, children: /* @__PURE__ */ i(K, { content: r == null ? void 0 : r.firstPageTooltip, style: cn, children: /* @__PURE__ */ D("div", { className: "rp-menu-item", "aria-disabled": a, children: [
2684
- /* @__PURE__ */ i("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ i(Fi, {}) }),
2685
- /* @__PURE__ */ i("span", { children: r == null ? void 0 : r.firstPageLabel })
2686
- ] }) }) }),
2687
- /* @__PURE__ */ i(Ce, { onClick: d, children: /* @__PURE__ */ i(K, { content: r == null ? void 0 : r.lastPageTooltip, style: cn, children: /* @__PURE__ */ D("div", { className: "rp-menu-item", "aria-disabled": l, children: [
2688
- /* @__PURE__ */ i("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ i(Wi, {}) }),
2689
- /* @__PURE__ */ i("span", { children: r == null ? void 0 : r.lastPageLabel })
2690
- ] }) }) }),
2691
- /* @__PURE__ */ i(xt, {})
2692
- ] }) : null;
2693
- }, Mi = () => {
2694
- const { container: e, pagesRef: t } = se(), { isSmallScreen: n } = Pe(), {
2695
- openFileTool: o,
2696
- downloadTool: r,
2697
- documentProperties: a,
2698
- scrollModeTool: l,
2699
- rotateTool: c,
2700
- selectionModeTool: d,
2701
- jumpNavigationTool: u,
2702
- printTool: f,
2703
- fullscreenTool: v
2704
- } = fe(), { localeMessages: h } = ce(), [w, b] = G(0), S = H(
2705
- new ResizeObserver((T) => {
2706
- b(T[0].contentRect.height);
2707
- })
2708
- ), P = M(() => {
2709
- const T = u || c || d || l || a;
2710
- let m = !1;
2711
- return n && (m = !(!o && !r && !f && !v)), T || m;
2712
- }, [
2713
- o,
2714
- r,
2715
- a,
2716
- l,
2717
- c,
2718
- d,
2719
- u,
2720
- n
2721
- ]);
2722
- return W(() => (t && S.current.observe(t), () => {
2723
- S.current.disconnect();
2724
- }), [t]), P ? /* @__PURE__ */ D(ie, { children: [
2725
- /* @__PURE__ */ i(
2726
- bn,
2727
- {
2728
- container: e,
2729
- triggerComponent: /* @__PURE__ */ i("div", { role: "button", children: /* @__PURE__ */ i(K, { content: h == null ? void 0 : h.moreOptionTooltip, children: /* @__PURE__ */ i(re, { "aria-label": h == null ? void 0 : h.moreOptionTooltip, children: /* @__PURE__ */ i(xr, {}) }) }) }),
2730
- side: "bottom",
2731
- avoidCollisions: !1,
2732
- children: /* @__PURE__ */ D(
2733
- "div",
2734
- {
2735
- style: { maxHeight: `${w}px`, overflow: "auto" },
2736
- className: Ri["rp-other-tool-content"],
2737
- "data-rp": "moreOptionsDropdown",
2738
- children: [
2739
- n && /* @__PURE__ */ D(Ye, { children: [
2740
- /* @__PURE__ */ i(_n, {}),
2741
- /* @__PURE__ */ i(Xn, {}),
2742
- /* @__PURE__ */ i(Qn, {}),
2743
- /* @__PURE__ */ i(Tn, {}),
2744
- /* @__PURE__ */ i(xt, {})
2745
- ] }),
2746
- /* @__PURE__ */ i(ki, {}),
2747
- /* @__PURE__ */ i(qr, {}),
2748
- /* @__PURE__ */ i(Xr, {}),
2749
- /* @__PURE__ */ i(Br, {}),
2750
- /* @__PURE__ */ i(Zr, {}),
2751
- /* @__PURE__ */ i(Vr, {})
2752
- ]
2753
- }
2754
- )
2755
- }
2756
- ),
2757
- /* @__PURE__ */ i(Ii, {})
2758
- ] }) : null;
2759
- }, Hi = () => {
2760
- const { isSmallScreen: e } = Pe();
2761
- return /* @__PURE__ */ D(ie, { children: [
2762
- /* @__PURE__ */ i(Sr, {}),
2763
- !e && /* @__PURE__ */ D(ie, { children: [
2764
- /* @__PURE__ */ i(_n, {}),
2765
- /* @__PURE__ */ i(Xn, {}),
2766
- /* @__PURE__ */ i(Qn, {}),
2767
- /* @__PURE__ */ i(Tn, {})
2768
- ] }),
2769
- /* @__PURE__ */ i(Mi, {})
2770
- ] });
2771
- }, ze = {
2772
- "rp-zoom-wrapper": "_rp-zoom-wrapper_1113m_1",
2773
- "rp-current-zoom-wrapper": "_rp-current-zoom-wrapper_1113m_6",
2774
- "rp-current-zoom-icon": "_rp-current-zoom-icon_1113m_11",
2775
- "rp-zoom-level-icon": "_rp-zoom-level-icon_1113m_16",
2776
- "rp-current-zoom-text": "_rp-current-zoom-text_1113m_20",
2777
- "rp-zoom-dropdown-content": "_rp-zoom-dropdown-content_1113m_24"
2778
- }, $i = 25, gt = 1e3, Gi = [50, 75, 100, 125, 150, 200, 300, 400], Ui = () => {
2779
- const { zoomInIcon: e } = he();
2780
- return e || /* @__PURE__ */ i(Yr, {});
2781
- }, Vi = () => {
2782
- const { zoomOutIcon: e } = he();
2783
- return e || /* @__PURE__ */ i(Jr, {});
2784
- }, qi = () => {
2785
- const { zoomLevel: e, setZoomLevel: t } = tt(), { container: n, pagesRef: o } = se(), { zoomTool: r = !0 } = fe(), { focusedPage: a } = ae(), { pageRotate: l } = Ve(), { pages: c } = X(), { isSmallScreen: d } = Pe(), { localeMessages: u } = ce(), { viewMode: f } = Ee(), [v, h] = G(0), w = H(
2786
- new ResizeObserver((s) => {
2787
- h(s[0].contentRect.height);
2788
- })
2789
- ), b = E(() => {
2790
- t((s) => {
2791
- const _ = Math.floor(s / 25) * 25;
2792
- return Math.min(_ + 25, gt);
2793
- });
2794
- }, [t]), S = E(() => {
2795
- t((s) => {
2796
- const _ = Math.ceil(s / 25) * 25;
2797
- return Math.min(_ - 25, gt);
2798
- });
2799
- }, [t]), P = M(() => e <= $i, [e]), T = M(() => e >= gt, [e]), m = M(() => {
2800
- const s = c.get(a);
2801
- return s ? s.page.getViewport({ scale: 1, rotation: l[a] }) : null;
2802
- }, [c, a, l]), p = E(
2803
- (s) => {
2804
- const _ = ((m == null ? void 0 : m.width) || 0) + 2 * Gt, C = ((m == null ? void 0 : m.height) || 0) + 2 * Gt, y = (o == null ? void 0 : o.clientWidth) || 0, L = (o == null ? void 0 : o.clientHeight) || 0, x = Qr(
2805
- s,
2806
- y,
2807
- L,
2808
- _,
2809
- C,
2810
- f
2811
- );
2812
- t(x);
2813
- },
2814
- [t, m, o]
2815
- ), g = E(
2816
- (s) => {
2817
- typeof s == "number" ? t(s) : p(s);
2818
- },
2819
- [t, p]
2820
- );
2821
- return W(() => (o && w.current.observe(o), () => {
2822
- w.current.disconnect();
2823
- }), [o]), typeof r != "boolean" ? /* @__PURE__ */ i(r, { zoomLevel: e, setZoomLevel: t }) : r ? /* @__PURE__ */ D("div", { className: ze["rp-zoom-wrapper"], children: [
2824
- /* @__PURE__ */ i(K, { content: u == null ? void 0 : u.zoomOutTooltip, children: /* @__PURE__ */ i(
2825
- re,
2826
- {
2827
- disabled: P,
2828
- onClick: S,
2829
- "aria-label": u == null ? void 0 : u.zoomOutTooltip,
2830
- children: /* @__PURE__ */ i(Vi, {})
2831
- }
2832
- ) }),
2833
- !d && /* @__PURE__ */ i(
2834
- bn,
2835
- {
2836
- container: n,
2837
- triggerComponent: /* @__PURE__ */ i("div", { role: "button", children: /* @__PURE__ */ i(K, { content: u == null ? void 0 : u.zoomSelectTooltip, children: /* @__PURE__ */ D(
2838
- re,
2839
- {
2840
- className: ze["rp-current-zoom-wrapper"],
2841
- "aria-label": u == null ? void 0 : u.zoomSelectTooltip,
2842
- children: [
2843
- /* @__PURE__ */ i("span", { className: ze["rp-current-zoom-text"], children: e }),
2844
- /* @__PURE__ */ i("span", { className: ze["rp-current-zoom-text"], children: "%" }),
2845
- /* @__PURE__ */ i(Ge, { className: ze["rp-current-zoom-icon"] })
2846
- ]
2847
- }
2848
- ) }) }),
2849
- style: { minWidth: "200px" },
2850
- align: "center",
2851
- side: "bottom",
2852
- avoidCollisions: !1,
2853
- children: /* @__PURE__ */ D(
2854
- "div",
2855
- {
2856
- style: { maxHeight: `${v}px`, overflow: "auto" },
2857
- className: ze["rp-zoom-dropdown-content"],
2858
- children: [
2859
- /* @__PURE__ */ D(Ye, { children: [
2860
- /* @__PURE__ */ i(Ce, { onClick: () => g(st.ACTUAL), children: u == null ? void 0 : u.zoomActualSize }),
2861
- /* @__PURE__ */ i(Ce, { onClick: () => g(st.PAGE_FIT), children: u == null ? void 0 : u.zoomPageFit }),
2862
- /* @__PURE__ */ i(Ce, { onClick: () => g(st.PAGE_WIDTH), children: u == null ? void 0 : u.zoomPageWidth })
2863
- ] }),
2864
- /* @__PURE__ */ i(xt, {}),
2865
- /* @__PURE__ */ i(Ye, { children: Gi.map((s) => /* @__PURE__ */ D(Ce, { onClick: () => g(s), children: [
2866
- s,
2867
- " %"
2868
- ] }, s)) })
2869
- ]
2870
- }
2871
- )
2872
- }
2873
- ),
2874
- /* @__PURE__ */ i(K, { content: u == null ? void 0 : u.zoomInTooltip, children: /* @__PURE__ */ i(
2875
- re,
2876
- {
2877
- disabled: T,
2878
- onClick: b,
2879
- "aria-label": u == null ? void 0 : u.zoomInTooltip,
2880
- children: /* @__PURE__ */ i(Ui, {})
2881
- }
2882
- ) })
2883
- ] }) : null;
2884
- }, ln = () => {
2885
- const {
2886
- totalMatches: e,
2887
- nextMatch: t,
2888
- prevMatch: n
2889
- } = Lt(), { localeMessages: o } = ce();
2890
- return /* @__PURE__ */ D(ie, { children: [
2891
- /* @__PURE__ */ i(K, { content: o == null ? void 0 : o.searchPrevTooltip, className: Q["rp-search-tool-result-navigator"], children: /* @__PURE__ */ i(re, { onClick: n, "aria-label": o == null ? void 0 : o.searchPrevTooltip, children: /* @__PURE__ */ i(
2892
- Ge,
2893
- {
2894
- className: Q["rp-search-tool-input-icon"],
2895
- "aria-disabled": !e
2896
- }
2897
- ) }) }),
2898
- /* @__PURE__ */ i(K, { content: o == null ? void 0 : o.searchNextTooltip, className: Q["rp-search-tool-result-navigator"], children: /* @__PURE__ */ i(re, { onClick: t, "aria-label": o == null ? void 0 : o.searchNextTooltip, children: /* @__PURE__ */ i(
2899
- Ge,
2900
- {
2901
- style: { transform: "rotate(180deg" },
2902
- className: Q["rp-search-tool-input-icon"],
2903
- "aria-disabled": !e
2904
- }
2905
- ) }) })
2906
- ] });
2907
- }, dn = () => {
2908
- const { searchIcon: e } = he();
2909
- return e || /* @__PURE__ */ i(eo, {});
2910
- }, Bi = ({ icon: e }) => {
2911
- const { container: t } = se(), [n, o] = G(!1), { pdf: r } = X(), [a, l] = G(null), {
2912
- searchOptions: c,
2913
- setSearchOptions: d,
2914
- loading: u,
2915
- setSearch: f,
2916
- totalMatches: v,
2917
- currentMatchPosition: h,
2918
- nextMatch: w,
2919
- prevMatch: b,
2920
- search: S
2921
- } = Lt(), { searchTool: P = !0 } = fe(), [T, m] = G(S), { localeMessages: p } = ce(), { isSmallScreen: g } = Pe(), s = E(() => {
2922
- o(!0);
2923
- }, []), _ = E(() => {
2924
- f(""), m(""), o(!1);
2925
- }, [f]), C = (N) => {
2926
- const k = N.key === "Enter", $ = N.key === " ";
2927
- (k || $) && _();
2928
- }, y = E(
2929
- (N) => {
2930
- N.key === "Escape" && n && _();
2931
- },
2932
- [n]
2933
- ), L = E(
2934
- (N) => {
2935
- N.shiftKey && N.key === "Enter" ? b() : N.key === "Enter" && S !== T ? f(T) : N.key === "Enter" && w();
2936
- },
2937
- [T, b, w, f, S]
2938
- );
2939
- W(() => (window.addEventListener("keydown", y), () => {
2940
- window.removeEventListener("keydown", y);
2941
- }), [y]), W(() => {
2942
- a && a.focus();
2943
- }, [a]);
2944
- const x = E((N) => {
2945
- m(N.target.value);
2946
- }, []), I = E(() => {
2947
- m(""), f("");
2948
- }, [f]), z = M(() => `${h} / ${v}`, [h, v]), { wholeWords: A, matchCase: F } = M(() => c, [c]), R = E(
2949
- (N) => {
2950
- d((k) => ({ ...k, matchCase: N }));
2951
- },
2952
- [d]
2953
- ), O = E(
2954
- (N) => {
2955
- d((k) => ({ ...k, wholeWords: N }));
2956
- },
2957
- [d]
2958
- );
2959
- return W(() => {
2960
- _();
2961
- }, [r, _]), P ? /* @__PURE__ */ i(ie, { children: /* @__PURE__ */ i(
2962
- $r,
2963
- {
2964
- open: n,
2965
- container: t,
2966
- triggerComponent: /* @__PURE__ */ i(K, { content: p == null ? void 0 : p.searchButtonTooltip, children: /* @__PURE__ */ i(re, { onClick: s, "aria-label": p == null ? void 0 : p.searchButtonTooltip, children: e || /* @__PURE__ */ i(dn, {}) }) }),
2967
- children: /* @__PURE__ */ D("div", { className: Q["rp-search-tool-content"], children: [
2968
- /* @__PURE__ */ D("div", { className: Q["rp-search-tool-input-wrapper"], children: [
2969
- /* @__PURE__ */ D("div", { className: Q["rp-search-tool-input"], children: [
2970
- /* @__PURE__ */ i(K, { content: p == null ? void 0 : p.searchInputTooltip, children: /* @__PURE__ */ i(
2971
- wn,
2972
- {
2973
- value: T,
2974
- onKeyDown: L,
2975
- onChange: x,
2976
- icon: /* @__PURE__ */ i(dn, {}),
2977
- placeholder: p == null ? void 0 : p.searchInputPlaceholder,
2978
- className: Q["rp-search-input"],
2979
- ref: l,
2980
- children: !!T && /* @__PURE__ */ i("span", { className: Q["rp-search-tool-input-clear"], onClick: I, children: /* @__PURE__ */ i(to, {}) })
2981
- }
2982
- ) }),
2983
- u ? /* @__PURE__ */ i("span", { children: /* @__PURE__ */ i(St, { className: Q["rp-search-loader-icon"] }) }) : /* @__PURE__ */ i("span", { children: z }),
2984
- g && /* @__PURE__ */ i("div", { className: Q["rp-search-tool-controls"], children: /* @__PURE__ */ i(Ht, { onKeyPress: C, handleClose: _ }) })
2985
- ] }),
2986
- /* @__PURE__ */ D("div", { className: Q["rp-search-tool-input-checkboxes"], children: [
2987
- g && /* @__PURE__ */ i(ln, {}),
2988
- /* @__PURE__ */ i($t, { name: "matchCase", value: F, onChange: R, children: p == null ? void 0 : p.searchMatchCaseLabel }),
2989
- !g && /* @__PURE__ */ i(K, { content: p == null ? void 0 : p.searchMatchCaseTooltip, children: /* @__PURE__ */ i("div", { className: Q["rp-search-icon-info"], tabIndex: 0, children: /* @__PURE__ */ i(Ut, {}) }) }),
2990
- /* @__PURE__ */ i($t, { name: "wholeWord", value: A, onChange: O, children: p == null ? void 0 : p.searchWholeWordsLabel }),
2991
- !g && /* @__PURE__ */ i(K, { content: p == null ? void 0 : p.searchWholeWordsTooltip, children: /* @__PURE__ */ i("div", { className: Q["rp-search-icon-info"], tabIndex: 0, children: /* @__PURE__ */ i(Ut, {}) }) })
2992
- ] })
2993
- ] }),
2994
- !g && /* @__PURE__ */ D("div", { className: Q["rp-search-tool-controls"], children: [
2995
- /* @__PURE__ */ i(ln, {}),
2996
- /* @__PURE__ */ i(Ht, { onKeyPress: C, handleClose: _ })
2997
- ] })
2998
- ] })
2999
- }
3000
- ) }) : null;
3001
- }, Zi = "_loading_wazy2_1", De = {
3002
- "rp-loading-overlay": "_rp-loading-overlay_wazy2_1",
3003
- "rp-loading-modal": "_rp-loading-modal_wazy2_14",
3004
- "rp-loading-title": "_rp-loading-title_wazy2_27",
3005
- "rp-loading-progress-bar": "_rp-loading-progress-bar_wazy2_35",
3006
- "rp-loading-progress": "_rp-loading-progress_wazy2_35",
3007
- "rp-loading-cancel-button": "_rp-loading-cancel-button_wazy2_55",
3008
- loading: Zi
3009
- }, er = ({ percentage: e }) => {
3010
- const { cancel: t } = Be(), { localeMessages: n } = ce();
3011
- return e < 1 ? null : /* @__PURE__ */ i("div", { className: ne(De["rp-loading-overlay"]), children: /* @__PURE__ */ D("div", { className: ne(De["rp-loading-modal"]), children: [
3012
- /* @__PURE__ */ D("div", { className: ne(De["rp-loading-title"]), children: [
3013
- n == null ? void 0 : n.printLoadingMessage,
3014
- "..."
3015
- ] }),
3016
- /* @__PURE__ */ i("div", { className: ne(De["rp-loading-progress-bar"]), children: /* @__PURE__ */ i(
3017
- "div",
3018
- {
3019
- className: ne(De["rp-loading-progress"]),
3020
- style: { width: `${e}%` }
3021
- }
3022
- ) }),
3023
- /* @__PURE__ */ i("button", { className: ne(De["rp-loading-cancel-button"]), onClick: t, children: n == null ? void 0 : n.printCancelLabel })
3024
- ] }) });
3025
- }, ji = We((e, t) => {
3026
- const { showPrintProgress: n } = fe(), { progress: o } = Be(), { isSmallScreen: r } = Pe(), { percentage: a } = o || {}, l = () => r ? { gridTemplateColumns: "25% 60% 15%" } : void 0;
3027
- return /* @__PURE__ */ D("div", { children: [
3028
- /* @__PURE__ */ i("div", { "data-rp": "topBar", ref: t, className: Me["rp-toolbar-content"], children: /* @__PURE__ */ D("div", { className: Me["rp-toolbar-wrapper"], style: l(), children: [
3029
- /* @__PURE__ */ D("div", { "data-rp": "topBarLeft", className: Me["rp-toolbar-start"], children: [
3030
- /* @__PURE__ */ i(Bi, {}),
3031
- /* @__PURE__ */ i(di, {})
3032
- ] }),
3033
- /* @__PURE__ */ i("div", { "data-rp": "topBarCenter", className: Me["rp-toolbar-middle"], children: /* @__PURE__ */ i(qi, {}) }),
3034
- /* @__PURE__ */ i("div", { "data-rp": "topBarRight", className: Me["rp-toolbar-end"], children: /* @__PURE__ */ i(Hi, {}) })
3035
- ] }) }),
3036
- n && a ? /* @__PURE__ */ i(er, { percentage: a }) : null
3037
- ] });
3038
- }), vt = {
3039
- "rp-sidebar-content-wrapper": "_rp-sidebar-content-wrapper_1sdl6_1",
3040
- "rp-sidebar-content": "_rp-sidebar-content_1sdl6_1",
3041
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_1sdl6_16",
3042
- "rp-thumbnail-dragging": "_rp-thumbnail-dragging_1sdl6_21"
3043
- }, He = {
3044
- "rp-thumbnail-wrapper": "_rp-thumbnail-wrapper_3fenb_1",
3045
- "rp-thumbnail-text": "_rp-thumbnail-text_3fenb_10",
3046
- "rp-thumbnail": "_rp-thumbnail_3fenb_1",
3047
- "rp-thumbnail-active": "_rp-thumbnail-active_3fenb_22",
3048
- "rp-thumbnail-loader": "_rp-thumbnail-loader_3fenb_31"
3049
- }, Ki = (e) => {
3050
- const { thumbnailSrc: t, pageNumber: n, isFocused: o, viewport: r } = e, { goToPage: a } = ae(), { pageRotate: l } = Ve(), c = M(() => o ? He["rp-thumbnail-active"] : "", [o]), d = M(() => ({
3051
- width: Math.round(r.width),
3052
- height: Math.round(r.height)
3053
- }), [r]), u = E(() => {
3054
- n && a(n);
3055
- }, [a, n]);
3056
- return /* @__PURE__ */ D(
3057
- "div",
3058
- {
3059
- onClick: u,
3060
- id: `page-${n}`,
3061
- className: He["rp-thumbnail-wrapper"],
3062
- children: [
3063
- /* @__PURE__ */ i(
3064
- "div",
3065
- {
3066
- style: {
3067
- transform: `rotate(${l[n || 0]}deg)`
3068
- },
3069
- className: ne(c, He["rp-thumbnail"]),
3070
- children: t ? /* @__PURE__ */ i(
3071
- "img",
3072
- {
3073
- src: t,
3074
- width: d.width,
3075
- height: d.height,
3076
- alt: "thumbnail"
3077
- }
3078
- ) : /* @__PURE__ */ i(
3079
- "div",
3080
- {
3081
- className: He["rp-thumbnail-loader"],
3082
- style: {
3083
- width: `${d.width}px`,
3084
- height: `${d.height}px`
3085
- },
3086
- children: /* @__PURE__ */ i(St, {})
3087
- }
3088
- )
3089
- }
3090
- ),
3091
- /* @__PURE__ */ i("div", { className: He["rp-thumbnail-text"], children: n })
3092
- ]
3093
- }
3094
- );
3095
- }, un = {
3096
- "rp-thumbnails-container": "_rp-thumbnails-container_16vqr_1",
3097
- "rp-thumbnails": "_rp-thumbnails_16vqr_1"
3098
- }, Xi = 16, Yi = (e, t) => {
3099
- const n = e == null ? void 0 : e.querySelector(`#page-${t}`);
3100
- e && (n != null && n.offsetTop) && (e.scrollTop = (n == null ? void 0 : n.offsetTop) - Xi);
3101
- }, tr = We((e, t) => {
3102
- const { show: n } = e, { focusedPage: o, totalPages: r } = ae(), { thumbnailPages: a, addPage: l, thumbnailLength: c, addToPage: d } = Rt(), u = H(null), f = H(1);
3103
- pn(t, () => u.current);
3104
- const v = M(() => Object.values(a), [a]), h = E(() => {
3105
- const w = c + 1;
3106
- w <= r && l(w);
3107
- }, [l, r, c]);
3108
- return W(() => {
3109
- o > c ? d(o) : n && f.current !== o && (Yi(u.current, o), f.current = o);
3110
- }, [o, c, d, n, v]), kr(u.current, h), /* @__PURE__ */ i("div", { ref: u, className: un["rp-thumbnails-container"], children: /* @__PURE__ */ i("div", { className: un["rp-thumbnails"], children: n ? v.map((w, b) => {
3111
- var S, P;
3112
- return /* @__PURE__ */ i(
3113
- Ki,
3114
- {
3115
- isFocused: o === ((S = w.page) == null ? void 0 : S.pageNumber),
3116
- pageNumber: (P = w.page) == null ? void 0 : P.pageNumber,
3117
- thumbnailSrc: w.thumbnailSrc,
3118
- loading: w.loading,
3119
- viewport: w.viewport,
3120
- defaultRotation: w.defaultRotation
3121
- },
3122
- b
3123
- );
3124
- }) : null }) });
3125
- }), Ji = () => {
3126
- const { thumbnailIcon: e } = he();
3127
- return e || /* @__PURE__ */ i(no, {});
3128
- }, Qi = () => {
3129
- const { active: e, setActive: t } = Rt(), [n, o] = G(200), r = H(null), { thumbnailTool: a, sidebarEnable: l } = fe(), { localeMessages: c } = ce(), d = E(() => {
3130
- t((f) => !f);
3131
- }, []), u = M(() => typeof a != "boolean" && a ? /* @__PURE__ */ i(a, { onClick: d, active: e }) : a ? /* @__PURE__ */ i(K, { content: c == null ? void 0 : c.thumbnailTooltip, children: /* @__PURE__ */ i(
3132
- re,
3133
- {
3134
- onClick: d,
3135
- active: e,
3136
- "aria-label": c == null ? void 0 : c.thumbnailTooltip,
3137
- children: /* @__PURE__ */ i(Ji, {})
3138
- }
3139
- ) }) : null, [a, e, d, c]);
3140
- return /* @__PURE__ */ i(ie, { children: l && /* @__PURE__ */ D(
3141
- "div",
3142
- {
3143
- style: { "--rp-thumbnail-width": `${n}px` },
3144
- className: vt["rp-sidebar-content-wrapper"],
3145
- "data-rp": "sidebar",
3146
- children: [
3147
- /* @__PURE__ */ i("div", { className: vt["rp-sidebar-content"], children: u }),
3148
- /* @__PURE__ */ D(
3149
- "div",
3150
- {
3151
- "data-rp": "thumbnailSidebar",
3152
- hidden: !e,
3153
- className: vt["rp-thumbnails-wrapper"],
3154
- children: [
3155
- /* @__PURE__ */ i(tr, { show: e, ref: r }),
3156
- /* @__PURE__ */ i(ro, { onWidthChange: o, thumbnailRef: r })
3157
- ]
3158
- }
3159
- )
3160
- ]
3161
- }
3162
- ) });
3163
- }, Ys = We((e, t) => {
3164
- const {
3165
- children: n,
3166
- slots: o,
3167
- icons: r,
3168
- style: a,
3169
- className: l,
3170
- mobileWidth: c,
3171
- onLoaded: d,
3172
- cleanupOnLoaded: u,
3173
- onLayoutWidthChange: f
3174
- } = e, [v, h] = G(null), { setContainer: w, setContentRef: b } = se(), { loading: S } = X(), { LoaderImageComponent: P } = Pt();
3175
- return W(() => (d && d(), () => {
3176
- u && u();
3177
- }), [d, u]), /* @__PURE__ */ i(Et, { toolbarRef: v, ref: t, children: /* @__PURE__ */ i(mn, { mobileWidth: c, onLayoutWidthChange: f, children: /* @__PURE__ */ i(yr, { slots: o, children: /* @__PURE__ */ i(Tr, { icons: r, children: /* @__PURE__ */ i(Cn, { children: /* @__PURE__ */ D(fn, { getContainerRef: w, style: a, className: l, children: [
3178
- /* @__PURE__ */ D(Pn, { children: [
3179
- /* @__PURE__ */ D("div", { className: ve["rp-layout"], children: [
3180
- /* @__PURE__ */ i(ji, { ref: h }),
3181
- /* @__PURE__ */ D("div", { className: ve["rp-content"], children: [
3182
- /* @__PURE__ */ i("div", { className: ve["rp-sidebar"], children: /* @__PURE__ */ i(Qi, {}) }),
3183
- /* @__PURE__ */ i("div", { ref: b, className: ve["rp-pages"], children: n })
3184
- ] })
3185
- ] }),
3186
- /* @__PURE__ */ i(Mr, {})
3187
- ] }),
3188
- S ? /* @__PURE__ */ i(
3189
- "div",
3190
- {
3191
- className: ve["rp-loader"],
3192
- style: {
3193
- position: "absolute",
3194
- top: 0,
3195
- left: 0,
3196
- right: 0,
3197
- bottom: 0,
3198
- width: "100%",
3199
- height: "100%"
3200
- },
3201
- children: /* @__PURE__ */ i(
3202
- "div",
3203
- {
3204
- style: {
3205
- display: "flex",
3206
- justifyContent: "center",
3207
- alignItems: "center",
3208
- height: "100%",
3209
- width: "100%"
3210
- },
3211
- children: P && /* @__PURE__ */ i(P, {})
3212
- }
3213
- )
3214
- }
3215
- ) : null
3216
- ] }) }) }) }) }) });
3217
- }), Ae = {
3218
- "rp-toolbar-layout": "_rp-toolbar-layout_vwobs_1",
3219
- "rp-content": "_rp-content_vwobs_7",
3220
- "rp-topbar-content": "_rp-topbar-content_vwobs_13",
3221
- "rp-sidebar-content": "_rp-sidebar-content_vwobs_22",
3222
- "rp-pages": "_rp-pages_vwobs_32",
3223
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_vwobs_37"
3224
- }, ea = (e) => {
3225
- const { children: t, topBar: n, sidebar: o } = e, r = H(null), { setContentRef: a } = se(), { active: l } = Rt(), { showPrintProgress: c } = fe(), { progress: d } = Be(), { percentage: u } = d || {};
3226
- return /* @__PURE__ */ D(ie, { children: [
3227
- /* @__PURE__ */ D("div", { className: Ae["rp-toolbar-layout"], children: [
3228
- n && /* @__PURE__ */ i("div", { "data-rp": "topbar", className: Ae["rp-topbar-content"], children: n }),
3229
- /* @__PURE__ */ D("div", { className: Ae["rp-content"], children: [
3230
- /* @__PURE__ */ D(ie, { children: [
3231
- o && /* @__PURE__ */ i("div", { "data-rp": "sidebar", className: Ae["rp-sidebar-content"], children: o }),
3232
- /* @__PURE__ */ i(
3233
- "div",
3234
- {
3235
- "data-rp": "thumbnailSidebar",
3236
- hidden: !l,
3237
- className: Ae["rp-thumbnails-wrapper"],
3238
- children: /* @__PURE__ */ i(tr, { show: l, ref: r })
3239
- }
3240
- )
3241
- ] }),
3242
- /* @__PURE__ */ i("div", { ref: a, className: Ae["rp-pages"], children: t })
3243
- ] })
3244
- ] }),
3245
- c && u ? /* @__PURE__ */ i(er, { percentage: u }) : null
3246
- ] });
3247
- }, Js = We((e, t) => {
3248
- const {
3249
- children: n,
3250
- style: o,
3251
- className: r,
3252
- mobileWidth: a,
3253
- onLoaded: l,
3254
- cleanupOnLoaded: c,
3255
- onLayoutWidthChange: d,
3256
- topBar: u,
3257
- sidebar: f
3258
- } = e, { setContainer: v } = se(), [h] = G(null), { loading: w } = X(), { LoaderImageComponent: b } = Pt();
3259
- return W(() => (l && l(), () => {
3260
- c && c();
3261
- }), [l, c]), /* @__PURE__ */ i(Et, { toolbarRef: h, ref: t, children: /* @__PURE__ */ i(mn, { mobileWidth: a, onLayoutWidthChange: d, children: /* @__PURE__ */ i(Cn, { children: /* @__PURE__ */ D(fn, { getContainerRef: v, style: o, className: r, children: [
3262
- /* @__PURE__ */ i(Pn, { children: /* @__PURE__ */ i(ea, { topBar: u, sidebar: f, children: n }) }),
3263
- w ? /* @__PURE__ */ i(
3264
- "div",
3265
- {
3266
- className: ve["rp-loader"],
3267
- style: {
3268
- position: "absolute",
3269
- top: 0,
3270
- left: 0,
3271
- right: 0,
3272
- bottom: 0,
3273
- width: "100%",
3274
- height: "100%"
3275
- },
3276
- children: /* @__PURE__ */ i(
3277
- "div",
3278
- {
3279
- style: {
3280
- display: "flex",
3281
- justifyContent: "center",
3282
- alignItems: "center",
3283
- height: "100%",
3284
- width: "100%"
3285
- },
3286
- children: b && /* @__PURE__ */ i(b, {})
3287
- }
3288
- )
3289
- }
3290
- ) : null
3291
- ] }) }) }) });
3292
- });
3293
- export {
3294
- Wo as A,
3295
- di as B,
3296
- Oo as C,
3297
- oi as D,
3298
- Ii as E,
3299
- Xn as F,
3300
- Qn as G,
3301
- Hi as H,
3302
- ln as I,
3303
- er as J,
3304
- ji as K,
3305
- Et as L,
3306
- ki as M,
3307
- Ki as N,
3308
- Mi as O,
3309
- Vs as P,
3310
- tr as Q,
3311
- js as R,
3312
- Bi as S,
3313
- Bs as T,
3314
- Qi as U,
3315
- ea as V,
3316
- qi as Z,
3317
- Ys as a,
3318
- Js as b,
3319
- Zn as c,
3320
- Be as d,
3321
- Lt as e,
3322
- Zs as f,
3323
- qs as g,
3324
- Rt as h,
3325
- mt as i,
3326
- ze as j,
3327
- Sn as k,
3328
- Ro as l,
3329
- xn as m,
3330
- Lo as n,
3331
- In as o,
3332
- No as p,
3333
- Rn as q,
3334
- Eo as r,
3335
- Ln as s,
3336
- Do as t,
3337
- ae as u,
3338
- Mo as v,
3339
- Nt as w,
3340
- ti as x,
3341
- ii as y,
3342
- ai as z
3343
- };