@pdf-viewer/react 0.6.0-beta.3 → 0.6.0-beta.5

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 (68) hide show
  1. package/dist/RPDefaultLayout-8e1a4756.js +2700 -0
  2. package/dist/assets/RPDefaultLayout.css +1 -0
  3. package/dist/components/RPController.js +66 -16
  4. package/dist/components/{RPViewer.js → RPPages.js} +18 -13
  5. package/dist/components/RPProvider.js +19 -0
  6. package/dist/components/layout/{RPLayout.js → RPDefaultLayout.js} +2 -5
  7. package/dist/components/layout/sidebar/RPSidebar.js +1 -1
  8. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  9. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  10. package/dist/components/layout/toolbar/DocumentDialog.js +17 -8
  11. package/dist/components/layout/toolbar/FileDownloadTool.js +1 -1
  12. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  13. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  14. package/dist/components/layout/toolbar/MostPageTool.js +19 -9
  15. package/dist/components/layout/toolbar/OtherTool.js +2 -2
  16. package/dist/components/layout/toolbar/Paginate.js +1 -1
  17. package/dist/components/layout/toolbar/PrintTool.js +1 -1
  18. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  19. package/dist/components/layout/toolbar/RPToolbarEnd.js +2 -2
  20. package/dist/components/layout/toolbar/RotateTool.js +1 -1
  21. package/dist/components/layout/toolbar/ScrollModeTool.js +1 -1
  22. package/dist/components/layout/toolbar/SearchTool.js +17 -8
  23. package/dist/components/layout/toolbar/SelectionModeTool.js +1 -1
  24. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  25. package/dist/components/layout/toolbar/ZoomTool.js +17 -9
  26. package/dist/components/page/AnnotationLayer.js +19 -10
  27. package/dist/components/page/CanvasLayer.js +18 -8
  28. package/dist/components/page/DualPage.js +1 -1
  29. package/dist/components/page/RPPage.js +18 -9
  30. package/dist/components/page/SinglePage.js +1 -1
  31. package/dist/components/page/TextLayer.js +18 -8
  32. package/dist/components/ui/Checkbox.js +1 -1
  33. package/dist/components/ui/DropDown.js +1 -1
  34. package/dist/components/ui/LoadingIndicator.js +1 -1
  35. package/dist/components/ui/RPTooltip.js +1793 -532
  36. package/dist/contexts/LayoutContainerContext.js +10 -7
  37. package/dist/contexts/PaginateContext.js +1 -1
  38. package/dist/contexts/PrintContext.js +3 -3
  39. package/dist/contexts/SearchContext.js +1 -1
  40. package/dist/contexts/ThumbnailsContext.js +2 -2
  41. package/dist/index-3459164c.js +3609 -0
  42. package/dist/{index-71898eb9.js → index-743c36f0.js} +30 -30
  43. package/dist/main.js +34 -32
  44. package/dist/types/components/RPPages.d.ts +2 -0
  45. package/dist/types/components/RPProvider.d.ts +3 -0
  46. package/dist/types/components/layout/RPDefaultLayout.d.ts +2 -0
  47. package/dist/types/contexts/LayoutContainerContext.d.ts +4 -2
  48. package/dist/types/main.d.ts +5 -4
  49. package/dist/types/utils/types.d.ts +4 -5
  50. package/dist/utils/hooks/useFileDownload.js +18 -8
  51. package/dist/utils/hooks/useLicense.js +15 -23
  52. package/dist/utils/hooks/useLoadPdf.js +27 -27
  53. package/dist/utils/hooks/useLoadWorker.js +1 -1
  54. package/dist/utils/hooks/usePaginate.js +17 -9
  55. package/dist/utils/hooks/usePrint.js +18 -8
  56. package/dist/utils/hooks/useScrollToPage.js +17 -10
  57. package/dist/utils/hooks/useSearch.js +18 -10
  58. package/dist/utils/hooks/useThumbnail.js +18 -8
  59. package/dist/utils/hooks/useVirtualReactWindow.js +17 -10
  60. package/package.json +1 -1
  61. package/dist/RPLayout-753dcb2b.js +0 -2758
  62. package/dist/assets/RPLayout.css +0 -1
  63. package/dist/components/RPDocument.js +0 -18
  64. package/dist/floating-ui.react-dom-e6d5fe8f.js +0 -1327
  65. package/dist/index-316854c1.js +0 -2299
  66. package/dist/types/components/RPDocument.d.ts +0 -3
  67. package/dist/types/components/RPViewer.d.ts +0 -2
  68. package/dist/types/components/layout/RPLayout.d.ts +0 -2
