@react-pdf-kit/viewer 2.8.0-beta.9 → 2.9.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 (112) hide show
  1. package/README.md +10 -0
  2. package/dist/{Button-BNlmxWrV.js → Button-DBu3SaMk.js} +1 -1
  3. package/dist/{Checkbox-Brta-YKG.js → Checkbox-CSIEUyO8.js} +4 -4
  4. package/dist/{Combination-DqNkTtir.js → Combination-11kyhTGt.js} +15 -15
  5. package/dist/{Container-BxNZX82X.js → Container-BuamPhw4.js} +1 -1
  6. package/dist/{DocumentDialog-C9G7lVTh.js → DocumentDialog-cRr9sSSH.js} +4 -4
  7. package/dist/{DropDown-DikL-krI.js → DropDown-CM6xEwZC.js} +2 -2
  8. package/dist/{Input-DjSWOjCI.js → Input-Dpo1Xfxe.js} +1 -1
  9. package/dist/{LoaderIcon-D9YjinGf.js → LoaderIcon-B3ddfd0D.js} +1 -1
  10. package/dist/{LoadingIndicator-B_Jsf8No.js → LoadingIndicator-0E8WHnSN.js} +1 -1
  11. package/dist/{MenuItem-D-GflAAo.js → MenuItem-lItnKNd5.js} +2 -2
  12. package/dist/{MenuSeparator-D1H5l8Ej.js → MenuSeparator-CaFxd8b5.js} +1 -1
  13. package/dist/{PasswordModal-S0leMhEd.js → PasswordModal-CxHFn0pB.js} +1 -1
  14. package/dist/{RPDropFileZone-D1C3ouep.js → RPDropFileZone-Bq1bzWmO.js} +1 -1
  15. package/dist/RPPages-cyO0Tn21.js +690 -0
  16. package/dist/{RPTooltip-COLVx-C_.js → RPTooltip-QWwWh4HW.js} +4 -4
  17. package/dist/{Thumbnail-C6zkvwcs.js → Thumbnail-BXMk0OWF.js} +2 -2
  18. package/dist/{Thumbnails-DKG6I7pb.js → Thumbnails-BIuN8LZ8.js} +1 -1
  19. package/dist/{clsx-B7LyVm5O.js → clsx-DSGuh5YW.js} +1 -1
  20. package/dist/components/RPConfig.js +5 -4
  21. package/dist/components/RPDropFileZone.js +1 -1
  22. package/dist/components/RPPages.js +1 -1
  23. package/dist/components/icons/LoaderIcon.js +1 -1
  24. package/dist/components/layout/Container.js +1 -1
  25. package/dist/components/layout/LayoutContainer.js +1 -1
  26. package/dist/components/layout/RPDefaultLayout.js +2 -2
  27. package/dist/components/layout/RPLayout.js +2 -2
  28. package/dist/components/layout/sidebar/RPSidebar.js +3 -3
  29. package/dist/components/layout/sidebar/Thumbnail.js +1 -1
  30. package/dist/components/layout/sidebar/Thumbnails.js +1 -1
  31. package/dist/components/layout/toolbar/DarkModeTool.js +2 -2
  32. package/dist/components/layout/toolbar/DocumentDialog.js +1 -1
  33. package/dist/components/layout/toolbar/DocumentProperties.js +3 -3
  34. package/dist/components/layout/toolbar/FileDownloadTool.js +3 -3
  35. package/dist/components/layout/toolbar/FileUploadTool.js +3 -3
  36. package/dist/components/layout/toolbar/FullScreenTool.js +3 -3
  37. package/dist/components/layout/toolbar/MenuItem.js +1 -1
  38. package/dist/components/layout/toolbar/MenuSeparator.js +1 -1
  39. package/dist/components/layout/toolbar/MostPageTool.js +4 -4
  40. package/dist/components/layout/toolbar/OtherTool.js +6 -6
  41. package/dist/components/layout/toolbar/Paginate.js +3 -3
  42. package/dist/components/layout/toolbar/PrintTool.js +3 -3
  43. package/dist/components/layout/toolbar/RPMenuItem.js +3 -3
  44. package/dist/components/layout/toolbar/RPMoreOptions.js +6 -6
  45. package/dist/components/layout/toolbar/RPToolbar.js +1 -1
  46. package/dist/components/layout/toolbar/RotateTool.js +4 -4
  47. package/dist/components/layout/toolbar/ScrollModeTool.js +3 -3
  48. package/dist/components/layout/toolbar/SearchCloseButton.js +2 -2
  49. package/dist/components/layout/toolbar/SearchResultNavigator.js +2 -2
  50. package/dist/components/layout/toolbar/SearchTool.js +6 -6
  51. package/dist/components/layout/toolbar/SelectionModeTool.js +4 -4
  52. package/dist/components/layout/toolbar/ThumbnailTool.js +2 -2
  53. package/dist/components/layout/toolbar/ToolbarCustom.js +2 -2
  54. package/dist/components/layout/toolbar/ToolbarDefault.js +2 -2
  55. package/dist/components/layout/toolbar/ViewModeTool.js +4 -4
  56. package/dist/components/layout/toolbar/ZoomTool.js +7 -7
  57. package/dist/components/layout/toolbar/tools/DocumentPropertiesTool.js +3 -3
  58. package/dist/components/layout/toolbar/tools/DualPageTool.js +2 -2
  59. package/dist/components/layout/toolbar/tools/DualPageWithCoverTool.js +1 -1
  60. package/dist/components/layout/toolbar/tools/FileDownloadTool.js +2 -2
  61. package/dist/components/layout/toolbar/tools/FileUploadTool.js +2 -2
  62. package/dist/components/layout/toolbar/tools/FirstPageTool.js +1 -1
  63. package/dist/components/layout/toolbar/tools/FullScreenTool.js +2 -2
  64. package/dist/components/layout/toolbar/tools/HorizontalScrollingTool.js +2 -2
  65. package/dist/components/layout/toolbar/tools/InputPageTool.js +2 -2
  66. package/dist/components/layout/toolbar/tools/LastPageTool.js +1 -1
  67. package/dist/components/layout/toolbar/tools/NextPageTool.js +2 -2
  68. package/dist/components/layout/toolbar/tools/PageScrollingTool.js +2 -2
  69. package/dist/components/layout/toolbar/tools/PreviousPageTool.js +2 -2
  70. package/dist/components/layout/toolbar/tools/PrintTool.js +2 -2
  71. package/dist/components/layout/toolbar/tools/RotateClockwiseTool.js +2 -2
  72. package/dist/components/layout/toolbar/tools/RotateCounterclockwiseTool.js +2 -2
  73. package/dist/components/layout/toolbar/tools/SelectionModeSwitcherTool.js +2 -2
  74. package/dist/components/layout/toolbar/tools/SinglePageTool.js +2 -2
  75. package/dist/components/layout/toolbar/tools/ThemeSwitcherTool.js +2 -2
  76. package/dist/components/layout/toolbar/tools/ThumbnailTool.js +2 -2
  77. package/dist/components/layout/toolbar/tools/VerticalScrollingTool.js +2 -2
  78. package/dist/components/layout/toolbar/tools/ZoomInTool.js +2 -2
  79. package/dist/components/layout/toolbar/tools/ZoomLevelTool.js +6 -6
  80. package/dist/components/layout/toolbar/tools/ZoomOutTool.js +2 -2
  81. package/dist/components/layout/toolbar/tools/more-options/DocumentProperties.js +2 -2
  82. package/dist/components/layout/toolbar/tools/more-options/FileDownloadTool.js +2 -2
  83. package/dist/components/layout/toolbar/tools/more-options/FileUploadTool.js +2 -2
  84. package/dist/components/layout/toolbar/tools/more-options/FullScreenTool.js +2 -2
  85. package/dist/components/layout/toolbar/tools/more-options/MostPageTool.js +4 -4
  86. package/dist/components/layout/toolbar/tools/more-options/PrintTool.js +2 -2
  87. package/dist/components/layout/toolbar/tools/more-options/RotateTool.js +4 -4
  88. package/dist/components/layout/toolbar/tools/more-options/ScrollModeTool.js +3 -3
  89. package/dist/components/layout/toolbar/tools/more-options/SelectionModeTool.js +4 -4
  90. package/dist/components/layout/toolbar/tools/more-options/ViewModeTool.js +4 -4
  91. package/dist/components/ui/Button.js +1 -1
  92. package/dist/components/ui/Checkbox.js +1 -1
  93. package/dist/components/ui/DropDown.js +1 -1
  94. package/dist/components/ui/Input.js +1 -1
  95. package/dist/components/ui/LoadingIndicator.js +1 -1
  96. package/dist/components/ui/PasswordModal.js +1 -1
  97. package/dist/components/ui/RPTooltip.js +1 -1
  98. package/dist/contexts/ConfigContext.js +2 -1
  99. package/dist/contexts/LoaderContext.js +1 -1
  100. package/dist/{dist-7FA4Do6I.js → dist-B2hwhF6G.js} +7 -7
  101. package/dist/{dist-BRVqFn7R.js → dist-BfuBBQ14.js} +6 -6
  102. package/dist/{dist-C3WNMuW2.js → dist-CNbFpoT1.js} +2 -2
  103. package/dist/{dist-bK-AHWLF.js → dist-CgoP608h.js} +7 -7
  104. package/dist/{dist-CKteKPPA.js → dist-VbpVNBs6.js} +7 -7
  105. package/dist/icons.js +1 -1
  106. package/dist/{main-7sMXtgRg.js → main-DCzVrq0G.js} +2 -2
  107. package/dist/main.js +4 -4
  108. package/dist/types/utils/types.d.ts +1 -0
  109. package/dist/utils/hooks/useLicense.js +1 -1
  110. package/dist/utils/hooks/useLoadPdf.js +38 -36
  111. package/package.json +1 -1
  112. package/dist/RPPages-BQw330_L.js +0 -655
