@cannymindstech/file-viewers 0.27.12 → 0.28.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 (91) hide show
  1. package/package.json +2 -2
  2. package/dist/chunk-2BLHLWNN.js +0 -299
  3. package/dist/chunk-2BLHLWNN.js.map +0 -1
  4. package/dist/chunk-6BRYDA3B.js +0 -329
  5. package/dist/chunk-6BRYDA3B.js.map +0 -1
  6. package/dist/chunk-7JPF5AYR.mjs +0 -488
  7. package/dist/chunk-7JPF5AYR.mjs.map +0 -1
  8. package/dist/chunk-7P6WEBHN.js +0 -2299
  9. package/dist/chunk-7P6WEBHN.js.map +0 -1
  10. package/dist/chunk-7PMZ4GN5.mjs +0 -290
  11. package/dist/chunk-7PMZ4GN5.mjs.map +0 -1
  12. package/dist/chunk-B5NNB4KD.mjs +0 -268
  13. package/dist/chunk-B5NNB4KD.mjs.map +0 -1
  14. package/dist/chunk-CIWCHSAA.js +0 -309
  15. package/dist/chunk-CIWCHSAA.js.map +0 -1
  16. package/dist/chunk-D7SDEVDM.js +0 -268
  17. package/dist/chunk-D7SDEVDM.js.map +0 -1
  18. package/dist/chunk-ECZ6IBOS.js +0 -424
  19. package/dist/chunk-ECZ6IBOS.js.map +0 -1
  20. package/dist/chunk-EKNP342T.mjs +0 -299
  21. package/dist/chunk-EKNP342T.mjs.map +0 -1
  22. package/dist/chunk-EM63H4SA.js +0 -290
  23. package/dist/chunk-EM63H4SA.js.map +0 -1
  24. package/dist/chunk-IJMNPAXX.mjs +0 -309
  25. package/dist/chunk-IJMNPAXX.mjs.map +0 -1
  26. package/dist/chunk-JKX5RSLF.mjs +0 -871
  27. package/dist/chunk-JKX5RSLF.mjs.map +0 -1
  28. package/dist/chunk-KJNOBIUZ.mjs +0 -36
  29. package/dist/chunk-KJNOBIUZ.mjs.map +0 -1
  30. package/dist/chunk-KQCU7XW2.mjs +0 -424
  31. package/dist/chunk-KQCU7XW2.mjs.map +0 -1
  32. package/dist/chunk-KQLIG6WK.js +0 -871
  33. package/dist/chunk-KQLIG6WK.js.map +0 -1
  34. package/dist/chunk-OPJOCUSL.js +0 -36
  35. package/dist/chunk-OPJOCUSL.js.map +0 -1
  36. package/dist/chunk-PZGUVU6N.mjs +0 -2299
  37. package/dist/chunk-PZGUVU6N.mjs.map +0 -1
  38. package/dist/chunk-QV63FULE.js +0 -488
  39. package/dist/chunk-QV63FULE.js.map +0 -1
  40. package/dist/chunk-XJQ5J2UF.mjs +0 -329
  41. package/dist/chunk-XJQ5J2UF.mjs.map +0 -1
  42. package/dist/components/viewers/AudioViewer.d.mts +0 -6
  43. package/dist/components/viewers/AudioViewer.d.ts +0 -6
  44. package/dist/components/viewers/AudioViewer.js +0 -10
  45. package/dist/components/viewers/AudioViewer.js.map +0 -1
  46. package/dist/components/viewers/AudioViewer.mjs +0 -10
  47. package/dist/components/viewers/AudioViewer.mjs.map +0 -1
  48. package/dist/components/viewers/DefaultViewer.d.mts +0 -6
  49. package/dist/components/viewers/DefaultViewer.d.ts +0 -6
  50. package/dist/components/viewers/DefaultViewer.js +0 -10
  51. package/dist/components/viewers/DefaultViewer.js.map +0 -1
  52. package/dist/components/viewers/DefaultViewer.mjs +0 -10
  53. package/dist/components/viewers/DefaultViewer.mjs.map +0 -1
  54. package/dist/components/viewers/ImageViewer.d.mts +0 -6
  55. package/dist/components/viewers/ImageViewer.d.ts +0 -6
  56. package/dist/components/viewers/ImageViewer.js +0 -10
  57. package/dist/components/viewers/ImageViewer.js.map +0 -1
  58. package/dist/components/viewers/ImageViewer.mjs +0 -10
  59. package/dist/components/viewers/ImageViewer.mjs.map +0 -1
  60. package/dist/components/viewers/PDFViewer.d.mts +0 -51
  61. package/dist/components/viewers/PDFViewer.d.ts +0 -51
  62. package/dist/components/viewers/PDFViewer.js +0 -11
  63. package/dist/components/viewers/PDFViewer.js.map +0 -1
  64. package/dist/components/viewers/PDFViewer.mjs +0 -11
  65. package/dist/components/viewers/PDFViewer.mjs.map +0 -1
  66. package/dist/components/viewers/TIFFViewer.d.mts +0 -6
  67. package/dist/components/viewers/TIFFViewer.d.ts +0 -6
  68. package/dist/components/viewers/TIFFViewer.js +0 -10
  69. package/dist/components/viewers/TIFFViewer.js.map +0 -1
  70. package/dist/components/viewers/TIFFViewer.mjs +0 -10
  71. package/dist/components/viewers/TIFFViewer.mjs.map +0 -1
  72. package/dist/components/viewers/TextViewer.d.mts +0 -6
  73. package/dist/components/viewers/TextViewer.d.ts +0 -6
  74. package/dist/components/viewers/TextViewer.js +0 -10
  75. package/dist/components/viewers/TextViewer.js.map +0 -1
  76. package/dist/components/viewers/TextViewer.mjs +0 -10
  77. package/dist/components/viewers/TextViewer.mjs.map +0 -1
  78. package/dist/components/viewers/VideoViewer.d.mts +0 -6
  79. package/dist/components/viewers/VideoViewer.d.ts +0 -6
  80. package/dist/components/viewers/VideoViewer.js +0 -10
  81. package/dist/components/viewers/VideoViewer.js.map +0 -1
  82. package/dist/components/viewers/VideoViewer.mjs +0 -10
  83. package/dist/components/viewers/VideoViewer.mjs.map +0 -1
  84. package/dist/index.d.mts +0 -75
  85. package/dist/index.d.ts +0 -75
  86. package/dist/index.js +0 -305
  87. package/dist/index.js.map +0 -1
  88. package/dist/index.mjs +0 -305
  89. package/dist/index.mjs.map +0 -1
  90. package/dist/types-BYTxtKEc.d.mts +0 -100
  91. package/dist/types-BYTxtKEc.d.ts +0 -100
