@pdf-viewer/react 0.4.0-beta.1 → 0.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/Container-337e1b18.js +37 -0
  2. package/dist/RPLayout-88110444.js +2757 -0
  3. package/dist/assets/Container.css +1 -1
  4. package/dist/assets/RPLayout.css +1 -0
  5. package/dist/assets/RPTooltip.css +1 -0
  6. package/dist/components/RPController.js +16 -47
  7. package/dist/components/RPDocument.js +13 -4
  8. package/dist/components/RPDropFileZone.js +18 -17
  9. package/dist/components/RPViewer.js +12 -22
  10. package/dist/components/layout/Container.js +6 -26
  11. package/dist/components/layout/RPLayout.js +14 -57
  12. package/dist/components/layout/WrapperLayout.js +9 -8
  13. package/dist/components/layout/sidebar/RPSidebar.js +10 -32
  14. package/dist/components/layout/sidebar/RPSplitter.js +9 -7
  15. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  16. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  17. package/dist/components/layout/toolbar/DarkModeTool.js +13 -12
  18. package/dist/components/layout/toolbar/DocumentDialog.js +7 -21
  19. package/dist/components/layout/toolbar/DocumentProperties.js +7 -6
  20. package/dist/components/layout/toolbar/FileDownloadTool.js +3 -2
  21. package/dist/components/layout/toolbar/FileUploadTool.js +16 -15
  22. package/dist/components/layout/toolbar/FullScreenTool.js +30 -32
  23. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  24. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  25. package/dist/components/layout/toolbar/MostPageTool.js +10 -23
  26. package/dist/components/layout/toolbar/OtherTool.js +4 -3
  27. package/dist/components/layout/toolbar/Paginate.js +3 -2
  28. package/dist/components/layout/toolbar/PrintTool.js +3 -2
  29. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  30. package/dist/components/layout/toolbar/RPToolbarEnd.js +2 -2
  31. package/dist/components/layout/toolbar/RotateTool.js +24 -23
  32. package/dist/components/layout/toolbar/ScrollModeTool.js +35 -34
  33. package/dist/components/layout/toolbar/SearchTool.js +8 -19
  34. package/dist/components/layout/toolbar/SelectionModeTool.js +27 -26
  35. package/dist/components/layout/toolbar/ViewModeTool.js +1 -1
  36. package/dist/components/layout/toolbar/ZoomTool.js +9 -19
  37. package/dist/components/page/AnnotationLayer.js +9 -23
  38. package/dist/components/page/CanvasLayer.js +7 -22
  39. package/dist/components/page/DualPage.js +1 -1
  40. package/dist/components/page/RPPage.js +8 -22
  41. package/dist/components/page/SinglePage.js +1 -1
  42. package/dist/components/page/TextLayer.js +7 -22
  43. package/dist/components/ui/Checkbox.js +1 -1
  44. package/dist/components/ui/DropDown.js +1 -1
  45. package/dist/components/ui/LoadingIndicator.js +1 -1
  46. package/dist/components/ui/RPTooltip.js +2397 -0
  47. package/dist/contexts/PaginateContext.js +3 -3
  48. package/dist/contexts/PrintContext.js +2 -2
  49. package/dist/contexts/RPDocumentContext.js +33 -25
  50. package/dist/contexts/SearchContext.js +3 -3
  51. package/dist/contexts/ThumbnailsContext.js +4 -4
  52. package/dist/index-2b077daa.js +122 -0
  53. package/dist/{index-3459164c.js → index-8049287f.js} +982 -952
  54. package/dist/main.js +31 -32
  55. package/dist/types/components/layout/RPLayout.d.ts +1 -2
  56. package/dist/types/components/ui/RPTooltip.d.ts +8 -0
  57. package/dist/types/contexts/RPDocumentContext.d.ts +4 -2
  58. package/dist/types/main.d.ts +1 -0
  59. package/dist/types/utils/hooks/useLoadPdf.d.ts +2 -2
  60. package/dist/types/utils/types.d.ts +9 -2
  61. package/dist/utils/hooks/useFileDownload.js +7 -22
  62. package/dist/utils/hooks/useLicense.js +15 -23
  63. package/dist/utils/hooks/useLoadPdf.js +27 -27
  64. package/dist/utils/hooks/usePaginate.js +8 -21
  65. package/dist/utils/hooks/usePrint.js +7 -22
  66. package/dist/utils/hooks/useScrollToPage.js +9 -21
  67. package/dist/utils/hooks/useSearch.js +9 -22
  68. package/dist/utils/hooks/useThumbnail.js +7 -22
  69. package/dist/utils/hooks/useVirtualReactWindow.js +9 -21
  70. package/package.json +2 -1
  71. package/dist/Container.module-cb7b45b9.js +0 -14
  72. package/dist/RPSplitter.module-13d612c4.js +0 -7
  73. package/dist/RPTheme.module-f756e5cd.js +0 -7
  74. package/dist/Thumbnails-06fa1aa5.js +0 -2657
  75. package/dist/WrapperLayout.module-147bc943.js +0 -6
  76. package/dist/assets/Thumbnails.css +0 -1
  77. package/dist/index-743c36f0.js +0 -139
  78. /package/dist/assets/{RPTheme.css → RPDropFileZone.css} +0 -0