@@ -1,655 +0,0 @@
1
- import { ErrorType as e, ScrollMode as t, SelectionMode as n } from "./utils/types.js";
2
- import { useDocumentPasswordContext as r } from "./contexts/DocumentPasswordContext.js";
3
- import { BROWSER_NOT_SUPPORTED_MESSAGE as i, INVALID_OR_CORRUPTED_PDF_MESSAGE as a, WASM_URL_REQUIRED_MESSAGE as o } from "./utils/const.js";
4
- import { useDocumentContext as s } from "./contexts/RPDocumentContext.js";
5
- import { useInitialStateContext as c } from "./contexts/InitialStateContext.js";
6
- import { useScrollModeContext as l } from "./contexts/ScrollModeContext.js";
7
- import { useViewModeContext as u } from "./contexts/ViewModeContext.js";
8
- import { useVirtualScrollContext as d } from "./contexts/VirtualScrollContext.js";
9
- import "./utils/constants.js";
10
- import { useLayoutContainer as f } from "./contexts/LayoutContainerContext.js";
11
- import { useEventCallbackContext as p } from "./contexts/EventCallbackContext.js";
12
- import { useDebounce as m } from "./utils/hooks/useDebounce.js";
13
- import { useZoomContext as h } from "./contexts/ZoomContext.js";
14
- import { usePagesRotateContext as ee } from "./contexts/PagesRotateContext.js";
15
- import { useDimensionPagesContext as g } from "./contexts/DimensionPagesContext.js";
16
- import { buildDocumentLayout as _, getPageContentOffset as v, getPageFromDocumentPoint as y, getPagePlacement as te, getRowsByIndexes as ne, getVisibleRows as re } from "./utils/documentLayout.js";
17
- import { a as ie, r as ae } from "./PaginationContext-DIzsZhFd.js";
18
- import { useSelectionModeContext as oe } from "./contexts/SelectionModeContext.js";
19
- import { useFullScreenContext as se } from "./contexts/FullScreenContext.js";
20
- import { useRenderQueue as ce } from "./contexts/RenderQueueProvider.js";
21
- import { t as le } from "./clsx-B7LyVm5O.js";
22
- import { useLoaderContext as ue } from "./contexts/LoaderContext.js";
23
- import { LayoutContainer as de } from "./components/layout/LayoutContainer.js";
24
- import { LayoutWrapper as b } from "./components/layout/LayoutWrapper.js";
25
- import { RPPage as fe } from "./components/page/RPPage.js";
26
- import { t as pe } from "./PasswordModal-S0leMhEd.js";
27
- import { approximateFraction as me } from "./utils/approximateFragtion.js";
28
- import { useCopyText as he } from "./utils/hooks/useCopyText.js";
29
- import { useGrabScroll as ge } from "./utils/hooks/useGrabScroll.js";
30
- import { useMousePressed as _e } from "./utils/hooks/useMousePressed.js";
31
- import { usePinch as ve } from "./utils/hooks/usePinch.js";
32
- import { usePresentPage as ye } from "./utils/hooks/usePresentPage.js";
33
- import { useTextSelection as be } from "./utils/hooks/useTextSelection.js";
34
- import { Component as xe, createElement as Se, useCallback as x, useEffect as S, useLayoutEffect as Ce, useMemo as C, useRef as w, useState as we } from "react";
35
- import { OutputScale as Te } from "pdfjs-dist";
36
- import { Fragment as Ee, jsx as T, jsxs as De } from "react/jsx-runtime";
37
- import './assets/RPPages.css';//#region node_modules/.pnpm/react-virtualized-auto-sizer@1.0.26_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/react-virtualized-auto-sizer/dist/react-virtualized-auto-sizer.esm.js
38
- var E = typeof window < "u" ? window : typeof self < "u" ? self : global, D = null, O = null, k = 20, A = E.clearTimeout, j = E.setTimeout, M = E.cancelAnimationFrame || E.mozCancelAnimationFrame || E.webkitCancelAnimationFrame, N = E.requestAnimationFrame || E.mozRequestAnimationFrame || E.webkitRequestAnimationFrame;
39
- M == null || N == null ? (D = A, O = function(e) {
40
- return j(e, k);
41
- }) : (D = function([e, t]) {
42
- M(e), A(t);
43
- }, O = function(e) {
44
- let t = N(function() {
45
- A(n), e();
46
- }), n = j(function() {
47
- M(t), e();
48
- }, k);
49
- return [t, n];
50
- });
51
- function P(e) {
52
- let t, n, r, i, a, o, s, c = typeof document < "u" && document.attachEvent;
53
- if (!c) {
54
- o = function(e) {
55
- let t = e.__resizeTriggers__, n = t.firstElementChild, r = t.lastElementChild, i = n.firstElementChild;
56
- r.scrollLeft = r.scrollWidth, r.scrollTop = r.scrollHeight, i.style.width = n.offsetWidth + 1 + "px", i.style.height = n.offsetHeight + 1 + "px", n.scrollLeft = n.scrollWidth, n.scrollTop = n.scrollHeight;
57
- }, a = function(e) {
58
- return e.offsetWidth !== e.__resizeLast__.width || e.offsetHeight !== e.__resizeLast__.height;
59
- }, s = function(e) {
60
- if (e.target.className && typeof e.target.className.indexOf == "function" && e.target.className.indexOf("contract-trigger") < 0 && e.target.className.indexOf("expand-trigger") < 0) return;
61
- let t = this;
62
- o(this), this.__resizeRAF__ && D(this.__resizeRAF__), this.__resizeRAF__ = O(function() {
63
- a(t) && (t.__resizeLast__.width = t.offsetWidth, t.__resizeLast__.height = t.offsetHeight, t.__resizeListeners__.forEach(function(n) {
64
- n.call(t, e);
65
- }));
66
- });
67
- };
68
- let e = !1, c = "";
69
- r = "animationstart";
70
- let l = "Webkit Moz O ms".split(" "), u = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), d = "";
71
- {
72
- let t = document.createElement("fakeelement");
73
- if (t.style.animationName !== void 0 && (e = !0), e === !1) {
74
- for (let n = 0; n < l.length; n++) if (t.style[l[n] + "AnimationName"] !== void 0) {
75
- d = l[n], c = "-" + d.toLowerCase() + "-", r = u[n], e = !0;
76
- break;
77
- }
78
- }
79
- }
80
- n = "resizeanim", t = "@" + c + "keyframes " + n + " { from { opacity: 0; } to { opacity: 0; } } ", i = c + "animation: 1ms " + n + "; ";
81
- }
82
- let l = function(n) {
83
- if (!n.getElementById("detectElementResize")) {
84
- let r = (t || "") + ".resize-triggers { " + (i || "") + "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%; }", a = n.head || n.getElementsByTagName("head")[0], o = n.createElement("style");
85
- o.id = "detectElementResize", o.type = "text/css", e != null && o.setAttribute("nonce", e), o.styleSheet ? o.styleSheet.cssText = r : o.appendChild(n.createTextNode(r)), a.appendChild(o);
86
- }
87
- };
88
- return {
89
- addResizeListener: function(e, t) {
90
- if (c) e.attachEvent("onresize", t);
91
- else {
92
- if (!e.__resizeTriggers__) {
93
- let t = e.ownerDocument, i = E.getComputedStyle(e);
94
- i && i.position === "static" && (e.style.position = "relative"), l(t), e.__resizeLast__ = {}, e.__resizeListeners__ = [], (e.__resizeTriggers__ = t.createElement("div")).className = "resize-triggers";
95
- let a = t.createElement("div");
96
- a.className = "expand-trigger", a.appendChild(t.createElement("div"));
97
- let c = t.createElement("div");
98
- c.className = "contract-trigger", e.__resizeTriggers__.appendChild(a), e.__resizeTriggers__.appendChild(c), e.appendChild(e.__resizeTriggers__), o(e), e.addEventListener("scroll", s, !0), r && (e.__resizeTriggers__.__animationListener__ = function(t) {
99
- t.animationName === n && o(e);
100
- }, e.__resizeTriggers__.addEventListener(r, e.__resizeTriggers__.__animationListener__));
101
- }
102
- e.__resizeListeners__.push(t);
103
- }
104
- },
105
- removeResizeListener: function(e, t) {
106
- if (c) e.detachEvent("onresize", t);
107
- else if (e.__resizeListeners__.splice(e.__resizeListeners__.indexOf(t), 1), !e.__resizeListeners__.length) {
108
- e.removeEventListener("scroll", s, !0), e.__resizeTriggers__.__animationListener__ && (e.__resizeTriggers__.removeEventListener(r, e.__resizeTriggers__.__animationListener__), e.__resizeTriggers__.__animationListener__ = null);
109
- try {
110
- e.__resizeTriggers__ = !e.removeChild(e.__resizeTriggers__);
111
- } catch {}
112
- }
113
- }
114
- };
115
- }
116
- var F = class extends xe {
117
- constructor(...e) {
118
- super(...e), this.state = {
119
- height: this.props.defaultHeight || 0,
120
- width: this.props.defaultWidth || 0
121
- }, this._autoSizer = null, this._detectElementResize = null, this._didLogDeprecationWarning = !1, this._parentNode = null, this._resizeObserver = null, this._timeoutId = null, this._onResize = () => {
122
- this._timeoutId = null;
123
- let { disableHeight: e, disableWidth: t, onResize: n } = this.props;
124
- if (this._parentNode) {
125
- let r = window.getComputedStyle(this._parentNode) || {}, i = parseFloat(r.paddingLeft || "0"), a = parseFloat(r.paddingRight || "0"), o = parseFloat(r.paddingTop || "0"), s = parseFloat(r.paddingBottom || "0"), c = this._parentNode.getBoundingClientRect(), l = c.height - o - s, u = c.width - i - a;
126
- if (!e && this.state.height !== l || !t && this.state.width !== u) {
127
- this.setState({
128
- height: l,
129
- width: u
130
- });
131
- let e = () => {
132
- this._didLogDeprecationWarning || (this._didLogDeprecationWarning = !0, console.warn("scaledWidth and scaledHeight parameters have been deprecated; use width and height instead"));
133
- };
134
- typeof n == "function" && n({
135
- height: l,
136
- width: u,
137
- get scaledHeight() {
138
- return e(), l;
139
- },
140
- get scaledWidth() {
141
- return e(), u;
142
- }
143
- });
144
- }
145
- }
146
- }, this._setRef = (e) => {
147
- this._autoSizer = e;
148
- };
149
- }
150
- componentDidMount() {
151
- let { nonce: e } = this.props, t = this._autoSizer ? this._autoSizer.parentNode : null;
152
- if (t != null && t.ownerDocument && t.ownerDocument.defaultView && t instanceof t.ownerDocument.defaultView.HTMLElement) {
153
- this._parentNode = t;
154
- let n = t.ownerDocument.defaultView.ResizeObserver;
155
- n == null ? (this._detectElementResize = P(e), this._detectElementResize.addResizeListener(t, this._onResize)) : (this._resizeObserver = new n(() => {
156
- this._timeoutId = setTimeout(this._onResize, 0);
157
- }), this._resizeObserver.observe(t)), this._onResize();
158
- }
159
- }
160
- componentWillUnmount() {
161
- this._parentNode && (this._detectElementResize && this._detectElementResize.removeResizeListener(this._parentNode, this._onResize), this._timeoutId !== null && clearTimeout(this._timeoutId), this._resizeObserver && this._resizeObserver.disconnect());
162
- }
163
- render() {
164
- let { children: e, defaultHeight: t, defaultWidth: n, disableHeight: r = !1, disableWidth: i = !1, doNotBailOutOnEmptyChildren: a = !1, nonce: o, onResize: s, style: c = {}, tagName: l = "div", ...u } = this.props, { height: d, width: f } = this.state, p = { overflow: "visible" }, m = {}, h = !1;
165
- return r || (d === 0 && (h = !0), p.height = 0, m.height = d, m.scaledHeight = d), i || (f === 0 && (h = !0), p.width = 0, m.width = f, m.scaledWidth = f), a && (h = !1), Se(l, {
166
- ref: this._setRef,
167
- style: {
168
- ...p,
169
- ...c
170
- },
171
- ...u
172
- }, !h && e(m));
173
- }
174
- }, I = {
175
- "rp-pages": "_rp-pages_ruuiz_1",
176
- "rp-page-scrolling-wrapper": "_rp-page-scrolling-wrapper_ruuiz_6",
177
- "rp-pages-flow": "_rp-pages-flow_ruuiz_6",
178
- "rp-document-wrapper": "_rp-document-wrapper_ruuiz_17",
179
- "rp-page-row": "_rp-page-row_ruuiz_22",
180
- "rp-pages-horizontal-scroll": "_rp-pages-horizontal-scroll_ruuiz_26",
181
- "rp-not-supported-list": "_rp-not-supported-list_ruuiz_30",
182
- "rp-pages-container": "_rp-pages-container_ruuiz_38",
183
- "rp-viewer": "_rp-viewer_ruuiz_80",
184
- "rp-cursor-grab": "_rp-cursor-grab_ruuiz_85",
185
- "rp-cursor-grabbing": "_rp-cursor-grabbing_ruuiz_93",
186
- "rp-loader": "_rp-loader_ruuiz_101",
187
- "rp-not-supported": "_rp-not-supported_ruuiz_30",
188
- "rp-not-supported-content": "_rp-not-supported-content_ruuiz_120",
189
- "rp-load-error": "_rp-load-error_ruuiz_126",
190
- "rp-load-error-message": "_rp-load-error-message_ruuiz_134"
191
- }, Oe = (e, t, n) => Math.max(t, Math.min(e, n)), ke = (e) => ({
192
- width: e.scrollWidth,
193
- height: e.scrollHeight
194
- }), Ae = (e, t, n, r, i) => {
195
- let a = n.scrollTop - t.offsetTop, o = a + i, s = n.scrollLeft - t.offsetLeft, c = s + r, l = /* @__PURE__ */ new Map();
196
- return e.forEach((e) => {
197
- e.pages.forEach((e) => {
198
- let t = e.left + e.width, n = e.top + e.height, r = Math.max(0, s - e.left), i = Math.max(0, a - e.top), u = Math.min(e.width, c - e.left), d = Math.min(e.height, o - e.top);
199
- if (t <= s || e.left >= c || n <= a || e.top >= o) return;
200
- let f = Math.max(0, u - r), p = Math.max(0, d - i), m = e.width * e.height || 1, h = Math.floor(f * p * 100 / m);
201
- f > 0 && p > 0 && l.set(e.pageNumber, {
202
- minX: r,
203
- minY: i,
204
- maxX: u,
205
- maxY: d,
206
- percent: h
207
- });
208
- });
209
- }), l;
210
- }, je = ({ row: e }) => /* @__PURE__ */ T("div", {
211
- className: I["rp-page-row"],
212
- style: {
213
- position: "absolute",
214
- top: e.top,
215
- left: 0,
216
- width: e.width,
217
- height: e.height
218
- },
219
- children: e.pages.map((t) => /* @__PURE__ */ T(fe, {
220
- pageNumber: t.pageNumber,
221
- style: {
222
- position: "absolute",
223
- left: t.left,
224
- top: t.top - e.top,
225
- width: t.width,
226
- height: t.height
227
- }
228
- }, t.pageNumber))
229
- }), Me = (t) => {
230
- if (t === e.WASM_URL_REQUIRED) return o;
231
- if (t === e.INVALID_OR_CORRUPTED_PDF) return a;
232
- if (t === e.NOT_SUPPORTED) return i;
233
- }, Ne = ({ width: r, height: i }) => {
234
- let { initialPage: a = 1, initialScrollMode: o } = c(), { pagesRef: de } = f(), { scrollToPage: b } = ie(), { getPageScrollElementRef: fe, getVirtualScrollableElementRef: pe, setTotalInnerDimensions: me, totalInnerDimensions: he, virtualScrollableElementRef: be, pageScrollElementRef: xe } = d(), Se = w(a > 1), [Te, Ee] = we(a > 1), { nextPage: E, prevPage: D, setFocusedPage: O, focusedPage: k, totalPages: A } = ae(), { scrollMode: j } = l(), { viewMode: M } = u(), { loading: N, error: P, pages: F } = s(), { pageRotate: Ne } = ee(), { LoaderImageComponent: Pe } = ue(), { isFullScreen: Fe } = se(), { onScroll: Ie } = p(), { widths: Le, heights: Re } = g(), ze = ce(), { targetZoom: L, zoomOrigin: R, isZooming: z, previousTargetZoom: Be } = h(), Ve = m(he, 100), He = w(null), B = w(he), Ue = w({
235
- viewMode: M,
236
- scrollMode: j
237
- }), V = w(null), H = w(null), U = w(null), W = w(null), G = w(!1), K = w(!1), q = w(L), We = Me(P), Ge = w(), J = w(), Ke = w(), qe = w([]), Je = w([]), Y = w({
238
- scrollTop: 0,
239
- scrollLeft: 0
240
- }), [X, Ye] = we(Y.current), Z = j === t.PAGE_SCROLLING ? xe ?? be : be ?? xe, { isPressed: Xe } = _e(), { initializeGrabScroll: Ze, resetGrabState: Qe } = ge({ isPressed: Xe }), { selectionMode: $e } = oe(), et = $e === n.HAND, Q = C(() => _({
241
- pageDimensions: {
242
- widths: Le,
243
- heights: Re
244
- },
245
- viewportWidth: r,
246
- viewportHeight: i,
247
- scrollMode: j,
248
- viewMode: M,
249
- focusedPage: k
250
- }), [
251
- k,
252
- i,
253
- Re,
254
- j,
255
- M,
256
- r,
257
- Le
258
- ]), tt = C(() => re(Q, X.scrollTop, X.scrollLeft, r, i, 2), [
259
- i,
260
- Q,
261
- X.scrollLeft,
262
- X.scrollTop,
263
- r
264
- ]), nt = C(() => z && qe.current.length ? ne(Q, qe.current, Je.current) : tt, [
265
- tt,
266
- z,
267
- Q
268
- ]), rt = C(() => Ae(nt, Q, X, r, i), [
269
- i,
270
- Q,
271
- X,
272
- nt,
273
- r
274
- ]);
275
- ye(Z, Q), S(() => {
276
- z || (qe.current = tt.map((e) => e.index), Je.current = tt.flatMap((e) => e.pages.map((e) => e.pageNumber)));
277
- }, [tt, z]), S(() => {
278
- Array.from(rt.entries()).sort(([, e], [, t]) => t.percent - e.percent).forEach(([e], t) => {
279
- ze.changePagePriority(`^page-${e}$`, t);
280
- });
281
- }, [rt, ze]), S(() => {
282
- z && ze.removeQueues(/^page-/);
283
- }, [z, ze]), S(() => {
284
- N && Qe();
285
- }, [N, Qe]), S(() => {
286
- if (!We) return;
287
- let e = requestAnimationFrame(() => {
288
- He.current?.focus();
289
- });
290
- return () => {
291
- cancelAnimationFrame(e);
292
- };
293
- }, [We]);
294
- let $ = x((e) => {
295
- let t = F.get(e);
296
- return Ne[e] ?? t?.defaultRotation ?? 0;
297
- }, [Ne, F]), it = x((e, t = k) => {
298
- let n = [], a = [];
299
- for (let t = 1; t <= A; t += 1) {
300
- let r = F.get(t);
301
- if (!r) continue;
302
- let i = $(t), o = r.page.getViewport({
303
- scale: 1,
304
- rotation: i,
305
- dontFlip: !0
306
- });
307
- n[t - 1] = o.width * e + 4, a[t - 1] = o.height * e + 4;
308
- }
309
- return _({
310
- pageDimensions: {
311
- widths: n,
312
- heights: a
313
- },
314
- viewportWidth: r,
315
- viewportHeight: i,
316
- scrollMode: j,
317
- viewMode: M,
318
- focusedPage: t
319
- });
320
- }, [
321
- k,
322
- $,
323
- i,
324
- F,
325
- j,
326
- A,
327
- M,
328
- r
329
- ]), at = x((e, t, n) => {
330
- let r = Z ? Math.max(0, n.scrollHeight - Z.clientHeight) : Math.max(0, n.scrollHeight), i = Z ? Math.max(0, n.scrollWidth - Z.clientWidth) : Math.max(0, n.scrollWidth);
331
- return {
332
- scrollTop: Math.round(Oe(e, 0, r)) || 0,
333
- scrollLeft: Math.round(Oe(t, 0, i)) || 0
334
- };
335
- }, [Z]), ot = x((e, t) => {
336
- if (!Z) return {
337
- scrollTop: 0,
338
- scrollLeft: 0
339
- };
340
- let n = Y.current.scrollTop > t, r = Y.current.scrollLeft > e;
341
- return n || r ? Y.current : {
342
- scrollTop: Z.scrollTop,
343
- scrollLeft: Z.scrollLeft
344
- };
345
- }, [Z]), st = x((e, t, n, r, i) => {
346
- if (!n || !r || !i || !F.size) return null;
347
- let a = t + n[0] - i.offsetLeft, o = e + n[1] - i.offsetTop, s = y(i, a, o) ?? te(i, k);
348
- if (!s) return null;
349
- let c = F.get(s.pageNumber);
350
- if (!c) return null;
351
- let l = $(s.pageNumber), u = c.page.getViewport({
352
- scale: r,
353
- rotation: l
354
- }), d = v(s.width, s.height, u.width, u.height), f = Oe(a - s.left - d.x, 0, u.width), p = Oe(o - s.top - d.y, 0, u.height), [m, h] = u.convertToPdfPoint(f, p);
355
- return {
356
- pageNumber: s.pageNumber,
357
- pdfX: m,
358
- pdfY: h,
359
- origin: n
360
- };
361
- }, [
362
- k,
363
- $,
364
- F
365
- ]), ct = x((e, t, n) => {
366
- let r = F.get(t.pageNumber), i = te(n, t.pageNumber);
367
- if (!r || !i || !e) return null;
368
- let a = $(t.pageNumber), o = r.page.getViewport({
369
- scale: e,
370
- rotation: a
371
- }), [s, c] = o.convertToViewportPoint(t.pdfX, t.pdfY), l = v(i.width, i.height, o.width, o.height);
372
- return {
373
- left: n.offsetLeft + i.left + l.x + s - t.origin[0],
374
- top: n.offsetTop + i.top + l.y + c - t.origin[1]
375
- };
376
- }, [$, F]), lt = x((e, t) => {
377
- (G.current || U.current || W.current) && (K.current = !0), Z?.scrollTo({
378
- top: e,
379
- left: t,
380
- behavior: "auto"
381
- }), Y.current = {
382
- scrollTop: e,
383
- scrollLeft: t
384
- }, Ye(Y.current);
385
- }, [Z]), ut = x(({ gesture: e, origin: t, previousScale: n, nextScale: r }) => {
386
- if (e !== "touch" || !t || !n || !r) return;
387
- G.current = !0;
388
- let i = W.current, a = i?.scale || q.current || n, o = i?.layout ?? V.current ?? Q, s = i?.scrollTop ?? Y.current.scrollTop, c = i?.scrollLeft ?? Y.current.scrollLeft, l = it(r), u = st(s, c, t, a, o), d = u ? ct(r, u, l) : null, f = 0, p = 0;
389
- if (d) p = d.left, f = d.top;
390
- else {
391
- let e = r / a;
392
- p = (c + t[0]) * e - t[0], f = (s + t[1]) * e - t[1];
393
- }
394
- let m = at(f, p, l);
395
- U.current = {
396
- location: u,
397
- origin: t,
398
- previousScale: a,
399
- nextScale: r,
400
- scrollTop: s,
401
- scrollLeft: c,
402
- targetScrollTop: m.scrollTop,
403
- targetScrollLeft: m.scrollLeft,
404
- targetLayout: l
405
- }, W.current = {
406
- scale: r,
407
- layout: l,
408
- scrollTop: m.scrollTop,
409
- scrollLeft: m.scrollLeft
410
- }, H.current = u;
411
- }, [
412
- ct,
413
- st,
414
- at,
415
- it,
416
- Q
417
- ]), dt = x(() => {
418
- G.current = !1, K.current = !1, U.current || (W.current = null, H.current = null);
419
- }, []), ft = x(() => {
420
- G.current = !1, K.current = !1, U.current = null, W.current = null, H.current = null;
421
- }, []);
422
- ve(Z || de, {
423
- onBeforeZoom: ut,
424
- onPinchEnd: dt
425
- });
426
- let pt = x((e, t) => {
427
- if (Ue.current.viewMode !== M || Ue.current.scrollMode !== j) {
428
- J.current && clearTimeout(J.current), H.current = null, ft(), b(k, "auto"), J.current = setTimeout(() => {
429
- requestAnimationFrame(() => {
430
- Ue.current = {
431
- viewMode: M,
432
- scrollMode: j
433
- }, V.current = Q, q.current = L;
434
- });
435
- }, 100);
436
- return;
437
- }
438
- let n = e.scrollTop, r = e.scrollLeft;
439
- if (!t.height || !t.width) return;
440
- let { height: i, width: o } = t, { height: s, width: c } = B.current, l = V.current, u = Math.abs(q.current - L) > 1e-10, d = u && !!R, f = q.current || Be || L, p = U.current, m = p?.nextScale ?? L;
441
- if (s === i && c === o) {
442
- if (p) {
443
- lt(p.targetScrollTop, p.targetScrollLeft), H.current = null, U.current = null, G.current || (W.current = null, K.current = !1), V.current = p.targetLayout, q.current = p.nextScale;
444
- return;
445
- }
446
- if (d && l) {
447
- H.current = st(n, r, R, f, l);
448
- return;
449
- }
450
- V.current = Q, q.current = L;
451
- return;
452
- }
453
- if (Se.current && a > 1) {
454
- H.current = null, ft(), B.current = {
455
- height: t.height,
456
- width: t.width
457
- }, V.current = Q, q.current = L;
458
- return;
459
- }
460
- if (!s || !c) {
461
- H.current = null, ft(), B.current = {
462
- height: t.height,
463
- width: t.width
464
- }, V.current = Q, q.current = L;
465
- return;
466
- }
467
- let h = !!p, ee = !!H.current;
468
- if (n === 0 && r === 0 && !(h || (u || ee) && (R || ee))) {
469
- B.current = {
470
- height: t.height,
471
- width: t.width
472
- }, V.current = Q, q.current = L;
473
- return;
474
- }
475
- let g = n / s * i, _ = r / c * o, v = !1;
476
- if (p) _ = p.targetScrollLeft, g = p.targetScrollTop, v = !0;
477
- else if ((u || ee) && l) {
478
- let e = H.current ?? st(n, r, R, f, l), t = e ? ct(L, e, Q) : null;
479
- if (t) _ = t.left, g = t.top, v = !0;
480
- else {
481
- let e = L / f, t = R ?? H.current?.origin;
482
- t && (_ = (r + t[0]) * e - t[0], g = (n + t[1]) * e - t[1], v = !0);
483
- }
484
- }
485
- let y = at(g, _, Q);
486
- v ? lt(y.scrollTop, y.scrollLeft) : Ge.current = setTimeout(() => {
487
- requestAnimationFrame(() => {
488
- lt(y.scrollTop, y.scrollLeft);
489
- });
490
- }, 0), H.current = null, U.current = null, G.current || (W.current = null, K.current = !1), B.current = {
491
- height: t.height,
492
- width: t.width
493
- }, V.current = Q, q.current = m;
494
- }, [
495
- ct,
496
- st,
497
- at,
498
- k,
499
- a,
500
- Q,
501
- Be,
502
- ft,
503
- j,
504
- b,
505
- lt,
506
- L,
507
- M,
508
- R
509
- ]);
510
- Ce(() => {
511
- clearTimeout(Ge.current);
512
- let e = ke(Q), t = !!U.current, n = t ? Y.current : ot(e.width, e.height);
513
- t || (Y.current = n, Ye(n)), pt(n, e), me(e);
514
- }, [
515
- ot,
516
- Q,
517
- me,
518
- pt
519
- ]);
520
- let mt = x((e) => {
521
- let t = document.activeElement !== de;
522
- !Fe && t || (["ArrowUp", "ArrowLeft"].includes(e.key) ? (e.preventDefault(), D()) : ["ArrowDown", "ArrowRight"].includes(e.key) && (e.preventDefault(), E()));
523
- }, [
524
- Fe,
525
- E,
526
- de,
527
- D
528
- ]);
529
- S(() => (window.addEventListener("keydown", mt), () => {
530
- window.removeEventListener("keydown", mt);
531
- }), [mt]), S(() => () => {
532
- J.current && clearTimeout(J.current), Ke.current && cancelAnimationFrame(Ke.current);
533
- }, []), S(() => {
534
- Ve.height === 0 || !Se.current || Z && (b(a, "auto"), requestAnimationFrame(() => {
535
- O(a), Se.current = !1, Ee(!1);
536
- }));
537
- }, [
538
- Ve.height,
539
- a,
540
- o,
541
- b,
542
- Z,
543
- O
544
- ]);
545
- let ht = x((e) => {
546
- e && (pe(e), fe(e), et && Ze(e));
547
- }, [
548
- fe,
549
- pe,
550
- Ze,
551
- et
552
- ]), gt = x((e) => {
553
- let t = e.currentTarget, n = {
554
- scrollTop: t.scrollTop,
555
- scrollLeft: t.scrollLeft
556
- };
557
- if (G.current || U.current || K.current) {
558
- K.current = !1, Ie?.(e.nativeEvent);
559
- return;
560
- }
561
- Y.current = n, Ke.current && cancelAnimationFrame(Ke.current), Ke.current = requestAnimationFrame(() => {
562
- Ye(n);
563
- }), Ie?.(e.nativeEvent);
564
- }, [Ie]);
565
- return P === e.INVALID_OR_CORRUPTED_PDF ? /* @__PURE__ */ T("div", {
566
- ref: He,
567
- className: I["rp-load-error"],
568
- style: {
569
- width: r,
570
- height: i
571
- },
572
- tabIndex: -1,
573
- role: "alert",
574
- "aria-live": "assertive",
575
- "aria-atomic": "true",
576
- children: /* @__PURE__ */ T("div", {
577
- className: I["rp-load-error-message"],
578
- children: "Invalid or corrupted PDF file."
579
- })
580
- }) : P === e.NOT_SUPPORTED ? /* @__PURE__ */ T("div", {
581
- className: I["rp-not-supported"],
582
- children: /* @__PURE__ */ De("div", {
583
- className: I["rp-not-supported-content"],
584
- children: ["React PDF Kit is unable to render on this browser. Please use the supported browsers from the list below:", /* @__PURE__ */ T("div", { children: /* @__PURE__ */ De("ul", {
585
- className: I["rp-not-supported-list"],
586
- children: [
587
- /* @__PURE__ */ T("li", { children: "Chrome 126+" }),
588
- /* @__PURE__ */ T("li", { children: "Edge 126+" }),
589
- /* @__PURE__ */ T("li", { children: "Firefox 126+" }),
590
- /* @__PURE__ */ T("li", { children: "Safari 18.4+" }),
591
- /* @__PURE__ */ T("li", { children: "Safari iOS 18.4+" }),
592
- /* @__PURE__ */ T("li", { children: "Chrome Android 126+" })
593
- ]
594
- }) })]
595
- })
596
- }) : !Q.pages.length && !N && !P ? /* @__PURE__ */ T("div", {
597
- className: I["rp-loader"],
598
- style: {
599
- width: r,
600
- height: i
601
- },
602
- children: Pe && /* @__PURE__ */ T(Pe, {})
603
- }) : /* @__PURE__ */ T("div", {
604
- "data-rp": "pages",
605
- ref: ht,
606
- className: le(I["rp-pages"], I["rp-pages-flow"], j === t.HORIZONTAL_SCROLLING && I["rp-pages-horizontal-scroll"], j === t.PAGE_SCROLLING && I["rp-page-scrolling-wrapper"]),
607
- onScroll: gt,
608
- style: {
609
- width: r,
610
- height: i,
611
- ...Te && { visibility: "hidden" }
612
- },
613
- children: /* @__PURE__ */ T("div", {
614
- className: I["rp-document-wrapper"],
615
- style: {
616
- width: Q.documentWidth,
617
- height: Q.documentHeight,
618
- marginLeft: Q.offsetLeft,
619
- marginTop: Q.offsetTop,
620
- "--rp-pages-height": `${Q.documentHeight}px`,
621
- "--rp-pages-width": `${Q.documentWidth}px`
622
- },
623
- children: nt.map((e) => /* @__PURE__ */ T(je, { row: e }, e.index))
624
- })
625
- });
626
- }, Pe = () => {
627
- let e = w(new Te()), { pagesRef: t, setPagesRef: i, setContentRef: a } = f(), { passwordRequired: o } = r(), { onTextSelect: s } = p(), { selectionMode: c } = oe(), { isPressed: l } = _e(), u = c === n.HAND, d = C(() => le(I["rp-pages-container"], {
628
- [I["rp-cursor-grab"]]: u && !l,
629
- [I["rp-cursor-grabbing"]]: u && l
630
- }), [u, l]);
631
- return he(t), be({
632
- onTextSelect: s,
633
- pagesRef: t
634
- }), /* @__PURE__ */ De(Ee, { children: [/* @__PURE__ */ T(b, {
635
- ref: a,
636
- children: /* @__PURE__ */ T(de, {
637
- ref: i,
638
- tabIndex: -1,
639
- className: d,
640
- style: {
641
- "--scale-round-x": `${me(e.current.sx)[1]}px`,
642
- "--scale-round-y": `${me(e.current.sy)[1]}px`
643
- },
644
- children: /* @__PURE__ */ T(F, {
645
- style: { minHeight: "50px" },
646
- children: ({ width: e, height: t }) => /* @__PURE__ */ T(Ne, {
647
- width: e,
648
- height: t
649
- })
650
- })
651
- })
652
- }), o && /* @__PURE__ */ T(pe, {})] });
653
- };
654
- //#endregion
655
- export { Pe as t };