@@ -1,2758 +0,0 @@
1
- import { jsx as a, jsxs as O, Fragment as Ae } from "react/jsx-runtime";
2
- import * as V from "react";
3
- import { useRef as $, useEffect as A, useCallback as M, useState as F, useMemo as D, createContext as We, useContext as He, forwardRef as $e, useImperativeHandle as qt, createElement as Le, PureComponent as zn, Component as Fn, memo as kn } from "react";
4
- import { ChevronUpIcon as Me } from "./components/icons/ChevronUpIcon.js";
5
- import { UIButton as B } from "./components/ui/Button.js";
6
- import { UIInput as Zt } from "./components/ui/Input.js";
7
- import { useScrollModeContext as Pe, ScrollModeProvider as Wn } from "./contexts/ScrollModeContext.js";
8
- import { useDocumentContext as Y } from "./contexts/RPDocumentContext.js";
9
- import "./components/RPConfig.js";
10
- import { ThumbnailIcon as Hn } from "./components/icons/Thumbnail.js";
11
- import { c as j } from "./clsx-0c6e471a.js";
12
- import { LoaderIcon as pt } from "./components/icons/LoaderIcon.js";
13
- import { renderPage as ot } from "./utils/renderPage.js";
14
- import "./contexts/ThemeContext.js";
15
- import { RPDropFileZone as $n } from "./components/RPDropFileZone.js";
16
- import { DropFileZoneProvider as Vn } from "./contexts/DropFileZoneContext.js";
17
- import { DarkModeProvider as Gn } from "./contexts/DarkModeContext.js";
18
- import { useToolbarComponentContext as se, ToolbarComponentProvider as Un } from "./contexts/ToolbarComponentContext.js";
19
- import { useRotateContext as Ve, RotateProvider as qn } from "./contexts/RotateContext.js";
20
- import { useViewModeContext as Ge, ViewModeProvider as Zn } from "./contexts/ViewModeContext.js";
21
- import { FileInputProvider as jn } from "./contexts/FileInputContext.js";
22
- import { useZoomContext as ht, ZoomProvider as Bn } from "./contexts/ZoomContext.js";
23
- import { findMatches as Kn, resetDivs as Xn, highlightMatches as Jn } from "./utils/highlight.js";
24
- import { useVirtualScrollContext as Ue, VirtualScrollProvider as Yn } from "./contexts/VirtualScrollContext.js";
25
- import * as Qn from "pdfjs-dist";
26
- import { AnnotationLayer as er, PixelsPerInch as tr, AnnotationMode as nr, RenderingCancelledException as rr } from "pdfjs-dist";
27
- import { getThumbnailViewport as It } from "./utils/getThumbnailViewport.js";
28
- import { useInfiniteScroll as or } from "./utils/hooks/useInfiniteScroll.js";
29
- import { RPSplitter as ar } from "./components/layout/sidebar/RPSplitter.js";
30
- import { useIconContext as re, IconProvider as ir } from "./contexts/IconContext.js";
31
- import X from "./components/ui/RPTooltip.js";
32
- import { c as he, C as sr } from "./Container-83627c27.js";
33
- import { useLayoutContainer as qe, LayoutContainerProvider as lr } from "./contexts/LayoutContainerContext.js";
34
- import { ViewMode as ze, ScrollMode as Q, AnnotationSubType as at, SelectionMode as jt, ZoomLevel as we } from "./utils/types.js";
35
- import { useLayerContext as cr, LayerProvider as ur } from "./contexts/LayerContext.js";
36
- import { useVirtualGridContext as Bt, VirtualGridProvider as dr } from "./contexts/VirtualGridContext.js";
37
- import { useScrollStateContext as Kt, ScrollStateProvider as pr } from "./contexts/ScrollStateContext.js";
38
- import { useViewportContext as ge, ViewportProvider as hr } from "./contexts/ViewportContext.js";
39
- import { useSelectionModeContext as fr, SelectionModeProvider as mr } from "./contexts/SelectionModeContext.js";
40
- import { useInitialStateContext as gr, InitialStateProvider as vr } from "./contexts/InitialStateContext.js";
41
- import { useFullScreenContext as _r, FullScreenProvider as wr } from "./contexts/FullScreenContext.js";
42
- import { WrapperLayout as br } from "./components/layout/WrapperLayout.js";
43
- import { SimpleLinkService as Cr } from "./utils/link_service.js";
44
- import { dateFormatter as it } from "./utils/dateFormatter.js";
45
- import { sanitizeExternalUrl as Pr } from "./utils/sanitizeExternalUrl.js";
46
- import { useWatermark as Sr } from "./utils/hooks/useWatermark.js";
47
- import { usePageDimension as Xt } from "./utils/hooks/usePageDimension.js";
48
- import { useMousePressed as Tr } from "./utils/hooks/useMousePressed.js";
49
- import { useGrabScroll as Ir } from "./utils/hooks/useGrabScroll.js";
50
- import { useDebounce as yr } from "./utils/hooks/useDebounce.js";
51
- import { appConsole as Rr } from "./utils/appConsole.js";
52
- import { FileUploadTool as Jt } from "./components/layout/toolbar/FileUploadTool.js";
53
- import { DarkModeTool as xr } from "./components/layout/toolbar/DarkModeTool.js";
54
- import { ThreeDotIcon as Mr } from "./components/icons/ThreeDotIcon.js";
55
- import { UIDropDown as ft } from "./components/ui/DropDown.js";
56
- import { u as mt, a as Ne, c as xe, b as gt, d as Nr, e as Lr, h as Er, f as Or, F as Dr, D as Ar, g as zr, G as Fe } from "./index-316854c1.js";
57
- import { c as Fr, e as kr, b as Wr } from "./index-71898eb9.js";
58
- import { e as Be } from "./floating-ui.react-dom-e6d5fe8f.js";
59
- import { CloseIcon as Yt } from "./components/icons/CloseIcon.js";
60
- import { PropertyItem as Hr } from "./components/layout/toolbar/PropertyItem.js";
61
- import { useOtherToolContext as $r, OtherToolProvider as Vr } from "./contexts/OtherToolContext.js";
62
- import { DocumentProperties as Gr } from "./components/layout/toolbar/DocumentProperties.js";
63
- import { RotateTool as Ur } from "./components/layout/toolbar/RotateTool.js";
64
- import { ScrollModeTool as qr } from "./components/layout/toolbar/ScrollModeTool.js";
65
- import { MenuSeparator as vt } from "./components/layout/toolbar/MenuSeparator.js";
66
- import { FileDownloadDefaultIcon as Zr } from "./components/icons/FileDownloadDefaultIcon.js";
67
- import { MenuItem as ce } from "./components/layout/toolbar/MenuItem.js";
68
- import { PrintDefaultTool as jr } from "./components/icons/PrintDefaultIcon.js";
69
- import { FullScreenTool as Qt } from "./components/layout/toolbar/FullScreenTool.js";
70
- import { GoToDownIcon as en } from "./components/icons/GoToDownIcon.js";
71
- import { SelectionModeTool as Br } from "./components/layout/toolbar/SelectionModeTool.js";
72
- import { ZoomInIcon as Kr } from "./components/icons/ZoomInIcon.js";
73
- import { ZoomOutIcon as Xr } from "./components/icons/ZoomOutIcon.js";
74
- import { PAGE_PADDING as yt } from "./utils/constants.js";
75
- import { SearchIcon as Jr } from "./components/icons/SearchIcon.js";
76
- import { UICheckbox as Rt } from "./components/ui/Checkbox.js";
77
- import { ClearIcon as Yr } from "./components/icons/ClearIcon.js";
78
- import './assets/RPLayout.css';const ae = {
79
- "rp-pages": "_rp-pages_34orh_1",
80
- "rp-pages-horizontal-scroll": "_rp-pages-horizontal-scroll_34orh_7",
81
- "rp-pages-container": "_rp-pages-container_34orh_11",
82
- "rp-page-scrolling-wrapper": "_rp-page-scrolling-wrapper_34orh_17",
83
- "rp-viewer": "_rp-viewer_34orh_22",
84
- "rp-cursor-grab": "_rp-cursor-grab_34orh_27",
85
- "rp-cursor-grabbing": "_rp-cursor-grabbing_34orh_35"
86
- }, Ke = {
87
- "rp-page-wrapper": "_rp-page-wrapper_h7a2q_1",
88
- "rp-page": "_rp-page_h7a2q_1",
89
- "rp-loader-wrapper": "_rp-loader-wrapper_h7a2q_14"
90
- }, Qr = (e) => {
91
- const { pageNumber: t, onLoaded: n, onLoading: r } = e, o = $(null), { pages: i } = Y(), { rotate: l } = Ve(), s = $(), { currentZoom: c } = ht();
92
- return A(() => {
93
- if (!i || c === 0)
94
- return;
95
- const p = i.get(t);
96
- if (o.current && p) {
97
- const h = o.current;
98
- h.hidden = !0;
99
- const m = s.current;
100
- m && m.cancel(), r && r(), s.current = ot(p.page, h, c, l), s.current.promise.then(() => {
101
- h.hidden = !1;
102
- }).catch((u) => {
103
- }).finally(() => {
104
- n && n();
105
- });
106
- }
107
- }, [i, t, l, c, r, n]), /* @__PURE__ */ a("canvas", { "data-rp": `page-${t}-canvas`, ref: o });
108
- }, Xe = {
109
- "rp-text-layer": "_rp-text-layer_1mgyz_1",
110
- "rp-text-layer-text": "_rp-text-layer-text_1mgyz_9"
111
- }, _t = () => {
112
- const { viewMode: e } = Ge(), { scrollMode: t } = Pe(), { virtualScrollRef: n, pageScrollElementRef: r } = Ue(), { setFocusedPage: o } = ee(), i = $(), { columnCount: l } = Bt(), s = Xt(), c = $(t), p = $(e);
113
- A(() => {
114
- n != null && n.scrollToItem && (i.current = n);
115
- }, [n]);
116
- const h = M(
117
- (u) => {
118
- if (!r)
119
- return;
120
- const f = Math.ceil(u / 2) * 2 - 1;
121
- u === f + 1 ? r.scrollTo({ left: s.widths[f], top: 0 }) : r.scrollTo({ left: 0, top: 0 });
122
- },
123
- [r, s]
124
- );
125
- return A(() => {
126
- c.current = t, p.current = e;
127
- }, [t, e]), { scrollToPage: M(
128
- (u, f = "start") => {
129
- const v = u - 1;
130
- let _ = v, g = 0;
131
- if (p.current === ze.DUAL_PAGE && c.current === Q.PAGE_SCROLLING) {
132
- h(u);
133
- return;
134
- }
135
- if (c.current === Q.PAGE_SCROLLING) {
136
- o(u);
137
- return;
138
- }
139
- i.current && (c.current === Q.HORIZONTAL_SCROLLING ? g = v : p.current === ze.DUAL_PAGE && (g = v % 2, _ = Math.floor(v / 2)), i.current.scrollToItem({ rowIndex: _, columnIndex: g, align: f }));
140
- },
141
- [l, h, o]
142
- ) };
143
- }, eo = (e = {}, t = "") => {
144
- const [n, r] = F(t), [o, i] = F(!1), { pdf: l } = Y(), s = $(!n), [c, p] = F([]), [h, m] = F(0), { focusedPage: u } = ee(), { scrollToPage: f } = _t(), { virtualScrollRef: v, pageScrollElementRef: _, virtualScrollableElementRef: g } = Ue(), { scrollMode: b } = Pe(), [S, P] = F(null), T = D(() => h === 0 ? null : c[h - 1], [h, c]), d = D(() => c.length, [c]);
145
- A(() => {
146
- if (T && u !== T.page) {
147
- const y = u < T.page ? "start" : "end";
148
- f(T.page, y);
149
- }
150
- }, [T, f]), A(() => {
151
- if (!T || u !== T.page || !S || !S.classList.contains("selected"))
152
- return;
153
- const y = g || _;
154
- if (!y)
155
- return;
156
- const R = S.getBoundingClientRect(), N = y.clientHeight / 2, L = y.clientWidth / 2, x = y.scrollTop + R.top - N, E = y.scrollLeft + R.left - L;
157
- y.scrollTo({
158
- top: x,
159
- left: E,
160
- behavior: "smooth"
161
- });
162
- }, [
163
- u,
164
- v,
165
- S,
166
- b,
167
- g,
168
- _
169
- ]);
170
- const C = M(() => {
171
- m((y) => d ? y + 1 > d ? 1 : y + 1 : 0);
172
- }, [d]), w = M(() => {
173
- m((y) => d ? y - 1 <= 0 ? d : y - 1 : 0);
174
- }, [d]), I = M(async (y) => {
175
- if (!y)
176
- return {};
177
- const R = y.numPages, N = {};
178
- for (let L = 1; L <= R; L++) {
179
- if (s.current)
180
- throw "close pop over";
181
- const x = await y.getPage(L);
182
- N[L.toString()] = await x.getTextContent();
183
- }
184
- return N;
185
- }, []);
186
- return A(() => {
187
- if (!n) {
188
- s.current = !0, p([]), m(0);
189
- return;
190
- }
191
- s.current = !1, i(!0), p([]), m(0), I(l).then((y) => {
192
- const N = Object.keys(y).reduce((L, x) => {
193
- const E = Kn(
194
- [n],
195
- y[x],
196
- Number(x) - 1,
197
- e
198
- ).map((z, k) => ({ ...z, page: Number(x), pageMatchIdx: k }));
199
- return [...L, ...E];
200
- }, []);
201
- p(N), m(N.length ? 1 : 0);
202
- }).catch(() => {
203
- p([]), m(0);
204
- }).finally(() => i(!1));
205
- }, [n, I, l, e]), {
206
- search: n,
207
- setSearch: r,
208
- loading: o,
209
- matches: c,
210
- totalMatches: d,
211
- currentMatchPosition: h,
212
- currentMatch: T,
213
- nextMatch: C,
214
- prevMatch: w,
215
- currentMatchElement: S,
216
- setCurrentMatchElement: P
217
- };
218
- }, tn = We({
219
- search: "",
220
- setSearch: (e) => {
221
- },
222
- loading: !1,
223
- matches: [],
224
- totalMatches: 0,
225
- currentMatchPosition: 0,
226
- currentMatch: null,
227
- nextMatch: () => {
228
- },
229
- prevMatch: () => {
230
- },
231
- searchOptions: {},
232
- setSearchOptions: (e) => e,
233
- currentMatchElement: null,
234
- setCurrentMatchElement: (e) => {
235
- }
236
- }), to = ({
237
- children: e,
238
- initialSearch: t
239
- }) => {
240
- const [n, r] = F({}), {
241
- loading: o,
242
- setSearch: i,
243
- totalMatches: l,
244
- currentMatchPosition: s,
245
- currentMatch: c,
246
- search: p,
247
- matches: h,
248
- nextMatch: m,
249
- prevMatch: u,
250
- currentMatchElement: f,
251
- setCurrentMatchElement: v
252
- } = eo(n, t);
253
- return /* @__PURE__ */ a(
254
- tn.Provider,
255
- {
256
- value: {
257
- searchOptions: n,
258
- setSearchOptions: r,
259
- loading: o,
260
- setSearch: i,
261
- totalMatches: l,
262
- currentMatchPosition: s,
263
- currentMatch: c,
264
- nextMatch: m,
265
- prevMatch: u,
266
- search: p,
267
- matches: h,
268
- currentMatchElement: f,
269
- setCurrentMatchElement: v
270
- },
271
- children: e
272
- }
273
- );
274
- }, nn = () => He(tn), no = (e) => {
275
- const { pageNumber: t } = e, { pages: n } = Y(), r = $(null), { matches: o, currentMatch: i, setCurrentMatchElement: l } = nn(), [s, c] = F(
276
- []
277
- ), p = $(), h = $(), m = $(), u = D(() => o.filter((v) => v.pageIndex === t - 1), [o, t]), f = M(
278
- (v, _, g = !1) => {
279
- if (g && Xn(v, _), !u.length) {
280
- m.current = void 0, c([]);
281
- return;
282
- }
283
- const b = Jn(u, v, _);
284
- c(b);
285
- },
286
- [u]
287
- );
288
- return A(() => {
289
- var g;
290
- if ((g = m.current) == null || g.classList.remove("selected"), !s.length || !i || i.pageIndex !== t - 1)
291
- return;
292
- const v = u.findIndex(
293
- (b) => JSON.stringify(b) === JSON.stringify(i)
294
- );
295
- if (v === -1)
296
- return;
297
- const _ = s.find((b) => b.index === v);
298
- _ && (m.current = _.element, l(_.element), _.element.classList.add("selected"));
299
- }, [i, s, u]), A(() => {
300
- const v = n.get(t);
301
- if (!(!v || !r.current))
302
- return p.current && p.current.cancel(), v.page.getTextContent().then((_) => {
303
- const g = v.page.getViewport({ scale: 1 });
304
- return p.current = new Qn.TextLayer({
305
- viewport: g,
306
- textContentSource: _,
307
- container: r.current
308
- }), h.current = _, r.current && (r.current.innerText = ""), p.current.render();
309
- }).then(() => {
310
- var b;
311
- [].slice.call(r.current.children).forEach((S) => {
312
- S.classList.add(Xe["rp-text-layer-text"]);
313
- });
314
- const g = (b = p.current) == null ? void 0 : b.textDivs;
315
- g && h.current && f(h.current, g);
316
- }).catch(() => {
317
- }), () => {
318
- var _;
319
- (_ = p.current) == null || _.cancel();
320
- };
321
- }, [n, t]), A(() => {
322
- var g;
323
- [].slice.call(r.current.children).forEach((b) => {
324
- b.classList.add(Xe["rp-text-layer-text"]);
325
- });
326
- const _ = (g = p.current) == null ? void 0 : g.textDivs;
327
- _ && h.current && f(h.current, _, !0);
328
- }, [f]), /* @__PURE__ */ a(
329
- "div",
330
- {
331
- "data-rp": `page-${t}-textLayer`,
332
- className: Xe["rp-text-layer"],
333
- ref: r
334
- }
335
- );
336
- }, ro = {
337
- "rp-annotation-layer": "_rp-annotation-layer_o0ksd_1"
338
- }, rn = ["click", "dblclick", "mouseover", "input", "change"];
339
- let oo = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/";
340
- const st = /* @__PURE__ */ new Map(), on = (e, t) => `${e.loadingTask.docId}___${t.num}R${t.gen === 0 ? "" : t.gen}`;
341
- function ao(e, t) {
342
- const n = on(e, t);
343
- return st.has(n) ? st.get(n) ?? null : null;
344
- }
345
- const io = (e, t, n) => {
346
- st.set(on(e, t), n);
347
- }, xt = (e, t) => {
348
- switch (t[1].name) {
349
- case "XYZ":
350
- return {
351
- bottomOffset: (n, r) => t[3] === null ? r : t[3],
352
- leftOffset: (n, r) => t[2] === null ? 0 : t[2],
353
- pageIndex: e,
354
- scaleTo: t[4]
355
- };
356
- case "Fit":
357
- case "FitB":
358
- return {
359
- bottomOffset: 0,
360
- leftOffset: 0,
361
- pageIndex: e,
362
- scaleTo: 1
363
- };
364
- case "FitH":
365
- case "FitBH":
366
- return {
367
- bottomOffset: t[2],
368
- leftOffset: 0,
369
- pageIndex: e,
370
- scaleTo: 1
371
- };
372
- default:
373
- return {
374
- bottomOffset: 0,
375
- leftOffset: 0,
376
- pageIndex: e,
377
- scaleTo: 1
378
- };
379
- }
380
- };
381
- async function an(e, t) {
382
- let n;
383
- if (typeof t == "string" ? n = await e.getDestination(t) : n = t, n && typeof n[0] == "object" && n[0] !== null) {
384
- const r = n[0], o = ao(e, r);
385
- if (o === null) {
386
- const i = await e.getPageIndex(r);
387
- return io(e, r, i), await an(e, n);
388
- } else
389
- return xt(o, n);
390
- } else
391
- return xt(n[0], n);
392
- }
393
- function so(e) {
394
- const { id: t, url: n, unsafeUrl: r } = e, o = new MutationObserver((i) => {
395
- const l = document.querySelector(`[data-annotation-id="${t}"]`);
396
- if (l) {
397
- const s = l.querySelector("a"), c = Pr((n || r) ?? "", "");
398
- s && (s.setAttribute("target", "_blank"), s.setAttribute("href", c), s.setAttribute("rel", "noopener noreferrer")), o.disconnect();
399
- }
400
- });
401
- o.observe(document.body, { childList: !0, subtree: !0 });
402
- }
403
- const lo = (e) => {
404
- const n = e.target.parentNode;
405
- if (!n)
406
- return;
407
- const r = new MutationObserver((o) => {
408
- o.forEach(() => {
409
- n.querySelectorAll(
410
- '[data-l10n-id="pdfjs-annotation-date-time-string"]'
411
- ).forEach((l) => {
412
- const s = l.getAttribute("data-l10n-args");
413
- if (s)
414
- try {
415
- const { dateObj: c } = JSON.parse(s);
416
- l.textContent = it(c);
417
- } catch {
418
- }
419
- });
420
- });
421
- });
422
- return r.observe(n, {
423
- childList: !0,
424
- // Watch for changes to child elements
425
- subtree: !0,
426
- // Watch all descendants, not just direct children
427
- attributes: !0
428
- // Watch for changes to attributes
429
- }), () => r.disconnect();
430
- }, Mt = (e, t, n, r) => {
431
- if (e.type !== "click")
432
- return;
433
- const o = e.target, i = o.getAttribute("data-element-id");
434
- if (o.getAttribute("href"))
435
- return;
436
- const s = t.find((c) => c.id === i);
437
- !s || s.annotationType !== at.Link || s.dest && an(n, s.dest).then((c) => {
438
- r(c);
439
- });
440
- };
441
- function co(e, t) {
442
- for (const n of rn)
443
- e.addEventListener(n, t);
444
- }
445
- function uo(e, t) {
446
- for (const n of rn)
447
- e.removeEventListener(n, t);
448
- }
449
- const po = (e) => {
450
- const { pageNumber: t } = e, n = $(null), { pages: r, pdf: o } = Y(), i = $(), [l, s] = F(), { setFocusedPage: c, goToPage: p } = ee(), { scrollMode: h } = Pe(), m = D(() => r.get(t), [r, t]), u = D(() => m == null ? void 0 : m.page.getViewport(), [m]);
451
- A(() => {
452
- i.current && (i.current.div.replaceChildren(), i.current = void 0);
453
- }, [o]);
454
- const f = D(() => o == null ? void 0 : o.annotationStorage, [o]);
455
- A(() => {
456
- m && m.page.getAnnotations().then((_) => {
457
- i.current = void 0, s(_), n.current && (n.current.innerText = "");
458
- });
459
- }, [m]);
460
- const v = M(
461
- (_) => {
462
- lo(_), !(!l || !o) && (h === Q.PAGE_SCROLLING ? Mt(_, l, o, (g) => c(g.pageIndex + 1)) : Mt(_, l, o, (g) => p(g.pageIndex + 1)));
463
- },
464
- [o, l, p, c, h]
465
- );
466
- return A(() => {
467
- if (!m || !l)
468
- return;
469
- const _ = m.page.getViewport();
470
- if (i.current) {
471
- i.current.update({
472
- viewport: _.clone({ dontFlip: !0 })
473
- });
474
- return;
475
- }
476
- for (const b of l) {
477
- const { annotationType: S } = b;
478
- switch (S) {
479
- case at.Link:
480
- so(b);
481
- break;
482
- case at.Widget:
483
- break;
484
- }
485
- }
486
- (async () => {
487
- i.current = new er({
488
- div: n.current,
489
- accessibilityManager: void 0,
490
- annotationCanvasMap: void 0,
491
- annotationEditorUIManager: void 0,
492
- structTreeLayer: void 0,
493
- page: m.page,
494
- viewport: _.clone({ dontFlip: !0 })
495
- }), n.current && uo(n.current, v);
496
- const b = await (o == null ? void 0 : o.hasJSActions()), S = await (o == null ? void 0 : o.getFieldObjects());
497
- return i.current.render({
498
- annotations: l,
499
- annotationStorage: f,
500
- hasJSActions: b,
501
- fieldObjects: S,
502
- div: n.current,
503
- viewport: _.clone({ dontFlip: !0 }),
504
- page: m.page,
505
- imageResourcesPath: oo,
506
- renderForms: !1,
507
- linkService: new Cr(),
508
- downloadManager: null,
509
- enableScripting: !1
510
- });
511
- })().then(() => {
512
- n.current && co(n.current, v);
513
- });
514
- }, [o, l, v]), /* @__PURE__ */ a(
515
- "div",
516
- {
517
- "data-rp": `page-${t}-annotationLayer`,
518
- style: { width: `${u == null ? void 0 : u.width}px`, height: `${u == null ? void 0 : u.height}px` },
519
- className: ro["rp-annotation-layer"],
520
- ref: n
521
- }
522
- );
523
- }, ho = Array.from({ length: 21 }, (e, t) => Number((t * 0.05).toFixed(2))), wt = $e((e, t) => {
524
- const { pageNumber: n, style: r, onIntersectRatioChange: o, ...i } = e, { pages: l } = Y(), { rotate: s } = Ve(), { textLayer: c } = cr(), { currentZoom: p } = ht(), h = $(l.get(n)), [m, u] = F(!1), f = $(null), [v, _] = F({
525
- width: 0,
526
- height: 0
527
- });
528
- qt(t, () => f.current), A(() => {
529
- if (l && (h.current = l.get(n), h.current)) {
530
- const P = h.current.page.getViewport({ scale: p, rotation: s });
531
- _(P);
532
- }
533
- }, [l, n, s, p]);
534
- const g = D(() => {
535
- switch (s) {
536
- case 90:
537
- return `${v.width / 2}px ${v.width / 2}px`;
538
- case -90:
539
- case 270:
540
- return `${v.height / 2}px ${v.height / 2}px`;
541
- default:
542
- return "center";
543
- }
544
- }, [s, v]), b = M(() => {
545
- u(!0);
546
- }, []), S = M(() => {
547
- u(!1);
548
- }, []);
549
- return A(() => {
550
- const P = new IntersectionObserver(
551
- (T) => {
552
- o && o(n, T[0].intersectionRatio);
553
- },
554
- { threshold: ho }
555
- );
556
- return f.current && P.observe(f.current), () => {
557
- P.disconnect(), o && o(n, -1);
558
- };
559
- }, [o, n, s]), /* @__PURE__ */ a(
560
- "div",
561
- {
562
- ref: f,
563
- id: `page-${n}`,
564
- "data-rp": `page-${n}`,
565
- ...i,
566
- style: {
567
- ...r,
568
- "--rp-rotate": `${s}deg`,
569
- "--rp-page-rotate-translate": `${g}`,
570
- "--scale-factor": p
571
- },
572
- className: Ke["rp-page-wrapper"],
573
- children: /* @__PURE__ */ O(
574
- "div",
575
- {
576
- style: {
577
- width: `${v.width}px`,
578
- height: `${v.height}px`
579
- },
580
- className: Ke["rp-page"],
581
- children: [
582
- /* @__PURE__ */ a(Qr, { onLoading: b, onLoaded: S, pageNumber: n }),
583
- m && /* @__PURE__ */ a("div", { className: Ke["rp-loader-wrapper"], children: /* @__PURE__ */ a(pt, {}) }),
584
- c && /* @__PURE__ */ a(no, { pageNumber: n }),
585
- /* @__PURE__ */ a(po, { pageNumber: n })
586
- ]
587
- }
588
- )
589
- }
590
- );
591
- });
592
- function lt() {
593
- return lt = Object.assign ? Object.assign.bind() : function(e) {
594
- for (var t = 1; t < arguments.length; t++) {
595
- var n = arguments[t];
596
- for (var r in n)
597
- ({}).hasOwnProperty.call(n, r) && (e[r] = n[r]);
598
- }
599
- return e;
600
- }, lt.apply(null, arguments);
601
- }
602
- function Nt(e) {
603
- if (e === void 0)
604
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
605
- return e;
606
- }
607
- function ct(e, t) {
608
- return ct = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, r) {
609
- return n.__proto__ = r, n;
610
- }, ct(e, t);
611
- }
612
- function fo(e, t) {
613
- e.prototype = Object.create(t.prototype), e.prototype.constructor = e, ct(e, t);
614
- }
615
- var Lt = Number.isNaN || function(t) {
616
- return typeof t == "number" && t !== t;
617
- };
618
- function mo(e, t) {
619
- return !!(e === t || Lt(e) && Lt(t));
620
- }
621
- function go(e, t) {
622
- if (e.length !== t.length)
623
- return !1;
624
- for (var n = 0; n < e.length; n++)
625
- if (!mo(e[n], t[n]))
626
- return !1;
627
- return !0;
628
- }
629
- function Je(e, t) {
630
- t === void 0 && (t = go);
631
- var n, r = [], o, i = !1;
632
- function l() {
633
- for (var s = [], c = 0; c < arguments.length; c++)
634
- s[c] = arguments[c];
635
- return i && n === this && t(s, r) || (o = e.apply(this, s), i = !0, n = this, r = s), o;
636
- }
637
- return l;
638
- }
639
- function Et(e, t) {
640
- if (e == null)
641
- return {};
642
- var n = {};
643
- for (var r in e)
644
- if ({}.hasOwnProperty.call(e, r)) {
645
- if (t.includes(r))
646
- continue;
647
- n[r] = e[r];
648
- }
649
- return n;
650
- }
651
- var vo = typeof performance == "object" && typeof performance.now == "function", Ot = vo ? function() {
652
- return performance.now();
653
- } : function() {
654
- return Date.now();
655
- };
656
- function Dt(e) {
657
- cancelAnimationFrame(e.id);
658
- }
659
- function _o(e, t) {
660
- var n = Ot();
661
- function r() {
662
- Ot() - n >= t ? e.call(null) : o.id = requestAnimationFrame(r);
663
- }
664
- var o = {
665
- id: requestAnimationFrame(r)
666
- };
667
- return o;
668
- }
669
- var Ye = -1;
670
- function wo(e) {
671
- if (e === void 0 && (e = !1), Ye === -1 || e) {
672
- var t = document.createElement("div"), n = t.style;
673
- n.width = "50px", n.height = "50px", n.overflow = "scroll", document.body.appendChild(t), Ye = t.offsetWidth - t.clientWidth, document.body.removeChild(t);
674
- }
675
- return Ye;
676
- }
677
- var be = null;
678
- function At(e) {
679
- if (e === void 0 && (e = !1), be === null || e) {
680
- var t = document.createElement("div"), n = t.style;
681
- n.width = "50px", n.height = "50px", n.overflow = "scroll", n.direction = "rtl";
682
- var r = document.createElement("div"), o = r.style;
683
- return o.width = "100px", o.height = "100px", t.appendChild(r), document.body.appendChild(t), t.scrollLeft > 0 ? be = "positive-descending" : (t.scrollLeft = 1, t.scrollLeft === 0 ? be = "negative" : be = "positive-ascending"), document.body.removeChild(t), be;
684
- }
685
- return be;
686
- }
687
- var bo = 150, Co = function(t) {
688
- var n = t.columnIndex;
689
- t.data;
690
- var r = t.rowIndex;
691
- return r + ":" + n;
692
- }, Ee = null, Oe = null, De = null;
693
- process.env.NODE_ENV !== "production" && typeof window < "u" && typeof window.WeakSet < "u" && (Ee = /* @__PURE__ */ new WeakSet(), Oe = /* @__PURE__ */ new WeakSet(), De = /* @__PURE__ */ new WeakSet());
694
- function Po(e) {
695
- var t, n = e.getColumnOffset, r = e.getColumnStartIndexForOffset, o = e.getColumnStopIndexForStartIndex, i = e.getColumnWidth, l = e.getEstimatedTotalHeight, s = e.getEstimatedTotalWidth, c = e.getOffsetForColumnAndAlignment, p = e.getOffsetForRowAndAlignment, h = e.getRowHeight, m = e.getRowOffset, u = e.getRowStartIndexForOffset, f = e.getRowStopIndexForStartIndex, v = e.initInstanceProps, _ = e.shouldResetStyleCacheOnItemSizeChange, g = e.validateProps;
696
- return t = /* @__PURE__ */ function(b) {
697
- fo(S, b);
698
- function S(T) {
699
- var d;
700
- return d = b.call(this, T) || this, d._instanceProps = v(d.props, Nt(d)), d._resetIsScrollingTimeoutId = null, d._outerRef = void 0, d.state = {
701
- instance: Nt(d),
702
- isScrolling: !1,
703
- horizontalScrollDirection: "forward",
704
- scrollLeft: typeof d.props.initialScrollLeft == "number" ? d.props.initialScrollLeft : 0,
705
- scrollTop: typeof d.props.initialScrollTop == "number" ? d.props.initialScrollTop : 0,
706
- scrollUpdateWasRequested: !1,
707
- verticalScrollDirection: "forward"
708
- }, d._callOnItemsRendered = void 0, d._callOnItemsRendered = Je(function(C, w, I, y, R, N, L, x) {
709
- return d.props.onItemsRendered({
710
- overscanColumnStartIndex: C,
711
- overscanColumnStopIndex: w,
712
- overscanRowStartIndex: I,
713
- overscanRowStopIndex: y,
714
- visibleColumnStartIndex: R,
715
- visibleColumnStopIndex: N,
716
- visibleRowStartIndex: L,
717
- visibleRowStopIndex: x
718
- });
719
- }), d._callOnScroll = void 0, d._callOnScroll = Je(function(C, w, I, y, R) {
720
- return d.props.onScroll({
721
- horizontalScrollDirection: I,
722
- scrollLeft: C,
723
- scrollTop: w,
724
- verticalScrollDirection: y,
725
- scrollUpdateWasRequested: R
726
- });
727
- }), d._getItemStyle = void 0, d._getItemStyle = function(C, w) {
728
- var I = d.props, y = I.columnWidth, R = I.direction, N = I.rowHeight, L = d._getItemStyleCache(_ && y, _ && R, _ && N), x = C + ":" + w, E;
729
- if (L.hasOwnProperty(x))
730
- E = L[x];
731
- else {
732
- var z = n(d.props, w, d._instanceProps), k = R === "rtl";
733
- L[x] = E = {
734
- position: "absolute",
735
- left: k ? void 0 : z,
736
- right: k ? z : void 0,
737
- top: m(d.props, C, d._instanceProps),
738
- height: h(d.props, C, d._instanceProps),
739
- width: i(d.props, w, d._instanceProps)
740
- };
741
- }
742
- return E;
743
- }, d._getItemStyleCache = void 0, d._getItemStyleCache = Je(function(C, w, I) {
744
- return {};
745
- }), d._onScroll = function(C) {
746
- var w = C.currentTarget, I = w.clientHeight, y = w.clientWidth, R = w.scrollLeft, N = w.scrollTop, L = w.scrollHeight, x = w.scrollWidth;
747
- d.setState(function(E) {
748
- if (E.scrollLeft === R && E.scrollTop === N)
749
- return null;
750
- var z = d.props.direction, k = R;
751
- if (z === "rtl")
752
- switch (At()) {
753
- case "negative":
754
- k = -R;
755
- break;
756
- case "positive-descending":
757
- k = x - y - R;
758
- break;
759
- }
760
- k = Math.max(0, Math.min(k, x - y));
761
- var G = Math.max(0, Math.min(N, L - I));
762
- return {
763
- isScrolling: !0,
764
- horizontalScrollDirection: E.scrollLeft < R ? "forward" : "backward",
765
- scrollLeft: k,
766
- scrollTop: G,
767
- verticalScrollDirection: E.scrollTop < N ? "forward" : "backward",
768
- scrollUpdateWasRequested: !1
769
- };
770
- }, d._resetIsScrollingDebounced);
771
- }, d._outerRefSetter = function(C) {
772
- var w = d.props.outerRef;
773
- d._outerRef = C, typeof w == "function" ? w(C) : w != null && typeof w == "object" && w.hasOwnProperty("current") && (w.current = C);
774
- }, d._resetIsScrollingDebounced = function() {
775
- d._resetIsScrollingTimeoutId !== null && Dt(d._resetIsScrollingTimeoutId), d._resetIsScrollingTimeoutId = _o(d._resetIsScrolling, bo);
776
- }, d._resetIsScrolling = function() {
777
- d._resetIsScrollingTimeoutId = null, d.setState({
778
- isScrolling: !1
779
- }, function() {
780
- d._getItemStyleCache(-1);
781
- });
782
- }, d;
783
- }
784
- S.getDerivedStateFromProps = function(d, C) {
785
- return So(d, C), g(d), null;
786
- };
787
- var P = S.prototype;
788
- return P.scrollTo = function(d) {
789
- var C = d.scrollLeft, w = d.scrollTop;
790
- C !== void 0 && (C = Math.max(0, C)), w !== void 0 && (w = Math.max(0, w)), this.setState(function(I) {
791
- return C === void 0 && (C = I.scrollLeft), w === void 0 && (w = I.scrollTop), I.scrollLeft === C && I.scrollTop === w ? null : {
792
- horizontalScrollDirection: I.scrollLeft < C ? "forward" : "backward",
793
- scrollLeft: C,
794
- scrollTop: w,
795
- scrollUpdateWasRequested: !0,
796
- verticalScrollDirection: I.scrollTop < w ? "forward" : "backward"
797
- };
798
- }, this._resetIsScrollingDebounced);
799
- }, P.scrollToItem = function(d) {
800
- var C = d.align, w = C === void 0 ? "auto" : C, I = d.columnIndex, y = d.rowIndex, R = this.props, N = R.columnCount, L = R.height, x = R.rowCount, E = R.width, z = this.state, k = z.scrollLeft, G = z.scrollTop, Z = wo();
801
- I !== void 0 && (I = Math.max(0, Math.min(I, N - 1))), y !== void 0 && (y = Math.max(0, Math.min(y, x - 1)));
802
- var U = l(this.props, this._instanceProps), K = s(this.props, this._instanceProps), ue = K > E ? Z : 0, oe = U > L ? Z : 0;
803
- this.scrollTo({
804
- scrollLeft: I !== void 0 ? c(this.props, I, w, k, this._instanceProps, oe) : k,
805
- scrollTop: y !== void 0 ? p(this.props, y, w, G, this._instanceProps, ue) : G
806
- });
807
- }, P.componentDidMount = function() {
808
- var d = this.props, C = d.initialScrollLeft, w = d.initialScrollTop;
809
- if (this._outerRef != null) {
810
- var I = this._outerRef;
811
- typeof C == "number" && (I.scrollLeft = C), typeof w == "number" && (I.scrollTop = w);
812
- }
813
- this._callPropsCallbacks();
814
- }, P.componentDidUpdate = function() {
815
- var d = this.props.direction, C = this.state, w = C.scrollLeft, I = C.scrollTop, y = C.scrollUpdateWasRequested;
816
- if (y && this._outerRef != null) {
817
- var R = this._outerRef;
818
- if (d === "rtl")
819
- switch (At()) {
820
- case "negative":
821
- R.scrollLeft = -w;
822
- break;
823
- case "positive-ascending":
824
- R.scrollLeft = w;
825
- break;
826
- default:
827
- var N = R.clientWidth, L = R.scrollWidth;
828
- R.scrollLeft = L - N - w;
829
- break;
830
- }
831
- else
832
- R.scrollLeft = Math.max(0, w);
833
- R.scrollTop = Math.max(0, I);
834
- }
835
- this._callPropsCallbacks();
836
- }, P.componentWillUnmount = function() {
837
- this._resetIsScrollingTimeoutId !== null && Dt(this._resetIsScrollingTimeoutId);
838
- }, P.render = function() {
839
- var d = this.props, C = d.children, w = d.className, I = d.columnCount, y = d.direction, R = d.height, N = d.innerRef, L = d.innerElementType, x = d.innerTagName, E = d.itemData, z = d.itemKey, k = z === void 0 ? Co : z, G = d.outerElementType, Z = d.outerTagName, U = d.rowCount, K = d.style, ue = d.useIsScrolling, oe = d.width, ve = this.state.isScrolling, _e = this._getHorizontalRangeToRender(), Se = _e[0], W = _e[1], H = this._getVerticalRangeToRender(), q = H[0], le = H[1], Te = [];
840
- if (I > 0 && U)
841
- for (var de = q; de <= le; de++)
842
- for (var pe = Se; pe <= W; pe++)
843
- Te.push(Le(C, {
844
- columnIndex: pe,
845
- data: E,
846
- isScrolling: ue ? ve : void 0,
847
- key: k({
848
- columnIndex: pe,
849
- data: E,
850
- rowIndex: de
851
- }),
852
- rowIndex: de,
853
- style: this._getItemStyle(de, pe)
854
- }));
855
- var Ze = l(this.props, this._instanceProps), je = s(this.props, this._instanceProps);
856
- return Le(G || Z || "div", {
857
- className: w,
858
- onScroll: this._onScroll,
859
- ref: this._outerRefSetter,
860
- style: lt({
861
- position: "relative",
862
- height: R,
863
- width: oe,
864
- overflow: "auto",
865
- WebkitOverflowScrolling: "touch",
866
- willChange: "transform",
867
- direction: y
868
- }, K)
869
- }, Le(L || x || "div", {
870
- children: Te,
871
- ref: N,
872
- style: {
873
- height: Ze,
874
- pointerEvents: ve ? "none" : void 0,
875
- width: je
876
- }
877
- }));
878
- }, P._callPropsCallbacks = function() {
879
- var d = this.props, C = d.columnCount, w = d.onItemsRendered, I = d.onScroll, y = d.rowCount;
880
- if (typeof w == "function" && C > 0 && y > 0) {
881
- var R = this._getHorizontalRangeToRender(), N = R[0], L = R[1], x = R[2], E = R[3], z = this._getVerticalRangeToRender(), k = z[0], G = z[1], Z = z[2], U = z[3];
882
- this._callOnItemsRendered(N, L, k, G, x, E, Z, U);
883
- }
884
- if (typeof I == "function") {
885
- var K = this.state, ue = K.horizontalScrollDirection, oe = K.scrollLeft, ve = K.scrollTop, _e = K.scrollUpdateWasRequested, Se = K.verticalScrollDirection;
886
- this._callOnScroll(oe, ve, ue, Se, _e);
887
- }
888
- }, P._getHorizontalRangeToRender = function() {
889
- var d = this.props, C = d.columnCount, w = d.overscanColumnCount, I = d.overscanColumnsCount, y = d.overscanCount, R = d.rowCount, N = this.state, L = N.horizontalScrollDirection, x = N.isScrolling, E = N.scrollLeft, z = w || I || y || 1;
890
- if (C === 0 || R === 0)
891
- return [0, 0, 0, 0];
892
- var k = r(this.props, E, this._instanceProps), G = o(this.props, k, E, this._instanceProps), Z = !x || L === "backward" ? Math.max(1, z) : 1, U = !x || L === "forward" ? Math.max(1, z) : 1;
893
- return [Math.max(0, k - Z), Math.max(0, Math.min(C - 1, G + U)), k, G];
894
- }, P._getVerticalRangeToRender = function() {
895
- var d = this.props, C = d.columnCount, w = d.overscanCount, I = d.overscanRowCount, y = d.overscanRowsCount, R = d.rowCount, N = this.state, L = N.isScrolling, x = N.verticalScrollDirection, E = N.scrollTop, z = I || y || w || 1;
896
- if (C === 0 || R === 0)
897
- return [0, 0, 0, 0];
898
- var k = u(this.props, E, this._instanceProps), G = f(this.props, k, E, this._instanceProps), Z = !L || x === "backward" ? Math.max(1, z) : 1, U = !L || x === "forward" ? Math.max(1, z) : 1;
899
- return [Math.max(0, k - Z), Math.max(0, Math.min(R - 1, G + U)), k, G];
900
- }, S;
901
- }(zn), t.defaultProps = {
902
- direction: "ltr",
903
- itemData: void 0,
904
- useIsScrolling: !1
905
- }, t;
906
- }
907
- var So = function(t, n) {
908
- var r = t.children, o = t.direction, i = t.height, l = t.innerTagName, s = t.outerTagName, c = t.overscanColumnsCount, p = t.overscanCount, h = t.overscanRowsCount, m = t.width, u = n.instance;
909
- if (process.env.NODE_ENV !== "production") {
910
- if (typeof p == "number" && Ee && !Ee.has(u) && (Ee.add(u), console.warn("The overscanCount prop has been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (typeof c == "number" || typeof h == "number") && Oe && !Oe.has(u) && (Oe.add(u), console.warn("The overscanColumnsCount and overscanRowsCount props have been deprecated. Please use the overscanColumnCount and overscanRowCount props instead.")), (l != null || s != null) && De && !De.has(u) && (De.add(u), console.warn("The innerTagName and outerTagName props have been deprecated. Please use the innerElementType and outerElementType props instead.")), r == null)
911
- throw Error('An invalid "children" prop has been specified. Value should be a React component. ' + ('"' + (r === null ? "null" : typeof r) + '" was specified.'));
912
- switch (o) {
913
- case "ltr":
914
- case "rtl":
915
- break;
916
- default:
917
- throw Error('An invalid "direction" prop has been specified. Value should be either "ltr" or "rtl". ' + ('"' + o + '" was specified.'));
918
- }
919
- if (typeof m != "number")
920
- throw Error('An invalid "width" prop has been specified. Grids must specify a number for width. ' + ('"' + (m === null ? "null" : typeof m) + '" was specified.'));
921
- if (typeof i != "number")
922
- throw Error('An invalid "height" prop has been specified. Grids must specify a number for height. ' + ('"' + (i === null ? "null" : typeof i) + '" was specified.'));
923
- }
924
- }, zt = 50, sn = function(t, n) {
925
- var r = t.rowCount, o = n.rowMetadataMap, i = n.estimatedRowHeight, l = n.lastMeasuredRowIndex, s = 0;
926
- if (l >= r && (l = r - 1), l >= 0) {
927
- var c = o[l];
928
- s = c.offset + c.size;
929
- }
930
- var p = r - l - 1, h = p * i;
931
- return s + h;
932
- }, ln = function(t, n) {
933
- var r = t.columnCount, o = n.columnMetadataMap, i = n.estimatedColumnWidth, l = n.lastMeasuredColumnIndex, s = 0;
934
- if (l >= r && (l = r - 1), l >= 0) {
935
- var c = o[l];
936
- s = c.offset + c.size;
937
- }
938
- var p = r - l - 1, h = p * i;
939
- return s + h;
940
- }, ie = function(t, n, r, o) {
941
- var i, l, s;
942
- if (t === "column" ? (i = o.columnMetadataMap, l = n.columnWidth, s = o.lastMeasuredColumnIndex) : (i = o.rowMetadataMap, l = n.rowHeight, s = o.lastMeasuredRowIndex), r > s) {
943
- var c = 0;
944
- if (s >= 0) {
945
- var p = i[s];
946
- c = p.offset + p.size;
947
- }
948
- for (var h = s + 1; h <= r; h++) {
949
- var m = l(h);
950
- i[h] = {
951
- offset: c,
952
- size: m
953
- }, c += m;
954
- }
955
- t === "column" ? o.lastMeasuredColumnIndex = r : o.lastMeasuredRowIndex = r;
956
- }
957
- return i[r];
958
- }, Ft = function(t, n, r, o) {
959
- var i, l;
960
- t === "column" ? (i = r.columnMetadataMap, l = r.lastMeasuredColumnIndex) : (i = r.rowMetadataMap, l = r.lastMeasuredRowIndex);
961
- var s = l > 0 ? i[l].offset : 0;
962
- return s >= o ? cn(t, n, r, l, 0, o) : To(t, n, r, Math.max(0, l), o);
963
- }, cn = function(t, n, r, o, i, l) {
964
- for (; i <= o; ) {
965
- var s = i + Math.floor((o - i) / 2), c = ie(t, n, s, r).offset;
966
- if (c === l)
967
- return s;
968
- c < l ? i = s + 1 : c > l && (o = s - 1);
969
- }
970
- return i > 0 ? i - 1 : 0;
971
- }, To = function(t, n, r, o, i) {
972
- for (var l = t === "column" ? n.columnCount : n.rowCount, s = 1; o < l && ie(t, n, o, r).offset < i; )
973
- o += s, s *= 2;
974
- return cn(t, n, r, Math.min(o, l - 1), Math.floor(o / 2), i);
975
- }, kt = function(t, n, r, o, i, l, s) {
976
- var c = t === "column" ? n.width : n.height, p = ie(t, n, r, l), h = t === "column" ? ln(n, l) : sn(n, l), m = Math.max(0, Math.min(h - c, p.offset)), u = Math.max(0, p.offset - c + s + p.size);
977
- switch (o === "smart" && (i >= u - c && i <= m + c ? o = "auto" : o = "center"), o) {
978
- case "start":
979
- return m;
980
- case "end":
981
- return u;
982
- case "center":
983
- return Math.round(u + (m - u) / 2);
984
- case "auto":
985
- default:
986
- return i >= u && i <= m ? i : u > m || i < u ? u : m;
987
- }
988
- }, Io = /* @__PURE__ */ Po({
989
- getColumnOffset: function(t, n, r) {
990
- return ie("column", t, n, r).offset;
991
- },
992
- getColumnStartIndexForOffset: function(t, n, r) {
993
- return Ft("column", t, r, n);
994
- },
995
- getColumnStopIndexForStartIndex: function(t, n, r, o) {
996
- for (var i = t.columnCount, l = t.width, s = ie("column", t, n, o), c = r + l, p = s.offset + s.size, h = n; h < i - 1 && p < c; )
997
- h++, p += ie("column", t, h, o).size;
998
- return h;
999
- },
1000
- getColumnWidth: function(t, n, r) {
1001
- return r.columnMetadataMap[n].size;
1002
- },
1003
- getEstimatedTotalHeight: sn,
1004
- getEstimatedTotalWidth: ln,
1005
- getOffsetForColumnAndAlignment: function(t, n, r, o, i, l) {
1006
- return kt("column", t, n, r, o, i, l);
1007
- },
1008
- getOffsetForRowAndAlignment: function(t, n, r, o, i, l) {
1009
- return kt("row", t, n, r, o, i, l);
1010
- },
1011
- getRowOffset: function(t, n, r) {
1012
- return ie("row", t, n, r).offset;
1013
- },
1014
- getRowHeight: function(t, n, r) {
1015
- return r.rowMetadataMap[n].size;
1016
- },
1017
- getRowStartIndexForOffset: function(t, n, r) {
1018
- return Ft("row", t, r, n);
1019
- },
1020
- getRowStopIndexForStartIndex: function(t, n, r, o) {
1021
- for (var i = t.rowCount, l = t.height, s = ie("row", t, n, o), c = r + l, p = s.offset + s.size, h = n; h < i - 1 && p < c; )
1022
- h++, p += ie("row", t, h, o).size;
1023
- return h;
1024
- },
1025
- initInstanceProps: function(t, n) {
1026
- var r = t, o = r.estimatedColumnWidth, i = r.estimatedRowHeight, l = {
1027
- columnMetadataMap: {},
1028
- estimatedColumnWidth: o || zt,
1029
- estimatedRowHeight: i || zt,
1030
- lastMeasuredColumnIndex: -1,
1031
- lastMeasuredRowIndex: -1,
1032
- rowMetadataMap: {}
1033
- };
1034
- return n.resetAfterColumnIndex = function(s, c) {
1035
- c === void 0 && (c = !0), n.resetAfterIndices({
1036
- columnIndex: s,
1037
- shouldForceUpdate: c
1038
- });
1039
- }, n.resetAfterRowIndex = function(s, c) {
1040
- c === void 0 && (c = !0), n.resetAfterIndices({
1041
- rowIndex: s,
1042
- shouldForceUpdate: c
1043
- });
1044
- }, n.resetAfterIndices = function(s) {
1045
- var c = s.columnIndex, p = s.rowIndex, h = s.shouldForceUpdate, m = h === void 0 ? !0 : h;
1046
- typeof c == "number" && (l.lastMeasuredColumnIndex = Math.min(l.lastMeasuredColumnIndex, c - 1)), typeof p == "number" && (l.lastMeasuredRowIndex = Math.min(l.lastMeasuredRowIndex, p - 1)), n._getItemStyleCache(-1), m && n.forceUpdate();
1047
- }, l;
1048
- },
1049
- shouldResetStyleCacheOnItemSizeChange: !1,
1050
- validateProps: function(t) {
1051
- var n = t.columnWidth, r = t.rowHeight;
1052
- if (process.env.NODE_ENV !== "production") {
1053
- if (typeof n != "function")
1054
- throw Error('An invalid "columnWidth" prop has been specified. Value should be a function. ' + ('"' + (n === null ? "null" : typeof n) + '" was specified.'));
1055
- if (typeof r != "function")
1056
- throw Error('An invalid "rowHeight" prop has been specified. Value should be a function. ' + ('"' + (r === null ? "null" : typeof r) + '" was specified.'));
1057
- }
1058
- }
1059
- });
1060
- process.env.NODE_ENV;
1061
- function Wt(e, t) {
1062
- for (var n in e)
1063
- if (!(n in t))
1064
- return !0;
1065
- for (var r in t)
1066
- if (e[r] !== t[r])
1067
- return !0;
1068
- return !1;
1069
- }
1070
- var yo = ["style"], Ro = ["style"];
1071
- function xo(e, t) {
1072
- var n = e.style, r = Et(e, yo), o = t.style, i = Et(t, Ro);
1073
- return !Wt(n, o) && !Wt(r, i);
1074
- }
1075
- const Mo = () => {
1076
- const { viewMode: e } = Ge(), { scrollMode: t } = Pe(), { setColumnCount: n } = Bt(), { virtualScrollableElementRef: r } = Ue(), o = Xt(), i = M(
1077
- (f) => o.widths[f] || 0,
1078
- [o]
1079
- ), l = M(
1080
- (f) => o.heights[f] || 0,
1081
- [o]
1082
- ), s = D(() => o.heights.length, [o]), c = D(() => Math.max(...o.widths), [o]), p = D(() => t === Q.HORIZONTAL_SCROLLING ? s : e === ze.DUAL_PAGE ? 2 : 1, [e, t, t, s, r, c]);
1083
- A(() => {
1084
- n(p);
1085
- }, [p, n]);
1086
- const h = D(() => t === Q.HORIZONTAL_SCROLLING || t === Q.PAGE_SCROLLING ? 1 : Math.round(s / p), [p, s, t]), m = D(() => o.heights.reduce((f, v) => f + v, 0) / o.heights.length || 0, [o]), u = D(() => o.widths.reduce((f, v) => f + v, 0) / o.heights.length || 0, [o]);
1087
- return {
1088
- rowCount: h,
1089
- rowHeight: l,
1090
- columnCount: p,
1091
- columnWidth: i,
1092
- pageDimension: o,
1093
- estimatedRowHeight: m,
1094
- estimatedColumnWidth: u
1095
- };
1096
- };
1097
- let J;
1098
- typeof window < "u" ? J = window : typeof self < "u" ? J = self : J = global;
1099
- let ut = null, dt = null;
1100
- const Ht = 20, Qe = J.clearTimeout, $t = J.setTimeout, et = J.cancelAnimationFrame || J.mozCancelAnimationFrame || J.webkitCancelAnimationFrame, Vt = J.requestAnimationFrame || J.mozRequestAnimationFrame || J.webkitRequestAnimationFrame;
1101
- et == null || Vt == null ? (ut = Qe, dt = function(t) {
1102
- return $t(t, Ht);
1103
- }) : (ut = function([t, n]) {
1104
- et(t), Qe(n);
1105
- }, dt = function(t) {
1106
- const n = Vt(function() {
1107
- Qe(r), t();
1108
- }), r = $t(function() {
1109
- et(n), t();
1110
- }, Ht);
1111
- return [n, r];
1112
- });
1113
- function No(e) {
1114
- let t, n, r, o, i, l, s;
1115
- const c = typeof document < "u" && document.attachEvent;
1116
- if (!c) {
1117
- l = function(b) {
1118
- const S = b.__resizeTriggers__, P = S.firstElementChild, T = S.lastElementChild, d = P.firstElementChild;
1119
- T.scrollLeft = T.scrollWidth, T.scrollTop = T.scrollHeight, d.style.width = P.offsetWidth + 1 + "px", d.style.height = P.offsetHeight + 1 + "px", P.scrollLeft = P.scrollWidth, P.scrollTop = P.scrollHeight;
1120
- }, i = function(b) {
1121
- return b.offsetWidth !== b.__resizeLast__.width || b.offsetHeight !== b.__resizeLast__.height;
1122
- }, s = function(b) {
1123
- if (b.target.className && typeof b.target.className.indexOf == "function" && b.target.className.indexOf("contract-trigger") < 0 && b.target.className.indexOf("expand-trigger") < 0)
1124
- return;
1125
- const S = this;
1126
- l(this), this.__resizeRAF__ && ut(this.__resizeRAF__), this.__resizeRAF__ = dt(function() {
1127
- i(S) && (S.__resizeLast__.width = S.offsetWidth, S.__resizeLast__.height = S.offsetHeight, S.__resizeListeners__.forEach(function(d) {
1128
- d.call(S, b);
1129
- }));
1130
- });
1131
- };
1132
- let u = !1, f = "";
1133
- r = "animationstart";
1134
- const v = "Webkit Moz O ms".split(" ");
1135
- let _ = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), g = "";
1136
- {
1137
- const b = document.createElement("fakeelement");
1138
- if (b.style.animationName !== void 0 && (u = !0), u === !1) {
1139
- for (let S = 0; S < v.length; S++)
1140
- if (b.style[v[S] + "AnimationName"] !== void 0) {
1141
- g = v[S], f = "-" + g.toLowerCase() + "-", r = _[S], u = !0;
1142
- break;
1143
- }
1144
- }
1145
- }
1146
- n = "resizeanim", t = "@" + f + "keyframes " + n + " { from { opacity: 0; } to { opacity: 0; } } ", o = f + "animation: 1ms " + n + "; ";
1147
- }
1148
- const p = function(u) {
1149
- if (!u.getElementById("detectElementResize")) {
1150
- const f = (t || "") + ".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%; }', v = u.head || u.getElementsByTagName("head")[0], _ = u.createElement("style");
1151
- _.id = "detectElementResize", _.type = "text/css", e != null && _.setAttribute("nonce", e), _.styleSheet ? _.styleSheet.cssText = f : _.appendChild(u.createTextNode(f)), v.appendChild(_);
1152
- }
1153
- };
1154
- return {
1155
- addResizeListener: function(u, f) {
1156
- if (c)
1157
- u.attachEvent("onresize", f);
1158
- else {
1159
- if (!u.__resizeTriggers__) {
1160
- const v = u.ownerDocument, _ = J.getComputedStyle(u);
1161
- _ && _.position === "static" && (u.style.position = "relative"), p(v), u.__resizeLast__ = {}, u.__resizeListeners__ = [], (u.__resizeTriggers__ = v.createElement("div")).className = "resize-triggers";
1162
- const g = v.createElement("div");
1163
- g.className = "expand-trigger", g.appendChild(v.createElement("div"));
1164
- const b = v.createElement("div");
1165
- b.className = "contract-trigger", u.__resizeTriggers__.appendChild(g), u.__resizeTriggers__.appendChild(b), u.appendChild(u.__resizeTriggers__), l(u), u.addEventListener("scroll", s, !0), r && (u.__resizeTriggers__.__animationListener__ = function(P) {
1166
- P.animationName === n && l(u);
1167
- }, u.__resizeTriggers__.addEventListener(r, u.__resizeTriggers__.__animationListener__));
1168
- }
1169
- u.__resizeListeners__.push(f);
1170
- }
1171
- },
1172
- removeResizeListener: function(u, f) {
1173
- if (c)
1174
- u.detachEvent("onresize", f);
1175
- else if (u.__resizeListeners__.splice(u.__resizeListeners__.indexOf(f), 1), !u.__resizeListeners__.length) {
1176
- u.removeEventListener("scroll", s, !0), u.__resizeTriggers__.__animationListener__ && (u.__resizeTriggers__.removeEventListener(r, u.__resizeTriggers__.__animationListener__), u.__resizeTriggers__.__animationListener__ = null);
1177
- try {
1178
- u.__resizeTriggers__ = !u.removeChild(u.__resizeTriggers__);
1179
- } catch {
1180
- }
1181
- }
1182
- }
1183
- };
1184
- }
1185
- class Lo extends Fn {
1186
- constructor(...t) {
1187
- super(...t), this.state = {
1188
- height: this.props.defaultHeight || 0,
1189
- scaledHeight: this.props.defaultHeight || 0,
1190
- scaledWidth: this.props.defaultWidth || 0,
1191
- width: this.props.defaultWidth || 0
1192
- }, this._autoSizer = null, this._detectElementResize = null, this._parentNode = null, this._resizeObserver = null, this._timeoutId = null, this._onResize = () => {
1193
- this._timeoutId = null;
1194
- const {
1195
- disableHeight: n,
1196
- disableWidth: r,
1197
- onResize: o
1198
- } = this.props;
1199
- if (this._parentNode) {
1200
- const i = window.getComputedStyle(this._parentNode) || {}, l = parseFloat(i.paddingLeft || "0"), s = parseFloat(i.paddingRight || "0"), c = parseFloat(i.paddingTop || "0"), p = parseFloat(i.paddingBottom || "0"), h = this._parentNode.getBoundingClientRect(), m = h.height - c - p, u = h.width - l - s, f = this._parentNode.offsetHeight - c - p, v = this._parentNode.offsetWidth - l - s;
1201
- (!n && (this.state.height !== f || this.state.scaledHeight !== m) || !r && (this.state.width !== v || this.state.scaledWidth !== u)) && (this.setState({
1202
- height: f,
1203
- width: v,
1204
- scaledHeight: m,
1205
- scaledWidth: u
1206
- }), typeof o == "function" && o({
1207
- height: f,
1208
- scaledHeight: m,
1209
- scaledWidth: u,
1210
- width: v
1211
- }));
1212
- }
1213
- }, this._setRef = (n) => {
1214
- this._autoSizer = n;
1215
- };
1216
- }
1217
- componentDidMount() {
1218
- const {
1219
- nonce: t
1220
- } = this.props, n = this._autoSizer ? this._autoSizer.parentNode : null;
1221
- if (n != null && n.ownerDocument && n.ownerDocument.defaultView && n instanceof n.ownerDocument.defaultView.HTMLElement) {
1222
- this._parentNode = n;
1223
- const r = n.ownerDocument.defaultView.ResizeObserver;
1224
- r != null ? (this._resizeObserver = new r(() => {
1225
- this._timeoutId = setTimeout(this._onResize, 0);
1226
- }), this._resizeObserver.observe(n)) : (this._detectElementResize = No(t), this._detectElementResize.addResizeListener(n, this._onResize)), this._onResize();
1227
- }
1228
- }
1229
- componentWillUnmount() {
1230
- this._parentNode && (this._detectElementResize && this._detectElementResize.removeResizeListener(this._parentNode, this._onResize), this._timeoutId !== null && clearTimeout(this._timeoutId), this._resizeObserver && this._resizeObserver.disconnect());
1231
- }
1232
- render() {
1233
- const {
1234
- children: t,
1235
- defaultHeight: n,
1236
- defaultWidth: r,
1237
- disableHeight: o = !1,
1238
- disableWidth: i = !1,
1239
- doNotBailOutOnEmptyChildren: l = !1,
1240
- nonce: s,
1241
- onResize: c,
1242
- style: p = {},
1243
- tagName: h = "div",
1244
- ...m
1245
- } = this.props, {
1246
- height: u,
1247
- scaledHeight: f,
1248
- scaledWidth: v,
1249
- width: _
1250
- } = this.state, g = {
1251
- overflow: "visible"
1252
- }, b = {};
1253
- let S = !1;
1254
- return o || (u === 0 && (S = !0), g.height = 0, b.height = u, b.scaledHeight = f), i || (_ === 0 && (S = !0), g.width = 0, b.width = _, b.scaledWidth = v), l && (S = !1), Le(h, {
1255
- ref: this._setRef,
1256
- style: {
1257
- ...g,
1258
- ...p
1259
- },
1260
- ...m
1261
- }, !S && t(b));
1262
- }
1263
- }
1264
- const Eo = (e = 1) => {
1265
- const [t, n] = F(e), [r, o] = F(0), { scrollToPage: i } = _t(), l = $(1), { isScrolling: s } = Kt(), { viewMode: c } = Ge(), { scrollMode: p } = Pe(), h = yr(t, 100), m = M(
1266
- (g) => {
1267
- if (!/^[0-9]*$/g.test(g.toString()) || !g)
1268
- return { success: !1, currentPage: l.current };
1269
- const S = +g;
1270
- return S < 0 || S > r ? { success: !1, currentPage: l.current } : (n(S), l.current = S, { success: !0, currentPage: +g });
1271
- },
1272
- [r]
1273
- ), u = M(m, [m]), f = M(
1274
- (g) => {
1275
- const b = m(g);
1276
- return b.success && (s.current = !0, i(b.currentPage)), b;
1277
- },
1278
- [m, i]
1279
- ), v = M(() => {
1280
- let g = t - 1;
1281
- f(g);
1282
- }, [f, t, c, p]), _ = M(() => {
1283
- let g = t + 1;
1284
- f(g);
1285
- }, [f, t, c, p]);
1286
- return {
1287
- focusedPage: h,
1288
- totalPages: r,
1289
- setFocusedPage: u,
1290
- setTotalPages: o,
1291
- nextPage: _,
1292
- prevPage: v,
1293
- goToPage: f
1294
- };
1295
- }, un = We({
1296
- focusedPage: 0,
1297
- setFocusedPage: (e) => {
1298
- },
1299
- goToPage: (e) => ({ success: !!e, currentPage: +e }),
1300
- totalPages: 0,
1301
- setTotalPages: (e) => {
1302
- },
1303
- prevPage: () => {
1304
- },
1305
- nextPage: () => {
1306
- }
1307
- }), ee = () => {
1308
- const e = He(un);
1309
- return typeof (e == null ? void 0 : e.focusedPage) > "u" && Rr.error("Please use this hooks inside children component of RPController or RPLayout"), e;
1310
- }, Oo = ({ children: e }) => {
1311
- const { initialPage: t = 1 } = gr(), { pdf: n } = Y(), { focusedPage: r, totalPages: o, setFocusedPage: i, setTotalPages: l, goToPage: s, nextPage: c, prevPage: p } = Eo(t);
1312
- return A(() => {
1313
- n != null && n.numPages && l(n.numPages);
1314
- }, [n, l, o, t]), A(() => {
1315
- requestAnimationFrame(() => {
1316
- s(t);
1317
- });
1318
- }, [s, t]), /* @__PURE__ */ a(
1319
- un.Provider,
1320
- {
1321
- value: {
1322
- focusedPage: r,
1323
- totalPages: o,
1324
- setFocusedPage: i,
1325
- setTotalPages: l,
1326
- nextPage: c,
1327
- prevPage: p,
1328
- goToPage: s
1329
- },
1330
- children: e
1331
- }
1332
- );
1333
- }, Do = ({ widths: e, heights: t }) => {
1334
- const { focusedPage: n, totalPages: r } = ee(), o = D(() => {
1335
- const s = [], c = Math.ceil(n / 2) * 2 - 1;
1336
- if (s.push(c), c + 1 < r) {
1337
- const p = c + 1;
1338
- s.push(p);
1339
- }
1340
- return s;
1341
- }, [n, r]), i = D(() => [
1342
- {
1343
- position: "absolute",
1344
- left: 0,
1345
- width: e(n - 1),
1346
- height: t(n - 1)
1347
- },
1348
- {
1349
- position: "absolute",
1350
- left: e(n),
1351
- top: 0,
1352
- width: e(n),
1353
- height: t(n)
1354
- }
1355
- ], [e, t, o]), l = D(() => i.reduce((s, c) => s + Number(c.width || 0), 0), [i]);
1356
- return /* @__PURE__ */ a("div", { style: { width: l, position: "relative" }, children: o.map((s, c) => /* @__PURE__ */ a(wt, { style: i[c], pageNumber: s }, s)) });
1357
- }, Ao = ({ widths: e, heights: t }) => {
1358
- const { focusedPage: n } = ee(), r = D(() => ({
1359
- position: "absolute",
1360
- width: e(n - 1),
1361
- height: t(n - 1)
1362
- }), [e, t, n]), o = D(() => e(n - 1), [e]);
1363
- return /* @__PURE__ */ a(
1364
- "div",
1365
- {
1366
- style: {
1367
- width: o,
1368
- position: "relative"
1369
- },
1370
- children: /* @__PURE__ */ a(wt, { style: r, pageNumber: n }, n)
1371
- }
1372
- );
1373
- }, zo = kn(({ columnIndex: e, rowIndex: t, data: n, style: r }) => {
1374
- const o = D(() => e + 1 + t * n.columnCount, [e, t, n]);
1375
- return /* @__PURE__ */ a(
1376
- wt,
1377
- {
1378
- style: r,
1379
- onIntersectRatioChange: n.handleIntersectRatioChange,
1380
- pageNumber: o
1381
- },
1382
- o
1383
- );
1384
- }, xo), ns = () => {
1385
- const { getContainer: e, container: t } = Sr(), { scrollToPage: n } = _t(), {
1386
- virtualScrollRef: r,
1387
- getVirtualScrollRef: o,
1388
- getPageScrollElementRef: i,
1389
- getVirtualScrollableElementRef: l,
1390
- setTotalInnerDimensions: s,
1391
- totalInnerDimensions: c
1392
- } = Ue(), { nextPage: p, prevPage: h, setFocusedPage: m, focusedPage: u } = ee(), { scrollMode: f } = Pe(), { viewMode: v } = Ge(), _ = $(null), g = $({
1393
- height: 0,
1394
- width: 0
1395
- }), b = $({
1396
- viewMode: v,
1397
- scrollMode: f
1398
- }), { isFullScreen: S } = _r(), {
1399
- pageDimension: P,
1400
- rowCount: T,
1401
- rowHeight: d,
1402
- columnCount: C,
1403
- columnWidth: w,
1404
- estimatedColumnWidth: I,
1405
- estimatedRowHeight: y
1406
- } = Mo(), [R, N] = F({}), { isScrolling: L } = Kt(), x = $(), E = $({
1407
- scrollTop: 0,
1408
- scrollLeft: 0
1409
- }), { isPressed: z } = Tr(), { selectionMode: k } = fr(), { initializeGrabScroll: G, scrollBehavior: Z } = Ir({
1410
- isPressed: z
1411
- }), U = D(() => k === jt.HAND, [k]), K = M((W, H) => {
1412
- N((q) => ({ ...q, [W]: Math.round(H * 100) }));
1413
- }, []), ue = D(() => ({
1414
- columnCount: C,
1415
- handleIntersectRatioChange: K
1416
- }), [C, K]), oe = M(
1417
- (W) => {
1418
- const H = document.activeElement !== t;
1419
- !S && H || (["ArrowUp", "ArrowLeft"].includes(W.key) ? (W.preventDefault(), h()) : ["ArrowDown", "ArrowRight"].includes(W.key) && (W.preventDefault(), p()));
1420
- },
1421
- [p, h, S, f]
1422
- ), ve = M((W) => {
1423
- E.current = {
1424
- scrollTop: W.scrollTop,
1425
- scrollLeft: W.scrollLeft
1426
- };
1427
- }, []);
1428
- A(() => (window.addEventListener("keydown", oe), () => {
1429
- window.removeEventListener("keydown", oe);
1430
- }), [oe]), A(() => {
1431
- if (_.current && (_.current.style.position = "relative"), !!r) {
1432
- g.current = c, s({
1433
- height: Array.from({ length: T }).reduce(
1434
- (W, H, q) => W + d(q),
1435
- 0
1436
- ),
1437
- width: Array.from({ length: C }).reduce(
1438
- (W, H, q) => W + w(q),
1439
- 0
1440
- )
1441
- });
1442
- for (let W = 0; W < T; W++)
1443
- for (let H = 0; H < C; H++)
1444
- r.resetAfterIndices({
1445
- columnIndex: H,
1446
- rowIndex: W,
1447
- shouldForceUpdate: !0
1448
- });
1449
- }
1450
- }, [T, C, P, r, n]), A(() => {
1451
- if (L.current)
1452
- return;
1453
- if (b.current.viewMode !== v || b.current.scrollMode !== f) {
1454
- x.current && clearTimeout(x.current), N({}), n(u), f === Q.HORIZONTAL_SCROLLING && (r == null || r.scrollTo({
1455
- scrollTop: 0
1456
- })), x.current = setTimeout(() => {
1457
- requestAnimationFrame(() => {
1458
- b.current = { viewMode: v, scrollMode: f };
1459
- });
1460
- }, 100);
1461
- return;
1462
- }
1463
- const H = E.current.scrollTop, q = E.current.scrollLeft;
1464
- if (c.height !== 0 && c.width !== 0) {
1465
- const { height: le, width: Te } = c, { height: de, width: pe } = g.current, Ze = H / de * le, je = q / pe * Te, Dn = Math.min(Ze, le) || 0, An = Math.min(je, Te) || 0;
1466
- r == null || r.scrollTo({
1467
- scrollTop: Dn,
1468
- scrollLeft: An
1469
- });
1470
- }
1471
- }, [c, v, f]), A(() => {
1472
- const W = Object.entries(R);
1473
- if (L.current) {
1474
- L.current && (L.current = !1);
1475
- return;
1476
- }
1477
- let H = 0, q = -1;
1478
- W.forEach((le) => {
1479
- q < le[1] && (H = Number(le[0]), q = le[1]);
1480
- }), H && m(H);
1481
- }, [R, m]), A(() => () => {
1482
- x.current && clearTimeout(x.current);
1483
- }, []);
1484
- const _e = D(() => j(ae["rp-pages-container"], {
1485
- [ae["rp-cursor-grab"]]: U && !z,
1486
- [ae["rp-cursor-grabbing"]]: U && z
1487
- }), [U, z]), Se = M(
1488
- (W) => {
1489
- if (U && W) {
1490
- const H = j(ae["rp-pages"]), q = document.querySelector(`.${H}`);
1491
- G(q);
1492
- }
1493
- },
1494
- [U, G, ae]
1495
- );
1496
- return /* @__PURE__ */ a("div", { ref: e, tabIndex: -1, className: _e, children: /* @__PURE__ */ a(Lo, { children: ({ width: W, height: H }) => /* @__PURE__ */ a(
1497
- "div",
1498
- {
1499
- "data-rp": "pagesWrapper",
1500
- ref: Se,
1501
- style: { width: W, height: H, scrollBehavior: Z },
1502
- children: f === Q.PAGE_SCROLLING ? /* @__PURE__ */ a(
1503
- "div",
1504
- {
1505
- ref: i,
1506
- style: { width: W, height: H },
1507
- className: j(ae["rp-pages"], ae["rp-page-scrolling-wrapper"]),
1508
- children: v === ze.DUAL_PAGE ? /* @__PURE__ */ a(Do, { widths: w, heights: d }) : /* @__PURE__ */ a(Ao, { widths: w, heights: d })
1509
- }
1510
- ) : I ? /* @__PURE__ */ a(
1511
- Io,
1512
- {
1513
- ref: o,
1514
- itemData: ue,
1515
- outerRef: l,
1516
- innerRef: _,
1517
- onScroll: ve,
1518
- columnCount: C,
1519
- columnWidth: w,
1520
- rowHeight: d,
1521
- height: H,
1522
- width: W,
1523
- estimatedColumnWidth: I,
1524
- estimatedRowHeight: y,
1525
- rowCount: T,
1526
- className: j(
1527
- ae["rp-pages"],
1528
- f === Q.HORIZONTAL_SCROLLING ? ae["rp-pages-horizontal-scroll"] : ""
1529
- ),
1530
- style: { scrollBehavior: Z },
1531
- children: zo
1532
- }
1533
- ) : null
1534
- }
1535
- ) }) });
1536
- }, Ie = {
1537
- "rp-toolbar-content": "_rp-toolbar-content_fw3uq_1",
1538
- "rp-toolbar-wrapper": "_rp-toolbar-wrapper_fw3uq_10",
1539
- "rp-toolbar-start": "_rp-toolbar-start_fw3uq_18",
1540
- "rp-toolbar-middle": "_rp-toolbar-middle_fw3uq_24",
1541
- "rp-toolbar-end": "_rp-toolbar-end_fw3uq_31"
1542
- }, tt = {
1543
- "rp-paginate": "_rp-paginate_1vu6o_1",
1544
- "rp-page-input": "_rp-page-input_1vu6o_6",
1545
- "rp-total-page": "_rp-total-page_1vu6o_12"
1546
- }, Fo = () => {
1547
- const { prevIcon: e } = re();
1548
- return e || /* @__PURE__ */ a(Me, {});
1549
- }, ko = () => {
1550
- const { nextIcon: e } = re();
1551
- return e || /* @__PURE__ */ a(Me, { style: { transform: "rotate(180deg" } });
1552
- }, Wo = () => {
1553
- const { focusedPage: e, totalPages: t, setFocusedPage: n, nextPage: r, prevPage: o, goToPage: i } = ee(), [l, s] = F(e.toString()), { pageNavigationTool: c = !0 } = se(), { isSmallScreen: p } = ge();
1554
- A(() => {
1555
- s(e.toString());
1556
- }, [e]);
1557
- const h = M((v) => {
1558
- const _ = v.target.value;
1559
- s(_);
1560
- }, []), m = M(() => {
1561
- const v = i(l);
1562
- v.success || s(v.currentPage.toString());
1563
- }, [i, l, t]), u = M(() => {
1564
- s(e.toString());
1565
- }, [e]), f = M(
1566
- (v) => {
1567
- v.key === "Enter" && m();
1568
- },
1569
- [m]
1570
- );
1571
- return typeof c != "boolean" ? /* @__PURE__ */ a(
1572
- c,
1573
- {
1574
- total: t,
1575
- current: e,
1576
- nextPage: r,
1577
- prevPage: o,
1578
- goToPage: i,
1579
- changePage: n
1580
- }
1581
- ) : c ? /* @__PURE__ */ O("div", { className: tt["rp-paginate"], children: [
1582
- !p && /* @__PURE__ */ a(X, { content: "Previous page", children: /* @__PURE__ */ a(B, { onClick: o, disabled: e === 1, children: /* @__PURE__ */ a(Fo, {}) }) }),
1583
- /* @__PURE__ */ a(
1584
- Zt,
1585
- {
1586
- onKeyDown: f,
1587
- onBlur: u,
1588
- onChange: h,
1589
- value: l,
1590
- className: tt["rp-page-input"]
1591
- }
1592
- ),
1593
- /* @__PURE__ */ O("span", { className: tt["rp-total-page"], children: [
1594
- "/",
1595
- t
1596
- ] }),
1597
- !p && /* @__PURE__ */ a(X, { content: "Next page", children: /* @__PURE__ */ a(B, { onClick: r, disabled: e === t, children: /* @__PURE__ */ a(ko, {}) }) })
1598
- ] }) : null;
1599
- };
1600
- var bt = "Dialog", [dn, rs] = Fr(bt), [Ho, te] = dn(bt), pn = (e) => {
1601
- const {
1602
- __scopeDialog: t,
1603
- children: n,
1604
- open: r,
1605
- defaultOpen: o,
1606
- onOpenChange: i,
1607
- modal: l = !0
1608
- } = e, s = V.useRef(null), c = V.useRef(null), [p = !1, h] = Wr({
1609
- prop: r,
1610
- defaultProp: o,
1611
- onChange: i
1612
- });
1613
- return /* @__PURE__ */ a(
1614
- Ho,
1615
- {
1616
- scope: t,
1617
- triggerRef: s,
1618
- contentRef: c,
1619
- contentId: Be(),
1620
- titleId: Be(),
1621
- descriptionId: Be(),
1622
- open: p,
1623
- onOpenChange: h,
1624
- onOpenToggle: V.useCallback(() => h((m) => !m), [h]),
1625
- modal: l,
1626
- children: n
1627
- }
1628
- );
1629
- };
1630
- pn.displayName = bt;
1631
- var hn = "DialogTrigger", $o = V.forwardRef(
1632
- (e, t) => {
1633
- const { __scopeDialog: n, ...r } = e, o = te(hn, n), i = mt(t, o.triggerRef);
1634
- return /* @__PURE__ */ a(
1635
- Ne.button,
1636
- {
1637
- type: "button",
1638
- "aria-haspopup": "dialog",
1639
- "aria-expanded": o.open,
1640
- "aria-controls": o.contentId,
1641
- "data-state": St(o.open),
1642
- ...r,
1643
- ref: i,
1644
- onClick: xe(e.onClick, o.onOpenToggle)
1645
- }
1646
- );
1647
- }
1648
- );
1649
- $o.displayName = hn;
1650
- var Ct = "DialogPortal", [Vo, fn] = dn(Ct, {
1651
- forceMount: void 0
1652
- }), mn = (e) => {
1653
- const { __scopeDialog: t, forceMount: n, children: r, container: o } = e, i = te(Ct, t);
1654
- return /* @__PURE__ */ a(Vo, { scope: t, forceMount: n, children: V.Children.map(r, (l) => /* @__PURE__ */ a(gt, { present: n || i.open, children: /* @__PURE__ */ a(zr, { asChild: !0, container: o, children: l }) })) });
1655
- };
1656
- mn.displayName = Ct;
1657
- var ke = "DialogOverlay", gn = V.forwardRef(
1658
- (e, t) => {
1659
- const n = fn(ke, e.__scopeDialog), { forceMount: r = n.forceMount, ...o } = e, i = te(ke, e.__scopeDialog);
1660
- return i.modal ? /* @__PURE__ */ a(gt, { present: r || i.open, children: /* @__PURE__ */ a(Go, { ...o, ref: t }) }) : null;
1661
- }
1662
- );
1663
- gn.displayName = ke;
1664
- var Go = V.forwardRef(
1665
- (e, t) => {
1666
- const { __scopeDialog: n, ...r } = e, o = te(ke, n);
1667
- return (
1668
- // Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
1669
- // ie. when `Overlay` and `Content` are siblings
1670
- /* @__PURE__ */ a(Nr, { as: Lr, allowPinchZoom: !0, shards: [o.contentRef], children: /* @__PURE__ */ a(
1671
- Ne.div,
1672
- {
1673
- "data-state": St(o.open),
1674
- ...r,
1675
- ref: t,
1676
- style: { pointerEvents: "auto", ...r.style }
1677
- }
1678
- ) })
1679
- );
1680
- }
1681
- ), me = "DialogContent", vn = V.forwardRef(
1682
- (e, t) => {
1683
- const n = fn(me, e.__scopeDialog), { forceMount: r = n.forceMount, ...o } = e, i = te(me, e.__scopeDialog);
1684
- return /* @__PURE__ */ a(gt, { present: r || i.open, children: i.modal ? /* @__PURE__ */ a(Uo, { ...o, ref: t }) : /* @__PURE__ */ a(qo, { ...o, ref: t }) });
1685
- }
1686
- );
1687
- vn.displayName = me;
1688
- var Uo = V.forwardRef(
1689
- (e, t) => {
1690
- const n = te(me, e.__scopeDialog), r = V.useRef(null), o = mt(t, n.contentRef, r);
1691
- return V.useEffect(() => {
1692
- const i = r.current;
1693
- if (i)
1694
- return Er(i);
1695
- }, []), /* @__PURE__ */ a(
1696
- _n,
1697
- {
1698
- ...e,
1699
- ref: o,
1700
- trapFocus: n.open,
1701
- disableOutsidePointerEvents: !0,
1702
- onCloseAutoFocus: xe(e.onCloseAutoFocus, (i) => {
1703
- var l;
1704
- i.preventDefault(), (l = n.triggerRef.current) == null || l.focus();
1705
- }),
1706
- onPointerDownOutside: xe(e.onPointerDownOutside, (i) => {
1707
- const l = i.detail.originalEvent, s = l.button === 0 && l.ctrlKey === !0;
1708
- (l.button === 2 || s) && i.preventDefault();
1709
- }),
1710
- onFocusOutside: xe(
1711
- e.onFocusOutside,
1712
- (i) => i.preventDefault()
1713
- )
1714
- }
1715
- );
1716
- }
1717
- ), qo = V.forwardRef(
1718
- (e, t) => {
1719
- const n = te(me, e.__scopeDialog), r = V.useRef(!1), o = V.useRef(!1);
1720
- return /* @__PURE__ */ a(
1721
- _n,
1722
- {
1723
- ...e,
1724
- ref: t,
1725
- trapFocus: !1,
1726
- disableOutsidePointerEvents: !1,
1727
- onCloseAutoFocus: (i) => {
1728
- var l, s;
1729
- (l = e.onCloseAutoFocus) == null || l.call(e, i), i.defaultPrevented || (r.current || (s = n.triggerRef.current) == null || s.focus(), i.preventDefault()), r.current = !1, o.current = !1;
1730
- },
1731
- onInteractOutside: (i) => {
1732
- var c, p;
1733
- (c = e.onInteractOutside) == null || c.call(e, i), i.defaultPrevented || (r.current = !0, i.detail.originalEvent.type === "pointerdown" && (o.current = !0));
1734
- const l = i.target;
1735
- ((p = n.triggerRef.current) == null ? void 0 : p.contains(l)) && i.preventDefault(), i.detail.originalEvent.type === "focusin" && o.current && i.preventDefault();
1736
- }
1737
- }
1738
- );
1739
- }
1740
- ), _n = V.forwardRef(
1741
- (e, t) => {
1742
- const { __scopeDialog: n, trapFocus: r, onOpenAutoFocus: o, onCloseAutoFocus: i, ...l } = e, s = te(me, n), c = V.useRef(null), p = mt(t, c);
1743
- return Or(), /* @__PURE__ */ O(Ae, { children: [
1744
- /* @__PURE__ */ a(
1745
- Dr,
1746
- {
1747
- asChild: !0,
1748
- loop: !0,
1749
- trapped: r,
1750
- onMountAutoFocus: o,
1751
- onUnmountAutoFocus: i,
1752
- children: /* @__PURE__ */ a(
1753
- Ar,
1754
- {
1755
- role: "dialog",
1756
- id: s.contentId,
1757
- "aria-describedby": s.descriptionId,
1758
- "aria-labelledby": s.titleId,
1759
- "data-state": St(s.open),
1760
- ...l,
1761
- ref: p,
1762
- onDismiss: () => s.onOpenChange(!1)
1763
- }
1764
- )
1765
- }
1766
- ),
1767
- /* @__PURE__ */ O(Ae, { children: [
1768
- /* @__PURE__ */ a(jo, { titleId: s.titleId }),
1769
- /* @__PURE__ */ a(Ko, { contentRef: c, descriptionId: s.descriptionId })
1770
- ] })
1771
- ] });
1772
- }
1773
- ), Pt = "DialogTitle", wn = V.forwardRef(
1774
- (e, t) => {
1775
- const { __scopeDialog: n, ...r } = e, o = te(Pt, n);
1776
- return /* @__PURE__ */ a(Ne.h2, { id: o.titleId, ...r, ref: t });
1777
- }
1778
- );
1779
- wn.displayName = Pt;
1780
- var bn = "DialogDescription", Zo = V.forwardRef(
1781
- (e, t) => {
1782
- const { __scopeDialog: n, ...r } = e, o = te(bn, n);
1783
- return /* @__PURE__ */ a(Ne.p, { id: o.descriptionId, ...r, ref: t });
1784
- }
1785
- );
1786
- Zo.displayName = bn;
1787
- var Cn = "DialogClose", Pn = V.forwardRef(
1788
- (e, t) => {
1789
- const { __scopeDialog: n, ...r } = e, o = te(Cn, n);
1790
- return /* @__PURE__ */ a(
1791
- Ne.button,
1792
- {
1793
- type: "button",
1794
- ...r,
1795
- ref: t,
1796
- onClick: xe(e.onClick, () => o.onOpenChange(!1))
1797
- }
1798
- );
1799
- }
1800
- );
1801
- Pn.displayName = Cn;
1802
- function St(e) {
1803
- return e ? "open" : "closed";
1804
- }
1805
- var Sn = "DialogTitleWarning", [os, Tn] = kr(Sn, {
1806
- contentName: me,
1807
- titleName: Pt,
1808
- docsSlug: "dialog"
1809
- }), jo = ({ titleId: e }) => {
1810
- const t = Tn(Sn), n = `\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
1811
-
1812
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
1813
-
1814
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;
1815
- return V.useEffect(() => {
1816
- e && (document.getElementById(e) || console.error(n));
1817
- }, [n, e]), null;
1818
- }, Bo = "DialogDescriptionWarning", Ko = ({ contentRef: e, descriptionId: t }) => {
1819
- const r = `Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Tn(Bo).contentName}}.`;
1820
- return V.useEffect(() => {
1821
- var i;
1822
- const o = (i = e.current) == null ? void 0 : i.getAttribute("aria-describedby");
1823
- t && o && (document.getElementById(t) || console.warn(r));
1824
- }, [r, e, t]), null;
1825
- }, Xo = pn, Jo = mn, Yo = gn, Qo = vn, ea = wn, ta = Pn;
1826
- const fe = {
1827
- "rp-dialog-wrapper": "_rp-dialog-wrapper_slqo7_1",
1828
- "rp-dialog-overlay": "_rp-dialog-overlay_slqo7_7",
1829
- "rp-document-dialog": "_rp-document-dialog_slqo7_13",
1830
- "rp-document-properties": "_rp-document-properties_slqo7_35",
1831
- "rp-dialog-title": "_rp-dialog-title_slqo7_39",
1832
- "rp-dialog-close": "_rp-dialog-close_slqo7_47",
1833
- "rp-properties-divider": "_rp-properties-divider_slqo7_55"
1834
- }, na = () => {
1835
- const { pdfProperties: e } = Y(), { container: t } = qe(), { activeDocumentProperties: n, setActiveDocumentProperties: r } = $r(), o = D(() => {
1836
- if (!e)
1837
- return [];
1838
- const {
1839
- fileSize: i,
1840
- filename: l,
1841
- title: s,
1842
- author: c,
1843
- subject: p,
1844
- createdOn: h,
1845
- creator: m,
1846
- keywords: u,
1847
- modifierOn: f,
1848
- pdfProducer: v,
1849
- pdfVersion: _,
1850
- pageCount: g
1851
- } = e;
1852
- return [
1853
- { label: "File name", value: l },
1854
- { label: "File size", value: i },
1855
- { separate: !0 },
1856
- { label: "Title", value: s },
1857
- { label: "Author", value: c },
1858
- { label: "Subject", value: p },
1859
- { label: "Keywords", value: u },
1860
- { label: "Creator", value: m },
1861
- {
1862
- label: "Created on",
1863
- value: h ? it(h) : ""
1864
- },
1865
- {
1866
- label: "Modified on",
1867
- value: f ? it(f) : ""
1868
- },
1869
- { separate: !0 },
1870
- { label: "PDF producer", value: v },
1871
- { label: "PDF version", value: _ },
1872
- { label: "Page count", value: g }
1873
- ];
1874
- }, [e]);
1875
- return /* @__PURE__ */ a(Xo, { open: n, onOpenChange: r, children: /* @__PURE__ */ a(Jo, { container: t, children: /* @__PURE__ */ O("div", { className: fe["rp-dialog-wrapper"], children: [
1876
- /* @__PURE__ */ a(Yo, { className: fe["rp-dialog-overlay"] }),
1877
- /* @__PURE__ */ O(Qo, { className: fe["rp-document-dialog"], children: [
1878
- /* @__PURE__ */ a(ea, { className: fe["rp-dialog-title"], children: "Document Properties" }),
1879
- /* @__PURE__ */ a("div", { className: fe["rp-document-properties"], children: o.map((i, l) => /* @__PURE__ */ a("div", { children: i.separate ? /* @__PURE__ */ a("div", { className: fe["rp-properties-divider"] }) : /* @__PURE__ */ a(Hr, { label: i.label, value: i.value }) }, l)) }),
1880
- /* @__PURE__ */ a(ta, { asChild: !0, className: fe["rp-dialog-close"], children: /* @__PURE__ */ a(Yt, {}) })
1881
- ] })
1882
- ] }) }) });
1883
- }, ra = {
1884
- "rp-other-tool-content": "_rp-other-tool-content_su718_1"
1885
- }, oa = () => {
1886
- const { filename: e, pdfSrc: t } = Y();
1887
- return { downloadFile: () => {
1888
- if (!e)
1889
- return;
1890
- const r = document.createElement("a");
1891
- r.href = t, r.download = e, document.body.appendChild(r), r.click(), document.body.removeChild(r);
1892
- } };
1893
- }, In = () => {
1894
- const { downloadIcon: e } = re();
1895
- return e || /* @__PURE__ */ a(Zr, {});
1896
- }, yn = ({ children: e, className: t }) => /* @__PURE__ */ a(X, { className: t, content: "Download file", children: e }), aa = ({ downloadFile: e }) => /* @__PURE__ */ a(yn, { children: /* @__PURE__ */ a(B, { onClick: e, children: /* @__PURE__ */ a(In, {}) }) }), ia = ({ downloadFile: e }) => /* @__PURE__ */ a(ce, { onClick: e, children: /* @__PURE__ */ O(yn, { className: "rp-menu-item", children: [
1897
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(In, {}) }),
1898
- "Download file"
1899
- ] }) }), Rn = () => {
1900
- const { downloadFile: e } = oa(), { downloadTool: t = !0 } = se(), { isSmallScreen: n } = ge();
1901
- return t ? n ? /* @__PURE__ */ a(ia, { downloadFile: e }) : typeof t == "function" ? /* @__PURE__ */ a(t, { downloadFile: e }) : t ? /* @__PURE__ */ a(aa, { downloadFile: e }) : null : null;
1902
- };
1903
- const sa = () => {
1904
- const { pdf: e, pages: t } = Y(), [n, r] = F({
1905
- loadedPages: 0,
1906
- totalPages: 0,
1907
- percentage: 0
1908
- }), [o, i] = F(!1), [l, s] = F(!1), [c, p] = F(null), h = $(!1);
1909
- A(() => {
1910
- h.current;
1911
- }, [h]);
1912
- const m = M(() => {
1913
- document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
1914
- const P = document.querySelector(".rp-print-zone");
1915
- P && P.remove();
1916
- }, []), u = M(() => {
1917
- h.current = !1, i(!1), s(!1), p(null), r({
1918
- loadedPages: 0,
1919
- totalPages: 0,
1920
- percentage: 0
1921
- });
1922
- }, []), f = () => {
1923
- h.current = !0;
1924
- }, v = async ({
1925
- scratchCanvas: P,
1926
- pdfDocument: T,
1927
- pageNumber: d,
1928
- viewerPdfPage: C,
1929
- printResolution: w,
1930
- optionalContentConfigPromise: I,
1931
- printAnnotationStoragePromise: y
1932
- }) => {
1933
- if (h.current) {
1934
- u();
1935
- return;
1936
- }
1937
- const R = w / tr.PDF;
1938
- P.width = Math.floor(C.width * R), P.height = Math.floor(C.height * R);
1939
- const N = P.getContext("2d");
1940
- N.save(), N.fillStyle = "rgb(255, 255, 255)", N.fillRect(0, 0, P.width, P.height), N.restore();
1941
- const [L, x] = await Promise.all([
1942
- T.getPage(d),
1943
- y
1944
- ]);
1945
- if (h.current) {
1946
- u();
1947
- return;
1948
- }
1949
- const E = {
1950
- canvasContext: N,
1951
- transform: [R, 0, 0, R, 0, 0],
1952
- viewport: L.getViewport({ scale: 1, rotation: C.rotation }),
1953
- intent: "print",
1954
- annotationMode: nr.ENABLE_STORAGE,
1955
- optionalContentConfigPromise: I,
1956
- printAnnotationStorage: x
1957
- };
1958
- try {
1959
- return L.render(E).promise;
1960
- } catch (z) {
1961
- throw z instanceof rr || console.error(z), z;
1962
- }
1963
- }, _ = M(() => {
1964
- const P = window.print;
1965
- return new Promise((T) => {
1966
- const d = (I) => {
1967
- setTimeout(() => {
1968
- P.call(window), setTimeout(() => I(), 20);
1969
- }, 0);
1970
- };
1971
- if (document.querySelector(".rp-print-zone")) {
1972
- d(T);
1973
- return;
1974
- }
1975
- const w = new MutationObserver(() => {
1976
- document.querySelector(".rp-print-zone") && (d(T), w.disconnect());
1977
- });
1978
- w.observe(document.body, { childList: !0, subtree: !0 });
1979
- });
1980
- }, []), g = async (P) => {
1981
- const T = document.createElement("img"), d = document.createElement("div");
1982
- return d.classList.add("rp-print-page"), await new Promise((C, w) => {
1983
- P.toBlob((I) => {
1984
- I ? (T.src = URL.createObjectURL(I), T.onload = () => {
1985
- URL.revokeObjectURL(T.src), C();
1986
- }, T.onerror = w) : w(new Error("Failed to create blob"));
1987
- });
1988
- }).catch(() => {
1989
- }), d.appendChild(T), d;
1990
- }, b = (P, T) => {
1991
- const d = document.createElement("div");
1992
- d.classList.add("rp-print-zone");
1993
- const C = document.createElement("style"), w = T.get(1);
1994
- if (w) {
1995
- const { width: I, height: y } = w == null ? void 0 : w.page.getViewport({ scale: 1 });
1996
- C.innerHTML = `@page { size: ${I}px ${y}px }`;
1997
- }
1998
- return d.appendChild(C), d.append(...P), d;
1999
- }, S = M(async () => {
2000
- if (!e)
2001
- return;
2002
- u();
2003
- const P = document.createElement("canvas"), T = [];
2004
- try {
2005
- e.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
2006
- const C = e.getOptionalContentConfig({ intent: "print" }), w = Promise.resolve(
2007
- e.annotationStorage.print ?? void 0
2008
- ), I = t.size;
2009
- for (const [R, N] of t) {
2010
- if (h.current) {
2011
- u();
2012
- return;
2013
- }
2014
- const L = N.page.getViewport({ scale: 1 });
2015
- if (await v({
2016
- scratchCanvas: P,
2017
- pdfDocument: e,
2018
- pageNumber: R,
2019
- viewerPdfPage: L,
2020
- printResolution: 150,
2021
- optionalContentConfigPromise: C,
2022
- printAnnotationStoragePromise: w
2023
- }), h.current) {
2024
- u();
2025
- return;
2026
- }
2027
- const x = await g(P);
2028
- T.push(x);
2029
- const E = parseFloat((T.length / I * 100).toFixed(2));
2030
- r({
2031
- loadedPages: R,
2032
- totalPages: I,
2033
- percentage: E
2034
- });
2035
- }
2036
- if (h.current) {
2037
- u();
2038
- return;
2039
- }
2040
- const y = b(T, t);
2041
- document.body.appendChild(y), document.documentElement.classList.add("rp-print-html-printing"), document.body.classList.add("rp-print-body-printing"), i(!0), await _();
2042
- } catch (d) {
2043
- s(!0), d instanceof Error && p(d);
2044
- } finally {
2045
- P.height = 0, P.width = 0;
2046
- }
2047
- }, [e, t, h]);
2048
- return A(() => {
2049
- const P = () => {
2050
- u(), m();
2051
- };
2052
- return window.addEventListener("afterprint", P, !0), () => {
2053
- window.removeEventListener("afterprint", P, !0);
2054
- };
2055
- }, [m, u]), {
2056
- print: S,
2057
- cancel: f,
2058
- progress: n,
2059
- isComplete: o,
2060
- isError: l,
2061
- error: c
2062
- };
2063
- }, xn = We({
2064
- print: () => {
2065
- },
2066
- cancel: () => {
2067
- },
2068
- setOnProgress: (e) => {
2069
- },
2070
- progress: {},
2071
- setOnComplete: (e) => e(),
2072
- setOnError: (e) => {
2073
- try {
2074
- const t = new Error("Print error occurred");
2075
- e(t);
2076
- } catch (t) {
2077
- console.error("Error in setOnError callback:", t);
2078
- }
2079
- }
2080
- }), la = ({ children: e }) => {
2081
- const [t, n] = F(null), [r, o] = F(null), { print: i, cancel: l, progress: s, isComplete: c, isError: p, error: h } = sa(), m = M((g) => {
2082
- g && typeof g == "function" && o(() => g);
2083
- }, []), u = (g) => {
2084
- h && g(h);
2085
- }, f = M(
2086
- (g) => {
2087
- n(() => g);
2088
- },
2089
- [s, t]
2090
- );
2091
- A(() => {
2092
- c && r && v();
2093
- }, [c, r]), A(() => {
2094
- p && u((g) => {
2095
- console.error(g);
2096
- });
2097
- }, [p]), A(() => {
2098
- s && t && t(s);
2099
- }, [s, t]);
2100
- const v = () => {
2101
- r && (r(), o(null));
2102
- }, _ = {
2103
- print: i,
2104
- cancel: l,
2105
- setOnProgress: f,
2106
- setOnComplete: m,
2107
- setOnError: u,
2108
- progress: s
2109
- };
2110
- return /* @__PURE__ */ a(xn.Provider, { value: _, children: e });
2111
- }, Tt = () => {
2112
- const e = He(xn);
2113
- if (!e)
2114
- throw new Error("usePrintContext must be used within a PrintProvider");
2115
- return e;
2116
- }, Mn = () => {
2117
- const { printIcon: e } = re();
2118
- return e || /* @__PURE__ */ a(jr, {});
2119
- }, Nn = ({ children: e, className: t }) => /* @__PURE__ */ a(X, { className: t, content: "Print", children: e }), ca = ({ print: e }) => /* @__PURE__ */ a(Nn, { children: /* @__PURE__ */ a(B, { onClick: e, children: /* @__PURE__ */ a(Mn, {}) }) }), ua = ({ print: e }) => /* @__PURE__ */ a(ce, { onClick: e, children: /* @__PURE__ */ O(Nn, { className: "rp-menu-item", children: [
2120
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(Mn, {}) }),
2121
- "Print"
2122
- ] }) }), Ln = () => {
2123
- const { print: e, cancel: t, setOnProgress: n, setOnComplete: r, setOnError: o, progress: i } = Tt(), { printTool: l = !0 } = se(), { isSmallScreen: s } = ge();
2124
- return l ? s ? /* @__PURE__ */ a(ua, { print: e }) : typeof l == "function" ? /* @__PURE__ */ a(
2125
- l,
2126
- {
2127
- print: e,
2128
- cancel: t,
2129
- setOnProgress: n,
2130
- setOnError: o,
2131
- setOnComplete: r,
2132
- progress: i
2133
- }
2134
- ) : l ? /* @__PURE__ */ a(ca, { print: e }) : null : null;
2135
- }, da = {
2136
- "rp-go-to-Top": "_rp-go-to-Top_4e0yd_1"
2137
- }, pa = () => {
2138
- const { goToFirstPageIcon: e } = re();
2139
- return e || /* @__PURE__ */ a(en, { className: da["rp-go-to-Top"] });
2140
- }, ha = () => {
2141
- const { goToLastPageIcon: e } = re();
2142
- return e || /* @__PURE__ */ a(en, {});
2143
- }, fa = () => {
2144
- const { goToPage: e, totalPages: t, focusedPage: n } = ee(), { jumpNavigationTool: r = !0 } = se(), o = D(() => n === 1, [n]), i = D(() => n === t, [n, t]), l = M(() => {
2145
- e(1);
2146
- }, [e]), s = M(() => {
2147
- e(t);
2148
- }, [e, t]);
2149
- return r ? /* @__PURE__ */ O(Fe, { children: [
2150
- /* @__PURE__ */ a(ce, { disabled: o, onClick: l, children: /* @__PURE__ */ O(X, { className: "rp-menu-item", content: "Go to first page", children: [
2151
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(pa, {}) }),
2152
- "First page"
2153
- ] }) }),
2154
- /* @__PURE__ */ a(ce, { disabled: i, onClick: s, children: /* @__PURE__ */ O(X, { className: "rp-menu-item", content: "Go to last page", children: [
2155
- /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(ha, {}) }),
2156
- "Last page"
2157
- ] }) }),
2158
- /* @__PURE__ */ a(vt, {})
2159
- ] }) : null;
2160
- }, ma = () => {
2161
- const { container: e } = qe(), { isSmallScreen: t } = ge(), {
2162
- openFileTool: n,
2163
- downloadTool: r,
2164
- documentProperties: o,
2165
- scrollModeTool: i,
2166
- rotateTool: l,
2167
- selectionModeTool: s,
2168
- jumpNavigationTool: c,
2169
- printTool: p,
2170
- fullscreenTool: h
2171
- } = se();
2172
- return D(() => {
2173
- const u = c || l || s || i || o;
2174
- let f = !1;
2175
- return t && (f = !(!n && !r && !p && !h)), u || f;
2176
- }, [
2177
- n,
2178
- r,
2179
- o,
2180
- i,
2181
- l,
2182
- s,
2183
- c,
2184
- t
2185
- ]) ? /* @__PURE__ */ O(Vr, { children: [
2186
- /* @__PURE__ */ a(
2187
- ft,
2188
- {
2189
- container: e,
2190
- triggerComponent: /* @__PURE__ */ a("div", { role: "button", children: /* @__PURE__ */ a(X, { content: "More options", children: /* @__PURE__ */ a(B, { children: /* @__PURE__ */ a(Mr, {}) }) }) }),
2191
- children: /* @__PURE__ */ O("div", { className: ra["rp-other-tool-content"], children: [
2192
- t && /* @__PURE__ */ O(Fe, { children: [
2193
- /* @__PURE__ */ a(Jt, {}),
2194
- /* @__PURE__ */ a(Rn, {}),
2195
- /* @__PURE__ */ a(Ln, {}),
2196
- /* @__PURE__ */ a(Qt, {}),
2197
- /* @__PURE__ */ a(vt, {})
2198
- ] }),
2199
- /* @__PURE__ */ a(fa, {}),
2200
- /* @__PURE__ */ a(Ur, {}),
2201
- /* @__PURE__ */ a(Br, {}),
2202
- /* @__PURE__ */ a(qr, {}),
2203
- /* @__PURE__ */ a(Gr, {})
2204
- ] })
2205
- }
2206
- ),
2207
- /* @__PURE__ */ a(na, {})
2208
- ] }) : null;
2209
- }, ga = () => {
2210
- const { isSmallScreen: e } = ge();
2211
- return /* @__PURE__ */ O(Ae, { children: [
2212
- /* @__PURE__ */ a(xr, {}),
2213
- !e && /* @__PURE__ */ O(Ae, { children: [
2214
- /* @__PURE__ */ a(Jt, {}),
2215
- /* @__PURE__ */ a(Rn, {}),
2216
- /* @__PURE__ */ a(Ln, {}),
2217
- /* @__PURE__ */ a(Qt, {})
2218
- ] }),
2219
- /* @__PURE__ */ a(ma, {})
2220
- ] });
2221
- }, ye = {
2222
- "rp-zoom-wrapper": "_rp-zoom-wrapper_163s9_1",
2223
- "rp-current-zoom-wrapper": "_rp-current-zoom-wrapper_163s9_6",
2224
- "rp-current-zoom-icon": "_rp-current-zoom-icon_163s9_11",
2225
- "rp-current-zoom": "_rp-current-zoom_163s9_6",
2226
- "rp-zoom-dropdown-content": "_rp-zoom-dropdown-content_163s9_20"
2227
- }, va = 25, nt = 1e3, _a = [50, 75, 100, 125, 150, 200, 300, 400], wa = () => {
2228
- const { zoomInIcon: e } = re();
2229
- return e || /* @__PURE__ */ a(Kr, {});
2230
- }, ba = () => {
2231
- const { zoomOutIcon: e } = re();
2232
- return e || /* @__PURE__ */ a(Xr, {});
2233
- }, Ca = () => {
2234
- const { zoomLevel: e, setZoomLevel: t } = ht(), { container: n, contentRef: r } = qe(), { zoomTool: o = !0 } = se(), { focusedPage: i } = ee(), { rotate: l } = Ve(), { pages: s } = Y(), { isSmallScreen: c } = ge(), p = M(() => {
2235
- t((g) => {
2236
- const b = Math.floor(g / 25) * 25;
2237
- return Math.min(b + 25, nt);
2238
- });
2239
- }, [t]), h = M(() => {
2240
- t((g) => {
2241
- const b = Math.ceil(g / 25) * 25;
2242
- return Math.min(b - 25, nt);
2243
- });
2244
- }, [t]), m = D(() => e === va, [e]), u = D(() => e === nt, [e]), f = D(() => {
2245
- var g;
2246
- return (g = s.get(i)) == null ? void 0 : g.page.getViewport({ scale: 1, rotation: l });
2247
- }, [s, i, l]), v = M(
2248
- (g) => {
2249
- const b = ((f == null ? void 0 : f.width) || 0) + 2 * yt, S = ((f == null ? void 0 : f.height) || 0) + 2 * yt, P = (r == null ? void 0 : r.clientWidth) || 0, T = (r == null ? void 0 : r.clientHeight) || 0;
2250
- switch (g) {
2251
- case we.ACTUAL:
2252
- t(100);
2253
- break;
2254
- case we.PAGE_FIT:
2255
- let d = 0;
2256
- const C = P > T;
2257
- S > b && C ? d = T / S : d = P / b;
2258
- const w = Math.floor(d * 100);
2259
- t(w);
2260
- break;
2261
- case we.PAGE_WIDTH:
2262
- t(Math.floor(P / b * 100));
2263
- break;
2264
- }
2265
- },
2266
- [t, f]
2267
- ), _ = M(
2268
- (g) => {
2269
- typeof g == "number" ? t(g) : v(g);
2270
- },
2271
- [t, v]
2272
- );
2273
- return typeof o != "boolean" ? /* @__PURE__ */ a(o, { zoomLevel: e, setZoomLevel: t }) : o ? /* @__PURE__ */ O("div", { className: ye["rp-zoom-wrapper"], children: [
2274
- /* @__PURE__ */ a(X, { content: "Zoom out", children: /* @__PURE__ */ a(B, { disabled: m, onClick: h, children: /* @__PURE__ */ a(ba, {}) }) }),
2275
- !c && /* @__PURE__ */ a(
2276
- ft,
2277
- {
2278
- container: n,
2279
- triggerComponent: /* @__PURE__ */ a("div", { role: "button", children: /* @__PURE__ */ a(X, { content: "Select zoom level", children: /* @__PURE__ */ O(B, { className: ye["rp-current-zoom-wrapper"], children: [
2280
- /* @__PURE__ */ O("span", { className: ye["rp-current-zoom"], children: [
2281
- e,
2282
- " %"
2283
- ] }),
2284
- /* @__PURE__ */ a(Me, { className: ye["rp-current-zoom-icon"] })
2285
- ] }) }) }),
2286
- style: { minWidth: "200px" },
2287
- align: "center",
2288
- children: /* @__PURE__ */ O("div", { className: ye["rp-zoom-dropdown-content"], children: [
2289
- /* @__PURE__ */ O(Fe, { children: [
2290
- /* @__PURE__ */ a(ce, { onClick: () => _(we.ACTUAL), children: "Actual size" }),
2291
- /* @__PURE__ */ a(ce, { onClick: () => _(we.PAGE_FIT), children: "Page fit" }),
2292
- /* @__PURE__ */ a(ce, { onClick: () => _(we.PAGE_WIDTH), children: "Page width" })
2293
- ] }),
2294
- /* @__PURE__ */ a(vt, {}),
2295
- /* @__PURE__ */ a(Fe, { children: _a.map((g) => /* @__PURE__ */ O(ce, { onClick: () => _(g), children: [
2296
- g,
2297
- " %"
2298
- ] }, g)) })
2299
- ] })
2300
- }
2301
- ),
2302
- /* @__PURE__ */ a(X, { content: "Zoom in", children: /* @__PURE__ */ a(B, { disabled: u, onClick: p, children: /* @__PURE__ */ a(wa, {}) }) })
2303
- ] }) : null;
2304
- }, ne = {
2305
- "rp-search-tool-content": "_rp-search-tool-content_1vxow_1",
2306
- "rp-search-tool-input": "_rp-search-tool-input_1vxow_6",
2307
- "rp-search-tool-input-icon": "_rp-search-tool-input-icon_1vxow_12",
2308
- "rp-search-tool-controls": "_rp-search-tool-controls_1vxow_16",
2309
- "rp-search-tool-input-wrapper": "_rp-search-tool-input-wrapper_1vxow_24",
2310
- "rp-search-tool-input-checkboxes": "_rp-search-tool-input-checkboxes_1vxow_30",
2311
- "rp-search-tool-input-clear": "_rp-search-tool-input-clear_1vxow_35",
2312
- "rp-search-input": "_rp-search-input_1vxow_49"
2313
- }, Gt = () => {
2314
- const { searchIcon: e } = re();
2315
- return e || /* @__PURE__ */ a(Jr, {});
2316
- }, Pa = () => {
2317
- const { container: e } = qe(), [t, n] = F(!1), { pdf: r } = Y(), [o, i] = F(null), {
2318
- searchOptions: l,
2319
- setSearchOptions: s,
2320
- loading: c,
2321
- setSearch: p,
2322
- totalMatches: h,
2323
- currentMatchPosition: m,
2324
- nextMatch: u,
2325
- prevMatch: f,
2326
- search: v
2327
- } = nn(), { searchTool: _ = !0 } = se(), [g, b] = F(v), S = M(() => {
2328
- n(!0);
2329
- }, []), P = M(() => {
2330
- p(""), b(""), n(!1);
2331
- }, [p]), T = M(
2332
- (x) => {
2333
- x.key === "Escape" && t && P();
2334
- },
2335
- [t]
2336
- ), d = M(
2337
- (x) => {
2338
- x.shiftKey && x.key === "Enter" ? f() : x.key === "Enter" && p((E) => (g === E && u(), g));
2339
- },
2340
- [g, f, u, p]
2341
- );
2342
- A(() => (window.addEventListener("keydown", T), () => {
2343
- window.removeEventListener("keydown", T);
2344
- }), [T]), A(() => {
2345
- o && o.focus();
2346
- }, [o]);
2347
- const C = M((x) => {
2348
- b(x.target.value);
2349
- }, []), w = M(() => {
2350
- b(""), p("");
2351
- }, [p]), I = D(() => `${m} / ${h}`, [m, h]), { wholeWords: y, matchCase: R } = D(() => l, [l]), N = M(
2352
- (x) => {
2353
- s((E) => ({ ...E, matchCase: x }));
2354
- },
2355
- [s]
2356
- ), L = M(
2357
- (x) => {
2358
- s((E) => ({ ...E, wholeWords: x }));
2359
- },
2360
- [s]
2361
- );
2362
- return A(() => {
2363
- P();
2364
- }, [r, P]), _ ? /* @__PURE__ */ a(
2365
- ft,
2366
- {
2367
- open: t,
2368
- container: e,
2369
- align: "start",
2370
- triggerComponent: /* @__PURE__ */ a(X, { content: "Search in document", children: /* @__PURE__ */ a(B, { onClick: S, children: /* @__PURE__ */ a(Gt, {}) }) }),
2371
- children: /* @__PURE__ */ O("div", { className: ne["rp-search-tool-content"], children: [
2372
- /* @__PURE__ */ O("div", { className: ne["rp-search-tool-input-wrapper"], children: [
2373
- /* @__PURE__ */ O("div", { className: ne["rp-search-tool-input"], children: [
2374
- /* @__PURE__ */ a(
2375
- Zt,
2376
- {
2377
- value: g,
2378
- onKeyDown: d,
2379
- onChange: C,
2380
- icon: /* @__PURE__ */ a(Gt, {}),
2381
- placeholder: "Enter to Search",
2382
- className: ne["rp-search-input"],
2383
- ref: i,
2384
- children: !!g && /* @__PURE__ */ a("span", { className: ne["rp-search-tool-input-clear"], onClick: w, children: /* @__PURE__ */ a(Yr, {}) })
2385
- }
2386
- ),
2387
- c ? /* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(pt, {}) }) : /* @__PURE__ */ a("span", { children: I })
2388
- ] }),
2389
- /* @__PURE__ */ O("div", { className: ne["rp-search-tool-input-checkboxes"], children: [
2390
- /* @__PURE__ */ a(Rt, { name: "matchCase", value: R, onChange: N, children: "Match Case" }),
2391
- /* @__PURE__ */ a(Rt, { name: "wholeWord", value: y, onChange: L, children: "Whole Word" })
2392
- ] })
2393
- ] }),
2394
- /* @__PURE__ */ O("div", { className: ne["rp-search-tool-controls"], children: [
2395
- /* @__PURE__ */ a(B, { onClick: f, children: /* @__PURE__ */ a(Me, { className: ne["rp-search-tool-input-icon"] }) }),
2396
- /* @__PURE__ */ a(B, { onClick: u, children: /* @__PURE__ */ a(
2397
- Me,
2398
- {
2399
- style: { transform: "rotate(180deg" },
2400
- className: ne["rp-search-tool-input-icon"]
2401
- }
2402
- ) }),
2403
- /* @__PURE__ */ a(B, { children: /* @__PURE__ */ a(Yt, { onClick: P, className: ne["rp-search-tool-input-icon"] }) })
2404
- ] })
2405
- ] })
2406
- }
2407
- ) : null;
2408
- }, Sa = "_loading_1snj5_1", Ce = {
2409
- "rp-loading-overlay": "_rp-loading-overlay_1snj5_1",
2410
- "rp-loading-modal": "_rp-loading-modal_1snj5_14",
2411
- "rp-loading-title": "_rp-loading-title_1snj5_27",
2412
- "rp-loading-progress-bar": "_rp-loading-progress-bar_1snj5_35",
2413
- "rp-loading-progress": "_rp-loading-progress_1snj5_35",
2414
- "rp-loading-cancel-button": "_rp-loading-cancel-button_1snj5_52",
2415
- loading: Sa
2416
- }, Ta = ({ percentage: e }) => {
2417
- const { cancel: t } = Tt();
2418
- return e < 1 ? null : /* @__PURE__ */ a("div", { className: j(Ce["rp-loading-overlay"]), children: /* @__PURE__ */ O("div", { className: j(Ce["rp-loading-modal"]), children: [
2419
- /* @__PURE__ */ a("div", { className: j(Ce["rp-loading-title"]), children: "Preparing document..." }),
2420
- /* @__PURE__ */ a("div", { className: j(Ce["rp-loading-progress-bar"]), children: /* @__PURE__ */ a(
2421
- "div",
2422
- {
2423
- className: j(Ce["rp-loading-progress"]),
2424
- style: { width: `${e}%` }
2425
- }
2426
- ) }),
2427
- /* @__PURE__ */ a("button", { className: j(Ce["rp-loading-cancel-button"]), onClick: t, children: "Cancel" })
2428
- ] }) });
2429
- }, Ia = $e((e, t) => {
2430
- const { showPrintProgress: n } = se(), { progress: r } = Tt(), { isSmallScreen: o } = ge(), { percentage: i } = r || {}, l = () => o ? { gridTemplateColumns: "25% 60% 15%" } : void 0;
2431
- return /* @__PURE__ */ O("div", { children: [
2432
- /* @__PURE__ */ a("div", { "data-rp": "topBarWrapper", ref: t, className: Ie["rp-toolbar-content"], children: /* @__PURE__ */ O("div", { "data-rp": "topBar", className: Ie["rp-toolbar-wrapper"], style: l(), children: [
2433
- /* @__PURE__ */ O("div", { "data-rp": "topBarStart", className: Ie["rp-toolbar-start"], children: [
2434
- /* @__PURE__ */ a(Pa, {}),
2435
- /* @__PURE__ */ a(Wo, {})
2436
- ] }),
2437
- /* @__PURE__ */ a("div", { "data-rp": "topBarMiddle", className: Ie["rp-toolbar-middle"], children: /* @__PURE__ */ a(Ca, {}) }),
2438
- /* @__PURE__ */ a("div", { "data-rp": "topBarEnd", className: Ie["rp-toolbar-end"], children: /* @__PURE__ */ a(ga, {}) })
2439
- ] }) }),
2440
- n && i ? /* @__PURE__ */ a(Ta, { percentage: i }) : null
2441
- ] });
2442
- }), rt = {
2443
- "rp-sidebar-content-wrapper": "_rp-sidebar-content-wrapper_4wlw3_1",
2444
- "rp-sidebar-content": "_rp-sidebar-content_4wlw3_1",
2445
- "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_4wlw3_16",
2446
- "rp-thumbnail-dragging": "_rp-thumbnail-dragging_4wlw3_21"
2447
- }, Re = {
2448
- "rp-thumbnail-wrapper": "_rp-thumbnail-wrapper_3fenb_1",
2449
- "rp-thumbnail-text": "_rp-thumbnail-text_3fenb_10",
2450
- "rp-thumbnail": "_rp-thumbnail_3fenb_1",
2451
- "rp-thumbnail-active": "_rp-thumbnail-active_3fenb_22",
2452
- "rp-thumbnail-loader": "_rp-thumbnail-loader_3fenb_31"
2453
- }, ya = (e) => {
2454
- const { thumbnailSrc: t, pageNumber: n, isFocused: r, viewport: o } = e, { goToPage: i } = ee(), l = D(() => r ? Re["rp-thumbnail-active"] : "", [r]), s = D(() => ({
2455
- width: Math.round(o.width),
2456
- height: Math.round(o.height)
2457
- }), [o]), c = M(() => {
2458
- n && i(n);
2459
- }, [i, n]);
2460
- return /* @__PURE__ */ O(
2461
- "div",
2462
- {
2463
- onClick: c,
2464
- id: `page-${n}`,
2465
- className: Re["rp-thumbnail-wrapper"],
2466
- children: [
2467
- /* @__PURE__ */ a("div", { className: j(l, Re["rp-thumbnail"]), children: t ? /* @__PURE__ */ a(
2468
- "img",
2469
- {
2470
- src: t,
2471
- width: s.width,
2472
- height: s.height,
2473
- alt: "thumbnail"
2474
- }
2475
- ) : /* @__PURE__ */ a(
2476
- "div",
2477
- {
2478
- className: Re["rp-thumbnail-loader"],
2479
- style: {
2480
- width: `${s.width}px`,
2481
- height: `${s.height}px`
2482
- },
2483
- children: /* @__PURE__ */ a(pt, {})
2484
- }
2485
- ) }),
2486
- /* @__PURE__ */ a("div", { className: Re["rp-thumbnail-text"], children: n })
2487
- ]
2488
- }
2489
- );
2490
- }, Ut = {
2491
- "rp-thumbnails-container": "_rp-thumbnails-container_16vqr_1",
2492
- "rp-thumbnails": "_rp-thumbnails_16vqr_1"
2493
- }, Ra = () => {
2494
- const [e, t] = F({}), { pages: n } = Y(), { rotate: r } = Ve(), o = D(() => Object.keys(e).length, [e]), i = M(
2495
- (s) => {
2496
- if (!n.size)
2497
- return;
2498
- const c = Array.from(n.values()).slice(0, s).map((m) => {
2499
- const { thumbnailViewport: u, scale: f } = It(m.page, r);
2500
- return {
2501
- scale: f,
2502
- page: m.page,
2503
- loading: !0,
2504
- viewport: u
2505
- };
2506
- }), p = c.reduce((m, u) => (m[u.page.pageNumber] = u, m), {});
2507
- t(p);
2508
- const h = [];
2509
- for (const m of c) {
2510
- const u = document.createElement("canvas"), f = ot(
2511
- m.page,
2512
- u,
2513
- m.scale,
2514
- r
2515
- ).promise.then(() => {
2516
- const v = u.toDataURL();
2517
- return {
2518
- ...m,
2519
- thumbnailSrc: v,
2520
- loading: !1
2521
- };
2522
- });
2523
- h.push(f);
2524
- }
2525
- Promise.all(h).then((m) => {
2526
- const u = m.reduce(
2527
- (f, v) => (f[v.page.pageNumber] = v, f),
2528
- {}
2529
- );
2530
- t((f) => ({ ...f, ...u }));
2531
- });
2532
- },
2533
- [n, r]
2534
- );
2535
- A(() => {
2536
- i(10);
2537
- }, [i]);
2538
- const l = M(
2539
- (s) => {
2540
- if (!n)
2541
- return;
2542
- const c = n.get(s);
2543
- if (!c)
2544
- return;
2545
- t((h) => ({
2546
- ...h,
2547
- [s]: {
2548
- loading: !0,
2549
- page: c.page,
2550
- viewport: c.thumbnailViewport,
2551
- scale: c.thumbnailScale
2552
- }
2553
- }));
2554
- const p = document.createElement("canvas");
2555
- ot(c.page, p, c.thumbnailScale, r).promise.then(() => {
2556
- const h = p.toDataURL(), { thumbnailViewport: m, scale: u } = It(c.page, r);
2557
- return {
2558
- scale: u,
2559
- thumbnailSrc: h,
2560
- page: c.page,
2561
- loading: !1,
2562
- viewport: m
2563
- };
2564
- }).then((h) => {
2565
- t((m) => ({ ...m, [s]: h }));
2566
- });
2567
- },
2568
- [n, r]
2569
- );
2570
- return { thumbnailPages: e, addPage: l, addToPage: i, thumbnailLength: o };
2571
- }, En = We({
2572
- thumbnailPages: {},
2573
- addPage: (e) => {
2574
- },
2575
- addToPage: (e) => {
2576
- },
2577
- thumbnailLength: 0,
2578
- setActive: (e) => {
2579
- },
2580
- active: !1
2581
- }), On = () => He(En), xa = ({
2582
- children: e,
2583
- initialThumbnailsVisible: t
2584
- }) => {
2585
- const { thumbnailPages: n, addPage: r, addToPage: o, thumbnailLength: i } = Ra(), [l, s] = F(t);
2586
- return /* @__PURE__ */ a(
2587
- En.Provider,
2588
- {
2589
- value: { thumbnailPages: n, addPage: r, addToPage: o, thumbnailLength: i, active: l, setActive: s },
2590
- children: e
2591
- }
2592
- );
2593
- }, Ma = 16, Na = (e, t) => {
2594
- const n = e == null ? void 0 : e.querySelector(`#page-${t}`);
2595
- e && (n != null && n.offsetTop) && (e.scrollTop = (n == null ? void 0 : n.offsetTop) - Ma);
2596
- }, La = $e((e, t) => {
2597
- const { show: n } = e, { focusedPage: r, totalPages: o } = ee(), { thumbnailPages: i, addPage: l, thumbnailLength: s, addToPage: c } = On(), p = $(null), h = $(1);
2598
- qt(t, () => p.current);
2599
- const m = D(() => Object.values(i), [i]), u = M(() => {
2600
- const f = s + 1;
2601
- f <= o && l(f);
2602
- }, [l, o, s]);
2603
- return A(() => {
2604
- r > s ? c(r) : n && h.current !== r && (Na(p.current, r), h.current = r);
2605
- }, [r, s, c, n, m]), or(p.current, u), /* @__PURE__ */ a("div", { ref: p, className: Ut["rp-thumbnails-container"], children: /* @__PURE__ */ a("div", { className: Ut["rp-thumbnails"], children: n ? m.map((f, v) => {
2606
- var _, g;
2607
- return /* @__PURE__ */ a(
2608
- ya,
2609
- {
2610
- isFocused: r === ((_ = f.page) == null ? void 0 : _.pageNumber),
2611
- pageNumber: (g = f.page) == null ? void 0 : g.pageNumber,
2612
- thumbnailSrc: f.thumbnailSrc,
2613
- loading: f.loading,
2614
- viewport: f.viewport
2615
- },
2616
- v
2617
- );
2618
- }) : null }) });
2619
- }), Ea = () => {
2620
- const { thumbnailIcon: e } = re();
2621
- return e || /* @__PURE__ */ a(Hn, {});
2622
- }, Oa = () => {
2623
- const { active: e, setActive: t } = On(), [n, r] = F(200), o = $(null), { thumbnailTool: i } = se(), l = M(() => {
2624
- t((c) => !c);
2625
- }, []), s = D(() => typeof i != "boolean" && i ? /* @__PURE__ */ a(i, { onClick: l, active: e }) : i ? /* @__PURE__ */ a(X, { content: "Thumbnail", children: /* @__PURE__ */ a(B, { onClick: l, active: e, children: /* @__PURE__ */ a(Ea, {}) }) }) : null, [i, e, l]);
2626
- return /* @__PURE__ */ O(
2627
- "div",
2628
- {
2629
- style: { "--rp-thumbnail-width": `${n}px` },
2630
- className: rt["rp-sidebar-content-wrapper"],
2631
- "data-rp": "sidebar",
2632
- children: [
2633
- /* @__PURE__ */ a("div", { "data-rp": "thumbnailButton", className: rt["rp-sidebar-content"], children: s }),
2634
- /* @__PURE__ */ O("div", { "data-rp": "thumbnails", hidden: !e, className: rt["rp-thumbnails-wrapper"], children: [
2635
- /* @__PURE__ */ a(La, { show: e, ref: o }),
2636
- /* @__PURE__ */ a(ar, { onWidthChange: r, thumbnailRef: o })
2637
- ] })
2638
- ]
2639
- }
2640
- );
2641
- }, Da = (e) => {
2642
- const {
2643
- children: t,
2644
- darkMode: n = !1,
2645
- onDarkModeChange: r,
2646
- initialRotate: o = 0,
2647
- textLayer: i = !0,
2648
- initialPage: l = 1,
2649
- // initialViewMode = ViewMode.SINGLE_PAGE,
2650
- initialScale: s,
2651
- initialScrollMode: c = Q.VERTICAL_SCROLLING,
2652
- mobileWidth: p
2653
- } = e;
2654
- return /* @__PURE__ */ a(
2655
- vr,
2656
- {
2657
- initialScale: s,
2658
- initialPage: l,
2659
- initialScrollMode: c,
2660
- initialRotate: o,
2661
- children: /* @__PURE__ */ a(hr, { mobileWidth: p, children: /* @__PURE__ */ a(dr, { children: /* @__PURE__ */ a(Yn, { children: /* @__PURE__ */ a(Zn, { children: /* @__PURE__ */ a(Wn, { children: /* @__PURE__ */ a(mr, { initialSelectionMode: jt.TEXT, children: /* @__PURE__ */ a(pr, { children: /* @__PURE__ */ a(Oo, { children: /* @__PURE__ */ a(qn, { children: /* @__PURE__ */ a(ur, { textLayer: i, children: /* @__PURE__ */ a(Bn, { children: /* @__PURE__ */ a(
2662
- Gn,
2663
- {
2664
- darkMode: n,
2665
- onDarkModeChange: r,
2666
- children: t
2667
- }
2668
- ) }) }) }) }) }) }) }) }) }) }) })
2669
- }
2670
- );
2671
- }, as = $e((e, t) => {
2672
- const {
2673
- children: n,
2674
- slots: r,
2675
- icons: o,
2676
- initialThumbnailsVisible: i = !1,
2677
- initialSearch: l,
2678
- showToolbar: s = !0,
2679
- style: c,
2680
- className: p,
2681
- onLoaded: h,
2682
- cleanupOnLoaded: m,
2683
- ...u
2684
- } = e, [f, v] = F(null), [_, g] = F(null), [b, S] = F(null);
2685
- return A(() => (h && h(), () => {
2686
- m && m();
2687
- }), [h, m]), /* @__PURE__ */ a("div", { ref: t, className: j(he["rp-theme-variables"], he["rp-container"]), children: /* @__PURE__ */ a(lr, { container: _, contentRef: b, children: /* @__PURE__ */ a(Da, { ...u, children: /* @__PURE__ */ a(to, { initialSearch: l, children: /* @__PURE__ */ a(xa, { initialThumbnailsVisible: i, children: /* @__PURE__ */ a(Un, { slots: r, children: /* @__PURE__ */ a(Vn, { children: /* @__PURE__ */ a(ir, { icons: o, children: /* @__PURE__ */ a(wr, { elementRef: b, children: /* @__PURE__ */ a(la, { children: /* @__PURE__ */ a(jn, { children: s ? /* @__PURE__ */ a(
2688
- sr,
2689
- {
2690
- getContainerRef: g,
2691
- toolbarRef: f,
2692
- style: c,
2693
- className: p,
2694
- children: /* @__PURE__ */ O(br, { children: [
2695
- /* @__PURE__ */ O("div", { className: he["rp-layout"], children: [
2696
- /* @__PURE__ */ a(Ia, { ref: v }),
2697
- /* @__PURE__ */ O("div", { className: he["rp-content"], children: [
2698
- /* @__PURE__ */ a("div", { className: he["rp-sidebar"], children: /* @__PURE__ */ a(Oa, {}) }),
2699
- /* @__PURE__ */ a("div", { ref: S, className: he["rp-pages"], children: n })
2700
- ] })
2701
- ] }),
2702
- /* @__PURE__ */ a($n, {})
2703
- ] })
2704
- }
2705
- ) : /* @__PURE__ */ a(
2706
- "div",
2707
- {
2708
- ref: S,
2709
- className: j(he["rp-pages"], p),
2710
- style: c,
2711
- children: n
2712
- }
2713
- ) }) }) }) }) }) }) }) }) }) }) });
2714
- });
2715
- export {
2716
- po as A,
2717
- xa as B,
2718
- Qr as C,
2719
- Do as D,
2720
- La as E,
2721
- Rn as F,
2722
- Oa as G,
2723
- Da as H,
2724
- Ta as L,
2725
- fa as M,
2726
- ma as O,
2727
- un as P,
2728
- ns as R,
2729
- tn as S,
2730
- no as T,
2731
- Ca as Z,
2732
- as as a,
2733
- oa as b,
2734
- Tt as c,
2735
- nn as d,
2736
- _t as e,
2737
- eo as f,
2738
- to as g,
2739
- wt as h,
2740
- Mo as i,
2741
- Eo as j,
2742
- Oo as k,
2743
- Ao as l,
2744
- Wo as m,
2745
- na as n,
2746
- sa as o,
2747
- xn as p,
2748
- la as q,
2749
- Ln as r,
2750
- ga as s,
2751
- Pa as t,
2752
- ee as u,
2753
- Ia as v,
2754
- ya as w,
2755
- Ra as x,
2756
- En as y,
2757
- On as z
2758
- };