@pdf-viewer/react 1.9.1-rc.0 → 1.9.1-rc.1

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