@@ -0,0 +1,2757 @@
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 z, useCallback as x, useState as F, useMemo as D, createContext as We, useContext as He, forwardRef as $e, useImperativeHandle as qt, createElement as Ne, 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 ne, 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-337e1b18.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 xr } from "./utils/appConsole.js";
52
+ import { FileUploadTool as Jt } from "./components/layout/toolbar/FileUploadTool.js";
53
+ import { DarkModeTool as Rr } 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 { c as Lr, u as mt, a as Le, b as Re, d as gt, e as Nr, f as Er, h as Or, g as Dr, F as Ar, D as zr, i as Fr, j as kr, k as Be, l as Wr, G as Fe } from "./index-8049287f.js";
57
+ import { CloseIcon as Yt } from "./components/icons/CloseIcon.js";
58
+ import { PropertyItem as Hr } from "./components/layout/toolbar/PropertyItem.js";
59
+ import { useOtherToolContext as $r, OtherToolProvider as Vr } from "./contexts/OtherToolContext.js";
60
+ import { DocumentProperties as Gr } from "./components/layout/toolbar/DocumentProperties.js";
61
+ import { RotateTool as Ur } from "./components/layout/toolbar/RotateTool.js";
62
+ import { ScrollModeTool as qr } from "./components/layout/toolbar/ScrollModeTool.js";
63
+ import { MenuSeparator as vt } from "./components/layout/toolbar/MenuSeparator.js";
64
+ import { FileDownloadDefaultIcon as Zr } from "./components/icons/FileDownloadDefaultIcon.js";
65
+ import { MenuItem as ce } from "./components/layout/toolbar/MenuItem.js";
66
+ import { PrintDefaultTool as jr } from "./components/icons/PrintDefaultIcon.js";
67
+ import { FullScreenTool as Qt } from "./components/layout/toolbar/FullScreenTool.js";
68
+ import { GoToDownIcon as en } from "./components/icons/GoToDownIcon.js";
69
+ import { SelectionModeTool as Br } from "./components/layout/toolbar/SelectionModeTool.js";
70
+ import { ZoomInIcon as Kr } from "./components/icons/ZoomInIcon.js";
71
+ import { ZoomOutIcon as Xr } from "./components/icons/ZoomOutIcon.js";
72
+ import { PAGE_PADDING as yt } from "./utils/constants.js";
73
+ import { SearchIcon as Jr } from "./components/icons/SearchIcon.js";
74
+ import { UICheckbox as xt } from "./components/ui/Checkbox.js";
75
+ import { ClearIcon as Yr } from "./components/icons/ClearIcon.js";
76
+ import './assets/RPLayout.css';const ae = {
77
+ "rp-pages": "_rp-pages_34orh_1",
78
+ "rp-pages-horizontal-scroll": "_rp-pages-horizontal-scroll_34orh_7",
79
+ "rp-pages-container": "_rp-pages-container_34orh_11",
80
+ "rp-page-scrolling-wrapper": "_rp-page-scrolling-wrapper_34orh_17",
81
+ "rp-viewer": "_rp-viewer_34orh_22",
82
+ "rp-cursor-grab": "_rp-cursor-grab_34orh_27",
83
+ "rp-cursor-grabbing": "_rp-cursor-grabbing_34orh_35"
84
+ }, Ke = {
85
+ "rp-page-wrapper": "_rp-page-wrapper_h7a2q_1",
86
+ "rp-page": "_rp-page_h7a2q_1",
87
+ "rp-loader-wrapper": "_rp-loader-wrapper_h7a2q_14"
88
+ }, Qr = (e) => {
89
+ const { pageNumber: t, onLoaded: n, onLoading: r } = e, o = $(null), { pages: i } = Y(), { rotate: l } = Ve(), s = $(), { currentZoom: c } = ht();
90
+ return z(() => {
91
+ if (!i || c === 0)
92
+ return;
93
+ const h = i.get(t);
94
+ if (o.current && h) {
95
+ const p = o.current;
96
+ p.hidden = !0;
97
+ const m = s.current;
98
+ m && m.cancel(), r && r(), s.current = ot(h.page, p, c, l), s.current.promise.then(() => {
99
+ p.hidden = !1;
100
+ }).catch((u) => {
101
+ }).finally(() => {
102
+ n && n();
103
+ });
104
+ }
105
+ }, [i, t, l, c, r, n]), /* @__PURE__ */ a("canvas", { "data-rp": `page-${t}-canvas`, ref: o });
106
+ }, Xe = {
107
+ "rp-text-layer": "_rp-text-layer_1mgyz_1",
108
+ "rp-text-layer-text": "_rp-text-layer-text_1mgyz_9"
109
+ }, _t = () => {
110
+ const { viewMode: e } = Ge(), { scrollMode: t } = Pe(), { virtualScrollRef: n, pageScrollElementRef: r } = Ue(), { setFocusedPage: o } = re(), i = $(), { columnCount: l } = Bt(), s = Xt(), c = $(t), h = $(e);
111
+ z(() => {
112
+ n != null && n.scrollToItem && (i.current = n);
113
+ }, [n]);
114
+ const p = x(
115
+ (u) => {
116
+ if (!r)
117
+ return;
118
+ const f = Math.ceil(u / 2) * 2 - 1;
119
+ u === f + 1 ? r.scrollTo({ left: s.widths[f], top: 0 }) : r.scrollTo({ left: 0, top: 0 });
120
+ },
121
+ [r, s]
122
+ );
123
+ return z(() => {
124
+ c.current = t, h.current = e;
125
+ }, [t, e]), { scrollToPage: x(
126
+ (u, f = "start") => {
127
+ const v = u - 1;
128
+ if (h.current === ze.DUAL_PAGE && c.current === Q.PAGE_SCROLLING) {
129
+ p(u);
130
+ return;
131
+ }
132
+ if (c.current === Q.PAGE_SCROLLING) {
133
+ o(u);
134
+ return;
135
+ }
136
+ if (i.current)
137
+ if (c.current === Q.HORIZONTAL_SCROLLING)
138
+ i.current.scrollToItem({ columnIndex: v, align: f });
139
+ else if (h.current === ze.DUAL_PAGE) {
140
+ const g = v % 2, C = Math.floor(v / 2);
141
+ i.current.scrollToItem({ columnIndex: g, rowIndex: C, align: f });
142
+ } else
143
+ i.current.scrollToItem({ rowIndex: v, align: f });
144
+ },
145
+ [l, p, o]
146
+ ) };
147
+ }, eo = (e = {}, t = "") => {
148
+ const [n, r] = F(t), [o, i] = F(!1), { pdf: l } = Y(), s = $(!n), [c, h] = F([]), [p, m] = F(0), { scrollToPage: u } = _t(), { virtualScrollRef: f, pageScrollElementRef: v, virtualScrollableElementRef: _ } = Ue(), { scrollMode: g } = Pe(), [C, y] = F(null), w = D(() => p === 0 ? null : c[p - 1], [p, c]), T = D(() => c.length, [c]);
149
+ z(() => {
150
+ if (!w || (u(w.page), !C || !C.classList.contains("selected")))
151
+ return;
152
+ const P = _ || v;
153
+ if (!P)
154
+ return;
155
+ const N = C.getBoundingClientRect(), I = P.clientHeight / 2, M = P.clientWidth / 2, L = P.scrollTop + N.top - I, R = P.scrollLeft + N.left - M;
156
+ P.scrollTo({
157
+ top: L,
158
+ left: R
159
+ });
160
+ }, [
161
+ w,
162
+ u,
163
+ f,
164
+ C,
165
+ g,
166
+ _,
167
+ v
168
+ ]);
169
+ const d = x(() => {
170
+ m((P) => T ? P + 1 > T ? 1 : P + 1 : 0);
171
+ }, [T]), S = x(() => {
172
+ m((P) => T ? P - 1 <= 0 ? T : P - 1 : 0);
173
+ }, [T]), b = x(async (P) => {
174
+ if (!P)
175
+ return {};
176
+ const N = P.numPages, I = {};
177
+ for (let M = 1; M <= N; M++) {
178
+ if (s.current)
179
+ throw "close pop over";
180
+ const L = await P.getPage(M);
181
+ I[M.toString()] = await L.getTextContent();
182
+ }
183
+ return I;
184
+ }, []);
185
+ return z(() => {
186
+ if (!n) {
187
+ s.current = !0, h([]), m(0);
188
+ return;
189
+ }
190
+ s.current = !1, i(!0), h([]), m(0), b(l).then((P) => {
191
+ const I = Object.keys(P).reduce((M, L) => {
192
+ const R = Kn(
193
+ [n],
194
+ P[L],
195
+ Number(L) - 1,
196
+ e
197
+ ).map((E, A) => ({ ...E, page: Number(L), pageMatchIdx: A }));
198
+ return [...M, ...R];
199
+ }, []);
200
+ h(I), m(I.length ? 1 : 0);
201
+ }).catch(() => {
202
+ h([]), m(0);
203
+ }).finally(() => i(!1));
204
+ }, [n, b, l, e]), {
205
+ search: n,
206
+ setSearch: r,
207
+ loading: o,
208
+ matches: c,
209
+ totalMatches: T,
210
+ currentMatchPosition: p,
211
+ currentMatch: w,
212
+ nextMatch: d,
213
+ prevMatch: S,
214
+ currentMatchElement: C,
215
+ setCurrentMatchElement: y
216
+ };
217
+ }, tn = We({
218
+ search: "",
219
+ setSearch: (e) => {
220
+ },
221
+ loading: !1,
222
+ matches: [],
223
+ totalMatches: 0,
224
+ currentMatchPosition: 0,
225
+ currentMatch: null,
226
+ nextMatch: () => {
227
+ },
228
+ prevMatch: () => {
229
+ },
230
+ searchOptions: {},
231
+ setSearchOptions: (e) => e,
232
+ currentMatchElement: null,
233
+ setCurrentMatchElement: (e) => {
234
+ }
235
+ }), to = ({
236
+ children: e,
237
+ initialSearch: t
238
+ }) => {
239
+ const [n, r] = F({}), {
240
+ loading: o,
241
+ setSearch: i,
242
+ totalMatches: l,
243
+ currentMatchPosition: s,
244
+ currentMatch: c,
245
+ search: h,
246
+ matches: p,
247
+ nextMatch: m,
248
+ prevMatch: u,
249
+ currentMatchElement: f,
250
+ setCurrentMatchElement: v
251
+ } = eo(n, t);
252
+ return /* @__PURE__ */ a(
253
+ tn.Provider,
254
+ {
255
+ value: {
256
+ searchOptions: n,
257
+ setSearchOptions: r,
258
+ loading: o,
259
+ setSearch: i,
260
+ totalMatches: l,
261
+ currentMatchPosition: s,
262
+ currentMatch: c,
263
+ nextMatch: m,
264
+ prevMatch: u,
265
+ search: h,
266
+ matches: p,
267
+ currentMatchElement: f,
268
+ setCurrentMatchElement: v
269
+ },
270
+ children: e
271
+ }
272
+ );
273
+ }, nn = () => He(tn), no = (e) => {
274
+ const { pageNumber: t } = e, { pages: n } = Y(), r = $(null), { matches: o, currentMatch: i, setCurrentMatchElement: l } = nn(), [s, c] = F(
275
+ []
276
+ ), h = $(), p = $(), m = $(), u = D(() => o.filter((v) => v.pageIndex === t - 1), [o, t]), f = x(
277
+ (v, _, g = !1) => {
278
+ if (g && Xn(v, _), !u.length) {
279
+ m.current = void 0, c([]);
280
+ return;
281
+ }
282
+ const C = Jn(u, v, _);
283
+ c(C);
284
+ },
285
+ [u]
286
+ );
287
+ return z(() => {
288
+ var g;
289
+ if ((g = m.current) == null || g.classList.remove("selected"), !s.length || !i || i.pageIndex !== t - 1)
290
+ return;
291
+ const v = u.findIndex(
292
+ (C) => JSON.stringify(C) === JSON.stringify(i)
293
+ );
294
+ if (v === -1)
295
+ return;
296
+ const _ = s.find((C) => C.index === v);
297
+ _ && (m.current = _.element, l(_.element), _.element.classList.add("selected"));
298
+ }, [i, s, u]), z(() => {
299
+ const v = n.get(t);
300
+ if (!(!v || !r.current))
301
+ return h.current && h.current.cancel(), v.page.getTextContent().then((_) => {
302
+ const g = v.page.getViewport({ scale: 1 });
303
+ return h.current = new Qn.TextLayer({
304
+ viewport: g,
305
+ textContentSource: _,
306
+ container: r.current
307
+ }), p.current = _, r.current && (r.current.innerText = ""), h.current.render();
308
+ }).then(() => {
309
+ var C;
310
+ [].slice.call(r.current.children).forEach((y) => {
311
+ y.classList.add(Xe["rp-text-layer-text"]);
312
+ });
313
+ const g = (C = h.current) == null ? void 0 : C.textDivs;
314
+ g && p.current && f(p.current, g);
315
+ }).catch(() => {
316
+ }), () => {
317
+ var _;
318
+ (_ = h.current) == null || _.cancel();
319
+ };
320
+ }, [n, t]), z(() => {
321
+ var g;
322
+ [].slice.call(r.current.children).forEach((C) => {
323
+ C.classList.add(Xe["rp-text-layer-text"]);
324
+ });
325
+ const _ = (g = h.current) == null ? void 0 : g.textDivs;
326
+ _ && p.current && f(p.current, _, !0);
327
+ }, [f]), /* @__PURE__ */ a(
328
+ "div",
329
+ {
330
+ "data-rp": `page-${t}-textLayer`,
331
+ className: Xe["rp-text-layer"],
332
+ ref: r
333
+ }
334
+ );
335
+ }, ro = {
336
+ "rp-annotation-layer": "_rp-annotation-layer_o0ksd_1"
337
+ }, rn = ["click", "dblclick", "mouseover", "input", "change"];
338
+ let oo = "https://unpkg.com/pdfjs-dist@4.4.168/web/images/";
339
+ const st = /* @__PURE__ */ new Map(), on = (e, t) => `${e.loadingTask.docId}___${t.num}R${t.gen === 0 ? "" : t.gen}`;
340
+ function ao(e, t) {
341
+ const n = on(e, t);
342
+ return st.has(n) ? st.get(n) ?? null : null;
343
+ }
344
+ const io = (e, t, n) => {
345
+ st.set(on(e, t), n);
346
+ }, Rt = (e, t) => {
347
+ switch (t[1].name) {
348
+ case "XYZ":
349
+ return {
350
+ bottomOffset: (n, r) => t[3] === null ? r : t[3],
351
+ leftOffset: (n, r) => t[2] === null ? 0 : t[2],
352
+ pageIndex: e,
353
+ scaleTo: t[4]
354
+ };
355
+ case "Fit":
356
+ case "FitB":
357
+ return {
358
+ bottomOffset: 0,
359
+ leftOffset: 0,
360
+ pageIndex: e,
361
+ scaleTo: 1
362
+ };
363
+ case "FitH":
364
+ case "FitBH":
365
+ return {
366
+ bottomOffset: t[2],
367
+ leftOffset: 0,
368
+ pageIndex: e,
369
+ scaleTo: 1
370
+ };
371
+ default:
372
+ return {
373
+ bottomOffset: 0,
374
+ leftOffset: 0,
375
+ pageIndex: e,
376
+ scaleTo: 1
377
+ };
378
+ }
379
+ };
380
+ async function an(e, t) {
381
+ let n;
382
+ if (typeof t == "string" ? n = await e.getDestination(t) : n = t, n && typeof n[0] == "object" && n[0] !== null) {
383
+ const r = n[0], o = ao(e, r);
384
+ if (o === null) {
385
+ const i = await e.getPageIndex(r);
386
+ return io(e, r, i), await an(e, n);
387
+ } else
388
+ return Rt(o, n);
389
+ } else
390
+ return Rt(n[0], n);
391
+ }
392
+ function so(e) {
393
+ const { id: t, url: n, unsafeUrl: r } = e, o = new MutationObserver((i) => {
394
+ const l = document.querySelector(`[data-annotation-id="${t}"]`);
395
+ if (l) {
396
+ const s = l.querySelector("a"), c = Pr((n || r) ?? "", "");
397
+ s && (s.setAttribute("target", "_blank"), s.setAttribute("href", c), s.setAttribute("rel", "noopener noreferrer")), o.disconnect();
398
+ }
399
+ });
400
+ o.observe(document.body, { childList: !0, subtree: !0 });
401
+ }
402
+ const lo = (e) => {
403
+ const n = e.target.parentNode;
404
+ if (!n)
405
+ return;
406
+ const r = new MutationObserver((o) => {
407
+ o.forEach(() => {
408
+ n.querySelectorAll(
409
+ '[data-l10n-id="pdfjs-annotation-date-time-string"]'
410
+ ).forEach((l) => {
411
+ const s = l.getAttribute("data-l10n-args");
412
+ if (s)
413
+ try {
414
+ const { dateObj: c } = JSON.parse(s);
415
+ l.textContent = it(c);
416
+ } catch {
417
+ }
418
+ });
419
+ });
420
+ });
421
+ return r.observe(n, {
422
+ childList: !0,
423
+ // Watch for changes to child elements
424
+ subtree: !0,
425
+ // Watch all descendants, not just direct children
426
+ attributes: !0
427
+ // Watch for changes to attributes
428
+ }), () => r.disconnect();
429
+ }, Mt = (e, t, n, r) => {
430
+ if (e.type !== "click")
431
+ return;
432
+ const o = e.target, i = o.getAttribute("data-element-id");
433
+ if (o.getAttribute("href"))
434
+ return;
435
+ const s = t.find((c) => c.id === i);
436
+ !s || s.annotationType !== at.Link || s.dest && an(n, s.dest).then((c) => {
437
+ console.log(">>> AnnotationLayer handleClick", c), r(c);
438
+ });
439
+ };
440
+ function co(e, t) {
441
+ for (const n of rn)
442
+ e.addEventListener(n, t);
443
+ }
444
+ function uo(e, t) {
445
+ for (const n of rn)
446
+ e.removeEventListener(n, t);
447
+ }
448
+ const po = (e) => {
449
+ const { pageNumber: t } = e, n = $(null), { pages: r, pdf: o } = Y(), i = $(), [l, s] = F(), [c, h] = F(null), [p, m] = F(), { setFocusedPage: u, goToPage: f } = re(), { scrollMode: v } = Pe(), _ = D(() => r.get(t), [r, t]), g = D(() => _ == null ? void 0 : _.page.getViewport(), [_]);
450
+ z(() => {
451
+ o == null || o.hasJSActions().then((w) => {
452
+ s(w);
453
+ }), o == null || o.getFieldObjects().then((w) => {
454
+ h(w);
455
+ }), i.current && (i.current.div.replaceChildren(), i.current = void 0);
456
+ }, [o]);
457
+ const C = D(() => o == null ? void 0 : o.annotationStorage, [o]);
458
+ z(() => {
459
+ _ && _.page.getAnnotations().then((w) => {
460
+ i.current = void 0, m(w), n.current && (n.current.innerText = "");
461
+ });
462
+ }, [_]);
463
+ const y = x(
464
+ (w) => {
465
+ lo(w), !(!p || !o) && (v === Q.PAGE_SCROLLING ? Mt(w, p, o, (T) => u(T.pageIndex + 1)) : Mt(w, p, o, (T) => f(T.pageIndex + 1)));
466
+ },
467
+ [o, p, f, u, v]
468
+ );
469
+ return z(() => {
470
+ if (!_ || !p)
471
+ return;
472
+ const w = _.page.getViewport();
473
+ if (i.current) {
474
+ i.current.update({
475
+ viewport: w.clone({ dontFlip: !0 })
476
+ });
477
+ return;
478
+ }
479
+ console.log(">>> AnnotationLayer useMemo", p, t);
480
+ for (const T of p) {
481
+ const { annotationType: d } = T;
482
+ switch (d) {
483
+ case at.Link:
484
+ so(T);
485
+ break;
486
+ case at.Widget:
487
+ break;
488
+ }
489
+ }
490
+ i.current = new er({
491
+ div: n.current,
492
+ accessibilityManager: void 0,
493
+ annotationCanvasMap: void 0,
494
+ annotationEditorUIManager: void 0,
495
+ structTreeLayer: void 0,
496
+ page: _.page,
497
+ viewport: w.clone({ dontFlip: !0 })
498
+ }), n.current && uo(n.current, y), i.current.render({
499
+ annotations: p,
500
+ annotationStorage: C,
501
+ hasJSActions: l,
502
+ fieldObjects: c,
503
+ div: n.current,
504
+ viewport: w.clone({ dontFlip: !0 }),
505
+ page: _.page,
506
+ imageResourcesPath: oo,
507
+ renderForms: !1,
508
+ linkService: new Cr(),
509
+ downloadManager: null,
510
+ enableScripting: !1
511
+ }).then(() => {
512
+ n.current && co(n.current, y);
513
+ });
514
+ }, [p, l, c, y]), /* @__PURE__ */ a(
515
+ "div",
516
+ {
517
+ "data-rp": `page-${t}-annotationLayer`,
518
+ style: { width: `${g == null ? void 0 : g.width}px`, height: `${g == null ? void 0 : g.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: h } = ht(), p = $(l.get(n)), [m, u] = F(!1), f = $(null), [v, _] = F({
525
+ width: 0,
526
+ height: 0
527
+ });
528
+ qt(t, () => f.current), z(() => {
529
+ if (l && (p.current = l.get(n), p.current)) {
530
+ const w = p.current.page.getViewport({ scale: h, rotation: s });
531
+ _(w);
532
+ }
533
+ }, [l, n, s, h]);
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]), C = x(() => {
545
+ u(!0);
546
+ }, []), y = x(() => {
547
+ u(!1);
548
+ }, []);
549
+ return z(() => {
550
+ const w = new IntersectionObserver(
551
+ (T) => {
552
+ o && o(n, T[0].intersectionRatio);
553
+ },
554
+ { threshold: ho }
555
+ );
556
+ return f.current && w.observe(f.current), () => {
557
+ w.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": h
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: C, onLoaded: y, 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 Lt(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 Nt = Number.isNaN || function(t) {
616
+ return typeof t == "number" && t !== t;
617
+ };
618
+ function mo(e, t) {
619
+ return !!(e === t || Nt(e) && Nt(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, h = e.getOffsetForRowAndAlignment, p = e.getRowHeight, m = e.getRowOffset, u = e.getRowStartIndexForOffset, f = e.getRowStopIndexForStartIndex, v = e.initInstanceProps, _ = e.shouldResetStyleCacheOnItemSizeChange, g = e.validateProps;
696
+ return t = /* @__PURE__ */ function(C) {
697
+ fo(y, C);
698
+ function y(T) {
699
+ var d;
700
+ return d = C.call(this, T) || this, d._instanceProps = v(d.props, Lt(d)), d._resetIsScrollingTimeoutId = null, d._outerRef = void 0, d.state = {
701
+ instance: Lt(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(S, b, P, N, I, M, L, R) {
709
+ return d.props.onItemsRendered({
710
+ overscanColumnStartIndex: S,
711
+ overscanColumnStopIndex: b,
712
+ overscanRowStartIndex: P,
713
+ overscanRowStopIndex: N,
714
+ visibleColumnStartIndex: I,
715
+ visibleColumnStopIndex: M,
716
+ visibleRowStartIndex: L,
717
+ visibleRowStopIndex: R
718
+ });
719
+ }), d._callOnScroll = void 0, d._callOnScroll = Je(function(S, b, P, N, I) {
720
+ return d.props.onScroll({
721
+ horizontalScrollDirection: P,
722
+ scrollLeft: S,
723
+ scrollTop: b,
724
+ verticalScrollDirection: N,
725
+ scrollUpdateWasRequested: I
726
+ });
727
+ }), d._getItemStyle = void 0, d._getItemStyle = function(S, b) {
728
+ var P = d.props, N = P.columnWidth, I = P.direction, M = P.rowHeight, L = d._getItemStyleCache(_ && N, _ && I, _ && M), R = S + ":" + b, E;
729
+ if (L.hasOwnProperty(R))
730
+ E = L[R];
731
+ else {
732
+ var A = n(d.props, b, d._instanceProps), W = I === "rtl";
733
+ L[R] = E = {
734
+ position: "absolute",
735
+ left: W ? void 0 : A,
736
+ right: W ? A : void 0,
737
+ top: m(d.props, S, d._instanceProps),
738
+ height: p(d.props, S, d._instanceProps),
739
+ width: i(d.props, b, d._instanceProps)
740
+ };
741
+ }
742
+ return E;
743
+ }, d._getItemStyleCache = void 0, d._getItemStyleCache = Je(function(S, b, P) {
744
+ return {};
745
+ }), d._onScroll = function(S) {
746
+ var b = S.currentTarget, P = b.clientHeight, N = b.clientWidth, I = b.scrollLeft, M = b.scrollTop, L = b.scrollHeight, R = b.scrollWidth;
747
+ d.setState(function(E) {
748
+ if (E.scrollLeft === I && E.scrollTop === M)
749
+ return null;
750
+ var A = d.props.direction, W = I;
751
+ if (A === "rtl")
752
+ switch (At()) {
753
+ case "negative":
754
+ W = -I;
755
+ break;
756
+ case "positive-descending":
757
+ W = R - N - I;
758
+ break;
759
+ }
760
+ W = Math.max(0, Math.min(W, R - N));
761
+ var G = Math.max(0, Math.min(M, L - P));
762
+ return {
763
+ isScrolling: !0,
764
+ horizontalScrollDirection: E.scrollLeft < I ? "forward" : "backward",
765
+ scrollLeft: W,
766
+ scrollTop: G,
767
+ verticalScrollDirection: E.scrollTop < M ? "forward" : "backward",
768
+ scrollUpdateWasRequested: !1
769
+ };
770
+ }, d._resetIsScrollingDebounced);
771
+ }, d._outerRefSetter = function(S) {
772
+ var b = d.props.outerRef;
773
+ d._outerRef = S, typeof b == "function" ? b(S) : b != null && typeof b == "object" && b.hasOwnProperty("current") && (b.current = S);
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
+ y.getDerivedStateFromProps = function(d, S) {
785
+ return So(d, S), g(d), null;
786
+ };
787
+ var w = y.prototype;
788
+ return w.scrollTo = function(d) {
789
+ var S = d.scrollLeft, b = d.scrollTop;
790
+ S !== void 0 && (S = Math.max(0, S)), b !== void 0 && (b = Math.max(0, b)), this.setState(function(P) {
791
+ return S === void 0 && (S = P.scrollLeft), b === void 0 && (b = P.scrollTop), P.scrollLeft === S && P.scrollTop === b ? null : {
792
+ horizontalScrollDirection: P.scrollLeft < S ? "forward" : "backward",
793
+ scrollLeft: S,
794
+ scrollTop: b,
795
+ scrollUpdateWasRequested: !0,
796
+ verticalScrollDirection: P.scrollTop < b ? "forward" : "backward"
797
+ };
798
+ }, this._resetIsScrollingDebounced);
799
+ }, w.scrollToItem = function(d) {
800
+ var S = d.align, b = S === void 0 ? "auto" : S, P = d.columnIndex, N = d.rowIndex, I = this.props, M = I.columnCount, L = I.height, R = I.rowCount, E = I.width, A = this.state, W = A.scrollLeft, G = A.scrollTop, Z = wo();
801
+ P !== void 0 && (P = Math.max(0, Math.min(P, M - 1))), N !== void 0 && (N = Math.max(0, Math.min(N, R - 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: P !== void 0 ? c(this.props, P, b, W, this._instanceProps, oe) : W,
805
+ scrollTop: N !== void 0 ? h(this.props, N, b, G, this._instanceProps, ue) : G
806
+ });
807
+ }, w.componentDidMount = function() {
808
+ var d = this.props, S = d.initialScrollLeft, b = d.initialScrollTop;
809
+ if (this._outerRef != null) {
810
+ var P = this._outerRef;
811
+ typeof S == "number" && (P.scrollLeft = S), typeof b == "number" && (P.scrollTop = b);
812
+ }
813
+ this._callPropsCallbacks();
814
+ }, w.componentDidUpdate = function() {
815
+ var d = this.props.direction, S = this.state, b = S.scrollLeft, P = S.scrollTop, N = S.scrollUpdateWasRequested;
816
+ if (N && this._outerRef != null) {
817
+ var I = this._outerRef;
818
+ if (d === "rtl")
819
+ switch (At()) {
820
+ case "negative":
821
+ I.scrollLeft = -b;
822
+ break;
823
+ case "positive-ascending":
824
+ I.scrollLeft = b;
825
+ break;
826
+ default:
827
+ var M = I.clientWidth, L = I.scrollWidth;
828
+ I.scrollLeft = L - M - b;
829
+ break;
830
+ }
831
+ else
832
+ I.scrollLeft = Math.max(0, b);
833
+ I.scrollTop = Math.max(0, P);
834
+ }
835
+ this._callPropsCallbacks();
836
+ }, w.componentWillUnmount = function() {
837
+ this._resetIsScrollingTimeoutId !== null && Dt(this._resetIsScrollingTimeoutId);
838
+ }, w.render = function() {
839
+ var d = this.props, S = d.children, b = d.className, P = d.columnCount, N = d.direction, I = d.height, M = d.innerRef, L = d.innerElementType, R = d.innerTagName, E = d.itemData, A = d.itemKey, W = A === void 0 ? Co : A, 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], k = _e[1], H = this._getVerticalRangeToRender(), q = H[0], le = H[1], Te = [];
840
+ if (P > 0 && U)
841
+ for (var de = q; de <= le; de++)
842
+ for (var pe = Se; pe <= k; pe++)
843
+ Te.push(Ne(S, {
844
+ columnIndex: pe,
845
+ data: E,
846
+ isScrolling: ue ? ve : void 0,
847
+ key: W({
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 Ne(G || Z || "div", {
857
+ className: b,
858
+ onScroll: this._onScroll,
859
+ ref: this._outerRefSetter,
860
+ style: lt({
861
+ position: "relative",
862
+ height: I,
863
+ width: oe,
864
+ overflow: "auto",
865
+ WebkitOverflowScrolling: "touch",
866
+ willChange: "transform",
867
+ direction: N
868
+ }, K)
869
+ }, Ne(L || R || "div", {
870
+ children: Te,
871
+ ref: M,
872
+ style: {
873
+ height: Ze,
874
+ pointerEvents: ve ? "none" : void 0,
875
+ width: je
876
+ }
877
+ }));
878
+ }, w._callPropsCallbacks = function() {
879
+ var d = this.props, S = d.columnCount, b = d.onItemsRendered, P = d.onScroll, N = d.rowCount;
880
+ if (typeof b == "function" && S > 0 && N > 0) {
881
+ var I = this._getHorizontalRangeToRender(), M = I[0], L = I[1], R = I[2], E = I[3], A = this._getVerticalRangeToRender(), W = A[0], G = A[1], Z = A[2], U = A[3];
882
+ this._callOnItemsRendered(M, L, W, G, R, E, Z, U);
883
+ }
884
+ if (typeof P == "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
+ }, w._getHorizontalRangeToRender = function() {
889
+ var d = this.props, S = d.columnCount, b = d.overscanColumnCount, P = d.overscanColumnsCount, N = d.overscanCount, I = d.rowCount, M = this.state, L = M.horizontalScrollDirection, R = M.isScrolling, E = M.scrollLeft, A = b || P || N || 1;
890
+ if (S === 0 || I === 0)
891
+ return [0, 0, 0, 0];
892
+ var W = r(this.props, E, this._instanceProps), G = o(this.props, W, E, this._instanceProps), Z = !R || L === "backward" ? Math.max(1, A) : 1, U = !R || L === "forward" ? Math.max(1, A) : 1;
893
+ return [Math.max(0, W - Z), Math.max(0, Math.min(S - 1, G + U)), W, G];
894
+ }, w._getVerticalRangeToRender = function() {
895
+ var d = this.props, S = d.columnCount, b = d.overscanCount, P = d.overscanRowCount, N = d.overscanRowsCount, I = d.rowCount, M = this.state, L = M.isScrolling, R = M.verticalScrollDirection, E = M.scrollTop, A = P || N || b || 1;
896
+ if (S === 0 || I === 0)
897
+ return [0, 0, 0, 0];
898
+ var W = u(this.props, E, this._instanceProps), G = f(this.props, W, E, this._instanceProps), Z = !L || R === "backward" ? Math.max(1, A) : 1, U = !L || R === "forward" ? Math.max(1, A) : 1;
899
+ return [Math.max(0, W - Z), Math.max(0, Math.min(I - 1, G + U)), W, G];
900
+ }, y;
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, h = t.overscanCount, p = t.overscanRowsCount, m = t.width, u = n.instance;
909
+ if (process.env.NODE_ENV !== "production") {
910
+ if (typeof h == "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 p == "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 h = r - l - 1, p = h * i;
931
+ return s + p;
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 h = r - l - 1, p = h * i;
939
+ return s + p;
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 h = i[s];
946
+ c = h.offset + h.size;
947
+ }
948
+ for (var p = s + 1; p <= r; p++) {
949
+ var m = l(p);
950
+ i[p] = {
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, h = ie(t, n, r, l), p = t === "column" ? ln(n, l) : sn(n, l), m = Math.max(0, Math.min(p - c, h.offset)), u = Math.max(0, h.offset - c + s + h.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, h = s.offset + s.size, p = n; p < i - 1 && h < c; )
997
+ p++, h += ie("column", t, p, o).size;
998
+ return p;
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, h = s.offset + s.size, p = n; p < i - 1 && h < c; )
1022
+ p++, h += ie("row", t, p, o).size;
1023
+ return p;
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, h = s.rowIndex, p = s.shouldForceUpdate, m = p === void 0 ? !0 : p;
1046
+ typeof c == "number" && (l.lastMeasuredColumnIndex = Math.min(l.lastMeasuredColumnIndex, c - 1)), typeof h == "number" && (l.lastMeasuredRowIndex = Math.min(l.lastMeasuredRowIndex, h - 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"], xo = ["style"];
1071
+ function Ro(e, t) {
1072
+ var n = e.style, r = Et(e, yo), o = t.style, i = Et(t, xo);
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 = x(
1077
+ (f) => o.widths[f] || 0,
1078
+ [o]
1079
+ ), l = x(
1080
+ (f) => o.heights[f] || 0,
1081
+ [o]
1082
+ ), s = D(() => o.heights.length, [o]), c = D(() => Math.max(...o.widths), [o]), h = D(() => t === Q.HORIZONTAL_SCROLLING ? s : e === ze.DUAL_PAGE ? 2 : 1, [e, t, t, s, r, c]);
1083
+ z(() => {
1084
+ n(h);
1085
+ }, [h, n]);
1086
+ const p = D(() => t === Q.HORIZONTAL_SCROLLING || t === Q.PAGE_SCROLLING ? 1 : Math.round(s / h), [h, 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: p,
1089
+ rowHeight: l,
1090
+ columnCount: h,
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 Lo(e) {
1114
+ let t, n, r, o, i, l, s;
1115
+ const c = typeof document < "u" && document.attachEvent;
1116
+ if (!c) {
1117
+ l = function(C) {
1118
+ const y = C.__resizeTriggers__, w = y.firstElementChild, T = y.lastElementChild, d = w.firstElementChild;
1119
+ T.scrollLeft = T.scrollWidth, T.scrollTop = T.scrollHeight, d.style.width = w.offsetWidth + 1 + "px", d.style.height = w.offsetHeight + 1 + "px", w.scrollLeft = w.scrollWidth, w.scrollTop = w.scrollHeight;
1120
+ }, i = function(C) {
1121
+ return C.offsetWidth !== C.__resizeLast__.width || C.offsetHeight !== C.__resizeLast__.height;
1122
+ }, s = function(C) {
1123
+ if (C.target.className && typeof C.target.className.indexOf == "function" && C.target.className.indexOf("contract-trigger") < 0 && C.target.className.indexOf("expand-trigger") < 0)
1124
+ return;
1125
+ const y = this;
1126
+ l(this), this.__resizeRAF__ && ut(this.__resizeRAF__), this.__resizeRAF__ = dt(function() {
1127
+ i(y) && (y.__resizeLast__.width = y.offsetWidth, y.__resizeLast__.height = y.offsetHeight, y.__resizeListeners__.forEach(function(d) {
1128
+ d.call(y, C);
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 C = document.createElement("fakeelement");
1138
+ if (C.style.animationName !== void 0 && (u = !0), u === !1) {
1139
+ for (let y = 0; y < v.length; y++)
1140
+ if (C.style[v[y] + "AnimationName"] !== void 0) {
1141
+ g = v[y], f = "-" + g.toLowerCase() + "-", r = _[y], 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 h = 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"), h(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 C = v.createElement("div");
1165
+ C.className = "contract-trigger", u.__resizeTriggers__.appendChild(g), u.__resizeTriggers__.appendChild(C), u.appendChild(u.__resizeTriggers__), l(u), u.addEventListener("scroll", s, !0), r && (u.__resizeTriggers__.__animationListener__ = function(w) {
1166
+ w.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 No 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"), h = parseFloat(i.paddingBottom || "0"), p = this._parentNode.getBoundingClientRect(), m = p.height - c - h, u = p.width - l - s, f = this._parentNode.offsetHeight - c - h, 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 = Lo(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: h = {},
1243
+ tagName: p = "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
+ }, C = {};
1253
+ let y = !1;
1254
+ return o || (u === 0 && (y = !0), g.height = 0, C.height = u, C.scaledHeight = f), i || (_ === 0 && (y = !0), g.width = 0, C.width = _, C.scaledWidth = v), l && (y = !1), Ne(p, {
1255
+ ref: this._setRef,
1256
+ style: {
1257
+ ...g,
1258
+ ...h
1259
+ },
1260
+ ...m
1261
+ }, !y && t(C));
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: h } = Pe(), p = yr(t, 100), m = x(
1266
+ (g) => {
1267
+ if (!/^[0-9]*$/g.test(g.toString()) || !g)
1268
+ return { success: !1, currentPage: l.current };
1269
+ const y = +g;
1270
+ return y < 0 || y > r ? { success: !1, currentPage: l.current } : (n(y), l.current = y, { success: !0, currentPage: +g });
1271
+ },
1272
+ [r]
1273
+ ), u = x(m, [m]), f = x(
1274
+ (g) => {
1275
+ const C = m(g);
1276
+ return C.success && (s.current = !0, i(C.currentPage)), C;
1277
+ },
1278
+ [m, i]
1279
+ ), v = x(() => {
1280
+ let g = t - 1;
1281
+ f(g);
1282
+ }, [f, t, c, h]), _ = x(() => {
1283
+ let g = t + 1;
1284
+ f(g);
1285
+ }, [f, t, c, h]);
1286
+ return {
1287
+ focusedPage: p,
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
+ }), re = () => {
1308
+ const e = He(un);
1309
+ return typeof (e == null ? void 0 : e.focusedPage) > "u" && xr.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: h } = Eo(t);
1312
+ return z(() => {
1313
+ n != null && n.numPages && l(n.numPages);
1314
+ }, [n, l, o, t]), z(() => {
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: h,
1328
+ goToPage: s
1329
+ },
1330
+ children: e
1331
+ }
1332
+ );
1333
+ }, Do = ({ widths: e, heights: t }) => {
1334
+ const { focusedPage: n, totalPages: r } = re(), o = D(() => {
1335
+ const s = [], c = Math.ceil(n / 2) * 2 - 1;
1336
+ if (s.push(c), c + 1 < r) {
1337
+ const h = c + 1;
1338
+ s.push(h);
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 } = re(), 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
+ }, Ro), es = () => {
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: h, prevPage: p, setFocusedPage: m, focusedPage: u } = re(), { scrollMode: f } = Pe(), { viewMode: v } = Ge(), _ = $(null), g = $({
1393
+ height: 0,
1394
+ width: 0
1395
+ }), C = $({
1396
+ viewMode: v,
1397
+ scrollMode: f
1398
+ }), { isFullScreen: y } = _r(), {
1399
+ pageDimension: w,
1400
+ rowCount: T,
1401
+ rowHeight: d,
1402
+ columnCount: S,
1403
+ columnWidth: b,
1404
+ estimatedColumnWidth: P,
1405
+ estimatedRowHeight: N
1406
+ } = Mo(), [I, M] = F({}), { isScrolling: L } = Kt(), R = $(), E = $({
1407
+ scrollTop: 0,
1408
+ scrollLeft: 0
1409
+ }), { isPressed: A } = Tr(), { selectionMode: W } = fr(), { initializeGrabScroll: G, scrollBehavior: Z } = Ir({
1410
+ isPressed: A
1411
+ }), U = D(() => W === jt.HAND, [W]), K = x((k, H) => {
1412
+ M((q) => ({ ...q, [k]: Math.round(H * 100) }));
1413
+ }, []), ue = D(() => ({
1414
+ columnCount: S,
1415
+ handleIntersectRatioChange: K
1416
+ }), [S, K]), oe = x(
1417
+ (k) => {
1418
+ const H = document.activeElement !== t;
1419
+ !y && H || (["ArrowUp", "ArrowLeft"].includes(k.key) ? (k.preventDefault(), p()) : ["ArrowDown", "ArrowRight"].includes(k.key) && (k.preventDefault(), h()));
1420
+ },
1421
+ [h, p, y, f]
1422
+ ), ve = x((k) => {
1423
+ E.current = {
1424
+ scrollTop: k.scrollTop,
1425
+ scrollLeft: k.scrollLeft
1426
+ };
1427
+ }, []);
1428
+ z(() => (window.addEventListener("keydown", oe), () => {
1429
+ window.removeEventListener("keydown", oe);
1430
+ }), [oe]), z(() => {
1431
+ if (_.current && (_.current.style.position = "relative"), !!r) {
1432
+ g.current = c, s({
1433
+ height: Array.from({ length: T }).reduce(
1434
+ (k, H, q) => k + d(q),
1435
+ 0
1436
+ ),
1437
+ width: Array.from({ length: S }).reduce(
1438
+ (k, H, q) => k + b(q),
1439
+ 0
1440
+ )
1441
+ });
1442
+ for (let k = 0; k < T; k++)
1443
+ for (let H = 0; H < S; H++)
1444
+ r.resetAfterIndices({
1445
+ columnIndex: H,
1446
+ rowIndex: k,
1447
+ shouldForceUpdate: !0
1448
+ });
1449
+ }
1450
+ }, [T, S, w, r, n]), z(() => {
1451
+ if (L.current)
1452
+ return;
1453
+ if (C.current.viewMode !== v || C.current.scrollMode !== f) {
1454
+ R.current && clearTimeout(R.current), M({}), n(u), f === Q.HORIZONTAL_SCROLLING && (r == null || r.scrollTo({
1455
+ scrollTop: 0
1456
+ })), R.current = setTimeout(() => {
1457
+ requestAnimationFrame(() => {
1458
+ C.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]), z(() => {
1472
+ const k = Object.entries(I);
1473
+ if (L.current) {
1474
+ L.current && (L.current = !1);
1475
+ return;
1476
+ }
1477
+ let H = 0, q = -1;
1478
+ k.forEach((le) => {
1479
+ q < le[1] && (H = Number(le[0]), q = le[1]);
1480
+ }), H && m(H);
1481
+ }, [I, m]), z(() => () => {
1482
+ R.current && clearTimeout(R.current);
1483
+ }, []);
1484
+ const _e = D(() => j(ae["rp-pages-container"], {
1485
+ [ae["rp-cursor-grab"]]: U && !A,
1486
+ [ae["rp-cursor-grabbing"]]: U && A
1487
+ }), [U, A]), Se = x(
1488
+ (k) => {
1489
+ if (U && k) {
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(No, { children: ({ width: k, height: H }) => /* @__PURE__ */ a(
1497
+ "div",
1498
+ {
1499
+ "data-rp": "pagesWrapper",
1500
+ ref: Se,
1501
+ style: { width: k, height: H, scrollBehavior: Z },
1502
+ children: f === Q.PAGE_SCROLLING ? /* @__PURE__ */ a(
1503
+ "div",
1504
+ {
1505
+ ref: i,
1506
+ style: { width: k, height: H },
1507
+ className: j(ae["rp-pages"], ae["rp-page-scrolling-wrapper"]),
1508
+ children: v === ze.DUAL_PAGE ? /* @__PURE__ */ a(Do, { widths: b, heights: d }) : /* @__PURE__ */ a(Ao, { widths: b, heights: d })
1509
+ }
1510
+ ) : P ? /* @__PURE__ */ a(
1511
+ Io,
1512
+ {
1513
+ ref: o,
1514
+ itemData: ue,
1515
+ outerRef: l,
1516
+ innerRef: _,
1517
+ onScroll: ve,
1518
+ columnCount: S,
1519
+ columnWidth: b,
1520
+ rowHeight: d,
1521
+ height: H,
1522
+ width: k,
1523
+ estimatedColumnWidth: P,
1524
+ estimatedRowHeight: N,
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_16hg5_1",
1538
+ "rp-toolbar-wrapper": "_rp-toolbar-wrapper_16hg5_9",
1539
+ "rp-toolbar-start": "_rp-toolbar-start_16hg5_17",
1540
+ "rp-toolbar-middle": "_rp-toolbar-middle_16hg5_23",
1541
+ "rp-toolbar-end": "_rp-toolbar-end_16hg5_30"
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 } = ne();
1548
+ return e || /* @__PURE__ */ a(Me, {});
1549
+ }, ko = () => {
1550
+ const { nextIcon: e } = ne();
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 } = re(), [l, s] = F(e.toString()), { pageNavigationTool: c = !0 } = se(), { isSmallScreen: h } = ge();
1554
+ z(() => {
1555
+ s(e.toString());
1556
+ }, [e]);
1557
+ const p = x((v) => {
1558
+ const _ = v.target.value;
1559
+ s(_);
1560
+ }, []), m = x(() => {
1561
+ const v = i(l);
1562
+ v.success || s(v.currentPage.toString());
1563
+ }, [i, l, t]), u = x(() => {
1564
+ s(e.toString());
1565
+ }, [e]), f = x(
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
+ !h && /* @__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: p,
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
+ !h && /* @__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, ts] = Lr(bt), [Ho, ee] = 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), [h = !1, p] = kr({
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: h,
1623
+ onOpenChange: p,
1624
+ onOpenToggle: V.useCallback(() => p((m) => !m), [p]),
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 = ee(hn, n), i = mt(t, o.triggerRef);
1634
+ return /* @__PURE__ */ a(
1635
+ Le.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: Re(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 = ee(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(Wr, { 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 = ee(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 = ee(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: Er, allowPinchZoom: !0, shards: [o.contentRef], children: /* @__PURE__ */ a(
1671
+ Le.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 = ee(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 = ee(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 Or(i);
1695
+ }, []), /* @__PURE__ */ a(
1696
+ _n,
1697
+ {
1698
+ ...e,
1699
+ ref: o,
1700
+ trapFocus: n.open,
1701
+ disableOutsidePointerEvents: !0,
1702
+ onCloseAutoFocus: Re(e.onCloseAutoFocus, (i) => {
1703
+ var l;
1704
+ i.preventDefault(), (l = n.triggerRef.current) == null || l.focus();
1705
+ }),
1706
+ onPointerDownOutside: Re(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: Re(
1711
+ e.onFocusOutside,
1712
+ (i) => i.preventDefault()
1713
+ )
1714
+ }
1715
+ );
1716
+ }
1717
+ ), qo = V.forwardRef(
1718
+ (e, t) => {
1719
+ const n = ee(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, h;
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
+ ((h = n.triggerRef.current) == null ? void 0 : h.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 = ee(me, n), c = V.useRef(null), h = mt(t, c);
1743
+ return Dr(), /* @__PURE__ */ O(Ae, { children: [
1744
+ /* @__PURE__ */ a(
1745
+ Ar,
1746
+ {
1747
+ asChild: !0,
1748
+ loop: !0,
1749
+ trapped: r,
1750
+ onMountAutoFocus: o,
1751
+ onUnmountAutoFocus: i,
1752
+ children: /* @__PURE__ */ a(
1753
+ zr,
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: h,
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 = ee(Pt, n);
1776
+ return /* @__PURE__ */ a(Le.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 = ee(bn, n);
1783
+ return /* @__PURE__ */ a(Le.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 = ee(Cn, n);
1790
+ return /* @__PURE__ */ a(
1791
+ Le.button,
1792
+ {
1793
+ type: "button",
1794
+ ...r,
1795
+ ref: t,
1796
+ onClick: Re(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", [ns, Tn] = Fr(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: h,
1844
+ createdOn: p,
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: h },
1859
+ { label: "Keywords", value: u },
1860
+ { label: "Creator", value: m },
1861
+ {
1862
+ label: "Created on",
1863
+ value: p ? it(p) : ""
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 } = ne();
1895
+ return e || /* @__PURE__ */ a(Zr, {});
1896
+ }, yn = ({ children: e }) => /* @__PURE__ */ a(X, { 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(yn, { children: /* @__PURE__ */ O(ce, { onClick: e, children: [
1897
+ /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(In, {}) }),
1898
+ "Download file"
1899
+ ] }) }), xn = () => {
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, h] = F(null), p = $(!1);
1909
+ z(() => {
1910
+ p.current;
1911
+ }, [p]);
1912
+ const m = x(() => {
1913
+ document.documentElement.classList.remove("rp-print-html-printing"), document.body.classList.remove("rp-print-body-printing");
1914
+ const w = document.querySelector(".rp-print-zone");
1915
+ w && w.remove();
1916
+ }, []), u = x(() => {
1917
+ p.current = !1, i(!1), s(!1), h(null), r({
1918
+ loadedPages: 0,
1919
+ totalPages: 0,
1920
+ percentage: 0
1921
+ });
1922
+ }, []), f = () => {
1923
+ p.current = !0;
1924
+ }, v = async ({
1925
+ scratchCanvas: w,
1926
+ pdfDocument: T,
1927
+ pageNumber: d,
1928
+ viewerPdfPage: S,
1929
+ printResolution: b,
1930
+ optionalContentConfigPromise: P,
1931
+ printAnnotationStoragePromise: N
1932
+ }) => {
1933
+ if (p.current) {
1934
+ u();
1935
+ return;
1936
+ }
1937
+ const I = b / tr.PDF;
1938
+ w.width = Math.floor(S.width * I), w.height = Math.floor(S.height * I);
1939
+ const M = w.getContext("2d");
1940
+ M.save(), M.fillStyle = "rgb(255, 255, 255)", M.fillRect(0, 0, w.width, w.height), M.restore();
1941
+ const [L, R] = await Promise.all([
1942
+ T.getPage(d),
1943
+ N
1944
+ ]);
1945
+ if (p.current) {
1946
+ u();
1947
+ return;
1948
+ }
1949
+ const E = {
1950
+ canvasContext: M,
1951
+ transform: [I, 0, 0, I, 0, 0],
1952
+ viewport: L.getViewport({ scale: 1, rotation: S.rotation }),
1953
+ intent: "print",
1954
+ annotationMode: nr.ENABLE_STORAGE,
1955
+ optionalContentConfigPromise: P,
1956
+ printAnnotationStorage: R
1957
+ };
1958
+ try {
1959
+ return L.render(E).promise;
1960
+ } catch (A) {
1961
+ throw A instanceof rr || console.error(A), A;
1962
+ }
1963
+ }, _ = x(() => {
1964
+ const w = window.print;
1965
+ return new Promise((T) => {
1966
+ const d = (P) => {
1967
+ setTimeout(() => {
1968
+ w.call(window), setTimeout(() => P(), 20);
1969
+ }, 0);
1970
+ };
1971
+ if (document.querySelector(".rp-print-zone")) {
1972
+ d(T);
1973
+ return;
1974
+ }
1975
+ const b = new MutationObserver(() => {
1976
+ document.querySelector(".rp-print-zone") && (d(T), b.disconnect());
1977
+ });
1978
+ b.observe(document.body, { childList: !0, subtree: !0 });
1979
+ });
1980
+ }, []), g = async (w) => {
1981
+ const T = document.createElement("img"), d = document.createElement("div");
1982
+ return d.classList.add("rp-print-page"), await new Promise((S, b) => {
1983
+ w.toBlob((P) => {
1984
+ P ? (T.src = URL.createObjectURL(P), T.onload = () => {
1985
+ URL.revokeObjectURL(T.src), S();
1986
+ }, T.onerror = b) : b(new Error("Failed to create blob"));
1987
+ });
1988
+ }).catch(() => {
1989
+ }), d.appendChild(T), d;
1990
+ }, C = (w, T) => {
1991
+ const d = document.createElement("div");
1992
+ d.classList.add("rp-print-zone");
1993
+ const S = document.createElement("style"), b = T.get(1);
1994
+ if (b) {
1995
+ const { width: P, height: N } = b == null ? void 0 : b.page.getViewport({ scale: 1 });
1996
+ S.innerHTML = `@page { size: ${P}px ${N}px }`;
1997
+ }
1998
+ return d.appendChild(S), d.append(...w), d;
1999
+ }, y = x(async () => {
2000
+ if (!e)
2001
+ return;
2002
+ u();
2003
+ const w = document.createElement("canvas"), T = [];
2004
+ try {
2005
+ e.isPureXfa && console.warn("[rp] XFA Form is not supported at the moment.");
2006
+ const S = e.getOptionalContentConfig({ intent: "print" }), b = Promise.resolve(
2007
+ e.annotationStorage.print ?? void 0
2008
+ ), P = t.size;
2009
+ for (const [I, M] of t) {
2010
+ if (p.current) {
2011
+ u();
2012
+ return;
2013
+ }
2014
+ const L = M.page.getViewport({ scale: 1 });
2015
+ if (await v({
2016
+ scratchCanvas: w,
2017
+ pdfDocument: e,
2018
+ pageNumber: I,
2019
+ viewerPdfPage: L,
2020
+ printResolution: 150,
2021
+ optionalContentConfigPromise: S,
2022
+ printAnnotationStoragePromise: b
2023
+ }), p.current) {
2024
+ u();
2025
+ return;
2026
+ }
2027
+ const R = await g(w);
2028
+ T.push(R);
2029
+ const E = parseFloat((T.length / P * 100).toFixed(2));
2030
+ r({
2031
+ loadedPages: I,
2032
+ totalPages: P,
2033
+ percentage: E
2034
+ });
2035
+ }
2036
+ if (p.current) {
2037
+ u();
2038
+ return;
2039
+ }
2040
+ const N = C(T, t);
2041
+ document.body.appendChild(N), 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 && h(d);
2044
+ } finally {
2045
+ w.height = 0, w.width = 0;
2046
+ }
2047
+ }, [e, t, p]);
2048
+ return z(() => {
2049
+ const w = () => {
2050
+ u(), m();
2051
+ };
2052
+ return window.addEventListener("afterprint", w, !0), () => {
2053
+ window.removeEventListener("afterprint", w, !0);
2054
+ };
2055
+ }, [m, u]), {
2056
+ print: y,
2057
+ cancel: f,
2058
+ progress: n,
2059
+ isComplete: o,
2060
+ isError: l,
2061
+ error: c
2062
+ };
2063
+ }, Rn = 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: h, error: p } = sa(), m = x((g) => {
2082
+ g && typeof g == "function" && o(() => g);
2083
+ }, []), u = (g) => {
2084
+ p && g(p);
2085
+ }, f = x(
2086
+ (g) => {
2087
+ n(() => g);
2088
+ },
2089
+ [s, t]
2090
+ );
2091
+ z(() => {
2092
+ c && r && v();
2093
+ }, [c, r]), z(() => {
2094
+ h && u((g) => {
2095
+ console.error(g);
2096
+ });
2097
+ }, [h]), z(() => {
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(Rn.Provider, { value: _, children: e });
2111
+ }, Tt = () => {
2112
+ const e = He(Rn);
2113
+ if (!e)
2114
+ throw new Error("usePrintContext must be used within a PrintProvider");
2115
+ return e;
2116
+ }, Mn = () => {
2117
+ const { printIcon: e } = ne();
2118
+ return e || /* @__PURE__ */ a(jr, {});
2119
+ }, Ln = ({ children: e }) => /* @__PURE__ */ a(X, { content: "Print", children: e }), ca = ({ print: e }) => /* @__PURE__ */ a(Ln, { children: /* @__PURE__ */ a(B, { onClick: e, children: /* @__PURE__ */ a(Mn, {}) }) }), ua = ({ print: e }) => /* @__PURE__ */ a(Ln, { children: /* @__PURE__ */ O(ce, { onClick: e, children: [
2120
+ /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(Mn, {}) }),
2121
+ "Print"
2122
+ ] }) }), Nn = () => {
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 } = ne();
2139
+ return e || /* @__PURE__ */ a(en, { className: da["rp-go-to-Top"] });
2140
+ }, ha = () => {
2141
+ const { goToLastPageIcon: e } = ne();
2142
+ return e || /* @__PURE__ */ a(en, {});
2143
+ }, fa = () => {
2144
+ const { goToPage: e, totalPages: t, focusedPage: n } = re(), { jumpNavigationTool: r = !0 } = se(), o = D(() => n === 1, [n]), i = D(() => n === t, [n, t]), l = x(() => {
2145
+ e(1);
2146
+ }, [e]), s = x(() => {
2147
+ e(t);
2148
+ }, [e, t]);
2149
+ return r ? /* @__PURE__ */ O(Fe, { children: [
2150
+ /* @__PURE__ */ a(X, { content: "Go to first page", children: /* @__PURE__ */ O(ce, { disabled: o, onClick: l, children: [
2151
+ /* @__PURE__ */ a("div", { className: "rp-menu-item-left", children: /* @__PURE__ */ a(pa, {}) }),
2152
+ "First page"
2153
+ ] }) }),
2154
+ /* @__PURE__ */ a(X, { content: "Go to last page", children: /* @__PURE__ */ O(ce, { disabled: i, onClick: s, 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: h,
2170
+ fullscreenTool: p
2171
+ } = se();
2172
+ return D(() => {
2173
+ const u = c || l || s || i || o;
2174
+ let f = !1;
2175
+ return t && (f = !(!n && !r && !h && !p)), u || f;
2176
+ }, [
2177
+ n,
2178
+ r,
2179
+ o,
2180
+ i,
2181
+ l,
2182
+ s,
2183
+ c
2184
+ ]) ? /* @__PURE__ */ O(Vr, { children: [
2185
+ /* @__PURE__ */ a(
2186
+ ft,
2187
+ {
2188
+ container: e,
2189
+ triggerComponent: /* @__PURE__ */ a(B, { children: /* @__PURE__ */ a(X, { content: "More options", children: /* @__PURE__ */ a(Mr, {}) }) }),
2190
+ children: /* @__PURE__ */ O("div", { className: ra["rp-other-tool-content"], children: [
2191
+ t && /* @__PURE__ */ O(Fe, { children: [
2192
+ /* @__PURE__ */ a(Jt, {}),
2193
+ /* @__PURE__ */ a(xn, {}),
2194
+ /* @__PURE__ */ a(Nn, {}),
2195
+ /* @__PURE__ */ a(Qt, {}),
2196
+ /* @__PURE__ */ a(vt, {})
2197
+ ] }),
2198
+ /* @__PURE__ */ a(fa, {}),
2199
+ /* @__PURE__ */ a(Ur, {}),
2200
+ /* @__PURE__ */ a(Br, {}),
2201
+ /* @__PURE__ */ a(qr, {}),
2202
+ /* @__PURE__ */ a(Gr, {})
2203
+ ] })
2204
+ }
2205
+ ),
2206
+ /* @__PURE__ */ a(na, {})
2207
+ ] }) : null;
2208
+ }, ga = () => {
2209
+ const { isSmallScreen: e } = ge();
2210
+ return /* @__PURE__ */ O(Ae, { children: [
2211
+ /* @__PURE__ */ a(Rr, {}),
2212
+ !e && /* @__PURE__ */ O(Ae, { children: [
2213
+ /* @__PURE__ */ a(Jt, {}),
2214
+ /* @__PURE__ */ a(xn, {}),
2215
+ /* @__PURE__ */ a(Nn, {}),
2216
+ /* @__PURE__ */ a(Qt, {})
2217
+ ] }),
2218
+ /* @__PURE__ */ a(ma, {})
2219
+ ] });
2220
+ }, ye = {
2221
+ "rp-zoom-wrapper": "_rp-zoom-wrapper_163s9_1",
2222
+ "rp-current-zoom-wrapper": "_rp-current-zoom-wrapper_163s9_6",
2223
+ "rp-current-zoom-icon": "_rp-current-zoom-icon_163s9_11",
2224
+ "rp-current-zoom": "_rp-current-zoom_163s9_6",
2225
+ "rp-zoom-dropdown-content": "_rp-zoom-dropdown-content_163s9_20"
2226
+ }, va = 25, nt = 1e3, _a = [50, 75, 100, 125, 150, 200, 300, 400], wa = () => {
2227
+ const { zoomInIcon: e } = ne();
2228
+ return e || /* @__PURE__ */ a(Kr, {});
2229
+ }, ba = () => {
2230
+ const { zoomOutIcon: e } = ne();
2231
+ return e || /* @__PURE__ */ a(Xr, {});
2232
+ }, Ca = () => {
2233
+ const { zoomLevel: e, setZoomLevel: t } = ht(), { container: n, contentRef: r } = qe(), { zoomTool: o = !0 } = se(), { focusedPage: i } = re(), { rotate: l } = Ve(), { pages: s } = Y(), { isSmallScreen: c } = ge(), h = x(() => {
2234
+ t((g) => {
2235
+ const C = Math.floor(g / 25) * 25;
2236
+ return Math.min(C + 25, nt);
2237
+ });
2238
+ }, [t]), p = x(() => {
2239
+ t((g) => {
2240
+ const C = Math.ceil(g / 25) * 25;
2241
+ return Math.min(C - 25, nt);
2242
+ });
2243
+ }, [t]), m = D(() => e === va, [e]), u = D(() => e === nt, [e]), f = D(() => {
2244
+ var g;
2245
+ return (g = s.get(i)) == null ? void 0 : g.page.getViewport({ scale: 1, rotation: l });
2246
+ }, [s, i, l]), v = x(
2247
+ (g) => {
2248
+ const C = ((f == null ? void 0 : f.width) || 0) + 2 * yt, y = ((f == null ? void 0 : f.height) || 0) + 2 * yt, w = (r == null ? void 0 : r.clientWidth) || 0, T = (r == null ? void 0 : r.clientHeight) || 0;
2249
+ switch (g) {
2250
+ case we.ACTUAL:
2251
+ t(100);
2252
+ break;
2253
+ case we.PAGE_FIT:
2254
+ let d = 0;
2255
+ const S = w > T;
2256
+ y > C && S ? d = T / y : d = w / C;
2257
+ const b = Math.floor(d * 100);
2258
+ t(b);
2259
+ break;
2260
+ case we.PAGE_WIDTH:
2261
+ t(Math.floor(w / C * 100));
2262
+ break;
2263
+ }
2264
+ },
2265
+ [t, f]
2266
+ ), _ = x(
2267
+ (g) => {
2268
+ typeof g == "number" ? t(g) : v(g);
2269
+ },
2270
+ [t, v]
2271
+ );
2272
+ return typeof o != "boolean" ? /* @__PURE__ */ a(o, { zoomLevel: e, setZoomLevel: t }) : o ? /* @__PURE__ */ O("div", { className: ye["rp-zoom-wrapper"], children: [
2273
+ /* @__PURE__ */ a(X, { content: "Zoom out", children: /* @__PURE__ */ a(B, { disabled: m, onClick: p, children: /* @__PURE__ */ a(ba, {}) }) }),
2274
+ !c && /* @__PURE__ */ a(X, { content: "Select zoom level", children: /* @__PURE__ */ a(
2275
+ ft,
2276
+ {
2277
+ container: n,
2278
+ triggerComponent: /* @__PURE__ */ O(B, { className: ye["rp-current-zoom-wrapper"], children: [
2279
+ /* @__PURE__ */ O("span", { className: ye["rp-current-zoom"], children: [
2280
+ e,
2281
+ " %"
2282
+ ] }),
2283
+ /* @__PURE__ */ a(Me, { className: ye["rp-current-zoom-icon"] })
2284
+ ] }),
2285
+ style: { minWidth: "200px" },
2286
+ align: "center",
2287
+ children: /* @__PURE__ */ O("div", { className: ye["rp-zoom-dropdown-content"], children: [
2288
+ /* @__PURE__ */ O(Fe, { children: [
2289
+ /* @__PURE__ */ a(ce, { onClick: () => _(we.ACTUAL), children: "Actual size" }),
2290
+ /* @__PURE__ */ a(ce, { onClick: () => _(we.PAGE_FIT), children: "Page fit" }),
2291
+ /* @__PURE__ */ a(ce, { onClick: () => _(we.PAGE_WIDTH), children: "Page width" })
2292
+ ] }),
2293
+ /* @__PURE__ */ a(vt, {}),
2294
+ /* @__PURE__ */ a(Fe, { children: _a.map((g) => /* @__PURE__ */ O(ce, { onClick: () => _(g), children: [
2295
+ g,
2296
+ " %"
2297
+ ] }, g)) })
2298
+ ] })
2299
+ }
2300
+ ) }),
2301
+ /* @__PURE__ */ a(X, { content: "Zoom in", children: /* @__PURE__ */ a(B, { disabled: u, onClick: h, children: /* @__PURE__ */ a(wa, {}) }) })
2302
+ ] }) : null;
2303
+ }, te = {
2304
+ "rp-search-tool-content": "_rp-search-tool-content_1vxow_1",
2305
+ "rp-search-tool-input": "_rp-search-tool-input_1vxow_6",
2306
+ "rp-search-tool-input-icon": "_rp-search-tool-input-icon_1vxow_12",
2307
+ "rp-search-tool-controls": "_rp-search-tool-controls_1vxow_16",
2308
+ "rp-search-tool-input-wrapper": "_rp-search-tool-input-wrapper_1vxow_24",
2309
+ "rp-search-tool-input-checkboxes": "_rp-search-tool-input-checkboxes_1vxow_30",
2310
+ "rp-search-tool-input-clear": "_rp-search-tool-input-clear_1vxow_35",
2311
+ "rp-search-input": "_rp-search-input_1vxow_49"
2312
+ }, Gt = () => {
2313
+ const { searchIcon: e } = ne();
2314
+ return e || /* @__PURE__ */ a(Jr, {});
2315
+ }, Pa = () => {
2316
+ const { container: e } = qe(), [t, n] = F(!1), { pdf: r } = Y(), [o, i] = F(null), {
2317
+ searchOptions: l,
2318
+ setSearchOptions: s,
2319
+ loading: c,
2320
+ setSearch: h,
2321
+ totalMatches: p,
2322
+ currentMatchPosition: m,
2323
+ nextMatch: u,
2324
+ prevMatch: f,
2325
+ search: v
2326
+ } = nn(), { searchTool: _ } = se(), [g, C] = F(v), y = x(() => {
2327
+ n(!0);
2328
+ }, []), w = x(() => {
2329
+ h(""), C(""), n(!1);
2330
+ }, [h]), T = x(
2331
+ (R) => {
2332
+ R.key === "Escape" && t && w();
2333
+ },
2334
+ [t]
2335
+ ), d = x(
2336
+ (R) => {
2337
+ R.shiftKey && R.key === "Enter" ? f() : R.key === "Enter" && h((E) => (g === E && u(), g));
2338
+ },
2339
+ [g, f, u, h]
2340
+ );
2341
+ z(() => (window.addEventListener("keydown", T), () => {
2342
+ window.removeEventListener("keydown", T);
2343
+ }), [T]), z(() => {
2344
+ o && o.focus();
2345
+ }, [o]);
2346
+ const S = x((R) => {
2347
+ C(R.target.value);
2348
+ }, []), b = x(() => {
2349
+ C(""), h("");
2350
+ }, [h]), P = D(() => `${m} / ${p}`, [m, p]), { wholeWords: N, matchCase: I } = D(() => l, [l]), M = x(
2351
+ (R) => {
2352
+ s((E) => ({ ...E, matchCase: R }));
2353
+ },
2354
+ [s]
2355
+ ), L = x(
2356
+ (R) => {
2357
+ s((E) => ({ ...E, wholeWords: R }));
2358
+ },
2359
+ [s]
2360
+ );
2361
+ return z(() => {
2362
+ w();
2363
+ }, [r, w]), _ ? /* @__PURE__ */ a(
2364
+ ft,
2365
+ {
2366
+ open: t,
2367
+ container: e,
2368
+ align: "start",
2369
+ triggerComponent: /* @__PURE__ */ a(X, { content: "Search in Document", children: /* @__PURE__ */ a(B, { onClick: y, children: /* @__PURE__ */ a(Gt, {}) }) }),
2370
+ children: /* @__PURE__ */ O("div", { className: te["rp-search-tool-content"], children: [
2371
+ /* @__PURE__ */ O("div", { className: te["rp-search-tool-input-wrapper"], children: [
2372
+ /* @__PURE__ */ O("div", { className: te["rp-search-tool-input"], children: [
2373
+ /* @__PURE__ */ a(
2374
+ Zt,
2375
+ {
2376
+ value: g,
2377
+ onKeyDown: d,
2378
+ onChange: S,
2379
+ icon: /* @__PURE__ */ a(Gt, {}),
2380
+ placeholder: "Enter to Search",
2381
+ className: te["rp-search-input"],
2382
+ ref: i,
2383
+ children: !!g && /* @__PURE__ */ a("span", { className: te["rp-search-tool-input-clear"], onClick: b, children: /* @__PURE__ */ a(Yr, {}) })
2384
+ }
2385
+ ),
2386
+ c ? /* @__PURE__ */ a("span", { children: /* @__PURE__ */ a(pt, {}) }) : /* @__PURE__ */ a("span", { children: P })
2387
+ ] }),
2388
+ /* @__PURE__ */ O("div", { className: te["rp-search-tool-input-checkboxes"], children: [
2389
+ /* @__PURE__ */ a(xt, { name: "matchCase", value: I, onChange: M, children: "Match Case" }),
2390
+ /* @__PURE__ */ a(xt, { name: "wholeWord", value: N, onChange: L, children: "Whole Word" })
2391
+ ] })
2392
+ ] }),
2393
+ /* @__PURE__ */ O("div", { className: te["rp-search-tool-controls"], children: [
2394
+ /* @__PURE__ */ a(B, { onClick: f, children: /* @__PURE__ */ a(Me, { className: te["rp-search-tool-input-icon"] }) }),
2395
+ /* @__PURE__ */ a(B, { onClick: u, children: /* @__PURE__ */ a(
2396
+ Me,
2397
+ {
2398
+ style: { transform: "rotate(180deg" },
2399
+ className: te["rp-search-tool-input-icon"]
2400
+ }
2401
+ ) }),
2402
+ /* @__PURE__ */ a(B, { children: /* @__PURE__ */ a(Yt, { onClick: w, className: te["rp-search-tool-input-icon"] }) })
2403
+ ] })
2404
+ ] })
2405
+ }
2406
+ ) : null;
2407
+ }, Sa = "_loading_1snj5_1", Ce = {
2408
+ "rp-loading-overlay": "_rp-loading-overlay_1snj5_1",
2409
+ "rp-loading-modal": "_rp-loading-modal_1snj5_14",
2410
+ "rp-loading-title": "_rp-loading-title_1snj5_27",
2411
+ "rp-loading-progress-bar": "_rp-loading-progress-bar_1snj5_35",
2412
+ "rp-loading-progress": "_rp-loading-progress_1snj5_35",
2413
+ "rp-loading-cancel-button": "_rp-loading-cancel-button_1snj5_52",
2414
+ loading: Sa
2415
+ }, Ta = ({ percentage: e }) => {
2416
+ const { cancel: t } = Tt();
2417
+ return e < 1 ? null : /* @__PURE__ */ a("div", { className: j(Ce["rp-loading-overlay"]), children: /* @__PURE__ */ O("div", { className: j(Ce["rp-loading-modal"]), children: [
2418
+ /* @__PURE__ */ a("div", { className: j(Ce["rp-loading-title"]), children: "Preparing document..." }),
2419
+ /* @__PURE__ */ a("div", { className: j(Ce["rp-loading-progress-bar"]), children: /* @__PURE__ */ a(
2420
+ "div",
2421
+ {
2422
+ className: j(Ce["rp-loading-progress"]),
2423
+ style: { width: `${e}%` }
2424
+ }
2425
+ ) }),
2426
+ /* @__PURE__ */ a("button", { className: j(Ce["rp-loading-cancel-button"]), onClick: t, children: "Cancel" })
2427
+ ] }) });
2428
+ }, Ia = $e((e, t) => {
2429
+ const { showPrintProgress: n } = se(), { progress: r } = Tt(), { isSmallScreen: o } = ge(), { percentage: i } = r || {}, l = () => o ? { gridTemplateColumns: "25% 60% 15%" } : void 0;
2430
+ return /* @__PURE__ */ O("div", { children: [
2431
+ /* @__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: [
2432
+ /* @__PURE__ */ O("div", { "data-rp": "topBarStart", className: Ie["rp-toolbar-start"], children: [
2433
+ /* @__PURE__ */ a(Pa, {}),
2434
+ /* @__PURE__ */ a(Wo, {})
2435
+ ] }),
2436
+ /* @__PURE__ */ a("div", { "data-rp": "topBarMiddle", className: Ie["rp-toolbar-middle"], children: /* @__PURE__ */ a(Ca, {}) }),
2437
+ /* @__PURE__ */ a("div", { "data-rp": "topBarEnd", className: Ie["rp-toolbar-end"], children: /* @__PURE__ */ a(ga, {}) })
2438
+ ] }) }),
2439
+ n && i ? /* @__PURE__ */ a(Ta, { percentage: i }) : null
2440
+ ] });
2441
+ }), rt = {
2442
+ "rp-sidebar-content-wrapper": "_rp-sidebar-content-wrapper_p2vax_1",
2443
+ "rp-sidebar-content": "_rp-sidebar-content_p2vax_1",
2444
+ "rp-thumbnails-wrapper": "_rp-thumbnails-wrapper_p2vax_16",
2445
+ "rp-thumbnail-dragging": "_rp-thumbnail-dragging_p2vax_21"
2446
+ }, xe = {
2447
+ "rp-thumbnail-wrapper": "_rp-thumbnail-wrapper_3fenb_1",
2448
+ "rp-thumbnail-text": "_rp-thumbnail-text_3fenb_10",
2449
+ "rp-thumbnail": "_rp-thumbnail_3fenb_1",
2450
+ "rp-thumbnail-active": "_rp-thumbnail-active_3fenb_22",
2451
+ "rp-thumbnail-loader": "_rp-thumbnail-loader_3fenb_31"
2452
+ }, ya = (e) => {
2453
+ const { thumbnailSrc: t, pageNumber: n, isFocused: r, viewport: o } = e, { goToPage: i } = re(), l = D(() => r ? xe["rp-thumbnail-active"] : "", [r]), s = D(() => ({
2454
+ width: Math.round(o.width),
2455
+ height: Math.round(o.height)
2456
+ }), [o]), c = x(() => {
2457
+ n && i(n);
2458
+ }, [i, n]);
2459
+ return /* @__PURE__ */ O(
2460
+ "div",
2461
+ {
2462
+ onClick: c,
2463
+ id: `page-${n}`,
2464
+ className: xe["rp-thumbnail-wrapper"],
2465
+ children: [
2466
+ /* @__PURE__ */ a("div", { className: j(l, xe["rp-thumbnail"]), children: t ? /* @__PURE__ */ a(
2467
+ "img",
2468
+ {
2469
+ src: t,
2470
+ width: s.width,
2471
+ height: s.height,
2472
+ alt: "thumbnail"
2473
+ }
2474
+ ) : /* @__PURE__ */ a(
2475
+ "div",
2476
+ {
2477
+ className: xe["rp-thumbnail-loader"],
2478
+ style: {
2479
+ width: `${s.width}px`,
2480
+ height: `${s.height}px`
2481
+ },
2482
+ children: /* @__PURE__ */ a(pt, {})
2483
+ }
2484
+ ) }),
2485
+ /* @__PURE__ */ a("div", { className: xe["rp-thumbnail-text"], children: n })
2486
+ ]
2487
+ }
2488
+ );
2489
+ }, Ut = {
2490
+ "rp-thumbnails-container": "_rp-thumbnails-container_16vqr_1",
2491
+ "rp-thumbnails": "_rp-thumbnails_16vqr_1"
2492
+ }, xa = () => {
2493
+ const [e, t] = F({}), { pages: n } = Y(), { rotate: r } = Ve(), o = D(() => Object.keys(e).length, [e]), i = x(
2494
+ (s) => {
2495
+ if (!n.size)
2496
+ return;
2497
+ const c = Array.from(n.values()).slice(0, s).map((m) => {
2498
+ const { thumbnailViewport: u, scale: f } = It(m.page, r);
2499
+ return {
2500
+ scale: f,
2501
+ page: m.page,
2502
+ loading: !0,
2503
+ viewport: u
2504
+ };
2505
+ }), h = c.reduce((m, u) => (m[u.page.pageNumber] = u, m), {});
2506
+ t(h);
2507
+ const p = [];
2508
+ for (const m of c) {
2509
+ const u = document.createElement("canvas"), f = ot(
2510
+ m.page,
2511
+ u,
2512
+ m.scale,
2513
+ r
2514
+ ).promise.then(() => {
2515
+ const v = u.toDataURL();
2516
+ return {
2517
+ ...m,
2518
+ thumbnailSrc: v,
2519
+ loading: !1
2520
+ };
2521
+ });
2522
+ p.push(f);
2523
+ }
2524
+ Promise.all(p).then((m) => {
2525
+ const u = m.reduce(
2526
+ (f, v) => (f[v.page.pageNumber] = v, f),
2527
+ {}
2528
+ );
2529
+ t((f) => ({ ...f, ...u }));
2530
+ });
2531
+ },
2532
+ [n, r]
2533
+ );
2534
+ z(() => {
2535
+ i(10);
2536
+ }, [i]);
2537
+ const l = x(
2538
+ (s) => {
2539
+ if (!n)
2540
+ return;
2541
+ const c = n.get(s);
2542
+ if (!c)
2543
+ return;
2544
+ t((p) => ({
2545
+ ...p,
2546
+ [s]: {
2547
+ loading: !0,
2548
+ page: c.page,
2549
+ viewport: c.thumbnailViewport,
2550
+ scale: c.thumbnailScale
2551
+ }
2552
+ }));
2553
+ const h = document.createElement("canvas");
2554
+ ot(c.page, h, c.thumbnailScale, r).promise.then(() => {
2555
+ const p = h.toDataURL(), { thumbnailViewport: m, scale: u } = It(c.page, r);
2556
+ return {
2557
+ scale: u,
2558
+ thumbnailSrc: p,
2559
+ page: c.page,
2560
+ loading: !1,
2561
+ viewport: m
2562
+ };
2563
+ }).then((p) => {
2564
+ t((m) => ({ ...m, [s]: p }));
2565
+ });
2566
+ },
2567
+ [n, r]
2568
+ );
2569
+ return { thumbnailPages: e, addPage: l, addToPage: i, thumbnailLength: o };
2570
+ }, En = We({
2571
+ thumbnailPages: {},
2572
+ addPage: (e) => {
2573
+ },
2574
+ addToPage: (e) => {
2575
+ },
2576
+ thumbnailLength: 0,
2577
+ setActive: (e) => {
2578
+ },
2579
+ active: !1
2580
+ }), On = () => He(En), Ra = ({
2581
+ children: e,
2582
+ initialThumbnailsVisible: t
2583
+ }) => {
2584
+ const { thumbnailPages: n, addPage: r, addToPage: o, thumbnailLength: i } = xa(), [l, s] = F(t);
2585
+ return /* @__PURE__ */ a(
2586
+ En.Provider,
2587
+ {
2588
+ value: { thumbnailPages: n, addPage: r, addToPage: o, thumbnailLength: i, active: l, setActive: s },
2589
+ children: e
2590
+ }
2591
+ );
2592
+ }, Ma = 16, La = (e, t) => {
2593
+ const n = e == null ? void 0 : e.querySelector(`#page-${t}`);
2594
+ e && (n != null && n.offsetTop) && (e.scrollTop = (n == null ? void 0 : n.offsetTop) - Ma);
2595
+ }, Na = $e((e, t) => {
2596
+ const { show: n } = e, { focusedPage: r, totalPages: o } = re(), { thumbnailPages: i, addPage: l, thumbnailLength: s, addToPage: c } = On(), h = $(null), p = $(1);
2597
+ qt(t, () => h.current);
2598
+ const m = D(() => Object.values(i), [i]), u = x(() => {
2599
+ const f = s + 1;
2600
+ f <= o && l(f);
2601
+ }, [l, o, s]);
2602
+ return z(() => {
2603
+ r > s ? c(r) : n && p.current !== r && (La(h.current, r), p.current = r);
2604
+ }, [r, s, c, n, m]), or(h.current, u), /* @__PURE__ */ a("div", { ref: h, className: Ut["rp-thumbnails-container"], children: /* @__PURE__ */ a("div", { className: Ut["rp-thumbnails"], children: n ? m.map((f, v) => {
2605
+ var _, g;
2606
+ return /* @__PURE__ */ a(
2607
+ ya,
2608
+ {
2609
+ isFocused: r === ((_ = f.page) == null ? void 0 : _.pageNumber),
2610
+ pageNumber: (g = f.page) == null ? void 0 : g.pageNumber,
2611
+ thumbnailSrc: f.thumbnailSrc,
2612
+ loading: f.loading,
2613
+ viewport: f.viewport
2614
+ },
2615
+ v
2616
+ );
2617
+ }) : null }) });
2618
+ }), Ea = () => {
2619
+ const { thumbnailIcon: e } = ne();
2620
+ return e || /* @__PURE__ */ a(Hn, {});
2621
+ }, Oa = () => {
2622
+ const { active: e, setActive: t } = On(), [n, r] = F(200), o = $(null), { thumbnailTool: i } = se(), l = x(() => {
2623
+ t((c) => !c);
2624
+ }, []), 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]);
2625
+ return /* @__PURE__ */ O(
2626
+ "div",
2627
+ {
2628
+ style: { "--rp-thumbnail-width": `${n}px` },
2629
+ className: rt["rp-sidebar-content-wrapper"],
2630
+ "data-rp": "sidebar",
2631
+ children: [
2632
+ /* @__PURE__ */ a("div", { "data-rp": "thumbnailButton", className: rt["rp-sidebar-content"], children: s }),
2633
+ /* @__PURE__ */ O("div", { "data-rp": "thumbnails", hidden: !e, className: rt["rp-thumbnails-wrapper"], children: [
2634
+ /* @__PURE__ */ a(Na, { show: e, ref: o }),
2635
+ /* @__PURE__ */ a(ar, { onWidthChange: r, thumbnailRef: o })
2636
+ ] })
2637
+ ]
2638
+ }
2639
+ );
2640
+ }, Da = (e) => {
2641
+ const {
2642
+ children: t,
2643
+ darkMode: n = !1,
2644
+ onDarkModeChange: r,
2645
+ initialRotate: o = 0,
2646
+ textLayer: i = !0,
2647
+ initialPage: l = 1,
2648
+ // initialViewMode = ViewMode.SINGLE_PAGE,
2649
+ initialScale: s,
2650
+ initialScrollMode: c = Q.VERTICAL_SCROLLING,
2651
+ mobileWidth: h
2652
+ } = e;
2653
+ return /* @__PURE__ */ a(
2654
+ vr,
2655
+ {
2656
+ initialScale: s,
2657
+ initialPage: l,
2658
+ initialScrollMode: c,
2659
+ initialRotate: o,
2660
+ children: /* @__PURE__ */ a(hr, { mobileWidth: h, 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(
2661
+ Gn,
2662
+ {
2663
+ darkMode: n,
2664
+ onDarkModeChange: r,
2665
+ children: t
2666
+ }
2667
+ ) }) }) }) }) }) }) }) }) }) }) })
2668
+ }
2669
+ );
2670
+ }, rs = $e((e, t) => {
2671
+ const {
2672
+ children: n,
2673
+ slots: r,
2674
+ icons: o,
2675
+ initialThumbnailsVisible: i = !1,
2676
+ initialSearch: l,
2677
+ showToolbar: s = !0,
2678
+ style: c,
2679
+ className: h,
2680
+ onLoaded: p,
2681
+ cleanupOnLoaded: m,
2682
+ ...u
2683
+ } = e, [f, v] = F(null), [_, g] = F(null), [C, y] = F(null);
2684
+ return z(() => (p && p(), () => {
2685
+ m && m();
2686
+ }), [p, m]), /* @__PURE__ */ a("div", { ref: t, className: j(he["rp-theme-variables"], he["rp-container"]), children: /* @__PURE__ */ a(lr, { container: _, contentRef: C, children: /* @__PURE__ */ a(Da, { ...u, children: /* @__PURE__ */ a(to, { initialSearch: l, children: /* @__PURE__ */ a(Ra, { initialThumbnailsVisible: i, children: /* @__PURE__ */ a(Un, { slots: r, children: /* @__PURE__ */ a(Vn, { children: /* @__PURE__ */ a(ir, { icons: o, children: /* @__PURE__ */ a(wr, { elementRef: C, children: /* @__PURE__ */ a(la, { children: /* @__PURE__ */ a(jn, { children: s ? /* @__PURE__ */ a(
2687
+ sr,
2688
+ {
2689
+ getContainerRef: g,
2690
+ toolbarRef: f,
2691
+ style: c,
2692
+ className: h,
2693
+ children: /* @__PURE__ */ O(br, { children: [
2694
+ /* @__PURE__ */ O("div", { className: he["rp-layout"], children: [
2695
+ /* @__PURE__ */ a(Ia, { ref: v }),
2696
+ /* @__PURE__ */ O("div", { className: he["rp-content"], children: [
2697
+ /* @__PURE__ */ a("div", { className: he["rp-sidebar"], children: /* @__PURE__ */ a(Oa, {}) }),
2698
+ /* @__PURE__ */ a("div", { ref: y, className: he["rp-pages"], children: n })
2699
+ ] })
2700
+ ] }),
2701
+ /* @__PURE__ */ a($n, {})
2702
+ ] })
2703
+ }
2704
+ ) : /* @__PURE__ */ a(
2705
+ "div",
2706
+ {
2707
+ ref: y,
2708
+ className: j(he["rp-pages"], h),
2709
+ style: c,
2710
+ children: n
2711
+ }
2712
+ ) }) }) }) }) }) }) }) }) }) }) });
2713
+ });
2714
+ export {
2715
+ po as A,
2716
+ Ra as B,
2717
+ Qr as C,
2718
+ Do as D,
2719
+ Na as E,
2720
+ xn as F,
2721
+ Oa as G,
2722
+ Da as H,
2723
+ Ta as L,
2724
+ fa as M,
2725
+ ma as O,
2726
+ un as P,
2727
+ es as R,
2728
+ tn as S,
2729
+ no as T,
2730
+ Ca as Z,
2731
+ rs as a,
2732
+ oa as b,
2733
+ Tt as c,
2734
+ nn as d,
2735
+ _t as e,
2736
+ eo as f,
2737
+ to as g,
2738
+ wt as h,
2739
+ Mo as i,
2740
+ Eo as j,
2741
+ Oo as k,
2742
+ Ao as l,
2743
+ Wo as m,
2744
+ na as n,
2745
+ sa as o,
2746
+ Rn as p,
2747
+ la as q,
2748
+ Nn as r,
2749
+ ga as s,
2750
+ Pa as t,
2751
+ re as u,
2752
+ Ia as v,
2753
+ ya as w,
2754
+ xa as x,
2755
+ En as y,
2756
+ On as z
2757
+ };