@@ -1,2299 +0,0 @@
1
- "use client";
2
- import {
3
- toolbarStyles
4
- } from "./chunk-KQCU7XW2.mjs";
5
- import {
6
- getFileExtension
7
- } from "./chunk-KJNOBIUZ.mjs";
8
- import {
9
- FileIcon_default,
10
- mergeToolbarConfig
11
- } from "./chunk-7PMZ4GN5.mjs";
12
-
13
- // src/components/viewers/PDFViewer.tsx
14
- import {
15
- useCallback,
16
- useEffect as useEffect4,
17
- useMemo,
18
- useRef as useRef3,
19
- useState as useState4,
20
- forwardRef,
21
- useImperativeHandle
22
- } from "react";
23
-
24
- // src/components/viewers/pdf/StablePDFViewer.tsx
25
- import React from "react";
26
- import { PDFViewer as HeadlessPDFViewerImport } from "@cannymindstech/pdf-viewer";
27
- import { jsx } from "react/jsx-runtime";
28
- var HeadlessPDFViewer = HeadlessPDFViewerImport;
29
- var StablePDFViewer = React.memo(({
30
- pdfBuffer,
31
- onPasswordRequest,
32
- pdfViewerRef,
33
- showAnnotations,
34
- userDetails,
35
- annotationSelectionMenu,
36
- isHighlighterActive,
37
- isStampActive,
38
- onHighlighterClick,
39
- onStampClick,
40
- onSignatureClick,
41
- onNoteClick,
42
- permissions,
43
- hideInternalLoading,
44
- isAnnotationForeign,
45
- onAnnotationNoteClick,
46
- isAnnotationInteractive
47
- }) => {
48
- return /* @__PURE__ */ jsx(
49
- HeadlessPDFViewer,
50
- {
51
- ref: pdfViewerRef,
52
- pdfBuffer,
53
- onPasswordRequest,
54
- showAnnotations,
55
- userDetails,
56
- annotationSelectionMenu,
57
- isHighlighterActive,
58
- isStampActive,
59
- onHighlighterClick,
60
- onStampClick,
61
- onSignatureClick,
62
- onNoteClick,
63
- permissions,
64
- hideInternalLoading,
65
- isAnnotationForeign,
66
- onAnnotationNoteClick,
67
- isAnnotationInteractive
68
- }
69
- );
70
- });
71
- StablePDFViewer.displayName = "StablePDFViewer";
72
-
73
- // src/components/viewers/pdf/PDFToolbar.tsx
74
- import React2, { useState, useRef, useEffect } from "react";
75
- import { Tooltip } from "@mui/material";
76
- import FirstPageIcon from "@mui/icons-material/FirstPage";
77
- import LastPageIcon from "@mui/icons-material/LastPage";
78
- import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
79
- import ChevronRightIcon from "@mui/icons-material/ChevronRight";
80
- import RemoveIcon from "@mui/icons-material/Remove";
81
- import AddIcon from "@mui/icons-material/Add";
82
- import FitScreenIcon from "@mui/icons-material/FitScreen";
83
- import AspectRatioIcon from "@mui/icons-material/AspectRatio";
84
- import TuneIcon from "@mui/icons-material/Tune";
85
- import SearchIcon from "@mui/icons-material/Search";
86
- import FullscreenIcon from "@mui/icons-material/Fullscreen";
87
- import DownloadIcon from "@mui/icons-material/Download";
88
- import PrintIcon from "@mui/icons-material/Print";
89
- import InfoIcon from "@mui/icons-material/Info";
90
- import DescriptionIcon from "@mui/icons-material/Description";
91
- import RotateLeftIcon from "@mui/icons-material/RotateLeft";
92
- import RotateRightIcon from "@mui/icons-material/RotateRight";
93
- import HistoryIcon from "@mui/icons-material/History";
94
- import { LocalOffer } from "@mui/icons-material";
95
- import HighlightIcon from "@mui/icons-material/Highlight";
96
- import DrawIcon from "@mui/icons-material/Draw";
97
- import ApprovalIcon from "@mui/icons-material/Approval";
98
- import StickyNote2Icon from "@mui/icons-material/StickyNote2";
99
- import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
100
- import PortraitIcon from "@mui/icons-material/Portrait";
101
- import SwapVertIcon from "@mui/icons-material/SwapVert";
102
- import AutoFixHighIcon from "@mui/icons-material/AutoFixHigh";
103
- import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
104
- var PDFToolbar = React2.memo(
105
- ({
106
- currentPage,
107
- totalPages,
108
- zoom,
109
- isSidebarOpen,
110
- showPageNavigation,
111
- showPageCount,
112
- showZoomControls,
113
- showSearch,
114
- showMetadata,
115
- showProperties,
116
- showTags,
117
- showHistory,
118
- showDownload,
119
- showPrint,
120
- showRotation,
121
- showAnnotations,
122
- // Destructure new props with defaults
123
- showAnnotate = true,
124
- disabledAnnotate = false,
125
- showPrintOriginal = true,
126
- showPrintWithAnnotations = true,
127
- showDownloadOriginal = true,
128
- showDownloadWithAnnotations = true,
129
- isHighlighterActive,
130
- isStampActive,
131
- disabledRotateLeft,
132
- disabledRotateRight,
133
- disabledMetadata,
134
- disabledProperties,
135
- disabledTags,
136
- disabledHistory,
137
- disabledDownload,
138
- disabledPrint,
139
- disabledCopy,
140
- disabledHighlighter,
141
- disabledStamp,
142
- disabledSignature,
143
- disabledNote,
144
- onFirstPage,
145
- onPreviousPage,
146
- onNextPage,
147
- onLastPage,
148
- onPageInput,
149
- onPageInputKeyPress,
150
- onZoomIn,
151
- onZoomOut,
152
- onFitToWidth,
153
- onFitToPage,
154
- onToggleSidebar,
155
- onToggleFullScreen,
156
- onRotateLeft,
157
- onRotateRight,
158
- onDownloadClick,
159
- onDownloadWithAnnotations,
160
- onDownloadWithoutAnnotations,
161
- onPrintClick,
162
- onPrintWithAnnotations,
163
- onPrintWithoutAnnotations,
164
- onCopyClick,
165
- onMetadataClick,
166
- onPropertiesClick,
167
- onTagsClick,
168
- onHistoryClick,
169
- onHighlighterClick,
170
- onStampClick,
171
- onSignatureClick,
172
- onNoteClick,
173
- // Save functionality
174
- hasUnsavedAnnotations,
175
- isSavingAnnotations,
176
- canSaveAnnotations,
177
- onSaveAnnotations
178
- }) => {
179
- const [isPrintMenuOpen, setIsPrintMenuOpen] = useState(false);
180
- const [isDownloadMenuOpen, setIsDownloadMenuOpen] = useState(false);
181
- const [isAnnotationMenuOpen, setIsAnnotationMenuOpen] = useState(false);
182
- const [isViewMenuOpen, setIsViewMenuOpen] = useState(false);
183
- const printMenuRef = useRef(null);
184
- const downloadMenuRef = useRef(null);
185
- const annotationMenuRef = useRef(null);
186
- const viewMenuRef = useRef(null);
187
- useEffect(() => {
188
- const handleClickOutside = (event) => {
189
- if (printMenuRef.current && !printMenuRef.current.contains(event.target)) {
190
- setIsPrintMenuOpen(false);
191
- }
192
- if (downloadMenuRef.current && !downloadMenuRef.current.contains(event.target)) {
193
- setIsDownloadMenuOpen(false);
194
- }
195
- if (annotationMenuRef.current && !annotationMenuRef.current.contains(event.target)) {
196
- setIsAnnotationMenuOpen(false);
197
- }
198
- if (viewMenuRef.current && !viewMenuRef.current.contains(event.target)) {
199
- setIsViewMenuOpen(false);
200
- }
201
- };
202
- document.addEventListener("mousedown", handleClickOutside);
203
- return () => document.removeEventListener("mousedown", handleClickOutside);
204
- }, []);
205
- const handlePrintWithAnnotations = () => {
206
- setIsPrintMenuOpen(false);
207
- onPrintWithAnnotations?.();
208
- };
209
- const handlePrintWithoutAnnotations = () => {
210
- setIsPrintMenuOpen(false);
211
- onPrintWithoutAnnotations?.();
212
- };
213
- const handleDownloadWithAnnotations = () => {
214
- setIsDownloadMenuOpen(false);
215
- onDownloadWithAnnotations?.();
216
- };
217
- const handleDownloadWithoutAnnotations = () => {
218
- setIsDownloadMenuOpen(false);
219
- onDownloadWithoutAnnotations?.();
220
- };
221
- const [activeMode, setActiveMode] = useState("view");
222
- return /* @__PURE__ */ jsxs("div", { className: "pdf-viewer-toolbar-container", children: [
223
- /* @__PURE__ */ jsxs("div", { className: "pdf-viewer-toolbar", children: [
224
- /* @__PURE__ */ jsxs("div", { className: "toolbar-left", children: [
225
- showPageNavigation && /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
226
- /* @__PURE__ */ jsx2(Tooltip, { title: "First Page", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
227
- "button",
228
- {
229
- className: "toolbar-button",
230
- onClick: onFirstPage,
231
- disabled: currentPage <= 1,
232
- children: /* @__PURE__ */ jsx2(FirstPageIcon, { fontSize: "small" })
233
- }
234
- ) }) }),
235
- /* @__PURE__ */ jsx2(Tooltip, { title: "Previous Page", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
236
- "button",
237
- {
238
- className: "toolbar-button",
239
- onClick: onPreviousPage,
240
- disabled: currentPage <= 1,
241
- children: /* @__PURE__ */ jsx2(ChevronLeftIcon, { fontSize: "small" })
242
- }
243
- ) }) }),
244
- /* @__PURE__ */ jsxs("span", { className: "page-info", style: { display: "flex", alignItems: "center", margin: "0 8px", fontSize: "14px", fontWeight: 500 }, children: [
245
- currentPage,
246
- " ",
247
- showPageCount && /* @__PURE__ */ jsxs("span", { style: { color: "#6b7280", marginLeft: "4px" }, children: [
248
- "/ ",
249
- totalPages || "..."
250
- ] })
251
- ] }),
252
- /* @__PURE__ */ jsx2(Tooltip, { title: "Next Page", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
253
- "button",
254
- {
255
- className: "toolbar-button",
256
- onClick: onNextPage,
257
- disabled: currentPage >= totalPages,
258
- children: /* @__PURE__ */ jsx2(ChevronRightIcon, { fontSize: "small" })
259
- }
260
- ) }) }),
261
- /* @__PURE__ */ jsx2(Tooltip, { title: "Last Page", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
262
- "button",
263
- {
264
- className: "toolbar-button",
265
- onClick: onLastPage,
266
- disabled: currentPage >= totalPages,
267
- children: /* @__PURE__ */ jsx2(LastPageIcon, { fontSize: "small" })
268
- }
269
- ) }) })
270
- ] }),
271
- showZoomControls && /* @__PURE__ */ jsxs(Fragment, { children: [
272
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
273
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
274
- /* @__PURE__ */ jsx2(Tooltip, { title: "Zoom Out", children: /* @__PURE__ */ jsx2(
275
- "button",
276
- {
277
- className: "toolbar-button",
278
- onClick: onZoomOut,
279
- children: /* @__PURE__ */ jsx2(RemoveIcon, { fontSize: "small" })
280
- }
281
- ) }),
282
- /* @__PURE__ */ jsxs("span", { className: "zoom-display", children: [
283
- zoom,
284
- "%"
285
- ] }),
286
- /* @__PURE__ */ jsx2(Tooltip, { title: "Zoom In", children: /* @__PURE__ */ jsx2(
287
- "button",
288
- {
289
- className: "toolbar-button",
290
- onClick: onZoomIn,
291
- children: /* @__PURE__ */ jsx2(AddIcon, { fontSize: "small" })
292
- }
293
- ) })
294
- ] })
295
- ] }),
296
- (showZoomControls || showRotation) && /* @__PURE__ */ jsxs(Fragment, { children: [
297
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
298
- /* @__PURE__ */ jsx2("div", { className: "toolbar-section", children: /* @__PURE__ */ jsxs("div", { className: "toolbar-dropdown-container", ref: viewMenuRef, children: [
299
- /* @__PURE__ */ jsx2(Tooltip, { title: "View Options", children: /* @__PURE__ */ jsxs(
300
- "button",
301
- {
302
- className: `toolbar-button toolbar-dropdown-button ${isViewMenuOpen ? "toolbar-button-active" : ""}`,
303
- onClick: () => setIsViewMenuOpen(!isViewMenuOpen),
304
- children: [
305
- /* @__PURE__ */ jsx2(TuneIcon, { fontSize: "small" }),
306
- /* @__PURE__ */ jsx2(KeyboardArrowDownIcon, { fontSize: "small", style: { marginLeft: -4 } })
307
- ]
308
- }
309
- ) }),
310
- isViewMenuOpen && /* @__PURE__ */ jsxs("div", { className: "toolbar-dropdown-menu", style: { width: "240px" }, children: [
311
- /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-header", children: "SPREAD MODE" }),
312
- /* @__PURE__ */ jsxs("button", { className: "toolbar-dropdown-item toolbar-dropdown-item-active", onClick: () => setIsViewMenuOpen(false), children: [
313
- /* @__PURE__ */ jsx2(PortraitIcon, { fontSize: "small" }),
314
- /* @__PURE__ */ jsx2("span", { children: "Single Page" })
315
- ] }),
316
- /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-divider" }),
317
- /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-header", children: "SCROLL LAYOUT" }),
318
- /* @__PURE__ */ jsxs("button", { className: "toolbar-dropdown-item toolbar-dropdown-item-active", onClick: () => setIsViewMenuOpen(false), children: [
319
- /* @__PURE__ */ jsx2(SwapVertIcon, { fontSize: "small" }),
320
- /* @__PURE__ */ jsx2("span", { children: "Vertical" })
321
- ] }),
322
- /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-divider" }),
323
- /* @__PURE__ */ jsxs("button", { className: "toolbar-dropdown-item", onClick: () => {
324
- setIsViewMenuOpen(false);
325
- onFitToWidth?.();
326
- }, children: [
327
- /* @__PURE__ */ jsx2(AspectRatioIcon, { fontSize: "small" }),
328
- /* @__PURE__ */ jsx2("span", { children: "Fit to Width" })
329
- ] }),
330
- /* @__PURE__ */ jsxs("button", { className: "toolbar-dropdown-item", onClick: () => {
331
- setIsViewMenuOpen(false);
332
- onFitToPage?.();
333
- }, children: [
334
- /* @__PURE__ */ jsx2(FitScreenIcon, { fontSize: "small" }),
335
- /* @__PURE__ */ jsx2("span", { children: "Fit to Page" })
336
- ] }),
337
- /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-divider" }),
338
- showRotation && /* @__PURE__ */ jsxs(Fragment, { children: [
339
- /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-header", children: "PAGE ROTATION" }),
340
- /* @__PURE__ */ jsxs(
341
- "button",
342
- {
343
- className: "toolbar-dropdown-item",
344
- onClick: () => {
345
- setIsViewMenuOpen(false);
346
- onRotateRight?.();
347
- },
348
- disabled: false,
349
- children: [
350
- /* @__PURE__ */ jsx2(RotateRightIcon, { fontSize: "small" }),
351
- /* @__PURE__ */ jsx2("span", { children: "Rotate Clockwise" })
352
- ]
353
- }
354
- ),
355
- /* @__PURE__ */ jsxs(
356
- "button",
357
- {
358
- className: "toolbar-dropdown-item",
359
- onClick: () => {
360
- setIsViewMenuOpen(false);
361
- onRotateLeft?.();
362
- },
363
- disabled: disabledRotateLeft,
364
- children: [
365
- /* @__PURE__ */ jsx2(RotateLeftIcon, { fontSize: "small" }),
366
- /* @__PURE__ */ jsx2("span", { children: "Rotate Counter-Clockwise" })
367
- ]
368
- }
369
- )
370
- ] }),
371
- /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-divider" }),
372
- /* @__PURE__ */ jsxs(
373
- "button",
374
- {
375
- className: "toolbar-dropdown-item",
376
- onClick: () => {
377
- setIsViewMenuOpen(false);
378
- onToggleFullScreen();
379
- },
380
- children: [
381
- /* @__PURE__ */ jsx2(FullscreenIcon, { fontSize: "small" }),
382
- /* @__PURE__ */ jsx2("span", { children: "Fullscreen" })
383
- ]
384
- }
385
- )
386
- ] })
387
- ] }) })
388
- ] }),
389
- showSearch && /* @__PURE__ */ jsxs(Fragment, { children: [
390
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
391
- /* @__PURE__ */ jsx2("div", { className: "toolbar-section", children: /* @__PURE__ */ jsx2(Tooltip, { title: "Search", children: /* @__PURE__ */ jsx2(
392
- "button",
393
- {
394
- className: `toolbar-button ${isSidebarOpen ? "toolbar-button-active" : ""}`,
395
- onClick: onToggleSidebar,
396
- children: /* @__PURE__ */ jsx2(SearchIcon, { fontSize: "small" })
397
- }
398
- ) }) })
399
- ] })
400
- ] }),
401
- /* @__PURE__ */ jsxs("div", { className: "toolbar-center", children: [
402
- /* @__PURE__ */ jsx2(
403
- "button",
404
- {
405
- className: `toolbar-tab ${activeMode === "view" ? "toolbar-tab-active" : ""}`,
406
- onClick: () => setActiveMode("view"),
407
- children: "View"
408
- }
409
- ),
410
- showAnnotate && /* @__PURE__ */ jsxs(
411
- "button",
412
- {
413
- className: `toolbar-tab ${activeMode === "annotate" ? "toolbar-tab-active" : ""}`,
414
- onClick: () => !disabledAnnotate && setActiveMode("annotate"),
415
- style: {
416
- position: "relative",
417
- opacity: disabledAnnotate ? 0.5 : 1,
418
- cursor: disabledAnnotate ? "not-allowed" : "pointer"
419
- },
420
- children: [
421
- "Annotate",
422
- hasUnsavedAnnotations && /* @__PURE__ */ jsx2("span", { style: {
423
- position: "absolute",
424
- top: "4px",
425
- right: "4px",
426
- width: "6px",
427
- height: "6px",
428
- backgroundColor: "#ef4444",
429
- borderRadius: "50%"
430
- } })
431
- ]
432
- }
433
- )
434
- ] }),
435
- /* @__PURE__ */ jsx2("div", { className: "toolbar-right", children: (hasUnsavedAnnotations || showDownload || showPrint || showMetadata || showProperties || showTags || showHistory) && /* @__PURE__ */ jsxs(Fragment, { children: [
436
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
437
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
438
- showDownload && /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-container", ref: downloadMenuRef, children: showDownloadOriginal && showDownloadWithAnnotations ? (
439
- // RENDER DROPDOWN if BOTH are enabled
440
- /* @__PURE__ */ jsxs(Fragment, { children: [
441
- /* @__PURE__ */ jsx2(Tooltip, { title: "Download", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsxs(
442
- "button",
443
- {
444
- className: `toolbar-button toolbar-dropdown-button ${isDownloadMenuOpen ? "toolbar-button-active" : ""}`,
445
- onClick: () => setIsDownloadMenuOpen(!isDownloadMenuOpen),
446
- disabled: disabledDownload,
447
- children: [
448
- /* @__PURE__ */ jsx2(DownloadIcon, { fontSize: "small" }),
449
- /* @__PURE__ */ jsx2(KeyboardArrowDownIcon, { fontSize: "small", style: { marginLeft: -4 } })
450
- ]
451
- }
452
- ) }) }),
453
- isDownloadMenuOpen && /* @__PURE__ */ jsxs("div", { className: "toolbar-dropdown-menu toolbar-dropdown-menu-right", children: [
454
- /* @__PURE__ */ jsx2(
455
- "button",
456
- {
457
- className: "toolbar-dropdown-item",
458
- onClick: handleDownloadWithoutAnnotations,
459
- children: /* @__PURE__ */ jsx2("span", { children: "Download Document Only" })
460
- }
461
- ),
462
- /* @__PURE__ */ jsx2(
463
- "button",
464
- {
465
- className: "toolbar-dropdown-item",
466
- onClick: handleDownloadWithAnnotations,
467
- children: /* @__PURE__ */ jsx2("span", { children: "Download with Annotations" })
468
- }
469
- )
470
- ] })
471
- ] })
472
- ) : (
473
- // RENDER SINGLE BUTTON if ONLY ONE is enabled
474
- (showDownloadOriginal || showDownloadWithAnnotations) && /* @__PURE__ */ jsx2(Tooltip, { title: "Download", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
475
- "button",
476
- {
477
- className: "toolbar-button",
478
- onClick: showDownloadOriginal ? handleDownloadWithoutAnnotations : handleDownloadWithAnnotations,
479
- disabled: disabledDownload,
480
- children: /* @__PURE__ */ jsx2(DownloadIcon, { fontSize: "small" })
481
- }
482
- ) }) })
483
- ) }),
484
- showPrint && /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-container", ref: printMenuRef, children: showPrintOriginal && showPrintWithAnnotations ? (
485
- // RENDER DROPDOWN if BOTH are enabled
486
- /* @__PURE__ */ jsxs(Fragment, { children: [
487
- /* @__PURE__ */ jsx2(Tooltip, { title: "Print", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsxs(
488
- "button",
489
- {
490
- className: `toolbar-button toolbar-dropdown-button ${isPrintMenuOpen ? "toolbar-button-active" : ""}`,
491
- onClick: () => setIsPrintMenuOpen(!isPrintMenuOpen),
492
- disabled: disabledPrint,
493
- children: [
494
- /* @__PURE__ */ jsx2(PrintIcon, { fontSize: "small" }),
495
- /* @__PURE__ */ jsx2(KeyboardArrowDownIcon, { fontSize: "small", style: { marginLeft: -4 } })
496
- ]
497
- }
498
- ) }) }),
499
- isPrintMenuOpen && /* @__PURE__ */ jsxs("div", { className: "toolbar-dropdown-menu toolbar-dropdown-menu-right", children: [
500
- /* @__PURE__ */ jsx2(
501
- "button",
502
- {
503
- className: "toolbar-dropdown-item",
504
- onClick: handlePrintWithoutAnnotations,
505
- children: /* @__PURE__ */ jsx2("span", { children: "Print Document Only" })
506
- }
507
- ),
508
- /* @__PURE__ */ jsx2(
509
- "button",
510
- {
511
- className: "toolbar-dropdown-item",
512
- onClick: handlePrintWithAnnotations,
513
- children: /* @__PURE__ */ jsx2("span", { children: "Print with Annotations" })
514
- }
515
- )
516
- ] })
517
- ] })
518
- ) : (
519
- // RENDER SINGLE BUTTON if ONLY ONE is enabled
520
- (showPrintOriginal || showPrintWithAnnotations) && /* @__PURE__ */ jsx2(Tooltip, { title: "Print", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
521
- "button",
522
- {
523
- className: "toolbar-button",
524
- onClick: showPrintOriginal ? handlePrintWithoutAnnotations : handlePrintWithAnnotations,
525
- disabled: disabledPrint,
526
- children: /* @__PURE__ */ jsx2(PrintIcon, { fontSize: "small" })
527
- }
528
- ) }) })
529
- ) }),
530
- showMetadata && /* @__PURE__ */ jsx2(Tooltip, { title: "Metadata", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
531
- "button",
532
- {
533
- className: "toolbar-button",
534
- onClick: onMetadataClick,
535
- disabled: disabledMetadata,
536
- children: /* @__PURE__ */ jsx2(DescriptionIcon, { fontSize: "small" })
537
- }
538
- ) }) }),
539
- showProperties && /* @__PURE__ */ jsx2(Tooltip, { title: "Properties", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
540
- "button",
541
- {
542
- className: "toolbar-button",
543
- onClick: onPropertiesClick,
544
- disabled: disabledProperties,
545
- children: /* @__PURE__ */ jsx2(InfoIcon, { fontSize: "small" })
546
- }
547
- ) }) }),
548
- showTags && /* @__PURE__ */ jsx2(Tooltip, { title: "Tags", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
549
- "button",
550
- {
551
- className: "toolbar-button",
552
- onClick: onTagsClick,
553
- disabled: disabledTags,
554
- children: /* @__PURE__ */ jsx2(LocalOffer, { fontSize: "small" })
555
- }
556
- ) }) }),
557
- showHistory && /* @__PURE__ */ jsx2(Tooltip, { title: "Version History", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
558
- "button",
559
- {
560
- className: "toolbar-button",
561
- onClick: onHistoryClick,
562
- disabled: disabledHistory,
563
- children: /* @__PURE__ */ jsx2(HistoryIcon, { fontSize: "small" })
564
- }
565
- ) }) })
566
- ] })
567
- ] }) })
568
- ] }),
569
- activeMode === "annotate" && showAnnotations && /* @__PURE__ */ jsxs("div", { className: "pdf-viewer-secondary-toolbar", children: [
570
- /* @__PURE__ */ jsx2(Tooltip, { title: "Highlight", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
571
- "button",
572
- {
573
- className: `toolbar-button ${isHighlighterActive ? "toolbar-button-active" : ""}`,
574
- onClick: onHighlighterClick,
575
- disabled: disabledHighlighter,
576
- children: /* @__PURE__ */ jsx2(HighlightIcon, { fontSize: "small" })
577
- }
578
- ) }) }),
579
- /* @__PURE__ */ jsx2(Tooltip, { title: "Stamp", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
580
- "button",
581
- {
582
- className: `toolbar-button ${isStampActive ? "toolbar-button-active" : ""}`,
583
- onClick: onStampClick,
584
- disabled: disabledStamp,
585
- children: /* @__PURE__ */ jsx2(ApprovalIcon, { fontSize: "small" })
586
- }
587
- ) }) }),
588
- /* @__PURE__ */ jsx2(Tooltip, { title: "Signature", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
589
- "button",
590
- {
591
- className: "toolbar-button",
592
- onClick: onSignatureClick,
593
- disabled: disabledSignature,
594
- children: /* @__PURE__ */ jsx2(DrawIcon, { fontSize: "small" })
595
- }
596
- ) }) }),
597
- onNoteClick && /* @__PURE__ */ jsx2(Tooltip, { title: "Sticky Note", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsx2(
598
- "button",
599
- {
600
- className: "toolbar-button",
601
- onClick: onNoteClick,
602
- disabled: disabledNote,
603
- children: /* @__PURE__ */ jsx2(StickyNote2Icon, { fontSize: "small" })
604
- }
605
- ) }) }),
606
- hasUnsavedAnnotations && canSaveAnnotations !== false && onSaveAnnotations && /* @__PURE__ */ jsxs(Fragment, { children: [
607
- /* @__PURE__ */ jsx2("div", { style: { width: 1, height: 24, backgroundColor: "#e5e7eb", margin: "0 8px" } }),
608
- /* @__PURE__ */ jsx2(Tooltip, { title: "Save Annotations", children: /* @__PURE__ */ jsx2("span", { children: /* @__PURE__ */ jsxs(
609
- "button",
610
- {
611
- className: "toolbar-button",
612
- onClick: onSaveAnnotations,
613
- disabled: isSavingAnnotations,
614
- style: {
615
- color: hasUnsavedAnnotations ? "#2563eb" : "inherit",
616
- padding: "6px 16px",
617
- border: hasUnsavedAnnotations ? "1px solid #2563eb" : "1px solid transparent",
618
- borderRadius: "6px",
619
- display: "flex",
620
- alignItems: "center",
621
- gap: "6px",
622
- backgroundColor: hasUnsavedAnnotations ? "#eff6ff" : "transparent",
623
- fontSize: "14px",
624
- fontWeight: 500,
625
- width: "auto",
626
- cursor: isSavingAnnotations ? "not-allowed" : "pointer"
627
- },
628
- children: [
629
- isSavingAnnotations ? /* @__PURE__ */ jsx2("svg", { width: "16", height: "16", viewBox: "0 0 24 24", style: { animation: "spin 1s linear infinite" }, children: /* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "3", fill: "none", strokeDasharray: "31.4", strokeDashoffset: "10" }) }) : /* @__PURE__ */ jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
630
- /* @__PURE__ */ jsx2("path", { d: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z" }),
631
- /* @__PURE__ */ jsx2("polyline", { points: "17 21 17 13 7 13 7 21" }),
632
- /* @__PURE__ */ jsx2("polyline", { points: "7 3 7 8 15 8" })
633
- ] }),
634
- /* @__PURE__ */ jsx2("span", { children: isSavingAnnotations ? "Saving..." : "Save" })
635
- ]
636
- }
637
- ) }) })
638
- ] })
639
- ] }),
640
- activeMode === "redact" && showAnnotations && /* @__PURE__ */ jsx2("div", { className: "pdf-viewer-secondary-toolbar", children: /* @__PURE__ */ jsx2(Tooltip, { title: "Redact Text", children: /* @__PURE__ */ jsx2("button", { className: "toolbar-button", children: /* @__PURE__ */ jsx2(AutoFixHighIcon, { fontSize: "small" }) }) }) })
641
- ] });
642
- }
643
- );
644
- PDFToolbar.displayName = "PDFToolbar";
645
-
646
- // src/components/viewers/pdf/PDFHeader.tsx
647
- import React3 from "react";
648
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
649
- var PDFHeader = React3.memo(({ fileName, fileExtension }) => {
650
- return /* @__PURE__ */ jsxs2("div", { className: "pdf-viewer-header", children: [
651
- /* @__PURE__ */ jsx3(FileIcon_default, { ext: fileExtension, size: 26 }),
652
- /* @__PURE__ */ jsx3("div", { className: "header-file-name", title: fileName, children: fileName })
653
- ] });
654
- });
655
- PDFHeader.displayName = "PDFHeader";
656
-
657
- // src/components/viewers/pdf/SearchSidebar.tsx
658
- import { useState as useState2, useLayoutEffect, useEffect as useEffect2, useRef as useRef2 } from "react";
659
- import {
660
- Box,
661
- Typography,
662
- TextField,
663
- IconButton,
664
- InputAdornment,
665
- Divider,
666
- CircularProgress
667
- } from "@mui/material";
668
- import SearchIcon2 from "@mui/icons-material/Search";
669
- import CloseIcon from "@mui/icons-material/Close";
670
- import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
671
- import KeyboardArrowDownIcon2 from "@mui/icons-material/KeyboardArrowDown";
672
- import ClearIcon from "@mui/icons-material/Clear";
673
- import FindInPageIcon from "@mui/icons-material/FindInPage";
674
- import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
675
- var SearchSidebar = ({
676
- isOpen,
677
- onClose,
678
- onSearch,
679
- onSearchResultClick,
680
- onNextResult,
681
- onPreviousResult,
682
- currentResultIndex,
683
- totalResults,
684
- searchKeyword,
685
- searchResults = [],
686
- isSearching = false,
687
- isSyntheticResults = false
688
- }) => {
689
- const [searchTerm, setSearchTerm] = useState2(searchKeyword || "");
690
- const [hasSearched, setHasSearched] = useState2(false);
691
- const contentRef = useRef2(null);
692
- useEffect2(() => {
693
- if (searchKeyword && searchKeyword !== searchTerm) {
694
- setSearchTerm(searchKeyword);
695
- }
696
- }, [searchKeyword]);
697
- useLayoutEffect(() => {
698
- const element = contentRef.current;
699
- if (!element) return;
700
- const handleMouseMove = (e) => {
701
- const rect = element.getBoundingClientRect();
702
- const distanceFromRight = rect.right - e.clientX;
703
- const distanceFromBottom = rect.bottom - e.clientY;
704
- if (distanceFromRight <= 15 || distanceFromBottom <= 15) {
705
- element.classList.add("scrollbar-hover");
706
- } else {
707
- element.classList.remove("scrollbar-hover");
708
- }
709
- };
710
- const handleMouseLeave = () => element.classList.remove("scrollbar-hover");
711
- element.addEventListener("mousemove", handleMouseMove);
712
- element.addEventListener("mouseleave", handleMouseLeave);
713
- return () => {
714
- element.removeEventListener("mousemove", handleMouseMove);
715
- element.removeEventListener("mouseleave", handleMouseLeave);
716
- };
717
- }, []);
718
- useLayoutEffect(() => {
719
- const style = document.createElement("style");
720
- style.id = "search-sidebar-scrollbar";
721
- style.textContent = `
722
- @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;600&family=Noto+Sans+Devanagari:wght@400;600&display=swap');
723
-
724
- .search-sidebar-content::-webkit-scrollbar {
725
- width: 12px;
726
- height: 12px;
727
- }
728
- .search-sidebar-content::-webkit-scrollbar-track {
729
- background-color: transparent;
730
- }
731
- .search-sidebar-content::-webkit-scrollbar-thumb {
732
- background-color: rgba(128, 128, 128, 0.3);
733
- border-radius: 8px;
734
- border: 4px solid transparent;
735
- background-clip: padding-box;
736
- transition: all 0.15s ease;
737
- }
738
- .search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
739
- background-color: rgba(128, 128, 128, 0.5);
740
- border: 2px solid transparent;
741
- }
742
- .search-sidebar-content::-webkit-scrollbar-thumb:active {
743
- background-color: rgba(25, 118, 210, 0.8);
744
- border: 1px solid transparent;
745
- }
746
-
747
- @media (prefers-color-scheme: dark) {
748
- .search-sidebar-content::-webkit-scrollbar-thumb {
749
- background-color: rgba(255, 255, 255, 0.2);
750
- }
751
- .search-sidebar-content.scrollbar-hover::-webkit-scrollbar-thumb {
752
- background-color: rgba(255, 255, 255, 0.35);
753
- }
754
- }
755
-
756
- /* Tamil font support for search results */
757
- .search-result-text {
758
- font-family: 'Noto Sans Tamil', 'Noto Sans Devanagari', Arial, sans-serif !important;
759
- }
760
- `;
761
- document.head.appendChild(style);
762
- return () => {
763
- const el = document.getElementById("search-sidebar-scrollbar");
764
- if (el) el.remove();
765
- };
766
- }, []);
767
- useLayoutEffect(() => {
768
- setSearchTerm(searchKeyword || "");
769
- if (searchKeyword || searchResults.length > 0) {
770
- setHasSearched(true);
771
- }
772
- }, [searchKeyword, searchResults]);
773
- const handleSearchSubmit = (e) => {
774
- if (e) e.preventDefault();
775
- if (searchTerm.trim()) {
776
- setHasSearched(true);
777
- onSearch(searchTerm.trim());
778
- }
779
- };
780
- const handleSearchChange = (e) => {
781
- const value = e.target.value;
782
- setSearchTerm(value);
783
- if (!value.trim()) {
784
- setHasSearched(false);
785
- onSearch("");
786
- }
787
- };
788
- const handleClearSearch = () => {
789
- setSearchTerm("");
790
- setHasSearched(false);
791
- onSearch("");
792
- };
793
- const resultsByPage = searchResults.reduce((acc, result) => {
794
- if (!acc[result.pageNumber]) {
795
- acc[result.pageNumber] = [];
796
- }
797
- acc[result.pageNumber].push(result);
798
- return acc;
799
- }, {});
800
- const highlightText = (text, keyword) => {
801
- if (!keyword) return text;
802
- const textString = typeof text === "string" ? text : String(text || "");
803
- if (!textString) return text;
804
- try {
805
- const escapedKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
806
- const regex = new RegExp(`(${escapedKeyword})`, "gi");
807
- const parts = textString.split(regex);
808
- return parts.map(
809
- (part, index) => regex.test(part) ? /* @__PURE__ */ jsx4(
810
- Box,
811
- {
812
- component: "span",
813
- sx: {
814
- color: "primary.main",
815
- fontWeight: 600,
816
- fontSize: "inherit"
817
- },
818
- children: part
819
- },
820
- index
821
- ) : part
822
- );
823
- } catch (error) {
824
- return textString;
825
- }
826
- };
827
- if (!isOpen) return null;
828
- return /* @__PURE__ */ jsxs3(
829
- Box,
830
- {
831
- sx: {
832
- display: "flex",
833
- flexDirection: "column",
834
- height: "100%",
835
- width: "320px",
836
- backgroundColor: "background.paper",
837
- borderLeft: "1px solid",
838
- borderColor: "divider",
839
- overflow: "hidden"
840
- },
841
- children: [
842
- /* @__PURE__ */ jsxs3(Box, { sx: { px: 3, py: 2.5, backgroundColor: "background.default" }, children: [
843
- /* @__PURE__ */ jsxs3(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2 }, children: [
844
- /* @__PURE__ */ jsx4(Typography, { variant: "h6", sx: { fontSize: "1.125rem", fontWeight: 600, color: "text.primary" }, children: "Search" }),
845
- /* @__PURE__ */ jsx4(
846
- IconButton,
847
- {
848
- size: "small",
849
- onClick: onClose,
850
- sx: {
851
- color: "text.secondary",
852
- padding: "6px"
853
- },
854
- children: /* @__PURE__ */ jsx4(CloseIcon, { fontSize: "small" })
855
- }
856
- )
857
- ] }),
858
- /* @__PURE__ */ jsx4("form", { onSubmit: handleSearchSubmit, children: /* @__PURE__ */ jsx4(
859
- TextField,
860
- {
861
- fullWidth: true,
862
- size: "medium",
863
- placeholder: "Search in document...",
864
- value: searchTerm,
865
- onChange: handleSearchChange,
866
- autoComplete: "off",
867
- InputProps: {
868
- startAdornment: /* @__PURE__ */ jsx4(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx4(SearchIcon2, { sx: { color: "text.disabled", fontSize: 20 } }) }),
869
- endAdornment: searchTerm && /* @__PURE__ */ jsx4(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx4(
870
- IconButton,
871
- {
872
- size: "small",
873
- onClick: handleClearSearch,
874
- sx: {
875
- color: "text.secondary",
876
- padding: "4px",
877
- "&:hover": {
878
- backgroundColor: "action.hover"
879
- }
880
- },
881
- children: /* @__PURE__ */ jsx4(ClearIcon, { sx: { fontSize: 18 } })
882
- }
883
- ) })
884
- },
885
- sx: {
886
- "& .MuiOutlinedInput-root": {
887
- fontSize: "0.9375rem",
888
- backgroundColor: "background.paper",
889
- borderRadius: "8px",
890
- "& fieldset": {
891
- borderColor: "divider"
892
- },
893
- "&.Mui-focused fieldset": {
894
- borderColor: "primary.main",
895
- borderWidth: "2px"
896
- }
897
- },
898
- "& .MuiInputBase-input": {
899
- padding: "10px 14px"
900
- }
901
- }
902
- }
903
- ) }),
904
- totalResults > 0 && /* @__PURE__ */ jsxs3(
905
- Box,
906
- {
907
- sx: {
908
- display: "flex",
909
- alignItems: "center",
910
- justifyContent: "space-between",
911
- mt: 2,
912
- pt: 2,
913
- borderTop: "1px solid",
914
- borderColor: "divider"
915
- },
916
- children: [
917
- /* @__PURE__ */ jsxs3(Typography, { variant: "body2", sx: { color: "text.secondary", fontSize: "0.875rem", fontWeight: 500 }, children: [
918
- currentResultIndex + 1,
919
- " of ",
920
- totalResults,
921
- " results"
922
- ] }),
923
- /* @__PURE__ */ jsxs3(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
924
- /* @__PURE__ */ jsx4(
925
- IconButton,
926
- {
927
- size: "small",
928
- onClick: onPreviousResult,
929
- disabled: currentResultIndex <= 0,
930
- sx: {
931
- color: currentResultIndex <= 0 ? "text.disabled" : "primary.main",
932
- padding: "6px",
933
- borderRadius: "6px",
934
- border: "1px solid",
935
- borderColor: currentResultIndex <= 0 ? "divider" : "primary.main"
936
- },
937
- children: /* @__PURE__ */ jsx4(KeyboardArrowUpIcon, { sx: { fontSize: 20 } })
938
- }
939
- ),
940
- /* @__PURE__ */ jsx4(
941
- IconButton,
942
- {
943
- size: "small",
944
- onClick: onNextResult,
945
- disabled: currentResultIndex >= totalResults - 1,
946
- sx: {
947
- color: currentResultIndex >= totalResults - 1 ? "text.disabled" : "primary.main",
948
- padding: "6px",
949
- borderRadius: "6px",
950
- border: "1px solid",
951
- borderColor: currentResultIndex >= totalResults - 1 ? "divider" : "primary.main"
952
- },
953
- children: /* @__PURE__ */ jsx4(KeyboardArrowDownIcon2, { sx: { fontSize: 20 } })
954
- }
955
- )
956
- ] })
957
- ]
958
- }
959
- )
960
- ] }),
961
- /* @__PURE__ */ jsx4(Divider, {}),
962
- /* @__PURE__ */ jsxs3(Box, { ref: contentRef, className: "search-sidebar-content", sx: {
963
- flex: 1,
964
- overflow: "auto",
965
- backgroundColor: "background.default"
966
- }, children: [
967
- !searchTerm && !hasSearched && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
968
- /* @__PURE__ */ jsx4(
969
- Box,
970
- {
971
- sx: {
972
- width: 80,
973
- height: 80,
974
- borderRadius: "50%",
975
- backgroundColor: "action.hover",
976
- display: "flex",
977
- alignItems: "center",
978
- justifyContent: "center",
979
- margin: "0 auto",
980
- mb: 3
981
- },
982
- children: /* @__PURE__ */ jsx4(SearchIcon2, { sx: { fontSize: 40, color: "text.disabled" } })
983
- }
984
- ),
985
- /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Search in Document" }),
986
- /* @__PURE__ */ jsx4(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: "Enter keywords to find text within the PDF document" })
987
- ] }),
988
- searchTerm && !hasSearched && !isSearching && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
989
- /* @__PURE__ */ jsx4(
990
- Box,
991
- {
992
- sx: {
993
- width: 80,
994
- height: 80,
995
- borderRadius: "50%",
996
- backgroundColor: "primary.light",
997
- display: "flex",
998
- alignItems: "center",
999
- justifyContent: "center",
1000
- margin: "0 auto",
1001
- mb: 3,
1002
- opacity: 0.2
1003
- },
1004
- children: /* @__PURE__ */ jsx4(FindInPageIcon, { sx: { fontSize: 40, color: "primary.main" } })
1005
- }
1006
- ),
1007
- /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Ready to Search" }),
1008
- /* @__PURE__ */ jsx4(Typography, { variant: "body2", sx: { color: "text.secondary", mb: 2, lineHeight: 1.6 }, children: "Press Enter to find" }),
1009
- /* @__PURE__ */ jsxs3(
1010
- Typography,
1011
- {
1012
- variant: "body2",
1013
- sx: {
1014
- color: "white",
1015
- fontWeight: 600,
1016
- backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(144, 202, 249, 0.16)" : "primary.light",
1017
- padding: "6px 16px",
1018
- borderRadius: "16px",
1019
- display: "inline-block",
1020
- opacity: 0.9
1021
- },
1022
- children: [
1023
- '"',
1024
- searchTerm,
1025
- '"'
1026
- ]
1027
- }
1028
- )
1029
- ] }),
1030
- isSearching && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
1031
- /* @__PURE__ */ jsx4(
1032
- Box,
1033
- {
1034
- sx: {
1035
- display: "flex",
1036
- alignItems: "center",
1037
- justifyContent: "center",
1038
- margin: "0 auto",
1039
- mb: 3
1040
- },
1041
- children: /* @__PURE__ */ jsx4(CircularProgress, { size: 60, thickness: 4 })
1042
- }
1043
- ),
1044
- /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Searching..." }),
1045
- /* @__PURE__ */ jsxs3(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
1046
- 'Finding matches for "',
1047
- searchTerm,
1048
- '"'
1049
- ] })
1050
- ] }),
1051
- hasSearched && totalResults === 0 && !isSearching && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
1052
- /* @__PURE__ */ jsx4(
1053
- Box,
1054
- {
1055
- sx: {
1056
- width: 80,
1057
- height: 80,
1058
- borderRadius: "50%",
1059
- backgroundColor: (theme) => theme.palette.mode === "dark" ? "rgba(255, 152, 0, 0.12)" : "warning.light",
1060
- display: "flex",
1061
- alignItems: "center",
1062
- justifyContent: "center",
1063
- margin: "0 auto",
1064
- mb: 3,
1065
- opacity: 0.6
1066
- },
1067
- children: /* @__PURE__ */ jsx4(SearchIcon2, { sx: { fontSize: 40, color: "warning.main" } })
1068
- }
1069
- ),
1070
- /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "No Results Found" }),
1071
- /* @__PURE__ */ jsxs3(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
1072
- "No matches found for ",
1073
- /* @__PURE__ */ jsxs3("strong", { children: [
1074
- '"',
1075
- searchTerm,
1076
- '"'
1077
- ] })
1078
- ] })
1079
- ] }),
1080
- totalResults > 0 && /* @__PURE__ */ jsx4(Box, { sx: { p: 2 }, children: Object.keys(resultsByPage).sort((a, b) => parseInt(a) - parseInt(b)).map((pageNum) => {
1081
- const pageNumber = parseInt(pageNum);
1082
- const pageResults = resultsByPage[pageNumber];
1083
- return /* @__PURE__ */ jsxs3(Box, { sx: { mb: 3 }, children: [
1084
- /* @__PURE__ */ jsxs3(
1085
- Typography,
1086
- {
1087
- variant: "subtitle2",
1088
- sx: {
1089
- color: "text.secondary",
1090
- mb: 1.5,
1091
- px: 1,
1092
- fontSize: "0.8125rem",
1093
- fontWeight: 600,
1094
- textTransform: "uppercase",
1095
- letterSpacing: "0.5px"
1096
- },
1097
- children: [
1098
- "Page ",
1099
- pageNumber
1100
- ]
1101
- }
1102
- ),
1103
- pageResults.map((result, index) => /* @__PURE__ */ jsx4(
1104
- Box,
1105
- {
1106
- onClick: () => onSearchResultClick(result.pageNumber, result.index),
1107
- sx: {
1108
- p: 2,
1109
- mx: 1,
1110
- mb: 1.5,
1111
- borderRadius: "8px",
1112
- border: "2px solid",
1113
- borderColor: result.index === currentResultIndex ? "primary.main" : "divider",
1114
- backgroundColor: "background.paper",
1115
- cursor: "pointer",
1116
- transition: "all 0.2s ease",
1117
- boxShadow: (theme) => theme.palette.mode === "dark" ? "0 1px 3px rgba(0, 0, 0, 0.3)" : "0 1px 3px rgba(0, 0, 0, 0.05)",
1118
- "&:hover": {
1119
- borderColor: "primary.main",
1120
- boxShadow: (theme) => theme.palette.mode === "dark" ? "0 2px 8px rgba(255, 255, 255, 0.15)" : "0 2px 8px rgba(0, 0, 0, 0.1)",
1121
- transform: "translateY(-1px)"
1122
- }
1123
- },
1124
- children: /* @__PURE__ */ jsx4(
1125
- Typography,
1126
- {
1127
- variant: "body2",
1128
- className: "search-result-text",
1129
- sx: {
1130
- fontSize: "0.875rem",
1131
- lineHeight: 1.6,
1132
- color: result.index === currentResultIndex ? "text.primary" : "text.secondary"
1133
- },
1134
- children: highlightText(result.context, searchTerm)
1135
- }
1136
- )
1137
- },
1138
- index
1139
- ))
1140
- ] }, pageNumber);
1141
- }) })
1142
- ] })
1143
- ]
1144
- }
1145
- );
1146
- };
1147
-
1148
- // src/components/viewers/pdf/PasswordDialog.tsx
1149
- import { useState as useState3, useEffect as useEffect3 } from "react";
1150
- import {
1151
- Dialog,
1152
- DialogTitle,
1153
- DialogContent,
1154
- DialogActions,
1155
- TextField as TextField2,
1156
- Button,
1157
- Typography as Typography2,
1158
- InputAdornment as InputAdornment2,
1159
- Box as Box2,
1160
- Alert,
1161
- IconButton as IconButton2,
1162
- CircularProgress as CircularProgress2
1163
- } from "@mui/material";
1164
- import LockIcon from "@mui/icons-material/Lock";
1165
- import VisibilityIcon from "@mui/icons-material/Visibility";
1166
- import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
1167
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1168
- var PasswordDialog = ({
1169
- open,
1170
- fileName,
1171
- onSubmit,
1172
- onCancel,
1173
- error,
1174
- isLoading = false
1175
- }) => {
1176
- const [password, setPassword] = useState3("");
1177
- const [showPassword, setShowPassword] = useState3(false);
1178
- useEffect3(() => {
1179
- if (open && !isLoading) {
1180
- if (error) {
1181
- setPassword("");
1182
- }
1183
- }
1184
- }, [open, error, isLoading]);
1185
- useEffect3(() => {
1186
- if (open) {
1187
- setShowPassword(false);
1188
- if (!error) {
1189
- setPassword("");
1190
- }
1191
- }
1192
- }, [open]);
1193
- const handleSubmit = (e) => {
1194
- e.preventDefault();
1195
- if (password.trim() && !isLoading) {
1196
- onSubmit(password);
1197
- }
1198
- };
1199
- const handleTogglePasswordVisibility = () => {
1200
- setShowPassword(!showPassword);
1201
- };
1202
- const handleKeyPress = (e) => {
1203
- if (e.key === "Enter" && password.trim() && !isLoading) {
1204
- handleSubmit(e);
1205
- }
1206
- };
1207
- return /* @__PURE__ */ jsxs4(
1208
- Dialog,
1209
- {
1210
- open,
1211
- disableEscapeKeyDown: true,
1212
- onClose: (event, reason) => {
1213
- if (reason === "backdropClick") return;
1214
- },
1215
- maxWidth: "sm",
1216
- fullWidth: true,
1217
- slotProps: {
1218
- backdrop: {
1219
- sx: {
1220
- backdropFilter: "blur(8px)",
1221
- backgroundColor: "rgba(0, 0, 0, 0.6)"
1222
- }
1223
- }
1224
- },
1225
- PaperProps: {
1226
- sx: {
1227
- borderRadius: 2
1228
- }
1229
- },
1230
- children: [
1231
- /* @__PURE__ */ jsx5(DialogTitle, { sx: { pb: 1 }, children: /* @__PURE__ */ jsxs4(Box2, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
1232
- /* @__PURE__ */ jsx5(
1233
- Box2,
1234
- {
1235
- sx: {
1236
- width: 40,
1237
- height: 40,
1238
- borderRadius: "50%",
1239
- backgroundColor: "primary.light",
1240
- display: "flex",
1241
- alignItems: "center",
1242
- justifyContent: "center",
1243
- opacity: 0.9
1244
- },
1245
- children: /* @__PURE__ */ jsx5(LockIcon, { sx: { color: "white", fontSize: 20 } })
1246
- }
1247
- ),
1248
- /* @__PURE__ */ jsx5(Typography2, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
1249
- ] }) }),
1250
- /* @__PURE__ */ jsxs4(DialogContent, { sx: { pt: 2 }, children: [
1251
- /* @__PURE__ */ jsxs4(Typography2, { variant: "body2", sx: { color: "text.secondary", mb: 3 }, children: [
1252
- "This PDF is password protected. Please enter the password to view",
1253
- " ",
1254
- fileName && /* @__PURE__ */ jsxs4("strong", { children: [
1255
- '"',
1256
- fileName,
1257
- '"'
1258
- ] })
1259
- ] }),
1260
- error && /* @__PURE__ */ jsx5(Alert, { severity: "error", sx: { mb: 2 }, children: error }),
1261
- /* @__PURE__ */ jsx5("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsx5(
1262
- TextField2,
1263
- {
1264
- fullWidth: true,
1265
- autoFocus: true,
1266
- type: showPassword ? "text" : "password",
1267
- label: "Password",
1268
- placeholder: "Enter password",
1269
- value: password,
1270
- onChange: (e) => setPassword(e.target.value),
1271
- onKeyPress: handleKeyPress,
1272
- error: Boolean(error),
1273
- disabled: isLoading,
1274
- InputProps: {
1275
- endAdornment: /* @__PURE__ */ jsx5(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx5(
1276
- IconButton2,
1277
- {
1278
- onClick: handleTogglePasswordVisibility,
1279
- edge: "end",
1280
- size: "small",
1281
- "aria-label": showPassword ? "Hide password" : "Show password",
1282
- disabled: isLoading,
1283
- children: showPassword ? /* @__PURE__ */ jsx5(VisibilityOffIcon, {}) : /* @__PURE__ */ jsx5(VisibilityIcon, {})
1284
- }
1285
- ) })
1286
- },
1287
- sx: {
1288
- "& .MuiOutlinedInput-root": {
1289
- borderRadius: 2
1290
- }
1291
- }
1292
- }
1293
- ) })
1294
- ] }),
1295
- /* @__PURE__ */ jsx5(DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: /* @__PURE__ */ jsx5(
1296
- Button,
1297
- {
1298
- onClick: handleSubmit,
1299
- variant: "contained",
1300
- disabled: !password.trim() || isLoading,
1301
- sx: {
1302
- borderRadius: 2,
1303
- textTransform: "none",
1304
- px: 3,
1305
- boxShadow: 2,
1306
- minWidth: 120
1307
- },
1308
- children: isLoading ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
1309
- /* @__PURE__ */ jsx5(CircularProgress2, { size: 16, color: "inherit", sx: { mr: 1 } }),
1310
- "Verifying..."
1311
- ] }) : "Unlock PDF"
1312
- }
1313
- ) })
1314
- ]
1315
- }
1316
- );
1317
- };
1318
-
1319
- // src/components/viewers/PDFViewer.tsx
1320
- import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
1321
- var PDFViewerContent = forwardRef(
1322
- (props, ref) => {
1323
- const {
1324
- file,
1325
- onLoad,
1326
- onError,
1327
- fileName,
1328
- showPageCount = true,
1329
- showPageNavigation = true,
1330
- showZoomControls = true,
1331
- showRotation = true,
1332
- showDownload = true,
1333
- showPrint = true,
1334
- showSearch = true,
1335
- showMetadata = true,
1336
- showProperties = true,
1337
- showTags = true,
1338
- showHistory = true,
1339
- onMetadataClick,
1340
- onPropertiesClick,
1341
- onTagsClick,
1342
- onHistoryClick,
1343
- onDownloadClick,
1344
- onDownloadWithAnnotations,
1345
- onDownloadWithoutAnnotations,
1346
- onPrintClick,
1347
- onPrintWithAnnotations,
1348
- onPrintWithoutAnnotations,
1349
- initialSearchText,
1350
- initialSearchPages,
1351
- showAnnotations,
1352
- userDetails,
1353
- annotationSelectionMenu,
1354
- isHighlighterActive,
1355
- isStampActive,
1356
- onHighlighterClick,
1357
- onStampClick,
1358
- onSignatureClick,
1359
- onNoteClick,
1360
- isAnnotationForeign,
1361
- onAnnotationNoteClick,
1362
- isAnnotationInteractive,
1363
- // New granular toolbar props
1364
- showAnnotate,
1365
- disabledAnnotate,
1366
- showPrintOriginal,
1367
- showPrintWithAnnotations,
1368
- showDownloadOriginal,
1369
- showDownloadWithAnnotations,
1370
- // Annotation save props
1371
- hasUnsavedAnnotations,
1372
- isSavingAnnotations,
1373
- canSaveAnnotations,
1374
- onSaveAnnotations,
1375
- loading
1376
- } = props;
1377
- const [pdfBuffer, setPdfBuffer] = useState4(null);
1378
- const [state, setState] = useState4("idle");
1379
- const [error, setError] = useState4(null);
1380
- const pdfViewerRef = useRef3(null);
1381
- const [isInternalReady, setIsInternalReady] = useState4(false);
1382
- const [internalHighlighterActive, setInternalHighlighterActive] = useState4(false);
1383
- const [internalStampActive, setInternalStampActive] = useState4(false);
1384
- const highlighterActive = isHighlighterActive !== void 0 ? isHighlighterActive : internalHighlighterActive;
1385
- const stampActive = isStampActive !== void 0 ? isStampActive : internalStampActive;
1386
- const resolvedFileName = useMemo(() => {
1387
- if (fileName) return fileName;
1388
- if (file instanceof File) return file.name;
1389
- if (typeof file === "string") {
1390
- const urlParts = file.split("/");
1391
- return urlParts[urlParts.length - 1] || "document.pdf";
1392
- }
1393
- return "document.pdf";
1394
- }, [file, fileName]);
1395
- const fileExtension = useMemo(
1396
- () => getFileExtension(resolvedFileName),
1397
- [resolvedFileName]
1398
- );
1399
- const [currentPage, setCurrentPage] = useState4(1);
1400
- const [totalPages, setTotalPages] = useState4(0);
1401
- const [zoom, setZoom] = useState4(100);
1402
- const [searchQuery, setSearchQuery] = useState4("");
1403
- const [isSearching, setIsSearching] = useState4(false);
1404
- const [pdfContainer, setPdfContainer] = useState4(null);
1405
- const [isSidebarOpen, setIsSidebarOpen] = useState4(false);
1406
- const [searchResults, setSearchResults] = useState4([]);
1407
- const [currentSearchResultIndex, setCurrentSearchResultIndex] = useState4(0);
1408
- const [totalSearchResults, setTotalSearchResults] = useState4(0);
1409
- const [autoExecuteSearch, setAutoExecuteSearch] = useState4(
1410
- !!initialSearchText
1411
- );
1412
- const [isFullScreen, setIsFullScreen] = useState4(false);
1413
- const containerRef = useRef3(null);
1414
- const [isPasswordDialogOpen, setIsPasswordDialogOpen] = useState4(false);
1415
- const [passwordError, setPasswordError] = useState4("");
1416
- const [isVerifyingPassword, setIsVerifyingPassword] = useState4(false);
1417
- const [passwordResolve, setPasswordResolve] = useState4(null);
1418
- const passwordTimeoutRef = useRef3(null);
1419
- const hasExecutedInitialSearch = useRef3(false);
1420
- const handleToggleFullScreen = useCallback(() => {
1421
- if (!isFullScreen && containerRef.current?.requestFullscreen) {
1422
- containerRef.current.requestFullscreen();
1423
- setIsFullScreen(true);
1424
- } else if (isFullScreen && document.exitFullscreen) {
1425
- document.exitFullscreen();
1426
- setIsFullScreen(false);
1427
- }
1428
- }, [isFullScreen]);
1429
- useEffect4(() => {
1430
- const handleFullscreenChange = () => {
1431
- const isCurrentlyFullscreen = !!document.fullscreenElement;
1432
- setIsFullScreen(isCurrentlyFullscreen);
1433
- };
1434
- document.addEventListener("fullscreenchange", handleFullscreenChange);
1435
- return () => {
1436
- document.removeEventListener("fullscreenchange", handleFullscreenChange);
1437
- };
1438
- }, []);
1439
- const handleSidebarClose = useCallback(() => {
1440
- setIsSidebarOpen(false);
1441
- setSearchQuery("");
1442
- setSearchResults([]);
1443
- setTotalSearchResults(0);
1444
- setCurrentSearchResultIndex(0);
1445
- pdfViewerRef.current?.search.stopSearch();
1446
- }, []);
1447
- const toolbar = mergeToolbarConfig({
1448
- showDownload,
1449
- showPrint,
1450
- showMetadata,
1451
- showProperties,
1452
- showTags,
1453
- showHistory,
1454
- showRotation,
1455
- onDownloadClick,
1456
- onPrintClick,
1457
- onMetadataClick,
1458
- onPropertiesClick,
1459
- onTagsClick,
1460
- onHistoryClick,
1461
- toolbarActions: props.toolbarActions
1462
- });
1463
- const toolbarHandlers = useMemo(
1464
- () => ({
1465
- handleZoomIn: () => {
1466
- pdfViewerRef.current?.zoom.zoomIn();
1467
- requestAnimationFrame(() => {
1468
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1469
- if (typeof zoomValue === "number") {
1470
- setZoom(Math.round(zoomValue * 100));
1471
- }
1472
- });
1473
- },
1474
- handleZoomOut: () => {
1475
- pdfViewerRef.current?.zoom.zoomOut();
1476
- requestAnimationFrame(() => {
1477
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1478
- if (typeof zoomValue === "number") {
1479
- setZoom(Math.round(zoomValue * 100));
1480
- }
1481
- });
1482
- },
1483
- handleFitToWidth: () => {
1484
- pdfViewerRef.current?.zoom.fitToWidth();
1485
- requestAnimationFrame(() => {
1486
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1487
- if (typeof zoomValue === "number") {
1488
- setZoom(Math.round(zoomValue * 100));
1489
- }
1490
- });
1491
- },
1492
- handleFitToPage: () => {
1493
- pdfViewerRef.current?.zoom.fitToPage();
1494
- requestAnimationFrame(() => {
1495
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1496
- if (typeof zoomValue === "number") {
1497
- setZoom(Math.round(zoomValue * 100));
1498
- }
1499
- });
1500
- },
1501
- handlePreviousPage: () => {
1502
- pdfViewerRef.current?.navigation.previousPage();
1503
- requestAnimationFrame(() => {
1504
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1505
- setCurrentPage(current);
1506
- });
1507
- },
1508
- handleNextPage: () => {
1509
- pdfViewerRef.current?.navigation.nextPage();
1510
- requestAnimationFrame(() => {
1511
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1512
- setCurrentPage(current);
1513
- });
1514
- },
1515
- handleFirstPage: () => {
1516
- pdfViewerRef.current?.navigation.goToFirstPage();
1517
- requestAnimationFrame(() => {
1518
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1519
- setCurrentPage(current);
1520
- });
1521
- },
1522
- handleLastPage: () => {
1523
- pdfViewerRef.current?.navigation.goToLastPage();
1524
- requestAnimationFrame(() => {
1525
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1526
- setCurrentPage(current);
1527
- });
1528
- },
1529
- toggleSidebar: () => {
1530
- if (isSidebarOpen) {
1531
- handleSidebarClose();
1532
- } else {
1533
- setIsSidebarOpen(true);
1534
- }
1535
- },
1536
- handlePageInput: (e) => {
1537
- const value = e.target.value;
1538
- if (/^\d*$/.test(value)) {
1539
- return;
1540
- }
1541
- const page = parseInt(value, 10);
1542
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1543
- pdfViewerRef.current?.navigation.goToPage(page);
1544
- setCurrentPage(page);
1545
- }
1546
- },
1547
- handlePageInputKeyPress: (e) => {
1548
- if (e.key === "Enter") {
1549
- const value = e.target.value;
1550
- const page = parseInt(value, 10);
1551
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1552
- pdfViewerRef.current?.navigation.goToPage(page);
1553
- setCurrentPage(page);
1554
- }
1555
- }
1556
- },
1557
- handleRotateLeft: () => {
1558
- pdfViewerRef.current?.rotate?.rotateBackward();
1559
- },
1560
- handleRotateRight: () => {
1561
- pdfViewerRef.current?.rotate?.rotateForward();
1562
- },
1563
- handlePrint: () => {
1564
- pdfViewerRef.current?.print?.print();
1565
- },
1566
- handlePrintWithAnnotations: async () => {
1567
- if (onPrintWithAnnotations) {
1568
- await onPrintWithAnnotations();
1569
- } else {
1570
- await pdfViewerRef.current?.print?.printWithAnnotations?.();
1571
- }
1572
- },
1573
- handlePrintWithoutAnnotations: async () => {
1574
- if (onPrintWithoutAnnotations) {
1575
- await onPrintWithoutAnnotations();
1576
- } else {
1577
- await pdfViewerRef.current?.print?.printWithoutAnnotations?.();
1578
- }
1579
- },
1580
- handleDownloadWithAnnotations: async () => {
1581
- if (onDownloadWithAnnotations) {
1582
- onDownloadWithAnnotations();
1583
- } else {
1584
- await pdfViewerRef.current?.download?.downloadWithAnnotations?.(resolvedFileName);
1585
- }
1586
- },
1587
- handleDownloadWithoutAnnotations: async () => {
1588
- if (onDownloadWithoutAnnotations) {
1589
- onDownloadWithoutAnnotations();
1590
- } else {
1591
- await pdfViewerRef.current?.download?.downloadWithoutAnnotations?.(resolvedFileName);
1592
- }
1593
- },
1594
- handleHighlighterClick: () => {
1595
- if (highlighterActive) {
1596
- pdfViewerRef.current?.annotation?.deactivateHighlighter();
1597
- setInternalHighlighterActive(false);
1598
- } else {
1599
- if (stampActive) {
1600
- pdfViewerRef.current?.annotation?.deactivateStamp();
1601
- setInternalStampActive(false);
1602
- }
1603
- pdfViewerRef.current?.annotation?.activateHighlighter();
1604
- setInternalHighlighterActive(true);
1605
- }
1606
- },
1607
- handleStampClick: () => {
1608
- if (stampActive) {
1609
- pdfViewerRef.current?.annotation?.deactivateStamp();
1610
- setInternalStampActive(false);
1611
- } else {
1612
- if (highlighterActive) {
1613
- pdfViewerRef.current?.annotation?.deactivateHighlighter();
1614
- setInternalHighlighterActive(false);
1615
- }
1616
- pdfViewerRef.current?.annotation?.activateStamp("");
1617
- setInternalStampActive(true);
1618
- }
1619
- },
1620
- handleSignatureClick: () => {
1621
- },
1622
- handleCopy: () => {
1623
- pdfViewerRef.current?.selection.copy();
1624
- },
1625
- handleToggleFullScreen
1626
- }),
1627
- [isSidebarOpen, totalPages, handleToggleFullScreen, highlighterActive, stampActive, onDownloadWithAnnotations, onDownloadWithoutAnnotations, onPrintWithAnnotations, onPrintWithoutAnnotations]
1628
- );
1629
- useEffect4(() => {
1630
- if (!initialSearchText || hasExecutedInitialSearch.current) return;
1631
- const isPDFReady = state === "ready";
1632
- const isPagesInitialized = totalPages > 0;
1633
- const isViewerAvailable = !!pdfViewerRef.current;
1634
- const isSearchAPIReady = !!pdfViewerRef.current?.search?.searchText;
1635
- const canExecuteSearch = isPDFReady && isPagesInitialized && isViewerAvailable && isSearchAPIReady;
1636
- if (!canExecuteSearch) return;
1637
- hasExecutedInitialSearch.current = true;
1638
- const SEARCH_INITIALIZATION_DELAY = 100;
1639
- setTimeout(() => {
1640
- if (!pdfViewerRef.current?.search?.searchText) {
1641
- hasExecutedInitialSearch.current = false;
1642
- return;
1643
- }
1644
- requestAnimationFrame(() => {
1645
- requestAnimationFrame(() => {
1646
- setIsSidebarOpen(true);
1647
- handleSidebarSearch(initialSearchText, initialSearchPages);
1648
- setAutoExecuteSearch(false);
1649
- });
1650
- });
1651
- }, SEARCH_INITIALIZATION_DELAY);
1652
- }, [
1653
- state,
1654
- totalPages,
1655
- pdfViewerRef.current,
1656
- initialSearchText,
1657
- initialSearchPages
1658
- ]);
1659
- useEffect4(() => {
1660
- setSearchQuery("");
1661
- setSearchResults([]);
1662
- setCurrentSearchResultIndex(0);
1663
- setTotalSearchResults(0);
1664
- setIsSearching(false);
1665
- setIsSidebarOpen(false);
1666
- hasExecutedInitialSearch.current = false;
1667
- setCurrentPage(1);
1668
- setTotalPages(0);
1669
- setZoom(100);
1670
- setState("idle");
1671
- setError(null);
1672
- setPdfBuffer(null);
1673
- }, [file]);
1674
- useEffect4(() => {
1675
- if (state !== "ready") return;
1676
- const container = document.querySelector(
1677
- '[data-pdf-viewer], .embedpdf-viewport, [role="document"]'
1678
- );
1679
- if (container) {
1680
- setPdfContainer(container);
1681
- return;
1682
- }
1683
- const observer = new MutationObserver(() => {
1684
- const foundContainer = document.querySelector(
1685
- '[data-pdf-viewer], .embedpdf-viewport, [role="document"]'
1686
- );
1687
- if (foundContainer) {
1688
- setPdfContainer(foundContainer);
1689
- observer.disconnect();
1690
- }
1691
- });
1692
- observer.observe(document.body, { childList: true, subtree: true });
1693
- return () => observer.disconnect();
1694
- }, [state]);
1695
- useEffect4(() => {
1696
- if (state !== "ready") return;
1697
- const checkInternalReadiness = async () => {
1698
- if (!pdfViewerRef.current) return;
1699
- try {
1700
- const count = pdfViewerRef.current.navigation?.getTotalPages?.();
1701
- if (count && count > 0) {
1702
- setTotalPages(count);
1703
- setIsInternalReady(true);
1704
- return;
1705
- }
1706
- const docInfo = pdfViewerRef.current?.document?.getDocumentInfo?.();
1707
- if (docInfo && docInfo.totalPages > 0) {
1708
- setTotalPages(docInfo.totalPages);
1709
- setIsInternalReady(true);
1710
- return;
1711
- }
1712
- } catch (e) {
1713
- }
1714
- };
1715
- const pollInterval = setInterval(checkInternalReadiness, 100);
1716
- return () => clearInterval(pollInterval);
1717
- }, [state]);
1718
- useEffect4(() => {
1719
- if (state !== "ready" || totalPages > 0) return;
1720
- const initializePageCount = async () => {
1721
- const waitForViewer = async (maxAttempts = 10) => {
1722
- for (let i = 0; i < maxAttempts; i++) {
1723
- if (pdfViewerRef.current) return pdfViewerRef.current;
1724
- await new Promise(
1725
- (resolve) => requestAnimationFrame(
1726
- () => setTimeout(resolve, Math.min(100 * Math.pow(2, i), 1e3))
1727
- )
1728
- );
1729
- }
1730
- return null;
1731
- };
1732
- const viewer = await waitForViewer();
1733
- if (!viewer) return;
1734
- await new Promise((resolve) => requestAnimationFrame(resolve));
1735
- try {
1736
- const count = viewer.navigation?.getTotalPages?.();
1737
- if (count && count > 0) {
1738
- setTotalPages(count);
1739
- setIsInternalReady(true);
1740
- return;
1741
- }
1742
- } catch (e) {
1743
- }
1744
- };
1745
- initializePageCount();
1746
- }, [state, totalPages]);
1747
- useEffect4(() => {
1748
- if (state === "ready") {
1749
- const updateInfo = () => {
1750
- if (!pdfViewerRef.current) return;
1751
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1752
- const docInfo = pdfViewerRef.current?.document?.getDocumentInfo?.();
1753
- const navTotal = pdfViewerRef.current?.navigation?.getTotalPages?.();
1754
- let total = 0;
1755
- if (docInfo && docInfo.totalPages > 0) {
1756
- total = docInfo.totalPages;
1757
- } else if (typeof navTotal === "number" && navTotal > 0) {
1758
- total = navTotal;
1759
- }
1760
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1761
- const currentSearchState = pdfViewerRef.current?.search.getSearchState();
1762
- setCurrentPage(current);
1763
- if (total > 0 && total !== totalPages) {
1764
- setTotalPages(total);
1765
- }
1766
- if (typeof zoomValue === "number") {
1767
- setZoom(Math.round(zoomValue * 100));
1768
- }
1769
- };
1770
- updateInfo();
1771
- const pollInterval = totalPages === 0 ? 50 : 300;
1772
- const interval = setInterval(updateInfo, pollInterval);
1773
- return () => clearInterval(interval);
1774
- }
1775
- }, [state, totalPages]);
1776
- useImperativeHandle(
1777
- ref,
1778
- () => ({
1779
- zoomIn: () => {
1780
- pdfViewerRef.current?.zoom.zoomIn();
1781
- updateZoomDisplay();
1782
- },
1783
- zoomOut: () => {
1784
- pdfViewerRef.current?.zoom.zoomOut();
1785
- updateZoomDisplay();
1786
- },
1787
- setZoom: (level) => {
1788
- pdfViewerRef.current?.zoom.setZoom(level);
1789
- updateZoomDisplay();
1790
- },
1791
- resetZoom: () => {
1792
- pdfViewerRef.current?.zoom.resetZoom();
1793
- updateZoomDisplay();
1794
- },
1795
- getZoom: () => {
1796
- const zoom2 = pdfViewerRef.current?.zoom.getZoom();
1797
- return typeof zoom2 === "number" ? zoom2 : 1;
1798
- },
1799
- goToPage: (page) => {
1800
- pdfViewerRef.current?.navigation.goToPage(page);
1801
- setCurrentPage(page);
1802
- },
1803
- getCurrentPage: () => pdfViewerRef.current?.navigation.getCurrentPage() || 1,
1804
- getTotalPages: () => pdfViewerRef.current?.navigation.getTotalPages() || 0,
1805
- nextPage: () => {
1806
- pdfViewerRef.current?.navigation.nextPage();
1807
- updatePageDisplay();
1808
- },
1809
- previousPage: () => {
1810
- pdfViewerRef.current?.navigation.previousPage();
1811
- updatePageDisplay();
1812
- },
1813
- goToFirstPage: () => {
1814
- pdfViewerRef.current?.navigation.goToFirstPage();
1815
- updatePageDisplay();
1816
- },
1817
- goToLastPage: () => {
1818
- pdfViewerRef.current?.navigation.goToLastPage();
1819
- updatePageDisplay();
1820
- },
1821
- searchText: async (keyword) => {
1822
- setIsSearching(true);
1823
- const results = await pdfViewerRef.current?.search.searchText(
1824
- keyword
1825
- );
1826
- setIsSearching(false);
1827
- setSearchQuery(keyword);
1828
- return results;
1829
- },
1830
- nextResult: () => {
1831
- const index = pdfViewerRef.current?.search.nextResult() || -1;
1832
- return index;
1833
- },
1834
- previousResult: () => {
1835
- const index = pdfViewerRef.current?.search.previousResult() || -1;
1836
- return index;
1837
- },
1838
- goToResult: (index) => pdfViewerRef.current?.search.goToResult(index) || -1,
1839
- stopSearch: () => {
1840
- pdfViewerRef.current?.search.stopSearch();
1841
- setSearchQuery("");
1842
- },
1843
- getSearchState: () => pdfViewerRef.current?.search.getSearchState() || null,
1844
- getSelectedText: async () => {
1845
- return await pdfViewerRef.current?.selection.getSelectedText() || "";
1846
- },
1847
- clearSelection: () => pdfViewerRef.current?.selection.clearSelection(),
1848
- copy: () => pdfViewerRef.current?.selection.copy(),
1849
- rotateForward: () => pdfViewerRef.current?.rotate?.rotateForward(),
1850
- rotateBackward: () => pdfViewerRef.current?.rotate?.rotateBackward(),
1851
- getRotation: () => pdfViewerRef.current?.rotate?.getRotation() || 0,
1852
- print: () => pdfViewerRef.current?.print?.print(),
1853
- printWithAnnotations: async () => {
1854
- await pdfViewerRef.current?.print?.printWithAnnotations?.();
1855
- },
1856
- printWithoutAnnotations: async () => {
1857
- await pdfViewerRef.current?.print?.printWithoutAnnotations?.();
1858
- },
1859
- downloadWithAnnotations: async (filename) => {
1860
- await pdfViewerRef.current?.download?.downloadWithAnnotations?.(filename);
1861
- },
1862
- downloadWithoutAnnotations: async (filename) => {
1863
- await pdfViewerRef.current?.download?.downloadWithoutAnnotations?.(filename);
1864
- },
1865
- get annotation() {
1866
- return pdfViewerRef.current?.annotation;
1867
- },
1868
- get download() {
1869
- return pdfViewerRef.current?.download;
1870
- }
1871
- }),
1872
- []
1873
- );
1874
- const updatePageDisplay = () => {
1875
- requestAnimationFrame(() => {
1876
- const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1877
- setCurrentPage(current);
1878
- });
1879
- };
1880
- const updateZoomDisplay = () => {
1881
- requestAnimationFrame(() => {
1882
- const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1883
- if (typeof zoomValue === "number") {
1884
- setZoom(Math.round(zoomValue * 100));
1885
- }
1886
- });
1887
- };
1888
- const handleSearch = async () => {
1889
- if (!searchQuery.trim()) return;
1890
- setIsSearching(true);
1891
- const results = await pdfViewerRef.current?.search.searchText(
1892
- searchQuery
1893
- );
1894
- setIsSearching(false);
1895
- if (results?.results && Array.isArray(results.results) && results.results.length > 0) {
1896
- const formattedResults = formatSearchResults(results.results);
1897
- updateSearchState(formattedResults);
1898
- } else {
1899
- clearSearchResults();
1900
- }
1901
- };
1902
- const handleSearchKeyPress = (e) => {
1903
- if (e.key === "Enter") {
1904
- handleSearch();
1905
- }
1906
- };
1907
- const handleSidebarSearch = async (keyword, pageNumbers) => {
1908
- setSearchQuery(keyword);
1909
- if (!keyword.trim()) {
1910
- setSearchResults([]);
1911
- setTotalSearchResults(0);
1912
- setCurrentSearchResultIndex(0);
1913
- pdfViewerRef.current?.search.stopSearch();
1914
- return;
1915
- }
1916
- if (!pdfViewerRef.current?.search?.searchText) {
1917
- console.warn("Search functionality not yet available");
1918
- return;
1919
- }
1920
- setIsSearching(true);
1921
- try {
1922
- const results = await pdfViewerRef.current.search.searchText(keyword);
1923
- setIsSearching(false);
1924
- const hasValidResults = results?.results && Array.isArray(results.results) && results.results.length > 0;
1925
- if (hasValidResults) {
1926
- const formattedResults = formatSearchResults(results.results);
1927
- updateSearchState(formattedResults);
1928
- navigateToFirstResult(formattedResults);
1929
- } else if (pageNumbers && pageNumbers.length > 0) {
1930
- const fallbackResults = createFallbackResults(pageNumbers, keyword);
1931
- updateSearchState(fallbackResults);
1932
- navigateToPage(pageNumbers[0]);
1933
- } else {
1934
- clearSearchResults();
1935
- }
1936
- } catch (error2) {
1937
- console.error("Search failed:", error2);
1938
- setIsSearching(false);
1939
- clearSearchResults();
1940
- }
1941
- };
1942
- const formatSearchResults = (results) => {
1943
- return results.map((result, index) => {
1944
- let textContent = "";
1945
- let contextContent = "";
1946
- if (result.context && typeof result.context === "object") {
1947
- const { before = "", match = "", after = "" } = result.context;
1948
- textContent = match;
1949
- contextContent = `${before}${match}${after}`;
1950
- } else if (typeof result === "string") {
1951
- textContent = result;
1952
- contextContent = result;
1953
- } else {
1954
- textContent = String(result.match || result.text || "");
1955
- contextContent = textContent;
1956
- }
1957
- return {
1958
- pageNumber: (result.pageIndex ?? result.pageNumber ?? 0) + 1,
1959
- text: textContent,
1960
- context: contextContent,
1961
- index
1962
- };
1963
- });
1964
- };
1965
- const createFallbackResults = (pageNumbers, keyword) => {
1966
- return pageNumbers.map((pageNum, index) => ({
1967
- pageNumber: pageNum,
1968
- text: keyword,
1969
- context: `"${keyword}" found on this page ${pageNum}`,
1970
- index
1971
- }));
1972
- };
1973
- const updateSearchState = (results) => {
1974
- setSearchResults(results);
1975
- setTotalSearchResults(results.length);
1976
- setCurrentSearchResultIndex(0);
1977
- };
1978
- const clearSearchResults = () => {
1979
- setSearchResults([]);
1980
- setTotalSearchResults(0);
1981
- setCurrentSearchResultIndex(0);
1982
- };
1983
- const navigateToFirstResult = (results) => {
1984
- if (results.length > 0) {
1985
- navigateToPage(results[0].pageNumber);
1986
- }
1987
- };
1988
- const navigateToPage = (pageNumber) => {
1989
- requestAnimationFrame(() => {
1990
- pdfViewerRef.current?.navigation.goToPage(pageNumber);
1991
- setCurrentPage(pageNumber);
1992
- });
1993
- };
1994
- const handleSearchResultClick = (pageNumber, resultIndex) => {
1995
- pdfViewerRef.current?.navigation.goToPage(pageNumber);
1996
- setCurrentSearchResultIndex(resultIndex);
1997
- setCurrentPage(pageNumber);
1998
- pdfViewerRef.current?.search.goToResult(resultIndex);
1999
- };
2000
- const handleNextSearchResult = () => {
2001
- if (currentSearchResultIndex < totalSearchResults - 1) {
2002
- const nextIndex = currentSearchResultIndex + 1;
2003
- setCurrentSearchResultIndex(nextIndex);
2004
- pdfViewerRef.current?.search.nextResult();
2005
- if (searchResults[nextIndex]) {
2006
- const pageNumber = searchResults[nextIndex].pageNumber;
2007
- pdfViewerRef.current?.navigation.goToPage(pageNumber);
2008
- setCurrentPage(pageNumber);
2009
- }
2010
- }
2011
- };
2012
- const handlePreviousSearchResult = () => {
2013
- if (currentSearchResultIndex > 0) {
2014
- const prevIndex = currentSearchResultIndex - 1;
2015
- setCurrentSearchResultIndex(prevIndex);
2016
- pdfViewerRef.current?.search.previousResult();
2017
- if (searchResults[prevIndex]) {
2018
- const pageNumber = searchResults[prevIndex].pageNumber;
2019
- pdfViewerRef.current?.navigation.goToPage(pageNumber);
2020
- setCurrentPage(pageNumber);
2021
- }
2022
- }
2023
- };
2024
- useEffect4(() => {
2025
- if (!file) {
2026
- setState("error");
2027
- setError("No file provided");
2028
- return;
2029
- }
2030
- const loadPDF = async () => {
2031
- try {
2032
- setState("loading");
2033
- setError(null);
2034
- let arrayBuffer;
2035
- if (file instanceof File) {
2036
- arrayBuffer = await file.arrayBuffer();
2037
- } else if (typeof file === "string") {
2038
- const response = await fetch(file);
2039
- if (!response.ok) {
2040
- throw new Error(`Failed to load PDF: ${response.statusText}`);
2041
- }
2042
- arrayBuffer = await response.arrayBuffer();
2043
- } else if (file instanceof ArrayBuffer) {
2044
- arrayBuffer = file;
2045
- } else {
2046
- throw new Error("Unsupported file type");
2047
- }
2048
- setPdfBuffer(arrayBuffer);
2049
- setState("ready");
2050
- onLoad?.();
2051
- } catch (err) {
2052
- const errorMessage = err.message || "Failed to load PDF";
2053
- setState("error");
2054
- setError(errorMessage);
2055
- onError?.(err);
2056
- }
2057
- };
2058
- loadPDF();
2059
- }, [file, onLoad, onError]);
2060
- const handlePasswordRequest = useCallback(
2061
- async (fileName2, isRetry) => {
2062
- return new Promise((resolve) => {
2063
- setPasswordResolve(() => resolve);
2064
- if (isRetry) {
2065
- setPasswordError("Incorrect password. Please try again.");
2066
- } else {
2067
- setPasswordError("");
2068
- }
2069
- setIsPasswordDialogOpen(true);
2070
- });
2071
- },
2072
- []
2073
- );
2074
- const handlePasswordSubmit = useCallback(
2075
- (password) => {
2076
- if (passwordResolve) {
2077
- passwordResolve(password);
2078
- }
2079
- setIsPasswordDialogOpen(false);
2080
- setPasswordResolve(null);
2081
- setPasswordError("");
2082
- },
2083
- [passwordResolve]
2084
- );
2085
- const handlePasswordCancel = useCallback(() => {
2086
- if (passwordResolve) {
2087
- passwordResolve(null);
2088
- setPasswordResolve(null);
2089
- setIsPasswordDialogOpen(false);
2090
- setPasswordError("");
2091
- }
2092
- }, [passwordResolve]);
2093
- const LoadingSpinner = ({ fileName: fileName2 }) => /* @__PURE__ */ jsxs5("div", { style: {
2094
- position: "absolute",
2095
- inset: 0,
2096
- zIndex: 50,
2097
- backgroundColor: "#fff",
2098
- display: "flex",
2099
- flexDirection: "column",
2100
- alignItems: "center",
2101
- justifyContent: "center"
2102
- }, children: [
2103
- /* @__PURE__ */ jsx6("div", { className: "dms-loading-spinner", style: {
2104
- width: "40px",
2105
- height: "40px",
2106
- border: "3px solid #f3f3f3",
2107
- borderTop: "3px solid #3498db",
2108
- borderRadius: "50%",
2109
- animation: "spin 1s linear infinite"
2110
- } }),
2111
- fileName2 && /* @__PURE__ */ jsxs5("p", { style: { marginTop: "16px", color: "#666", fontSize: "14px" }, children: [
2112
- "Loading ",
2113
- fileName2,
2114
- "..."
2115
- ] }),
2116
- /* @__PURE__ */ jsx6("style", { children: `@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }` })
2117
- ] });
2118
- if (state === "error" || error) {
2119
- return /* @__PURE__ */ jsx6(
2120
- "div",
2121
- {
2122
- style: {
2123
- display: "flex",
2124
- flexDirection: "column",
2125
- alignItems: "center",
2126
- justifyContent: "center",
2127
- height: "100%",
2128
- padding: "24px"
2129
- },
2130
- children: /* @__PURE__ */ jsxs5(
2131
- "div",
2132
- {
2133
- style: {
2134
- maxWidth: "400px",
2135
- padding: "16px",
2136
- backgroundColor: "#fee",
2137
- border: "1px solid #fcc",
2138
- borderRadius: "4px"
2139
- },
2140
- children: [
2141
- /* @__PURE__ */ jsx6("h3", { style: { marginTop: 0 }, children: "Failed to Load PDF" }),
2142
- /* @__PURE__ */ jsx6("p", { children: error || "Unknown error occurred" })
2143
- ]
2144
- }
2145
- )
2146
- }
2147
- );
2148
- }
2149
- const isReady = pdfBuffer && state === "ready";
2150
- const showOverlay = loading || !isReady || !isInternalReady;
2151
- return /* @__PURE__ */ jsxs5("div", { ref: containerRef, className: "pdf-viewer-container", style: { position: "relative", height: "100%", width: "100%" }, children: [
2152
- /* @__PURE__ */ jsx6("style", { children: toolbarStyles }),
2153
- showOverlay && /* @__PURE__ */ jsx6(LoadingSpinner, { fileName: resolvedFileName }),
2154
- /* @__PURE__ */ jsxs5("div", { style: { opacity: !showOverlay ? 1 : 0, height: "100%", display: "flex", flexDirection: "column" }, children: [
2155
- /* @__PURE__ */ jsx6(PDFHeader, { fileName: resolvedFileName, fileExtension }),
2156
- /* @__PURE__ */ jsx6(
2157
- PDFToolbar,
2158
- {
2159
- currentPage,
2160
- totalPages,
2161
- zoom,
2162
- isSidebarOpen,
2163
- showPageNavigation,
2164
- showPageCount,
2165
- showZoomControls,
2166
- showSearch,
2167
- showRotation: !toolbar.isHidden("rotation"),
2168
- showMetadata: !toolbar.isHidden("metadata"),
2169
- showProperties: !toolbar.isHidden("properties"),
2170
- showDownload: !toolbar.isHidden("download"),
2171
- showPrint: !toolbar.isHidden("print"),
2172
- showTags: !toolbar.isHidden("tags"),
2173
- showHistory: !toolbar.isHidden("history"),
2174
- disabledRotateLeft: toolbar.isDisabled("rotateLeft"),
2175
- disabledRotateRight: false,
2176
- disabledMetadata: toolbar.isDisabled("metadata"),
2177
- disabledTags: toolbar.isDisabled("tags"),
2178
- disabledProperties: toolbar.isDisabled("properties"),
2179
- disabledHistory: toolbar.isDisabled("history"),
2180
- disabledDownload: toolbar.isDisabled("download"),
2181
- disabledPrint: toolbar.isDisabled("print"),
2182
- onFirstPage: toolbarHandlers.handleFirstPage,
2183
- onPreviousPage: toolbarHandlers.handlePreviousPage,
2184
- onNextPage: toolbarHandlers.handleNextPage,
2185
- onLastPage: toolbarHandlers.handleLastPage,
2186
- onPageInput: toolbarHandlers.handlePageInput,
2187
- onPageInputKeyPress: toolbarHandlers.handlePageInputKeyPress,
2188
- onZoomIn: toolbarHandlers.handleZoomIn,
2189
- onZoomOut: toolbarHandlers.handleZoomOut,
2190
- onFitToWidth: toolbarHandlers.handleFitToWidth,
2191
- onFitToPage: toolbarHandlers.handleFitToPage,
2192
- onToggleSidebar: toolbarHandlers.toggleSidebar,
2193
- onToggleFullScreen: toolbarHandlers.handleToggleFullScreen,
2194
- onRotateLeft: toolbarHandlers.handleRotateLeft,
2195
- onRotateRight: toolbarHandlers.handleRotateRight,
2196
- onDownloadClick: toolbar.getHandler("download", onDownloadClick),
2197
- onDownloadWithAnnotations: toolbarHandlers.handleDownloadWithAnnotations,
2198
- onDownloadWithoutAnnotations: toolbarHandlers.handleDownloadWithoutAnnotations,
2199
- onPrintClick: toolbar.getHandler("print", onPrintClick || toolbarHandlers.handlePrint),
2200
- onPrintWithAnnotations: toolbarHandlers.handlePrintWithAnnotations,
2201
- onPrintWithoutAnnotations: toolbarHandlers.handlePrintWithoutAnnotations,
2202
- onCopyClick: toolbarHandlers.handleCopy,
2203
- onMetadataClick: toolbar.getHandler("metadata", onMetadataClick),
2204
- onPropertiesClick: toolbar.getHandler(
2205
- "properties",
2206
- onPropertiesClick
2207
- ),
2208
- onTagsClick: toolbar.getHandler("tags", onTagsClick),
2209
- onHistoryClick: toolbar.getHandler("history", onHistoryClick),
2210
- showAnnotations,
2211
- isHighlighterActive: highlighterActive,
2212
- isStampActive: stampActive,
2213
- disabledHighlighter: toolbar.isDisabled("highlighter"),
2214
- disabledStamp: toolbar.isDisabled("stamp"),
2215
- disabledSignature: toolbar.isDisabled("signature"),
2216
- disabledNote: toolbar.isDisabled("note"),
2217
- onHighlighterClick: toolbar.getHandler("highlighter", onHighlighterClick || toolbarHandlers.handleHighlighterClick),
2218
- onStampClick: toolbar.getHandler("stamp", onStampClick || toolbarHandlers.handleStampClick),
2219
- onSignatureClick: toolbar.getHandler("signature", onSignatureClick || toolbarHandlers.handleSignatureClick),
2220
- onNoteClick: toolbar.getHandler("note", onNoteClick),
2221
- showAnnotate,
2222
- disabledAnnotate,
2223
- showPrintOriginal,
2224
- showPrintWithAnnotations,
2225
- showDownloadOriginal,
2226
- showDownloadWithAnnotations,
2227
- hasUnsavedAnnotations,
2228
- isSavingAnnotations,
2229
- canSaveAnnotations,
2230
- onSaveAnnotations
2231
- }
2232
- ),
2233
- /* @__PURE__ */ jsxs5("div", { className: "pdf-viewer-main", children: [
2234
- /* @__PURE__ */ jsx6("div", { className: "pdf-viewer-viewer-area", children: /* @__PURE__ */ jsx6(
2235
- StablePDFViewer,
2236
- {
2237
- pdfBuffer: pdfBuffer || new ArrayBuffer(0),
2238
- onPasswordRequest: handlePasswordRequest,
2239
- pdfViewerRef,
2240
- hideInternalLoading: true,
2241
- showAnnotations,
2242
- userDetails,
2243
- annotationSelectionMenu,
2244
- isHighlighterActive: highlighterActive,
2245
- isStampActive: stampActive,
2246
- onHighlighterClick: onHighlighterClick || toolbarHandlers.handleHighlighterClick,
2247
- onStampClick: onStampClick || toolbarHandlers.handleStampClick,
2248
- onSignatureClick: onSignatureClick || toolbarHandlers.handleSignatureClick,
2249
- onNoteClick,
2250
- permissions: props.permissions,
2251
- isAnnotationForeign,
2252
- onAnnotationNoteClick,
2253
- isAnnotationInteractive
2254
- }
2255
- ) }),
2256
- /* @__PURE__ */ jsx6(
2257
- SearchSidebar,
2258
- {
2259
- isOpen: isSidebarOpen,
2260
- onClose: handleSidebarClose,
2261
- onSearch: handleSidebarSearch,
2262
- onSearchResultClick: handleSearchResultClick,
2263
- onNextResult: handleNextSearchResult,
2264
- onPreviousResult: handlePreviousSearchResult,
2265
- currentResultIndex: currentSearchResultIndex,
2266
- totalResults: totalSearchResults,
2267
- searchKeyword: searchQuery,
2268
- searchResults,
2269
- isSearching
2270
- }
2271
- )
2272
- ] }),
2273
- /* @__PURE__ */ jsx6(
2274
- PasswordDialog,
2275
- {
2276
- open: isPasswordDialogOpen,
2277
- fileName: resolvedFileName,
2278
- onSubmit: handlePasswordSubmit,
2279
- onCancel: handlePasswordCancel,
2280
- error: passwordError,
2281
- isLoading: isVerifyingPassword
2282
- }
2283
- )
2284
- ] })
2285
- ] });
2286
- }
2287
- );
2288
- PDFViewerContent.displayName = "PDFViewerContent";
2289
- var PDFViewer = forwardRef(
2290
- (props, ref) => {
2291
- return /* @__PURE__ */ jsx6(PDFViewerContent, { ...props, sourceDescription: "doc.pdf", ref });
2292
- }
2293
- );
2294
- PDFViewer.displayName = "PDFViewer";
2295
-
2296
- export {
2297
- PDFViewer
2298
- };
2299
- //# sourceMappingURL=chunk-PZGUVU6N.mjs.map