@cannyminds/dms-file-viewers 0.19.0 → 0.21.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 (43) hide show
  1. package/dist/{chunk-RTQRDZSN.js → chunk-26SS5FLZ.js} +683 -358
  2. package/dist/chunk-26SS5FLZ.js.map +1 -0
  3. package/dist/{chunk-ZTKUXLTZ.mjs → chunk-4XX5VZA2.mjs} +2 -2
  4. package/dist/chunk-5ECHDPQZ.js +425 -0
  5. package/dist/chunk-5ECHDPQZ.js.map +1 -0
  6. package/dist/{chunk-TOGDBQAN.js → chunk-AVQCUOWM.js} +4 -4
  7. package/dist/{chunk-TOGDBQAN.js.map → chunk-AVQCUOWM.js.map} +1 -1
  8. package/dist/{chunk-TQXRQCS4.mjs → chunk-IY5EEUCU.mjs} +655 -330
  9. package/dist/chunk-IY5EEUCU.mjs.map +1 -0
  10. package/dist/chunk-UVF6YOXY.mjs +425 -0
  11. package/dist/chunk-UVF6YOXY.mjs.map +1 -0
  12. package/dist/components/viewers/AudioViewer.d.mts +1 -1
  13. package/dist/components/viewers/AudioViewer.d.ts +1 -1
  14. package/dist/components/viewers/DefaultViewer.d.mts +1 -1
  15. package/dist/components/viewers/DefaultViewer.d.ts +1 -1
  16. package/dist/components/viewers/ImageViewer.d.mts +1 -1
  17. package/dist/components/viewers/ImageViewer.d.ts +1 -1
  18. package/dist/components/viewers/ImageViewer.js +3 -3
  19. package/dist/components/viewers/ImageViewer.mjs +2 -2
  20. package/dist/components/viewers/PDFViewer.d.mts +18 -1
  21. package/dist/components/viewers/PDFViewer.d.ts +18 -1
  22. package/dist/components/viewers/PDFViewer.js +3 -3
  23. package/dist/components/viewers/PDFViewer.mjs +2 -2
  24. package/dist/components/viewers/TIFFViewer.d.mts +1 -1
  25. package/dist/components/viewers/TIFFViewer.d.ts +1 -1
  26. package/dist/components/viewers/TextViewer.d.mts +1 -1
  27. package/dist/components/viewers/TextViewer.d.ts +1 -1
  28. package/dist/components/viewers/VideoViewer.d.mts +1 -1
  29. package/dist/components/viewers/VideoViewer.d.ts +1 -1
  30. package/dist/index.d.mts +3 -3
  31. package/dist/index.d.ts +3 -3
  32. package/dist/index.js +4 -4
  33. package/dist/index.mjs +3 -3
  34. package/dist/{types-DM0RG-Yu.d.mts → types-DFkMK86Q.d.mts} +18 -1
  35. package/dist/{types-DM0RG-Yu.d.ts → types-DFkMK86Q.d.ts} +18 -1
  36. package/package.json +45 -45
  37. package/dist/chunk-GMD6QQLG.js +0 -154
  38. package/dist/chunk-GMD6QQLG.js.map +0 -1
  39. package/dist/chunk-PPELANB4.mjs +0 -154
  40. package/dist/chunk-PPELANB4.mjs.map +0 -1
  41. package/dist/chunk-RTQRDZSN.js.map +0 -1
  42. package/dist/chunk-TQXRQCS4.mjs.map +0 -1
  43. /package/dist/{chunk-ZTKUXLTZ.mjs.map → chunk-4XX5VZA2.mjs.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  toolbarStyles
4
- } from "./chunk-PPELANB4.mjs";
4
+ } from "./chunk-UVF6YOXY.mjs";
5
5
  import {
6
6
  getFileExtension
7
7
  } from "./chunk-M57PSU4O.mjs";
@@ -13,10 +13,10 @@ import {
13
13
  // src/components/viewers/PDFViewer.tsx
14
14
  import {
15
15
  useCallback,
16
- useEffect as useEffect3,
16
+ useEffect as useEffect4,
17
17
  useMemo,
18
- useRef as useRef2,
19
- useState as useState3,
18
+ useRef as useRef3,
19
+ useState as useState4,
20
20
  forwardRef,
21
21
  useImperativeHandle
22
22
  } from "react";
@@ -29,29 +29,49 @@ var HeadlessPDFViewer = HeadlessPDFViewerImport;
29
29
  var StablePDFViewer = React.memo(({
30
30
  pdfBuffer,
31
31
  onPasswordRequest,
32
- pdfViewerRef
32
+ pdfViewerRef,
33
+ showAnnotations,
34
+ userDetails,
35
+ annotationSelectionMenu,
36
+ isHighlighterActive,
37
+ isStampActive,
38
+ onHighlighterClick,
39
+ onStampClick,
40
+ onSignatureClick,
41
+ permissions
33
42
  }) => {
34
43
  return /* @__PURE__ */ jsx(
35
44
  HeadlessPDFViewer,
36
45
  {
37
46
  ref: pdfViewerRef,
38
47
  pdfBuffer,
39
- onPasswordRequest
48
+ onPasswordRequest,
49
+ showAnnotations,
50
+ userDetails,
51
+ annotationSelectionMenu: annotationSelectionMenu || [],
52
+ isHighlighterActive,
53
+ isStampActive,
54
+ onHighlighterClick,
55
+ onStampClick,
56
+ onSignatureClick,
57
+ permissions
40
58
  }
41
59
  );
42
60
  });
43
61
  StablePDFViewer.displayName = "StablePDFViewer";
44
62
 
45
63
  // src/components/viewers/pdf/PDFToolbar.tsx
46
- import React2 from "react";
64
+ import React2, { useState, useRef, useEffect } from "react";
65
+ import { Tooltip } from "@mui/material";
47
66
  import FirstPageIcon from "@mui/icons-material/FirstPage";
48
67
  import LastPageIcon from "@mui/icons-material/LastPage";
49
68
  import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
50
69
  import ChevronRightIcon from "@mui/icons-material/ChevronRight";
51
- import ZoomInIcon from "@mui/icons-material/ZoomIn";
52
- import ZoomOutIcon from "@mui/icons-material/ZoomOut";
70
+ import RemoveIcon from "@mui/icons-material/Remove";
71
+ import AddIcon from "@mui/icons-material/Add";
53
72
  import FitScreenIcon from "@mui/icons-material/FitScreen";
54
73
  import AspectRatioIcon from "@mui/icons-material/AspectRatio";
74
+ import TuneIcon from "@mui/icons-material/Tune";
55
75
  import SearchIcon from "@mui/icons-material/Search";
56
76
  import FullscreenIcon from "@mui/icons-material/Fullscreen";
57
77
  import DownloadIcon from "@mui/icons-material/Download";
@@ -62,6 +82,13 @@ import RotateLeftIcon from "@mui/icons-material/RotateLeft";
62
82
  import RotateRightIcon from "@mui/icons-material/RotateRight";
63
83
  import HistoryIcon from "@mui/icons-material/History";
64
84
  import { LocalOffer } from "@mui/icons-material";
85
+ import HighlightIcon from "@mui/icons-material/Highlight";
86
+ import DrawIcon from "@mui/icons-material/Draw";
87
+ import ApprovalIcon from "@mui/icons-material/Approval";
88
+ import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
89
+ import PortraitIcon from "@mui/icons-material/Portrait";
90
+ import SwapVertIcon from "@mui/icons-material/SwapVert";
91
+ import AutoFixHighIcon from "@mui/icons-material/AutoFixHigh";
65
92
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
66
93
  var PDFToolbar = React2.memo(
67
94
  ({
@@ -80,6 +107,9 @@ var PDFToolbar = React2.memo(
80
107
  showDownload,
81
108
  showPrint,
82
109
  showRotation,
110
+ showAnnotations,
111
+ isHighlighterActive,
112
+ isStampActive,
83
113
  disabledRotateLeft,
84
114
  disabledRotateRight,
85
115
  disabledMetadata,
@@ -88,6 +118,9 @@ var PDFToolbar = React2.memo(
88
118
  disabledHistory,
89
119
  disabledDownload,
90
120
  disabledPrint,
121
+ disabledHighlighter,
122
+ disabledStamp,
123
+ disabledSignature,
91
124
  onFirstPage,
92
125
  onPreviousPage,
93
126
  onNextPage,
@@ -104,234 +137,412 @@ var PDFToolbar = React2.memo(
104
137
  onRotateRight,
105
138
  onDownloadClick,
106
139
  onPrintClick,
140
+ onPrintWithAnnotations,
141
+ onPrintWithoutAnnotations,
107
142
  onMetadataClick,
108
143
  onPropertiesClick,
109
144
  onTagsClick,
110
- onHistoryClick
145
+ onHistoryClick,
146
+ onHighlighterClick,
147
+ onStampClick,
148
+ onSignatureClick,
149
+ // Save functionality
150
+ hasUnsavedAnnotations,
151
+ isSavingAnnotations,
152
+ canSaveAnnotations,
153
+ onSaveAnnotations
111
154
  }) => {
112
- return /* @__PURE__ */ jsxs("div", { className: "pdf-viewer-toolbar", children: [
113
- showPageNavigation && /* @__PURE__ */ jsxs(Fragment, { children: [
114
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
115
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
116
- /* @__PURE__ */ jsx2(
117
- "button",
118
- {
119
- className: "toolbar-button",
120
- onClick: onFirstPage,
121
- disabled: currentPage <= 1,
122
- title: "First Page",
123
- children: /* @__PURE__ */ jsx2(FirstPageIcon, { fontSize: "small" })
124
- }
125
- ),
126
- /* @__PURE__ */ jsx2(
127
- "button",
128
- {
129
- className: "toolbar-button",
130
- onClick: onPreviousPage,
131
- disabled: currentPage <= 1,
132
- title: "Previous Page",
133
- children: /* @__PURE__ */ jsx2(ChevronLeftIcon, { fontSize: "small" })
134
- }
135
- ),
136
- /* @__PURE__ */ jsx2(
137
- "input",
138
- {
139
- type: "number",
140
- className: "page-input",
141
- value: currentPage,
142
- onChange: onPageInput,
143
- onKeyPress: onPageInputKeyPress,
144
- min: 1,
145
- max: totalPages || void 0
146
- }
147
- ),
148
- showPageCount && /* @__PURE__ */ jsxs("span", { className: "page-info", children: [
149
- "of ",
150
- totalPages || "..."
155
+ const [isPrintMenuOpen, setIsPrintMenuOpen] = useState(false);
156
+ const [isAnnotationMenuOpen, setIsAnnotationMenuOpen] = useState(false);
157
+ const [isViewMenuOpen, setIsViewMenuOpen] = useState(false);
158
+ const printMenuRef = useRef(null);
159
+ const annotationMenuRef = useRef(null);
160
+ const viewMenuRef = useRef(null);
161
+ useEffect(() => {
162
+ const handleClickOutside = (event) => {
163
+ if (printMenuRef.current && !printMenuRef.current.contains(event.target)) {
164
+ setIsPrintMenuOpen(false);
165
+ }
166
+ if (annotationMenuRef.current && !annotationMenuRef.current.contains(event.target)) {
167
+ setIsAnnotationMenuOpen(false);
168
+ }
169
+ if (viewMenuRef.current && !viewMenuRef.current.contains(event.target)) {
170
+ setIsViewMenuOpen(false);
171
+ }
172
+ };
173
+ document.addEventListener("mousedown", handleClickOutside);
174
+ return () => document.removeEventListener("mousedown", handleClickOutside);
175
+ }, []);
176
+ const handlePrintWithAnnotations = () => {
177
+ setIsPrintMenuOpen(false);
178
+ onPrintWithAnnotations?.();
179
+ };
180
+ const handlePrintWithoutAnnotations = () => {
181
+ setIsPrintMenuOpen(false);
182
+ onPrintWithoutAnnotations?.();
183
+ };
184
+ const [activeMode, setActiveMode] = useState("view");
185
+ return /* @__PURE__ */ jsxs("div", { className: "pdf-viewer-toolbar-container", children: [
186
+ /* @__PURE__ */ jsxs("div", { className: "pdf-viewer-toolbar", children: [
187
+ /* @__PURE__ */ jsxs("div", { className: "toolbar-left", children: [
188
+ showPageNavigation && /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
189
+ /* @__PURE__ */ jsx2(Tooltip, { title: "First Page", children: /* @__PURE__ */ jsx2(
190
+ "button",
191
+ {
192
+ className: "toolbar-button",
193
+ onClick: onFirstPage,
194
+ disabled: currentPage <= 1,
195
+ children: /* @__PURE__ */ jsx2(FirstPageIcon, { fontSize: "small" })
196
+ }
197
+ ) }),
198
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Previous Page", children: /* @__PURE__ */ jsx2(
199
+ "button",
200
+ {
201
+ className: "toolbar-button",
202
+ onClick: onPreviousPage,
203
+ disabled: currentPage <= 1,
204
+ children: /* @__PURE__ */ jsx2(ChevronLeftIcon, { fontSize: "small" })
205
+ }
206
+ ) }),
207
+ /* @__PURE__ */ jsx2(
208
+ "input",
209
+ {
210
+ type: "number",
211
+ className: "page-input",
212
+ value: currentPage,
213
+ onChange: onPageInput,
214
+ onKeyPress: onPageInputKeyPress,
215
+ min: 1,
216
+ max: totalPages || void 0
217
+ }
218
+ ),
219
+ showPageCount && /* @__PURE__ */ jsxs("span", { className: "page-info", children: [
220
+ "/ ",
221
+ totalPages || "..."
222
+ ] }),
223
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Next Page", children: /* @__PURE__ */ jsx2(
224
+ "button",
225
+ {
226
+ className: "toolbar-button",
227
+ onClick: onNextPage,
228
+ disabled: currentPage >= totalPages,
229
+ children: /* @__PURE__ */ jsx2(ChevronRightIcon, { fontSize: "small" })
230
+ }
231
+ ) }),
232
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Last Page", children: /* @__PURE__ */ jsx2(
233
+ "button",
234
+ {
235
+ className: "toolbar-button",
236
+ onClick: onLastPage,
237
+ disabled: currentPage >= totalPages,
238
+ children: /* @__PURE__ */ jsx2(LastPageIcon, { fontSize: "small" })
239
+ }
240
+ ) })
151
241
  ] }),
152
- /* @__PURE__ */ jsx2(
153
- "button",
154
- {
155
- className: "toolbar-button",
156
- onClick: onNextPage,
157
- disabled: currentPage >= totalPages,
158
- title: "Next Page",
159
- children: /* @__PURE__ */ jsx2(ChevronRightIcon, { fontSize: "small" })
160
- }
161
- ),
162
- /* @__PURE__ */ jsx2(
163
- "button",
164
- {
165
- className: "toolbar-button",
166
- onClick: onLastPage,
167
- disabled: currentPage >= totalPages,
168
- title: "Last Page",
169
- children: /* @__PURE__ */ jsx2(LastPageIcon, { fontSize: "small" })
170
- }
171
- )
172
- ] })
173
- ] }),
174
- showZoomControls && /* @__PURE__ */ jsxs(Fragment, { children: [
175
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
176
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
177
- /* @__PURE__ */ jsx2(
178
- "button",
179
- {
180
- className: "toolbar-button",
181
- onClick: onZoomOut,
182
- title: "Zoom Out",
183
- children: /* @__PURE__ */ jsx2(ZoomOutIcon, { fontSize: "small" })
184
- }
185
- ),
186
- /* @__PURE__ */ jsxs("span", { className: "zoom-display", children: [
187
- zoom,
188
- "%"
242
+ showZoomControls && /* @__PURE__ */ jsxs(Fragment, { children: [
243
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
244
+ /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
245
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Zoom Out", children: /* @__PURE__ */ jsx2(
246
+ "button",
247
+ {
248
+ className: "toolbar-button",
249
+ onClick: onZoomOut,
250
+ children: /* @__PURE__ */ jsx2(RemoveIcon, { fontSize: "small" })
251
+ }
252
+ ) }),
253
+ /* @__PURE__ */ jsxs("span", { className: "zoom-display", children: [
254
+ zoom,
255
+ "%"
256
+ ] }),
257
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Zoom In", children: /* @__PURE__ */ jsx2(
258
+ "button",
259
+ {
260
+ className: "toolbar-button",
261
+ onClick: onZoomIn,
262
+ children: /* @__PURE__ */ jsx2(AddIcon, { fontSize: "small" })
263
+ }
264
+ ) })
265
+ ] })
189
266
  ] }),
267
+ (showZoomControls || showRotation) && /* @__PURE__ */ jsxs(Fragment, { children: [
268
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
269
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-section", children: /* @__PURE__ */ jsxs("div", { className: "toolbar-dropdown-container", ref: viewMenuRef, children: [
270
+ /* @__PURE__ */ jsx2(Tooltip, { title: "View Options", children: /* @__PURE__ */ jsxs(
271
+ "button",
272
+ {
273
+ className: `toolbar-button toolbar-dropdown-button ${isViewMenuOpen ? "toolbar-button-active" : ""}`,
274
+ onClick: () => setIsViewMenuOpen(!isViewMenuOpen),
275
+ children: [
276
+ /* @__PURE__ */ jsx2(TuneIcon, { fontSize: "small" }),
277
+ /* @__PURE__ */ jsx2(KeyboardArrowDownIcon, { fontSize: "small", style: { marginLeft: -4 } })
278
+ ]
279
+ }
280
+ ) }),
281
+ isViewMenuOpen && /* @__PURE__ */ jsxs("div", { className: "toolbar-dropdown-menu", style: { width: "240px" }, children: [
282
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-header", children: "SPREAD MODE" }),
283
+ /* @__PURE__ */ jsxs("button", { className: "toolbar-dropdown-item toolbar-dropdown-item-active", onClick: () => setIsViewMenuOpen(false), children: [
284
+ /* @__PURE__ */ jsx2(PortraitIcon, { fontSize: "small" }),
285
+ /* @__PURE__ */ jsx2("span", { children: "Single Page" })
286
+ ] }),
287
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-divider" }),
288
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-header", children: "SCROLL LAYOUT" }),
289
+ /* @__PURE__ */ jsxs("button", { className: "toolbar-dropdown-item toolbar-dropdown-item-active", onClick: () => setIsViewMenuOpen(false), children: [
290
+ /* @__PURE__ */ jsx2(SwapVertIcon, { fontSize: "small" }),
291
+ /* @__PURE__ */ jsx2("span", { children: "Vertical" })
292
+ ] }),
293
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-divider" }),
294
+ /* @__PURE__ */ jsxs("button", { className: "toolbar-dropdown-item", onClick: () => {
295
+ setIsViewMenuOpen(false);
296
+ onFitToWidth?.();
297
+ }, children: [
298
+ /* @__PURE__ */ jsx2(AspectRatioIcon, { fontSize: "small" }),
299
+ /* @__PURE__ */ jsx2("span", { children: "Fit to Width" })
300
+ ] }),
301
+ /* @__PURE__ */ jsxs("button", { className: "toolbar-dropdown-item", onClick: () => {
302
+ setIsViewMenuOpen(false);
303
+ onFitToPage?.();
304
+ }, children: [
305
+ /* @__PURE__ */ jsx2(FitScreenIcon, { fontSize: "small" }),
306
+ /* @__PURE__ */ jsx2("span", { children: "Fit to Page" })
307
+ ] }),
308
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-divider" }),
309
+ showRotation && /* @__PURE__ */ jsxs(Fragment, { children: [
310
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-header", children: "PAGE ROTATION" }),
311
+ /* @__PURE__ */ jsxs(
312
+ "button",
313
+ {
314
+ className: "toolbar-dropdown-item",
315
+ onClick: () => {
316
+ setIsViewMenuOpen(false);
317
+ onRotateRight?.();
318
+ },
319
+ disabled: false,
320
+ children: [
321
+ /* @__PURE__ */ jsx2(RotateRightIcon, { fontSize: "small" }),
322
+ /* @__PURE__ */ jsx2("span", { children: "Rotate Clockwise" })
323
+ ]
324
+ }
325
+ ),
326
+ /* @__PURE__ */ jsxs(
327
+ "button",
328
+ {
329
+ className: "toolbar-dropdown-item",
330
+ onClick: () => {
331
+ setIsViewMenuOpen(false);
332
+ onRotateLeft?.();
333
+ },
334
+ disabled: disabledRotateLeft,
335
+ children: [
336
+ /* @__PURE__ */ jsx2(RotateLeftIcon, { fontSize: "small" }),
337
+ /* @__PURE__ */ jsx2("span", { children: "Rotate Counter-Clockwise" })
338
+ ]
339
+ }
340
+ )
341
+ ] }),
342
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-dropdown-divider" }),
343
+ /* @__PURE__ */ jsxs(
344
+ "button",
345
+ {
346
+ className: "toolbar-dropdown-item",
347
+ onClick: () => {
348
+ setIsViewMenuOpen(false);
349
+ onToggleFullScreen();
350
+ },
351
+ children: [
352
+ /* @__PURE__ */ jsx2(FullscreenIcon, { fontSize: "small" }),
353
+ /* @__PURE__ */ jsx2("span", { children: "Fullscreen" })
354
+ ]
355
+ }
356
+ )
357
+ ] })
358
+ ] }) })
359
+ ] }),
360
+ showSearch && /* @__PURE__ */ jsxs(Fragment, { children: [
361
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
362
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-section", children: /* @__PURE__ */ jsx2(Tooltip, { title: "Search", children: /* @__PURE__ */ jsx2(
363
+ "button",
364
+ {
365
+ className: `toolbar-button ${isSidebarOpen ? "toolbar-button-active" : ""}`,
366
+ onClick: onToggleSidebar,
367
+ children: /* @__PURE__ */ jsx2(SearchIcon, { fontSize: "small" })
368
+ }
369
+ ) }) })
370
+ ] })
371
+ ] }),
372
+ /* @__PURE__ */ jsxs("div", { className: "toolbar-center", children: [
190
373
  /* @__PURE__ */ jsx2(
191
374
  "button",
192
375
  {
193
- className: "toolbar-button",
194
- onClick: onZoomIn,
195
- title: "Zoom In",
196
- children: /* @__PURE__ */ jsx2(ZoomInIcon, { fontSize: "small" })
197
- }
198
- ),
199
- /* @__PURE__ */ jsx2(
200
- "button",
201
- {
202
- className: "toolbar-button",
203
- onClick: onFitToWidth,
204
- title: "Fit to Width",
205
- children: /* @__PURE__ */ jsx2(AspectRatioIcon, { fontSize: "small" })
206
- }
207
- ),
208
- /* @__PURE__ */ jsx2(
209
- "button",
210
- {
211
- className: "toolbar-button",
212
- onClick: onFitToPage,
213
- title: "Fit to Page",
214
- children: /* @__PURE__ */ jsx2(FitScreenIcon, { fontSize: "small" })
215
- }
216
- )
217
- ] })
218
- ] }),
219
- showRotation && /* @__PURE__ */ jsxs(Fragment, { children: [
220
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
221
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
222
- /* @__PURE__ */ jsx2(
223
- "button",
224
- {
225
- className: "toolbar-button",
226
- onClick: onRotateLeft,
227
- disabled: disabledRotateLeft,
228
- title: "Rotate Counterclockwise",
229
- children: /* @__PURE__ */ jsx2(RotateLeftIcon, { fontSize: "small" })
376
+ className: `toolbar-tab ${activeMode === "view" ? "toolbar-tab-active" : ""}`,
377
+ onClick: () => setActiveMode("view"),
378
+ children: "View"
230
379
  }
231
380
  ),
232
- /* @__PURE__ */ jsx2(
381
+ /* @__PURE__ */ jsxs(
233
382
  "button",
234
383
  {
235
- className: "toolbar-button",
236
- onClick: onRotateRight,
237
- disabled: disabledRotateRight,
238
- title: "Rotate Clockwise",
239
- children: /* @__PURE__ */ jsx2(RotateRightIcon, { fontSize: "small" })
384
+ className: `toolbar-tab ${activeMode === "annotate" ? "toolbar-tab-active" : ""}`,
385
+ onClick: () => setActiveMode("annotate"),
386
+ style: { position: "relative" },
387
+ children: [
388
+ "Annotate",
389
+ hasUnsavedAnnotations && /* @__PURE__ */ jsx2("span", { style: {
390
+ position: "absolute",
391
+ top: "4px",
392
+ right: "4px",
393
+ width: "6px",
394
+ height: "6px",
395
+ backgroundColor: "#ef4444",
396
+ borderRadius: "50%"
397
+ } })
398
+ ]
240
399
  }
241
400
  )
242
- ] })
401
+ ] }),
402
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-right", children: (hasUnsavedAnnotations || showDownload || showPrint || showMetadata || showProperties || showTags || showHistory) && /* @__PURE__ */ jsxs(Fragment, { children: [
403
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
404
+ /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
405
+ showDownload && /* @__PURE__ */ jsx2(Tooltip, { title: "Download", children: /* @__PURE__ */ jsx2(
406
+ "button",
407
+ {
408
+ className: "toolbar-button",
409
+ onClick: onDownloadClick,
410
+ disabled: disabledDownload,
411
+ children: /* @__PURE__ */ jsx2(DownloadIcon, { fontSize: "small" })
412
+ }
413
+ ) }),
414
+ showPrint && /* @__PURE__ */ jsxs("div", { className: "toolbar-dropdown-container", ref: printMenuRef, children: [
415
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Print", children: /* @__PURE__ */ jsxs(
416
+ "button",
417
+ {
418
+ className: `toolbar-button toolbar-dropdown-button ${isPrintMenuOpen ? "toolbar-button-active" : ""}`,
419
+ onClick: () => setIsPrintMenuOpen(!isPrintMenuOpen),
420
+ children: [
421
+ /* @__PURE__ */ jsx2(PrintIcon, { fontSize: "small" }),
422
+ /* @__PURE__ */ jsx2(KeyboardArrowDownIcon, { fontSize: "small", style: { marginLeft: -4 } })
423
+ ]
424
+ }
425
+ ) }),
426
+ isPrintMenuOpen && /* @__PURE__ */ jsxs("div", { className: "toolbar-dropdown-menu", children: [
427
+ /* @__PURE__ */ jsx2(
428
+ "button",
429
+ {
430
+ className: "toolbar-dropdown-item",
431
+ onClick: handlePrintWithoutAnnotations,
432
+ children: /* @__PURE__ */ jsx2("span", { children: "Print Document Only" })
433
+ }
434
+ ),
435
+ /* @__PURE__ */ jsx2(
436
+ "button",
437
+ {
438
+ className: "toolbar-dropdown-item",
439
+ onClick: handlePrintWithAnnotations,
440
+ children: /* @__PURE__ */ jsx2("span", { children: "Print with Annotations" })
441
+ }
442
+ )
443
+ ] })
444
+ ] }),
445
+ showMetadata && /* @__PURE__ */ jsx2(Tooltip, { title: "Metadata", children: /* @__PURE__ */ jsx2(
446
+ "button",
447
+ {
448
+ className: "toolbar-button",
449
+ onClick: onMetadataClick,
450
+ disabled: disabledMetadata,
451
+ children: /* @__PURE__ */ jsx2(DescriptionIcon, { fontSize: "small" })
452
+ }
453
+ ) }),
454
+ showProperties && /* @__PURE__ */ jsx2(Tooltip, { title: "Properties", children: /* @__PURE__ */ jsx2(
455
+ "button",
456
+ {
457
+ className: "toolbar-button",
458
+ onClick: onPropertiesClick,
459
+ disabled: disabledProperties,
460
+ children: /* @__PURE__ */ jsx2(InfoIcon, { fontSize: "small" })
461
+ }
462
+ ) }),
463
+ showTags && /* @__PURE__ */ jsx2(Tooltip, { title: "Tags", children: /* @__PURE__ */ jsx2(
464
+ "button",
465
+ {
466
+ className: "toolbar-button",
467
+ onClick: onTagsClick,
468
+ disabled: disabledTags,
469
+ children: /* @__PURE__ */ jsx2(LocalOffer, { fontSize: "small" })
470
+ }
471
+ ) }),
472
+ showHistory && /* @__PURE__ */ jsx2(Tooltip, { title: "Version History", children: /* @__PURE__ */ jsx2(
473
+ "button",
474
+ {
475
+ className: "toolbar-button",
476
+ onClick: onHistoryClick,
477
+ disabled: disabledHistory,
478
+ children: /* @__PURE__ */ jsx2(HistoryIcon, { fontSize: "small" })
479
+ }
480
+ ) })
481
+ ] })
482
+ ] }) })
243
483
  ] }),
244
- showSearch && /* @__PURE__ */ jsxs(Fragment, { children: [
245
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
246
- /* @__PURE__ */ jsx2("div", { className: "toolbar-section", children: /* @__PURE__ */ jsx2(
484
+ activeMode === "annotate" && showAnnotations && /* @__PURE__ */ jsxs("div", { className: "pdf-viewer-secondary-toolbar", children: [
485
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Highlight", children: /* @__PURE__ */ jsx2(
486
+ "button",
487
+ {
488
+ className: `toolbar-button ${isHighlighterActive ? "toolbar-button-active" : ""}`,
489
+ onClick: onHighlighterClick,
490
+ disabled: disabledHighlighter,
491
+ children: /* @__PURE__ */ jsx2(HighlightIcon, { fontSize: "small" })
492
+ }
493
+ ) }),
494
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Stamp", children: /* @__PURE__ */ jsx2(
495
+ "button",
496
+ {
497
+ className: `toolbar-button ${isStampActive ? "toolbar-button-active" : ""}`,
498
+ onClick: onStampClick,
499
+ disabled: disabledStamp,
500
+ children: /* @__PURE__ */ jsx2(ApprovalIcon, { fontSize: "small" })
501
+ }
502
+ ) }),
503
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Signature", children: /* @__PURE__ */ jsx2(
247
504
  "button",
248
505
  {
249
506
  className: "toolbar-button",
250
- onClick: onToggleSidebar,
251
- title: "Search in PDF",
252
- style: {
253
- backgroundColor: isSidebarOpen ? "#e3f2fd" : "transparent",
254
- color: isSidebarOpen ? "#1976d2" : "inherit"
255
- },
256
- children: /* @__PURE__ */ jsx2(SearchIcon, { fontSize: "small" })
507
+ onClick: onSignatureClick,
508
+ disabled: disabledSignature,
509
+ children: /* @__PURE__ */ jsx2(DrawIcon, { fontSize: "small" })
257
510
  }
258
- ) })
259
- ] }),
260
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
261
- /* @__PURE__ */ jsx2("div", { className: "toolbar-section", children: /* @__PURE__ */ jsx2(
262
- "button",
263
- {
264
- className: "toolbar-button",
265
- onClick: onToggleFullScreen,
266
- title: "Fullscreen",
267
- children: /* @__PURE__ */ jsx2(FullscreenIcon, { fontSize: "small" })
268
- }
269
- ) }),
270
- (showMetadata || showProperties || showDownload || showPrint || showTags || showHistory) && /* @__PURE__ */ jsxs(Fragment, { children: [
271
- /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
272
- /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
273
- showDownload && /* @__PURE__ */ jsx2(
274
- "button",
275
- {
276
- className: "toolbar-button",
277
- onClick: onDownloadClick,
278
- disabled: disabledDownload,
279
- title: "Download PDF",
280
- children: /* @__PURE__ */ jsx2(DownloadIcon, { fontSize: "small" })
281
- }
282
- ),
283
- showPrint && /* @__PURE__ */ jsx2(
284
- "button",
285
- {
286
- className: "toolbar-button",
287
- onClick: onPrintClick,
288
- disabled: disabledPrint,
289
- title: "Print PDF",
290
- children: /* @__PURE__ */ jsx2(PrintIcon, { fontSize: "small" })
291
- }
292
- ),
293
- showMetadata && /* @__PURE__ */ jsx2(
294
- "button",
295
- {
296
- className: "toolbar-button",
297
- onClick: onMetadataClick,
298
- disabled: disabledMetadata,
299
- title: "Document Metadata",
300
- children: /* @__PURE__ */ jsx2(DescriptionIcon, { fontSize: "small" })
301
- }
302
- ),
303
- showProperties && /* @__PURE__ */ jsx2(
304
- "button",
305
- {
306
- className: "toolbar-button",
307
- onClick: onPropertiesClick,
308
- disabled: disabledProperties,
309
- title: "Document Properties",
310
- children: /* @__PURE__ */ jsx2(InfoIcon, { fontSize: "small" })
311
- }
312
- ),
313
- showTags && /* @__PURE__ */ jsx2(
314
- "button",
315
- {
316
- className: "toolbar-button",
317
- onClick: onTagsClick,
318
- disabled: disabledTags,
319
- title: "Document Tags",
320
- children: /* @__PURE__ */ jsx2(LocalOffer, { fontSize: "small" })
321
- }
322
- ),
323
- showHistory && /* @__PURE__ */ jsx2(
511
+ ) }),
512
+ hasUnsavedAnnotations && canSaveAnnotations !== false && onSaveAnnotations && /* @__PURE__ */ jsxs(Fragment, { children: [
513
+ /* @__PURE__ */ jsx2("div", { style: { width: 1, height: 24, backgroundColor: "#e5e7eb", margin: "0 8px" } }),
514
+ /* @__PURE__ */ jsx2(Tooltip, { title: "Save Annotations", children: /* @__PURE__ */ jsxs(
324
515
  "button",
325
516
  {
326
517
  className: "toolbar-button",
327
- onClick: onHistoryClick,
328
- disabled: disabledHistory,
329
- title: "Document History",
330
- children: /* @__PURE__ */ jsx2(HistoryIcon, { fontSize: "small" })
518
+ onClick: onSaveAnnotations,
519
+ disabled: isSavingAnnotations,
520
+ style: {
521
+ color: hasUnsavedAnnotations ? "#2563eb" : "inherit",
522
+ padding: "6px 16px",
523
+ border: hasUnsavedAnnotations ? "1px solid #2563eb" : "1px solid transparent",
524
+ borderRadius: "6px",
525
+ display: "flex",
526
+ alignItems: "center",
527
+ gap: "6px",
528
+ backgroundColor: hasUnsavedAnnotations ? "#eff6ff" : "transparent",
529
+ fontSize: "14px",
530
+ fontWeight: 500,
531
+ width: "auto"
532
+ },
533
+ children: [
534
+ 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: [
535
+ /* @__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" }),
536
+ /* @__PURE__ */ jsx2("polyline", { points: "17 21 17 13 7 13 7 21" }),
537
+ /* @__PURE__ */ jsx2("polyline", { points: "7 3 7 8 15 8" })
538
+ ] }),
539
+ /* @__PURE__ */ jsx2("span", { children: isSavingAnnotations ? "Saving..." : "Save" })
540
+ ]
331
541
  }
332
- )
542
+ ) })
333
543
  ] })
334
- ] })
544
+ ] }),
545
+ 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" }) }) }) })
335
546
  ] });
336
547
  }
337
548
  );
@@ -349,7 +560,7 @@ var PDFHeader = React3.memo(({ fileName, fileExtension }) => {
349
560
  PDFHeader.displayName = "PDFHeader";
350
561
 
351
562
  // src/components/viewers/pdf/SearchSidebar.tsx
352
- import { useState, useLayoutEffect, useEffect, useRef } from "react";
563
+ import { useState as useState2, useLayoutEffect, useEffect as useEffect2, useRef as useRef2 } from "react";
353
564
  import {
354
565
  Box,
355
566
  Typography,
@@ -362,7 +573,7 @@ import {
362
573
  import SearchIcon2 from "@mui/icons-material/Search";
363
574
  import CloseIcon from "@mui/icons-material/Close";
364
575
  import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
365
- import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
576
+ import KeyboardArrowDownIcon2 from "@mui/icons-material/KeyboardArrowDown";
366
577
  import ClearIcon from "@mui/icons-material/Clear";
367
578
  import FindInPageIcon from "@mui/icons-material/FindInPage";
368
579
  import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
@@ -380,10 +591,10 @@ var SearchSidebar = ({
380
591
  isSearching = false,
381
592
  isSyntheticResults = false
382
593
  }) => {
383
- const [searchTerm, setSearchTerm] = useState(searchKeyword || "");
384
- const [hasSearched, setHasSearched] = useState(false);
385
- const contentRef = useRef(null);
386
- useEffect(() => {
594
+ const [searchTerm, setSearchTerm] = useState2(searchKeyword || "");
595
+ const [hasSearched, setHasSearched] = useState2(false);
596
+ const contentRef = useRef2(null);
597
+ useEffect2(() => {
387
598
  if (searchKeyword && searchKeyword !== searchTerm) {
388
599
  setSearchTerm(searchKeyword);
389
600
  }
@@ -644,7 +855,7 @@ var SearchSidebar = ({
644
855
  border: "1px solid",
645
856
  borderColor: currentResultIndex >= totalResults - 1 ? "divider" : "primary.main"
646
857
  },
647
- children: /* @__PURE__ */ jsx4(KeyboardArrowDownIcon, { sx: { fontSize: 20 } })
858
+ children: /* @__PURE__ */ jsx4(KeyboardArrowDownIcon2, { sx: { fontSize: 20 } })
648
859
  }
649
860
  )
650
861
  ] })
@@ -840,7 +1051,7 @@ var SearchSidebar = ({
840
1051
  };
841
1052
 
842
1053
  // src/components/viewers/pdf/PasswordDialog.tsx
843
- import { useState as useState2, useEffect as useEffect2 } from "react";
1054
+ import { useState as useState3, useEffect as useEffect3 } from "react";
844
1055
  import {
845
1056
  Dialog,
846
1057
  DialogTitle,
@@ -849,34 +1060,44 @@ import {
849
1060
  TextField as TextField2,
850
1061
  Button,
851
1062
  Typography as Typography2,
852
- IconButton as IconButton2,
853
1063
  InputAdornment as InputAdornment2,
854
1064
  Box as Box2,
855
- Alert
1065
+ Alert,
1066
+ IconButton as IconButton2,
1067
+ CircularProgress as CircularProgress2
856
1068
  } from "@mui/material";
857
- import CloseIcon2 from "@mui/icons-material/Close";
858
1069
  import LockIcon from "@mui/icons-material/Lock";
859
1070
  import VisibilityIcon from "@mui/icons-material/Visibility";
860
1071
  import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
861
- import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
1072
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
862
1073
  var PasswordDialog = ({
863
1074
  open,
864
1075
  fileName,
865
1076
  onSubmit,
866
1077
  onCancel,
867
- error
1078
+ error,
1079
+ isLoading = false
868
1080
  }) => {
869
- const [password, setPassword] = useState2("");
870
- const [showPassword, setShowPassword] = useState2(false);
871
- useEffect2(() => {
1081
+ const [password, setPassword] = useState3("");
1082
+ const [showPassword, setShowPassword] = useState3(false);
1083
+ useEffect3(() => {
1084
+ if (open && !isLoading) {
1085
+ if (error) {
1086
+ setPassword("");
1087
+ }
1088
+ }
1089
+ }, [open, error, isLoading]);
1090
+ useEffect3(() => {
872
1091
  if (open) {
873
- setPassword("");
874
1092
  setShowPassword(false);
1093
+ if (!error) {
1094
+ setPassword("");
1095
+ }
875
1096
  }
876
1097
  }, [open]);
877
1098
  const handleSubmit = (e) => {
878
1099
  e.preventDefault();
879
- if (password.trim()) {
1100
+ if (password.trim() && !isLoading) {
880
1101
  onSubmit(password);
881
1102
  }
882
1103
  };
@@ -884,7 +1105,7 @@ var PasswordDialog = ({
884
1105
  setShowPassword(!showPassword);
885
1106
  };
886
1107
  const handleKeyPress = (e) => {
887
- if (e.key === "Enter" && password.trim()) {
1108
+ if (e.key === "Enter" && password.trim() && !isLoading) {
888
1109
  handleSubmit(e);
889
1110
  }
890
1111
  };
@@ -892,45 +1113,44 @@ var PasswordDialog = ({
892
1113
  Dialog,
893
1114
  {
894
1115
  open,
895
- onClose: onCancel,
1116
+ disableEscapeKeyDown: true,
1117
+ onClose: (event, reason) => {
1118
+ if (reason === "backdropClick") return;
1119
+ },
896
1120
  maxWidth: "sm",
897
1121
  fullWidth: true,
1122
+ slotProps: {
1123
+ backdrop: {
1124
+ sx: {
1125
+ backdropFilter: "blur(8px)",
1126
+ backgroundColor: "rgba(0, 0, 0, 0.6)"
1127
+ }
1128
+ }
1129
+ },
898
1130
  PaperProps: {
899
1131
  sx: {
900
1132
  borderRadius: 2
901
1133
  }
902
1134
  },
903
1135
  children: [
904
- /* @__PURE__ */ jsx5(DialogTitle, { sx: { pb: 1 }, children: /* @__PURE__ */ jsxs4(Box2, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
905
- /* @__PURE__ */ jsxs4(Box2, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
906
- /* @__PURE__ */ jsx5(
907
- Box2,
908
- {
909
- sx: {
910
- width: 40,
911
- height: 40,
912
- borderRadius: "50%",
913
- backgroundColor: "primary.light",
914
- display: "flex",
915
- alignItems: "center",
916
- justifyContent: "center",
917
- opacity: 0.9
918
- },
919
- children: /* @__PURE__ */ jsx5(LockIcon, { sx: { color: "white", fontSize: 20 } })
920
- }
921
- ),
922
- /* @__PURE__ */ jsx5(Typography2, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
923
- ] }),
1136
+ /* @__PURE__ */ jsx5(DialogTitle, { sx: { pb: 1 }, children: /* @__PURE__ */ jsxs4(Box2, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
924
1137
  /* @__PURE__ */ jsx5(
925
- IconButton2,
1138
+ Box2,
926
1139
  {
927
- size: "small",
928
- onClick: onCancel,
929
- sx: { color: "text.secondary" },
930
- "aria-label": "Close dialog",
931
- children: /* @__PURE__ */ jsx5(CloseIcon2, { fontSize: "small" })
1140
+ sx: {
1141
+ width: 40,
1142
+ height: 40,
1143
+ borderRadius: "50%",
1144
+ backgroundColor: "primary.light",
1145
+ display: "flex",
1146
+ alignItems: "center",
1147
+ justifyContent: "center",
1148
+ opacity: 0.9
1149
+ },
1150
+ children: /* @__PURE__ */ jsx5(LockIcon, { sx: { color: "white", fontSize: 20 } })
932
1151
  }
933
- )
1152
+ ),
1153
+ /* @__PURE__ */ jsx5(Typography2, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
934
1154
  ] }) }),
935
1155
  /* @__PURE__ */ jsxs4(DialogContent, { sx: { pt: 2 }, children: [
936
1156
  /* @__PURE__ */ jsxs4(Typography2, { variant: "body2", sx: { color: "text.secondary", mb: 3 }, children: [
@@ -955,6 +1175,7 @@ var PasswordDialog = ({
955
1175
  onChange: (e) => setPassword(e.target.value),
956
1176
  onKeyPress: handleKeyPress,
957
1177
  error: Boolean(error),
1178
+ disabled: isLoading,
958
1179
  InputProps: {
959
1180
  endAdornment: /* @__PURE__ */ jsx5(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx5(
960
1181
  IconButton2,
@@ -963,6 +1184,7 @@ var PasswordDialog = ({
963
1184
  edge: "end",
964
1185
  size: "small",
965
1186
  "aria-label": showPassword ? "Hide password" : "Show password",
1187
+ disabled: isLoading,
966
1188
  children: showPassword ? /* @__PURE__ */ jsx5(VisibilityOffIcon, {}) : /* @__PURE__ */ jsx5(VisibilityIcon, {})
967
1189
  }
968
1190
  ) })
@@ -975,36 +1197,25 @@ var PasswordDialog = ({
975
1197
  }
976
1198
  ) })
977
1199
  ] }),
978
- /* @__PURE__ */ jsxs4(DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: [
979
- /* @__PURE__ */ jsx5(
980
- Button,
981
- {
982
- onClick: onCancel,
983
- variant: "outlined",
984
- sx: {
985
- borderRadius: 2,
986
- textTransform: "none",
987
- px: 3
988
- },
989
- children: "Cancel"
990
- }
991
- ),
992
- /* @__PURE__ */ jsx5(
993
- Button,
994
- {
995
- onClick: handleSubmit,
996
- variant: "contained",
997
- disabled: !password.trim(),
998
- sx: {
999
- borderRadius: 2,
1000
- textTransform: "none",
1001
- px: 3,
1002
- boxShadow: 2
1003
- },
1004
- children: "Unlock PDF"
1005
- }
1006
- )
1007
- ] })
1200
+ /* @__PURE__ */ jsx5(DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: /* @__PURE__ */ jsx5(
1201
+ Button,
1202
+ {
1203
+ onClick: handleSubmit,
1204
+ variant: "contained",
1205
+ disabled: !password.trim() || isLoading,
1206
+ sx: {
1207
+ borderRadius: 2,
1208
+ textTransform: "none",
1209
+ px: 3,
1210
+ boxShadow: 2,
1211
+ minWidth: 120
1212
+ },
1213
+ children: isLoading ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
1214
+ /* @__PURE__ */ jsx5(CircularProgress2, { size: 16, color: "inherit", sx: { mr: 1 } }),
1215
+ "Verifying..."
1216
+ ] }) : "Unlock PDF"
1217
+ }
1218
+ ) })
1008
1219
  ]
1009
1220
  }
1010
1221
  );
@@ -1037,12 +1248,29 @@ var PDFViewerContent = forwardRef(
1037
1248
  onDownloadClick,
1038
1249
  onPrintClick,
1039
1250
  initialSearchText,
1040
- initialSearchPages
1251
+ initialSearchPages,
1252
+ showAnnotations,
1253
+ userDetails,
1254
+ annotationSelectionMenu,
1255
+ isHighlighterActive,
1256
+ isStampActive,
1257
+ onHighlighterClick,
1258
+ onStampClick,
1259
+ onSignatureClick,
1260
+ // Annotation save props
1261
+ hasUnsavedAnnotations,
1262
+ isSavingAnnotations,
1263
+ canSaveAnnotations,
1264
+ onSaveAnnotations
1041
1265
  } = props;
1042
- const [pdfBuffer, setPdfBuffer] = useState3(null);
1043
- const [state, setState] = useState3("idle");
1044
- const [error, setError] = useState3(null);
1045
- const pdfViewerRef = useRef2(null);
1266
+ const [pdfBuffer, setPdfBuffer] = useState4(null);
1267
+ const [state, setState] = useState4("idle");
1268
+ const [error, setError] = useState4(null);
1269
+ const pdfViewerRef = useRef3(null);
1270
+ const [internalHighlighterActive, setInternalHighlighterActive] = useState4(false);
1271
+ const [internalStampActive, setInternalStampActive] = useState4(false);
1272
+ const highlighterActive = isHighlighterActive !== void 0 ? isHighlighterActive : internalHighlighterActive;
1273
+ const stampActive = isStampActive !== void 0 ? isStampActive : internalStampActive;
1046
1274
  const resolvedFileName = useMemo(() => {
1047
1275
  if (fileName) return fileName;
1048
1276
  if (file instanceof File) return file.name;
@@ -1056,25 +1284,27 @@ var PDFViewerContent = forwardRef(
1056
1284
  () => getFileExtension(resolvedFileName),
1057
1285
  [resolvedFileName]
1058
1286
  );
1059
- const [currentPage, setCurrentPage] = useState3(1);
1060
- const [totalPages, setTotalPages] = useState3(0);
1061
- const [zoom, setZoom] = useState3(100);
1062
- const [searchQuery, setSearchQuery] = useState3("");
1063
- const [isSearching, setIsSearching] = useState3(false);
1064
- const [pdfContainer, setPdfContainer] = useState3(null);
1065
- const [isSidebarOpen, setIsSidebarOpen] = useState3(false);
1066
- const [searchResults, setSearchResults] = useState3([]);
1067
- const [currentSearchResultIndex, setCurrentSearchResultIndex] = useState3(0);
1068
- const [totalSearchResults, setTotalSearchResults] = useState3(0);
1069
- const [autoExecuteSearch, setAutoExecuteSearch] = useState3(
1287
+ const [currentPage, setCurrentPage] = useState4(1);
1288
+ const [totalPages, setTotalPages] = useState4(0);
1289
+ const [zoom, setZoom] = useState4(100);
1290
+ const [searchQuery, setSearchQuery] = useState4("");
1291
+ const [isSearching, setIsSearching] = useState4(false);
1292
+ const [pdfContainer, setPdfContainer] = useState4(null);
1293
+ const [isSidebarOpen, setIsSidebarOpen] = useState4(false);
1294
+ const [searchResults, setSearchResults] = useState4([]);
1295
+ const [currentSearchResultIndex, setCurrentSearchResultIndex] = useState4(0);
1296
+ const [totalSearchResults, setTotalSearchResults] = useState4(0);
1297
+ const [autoExecuteSearch, setAutoExecuteSearch] = useState4(
1070
1298
  !!initialSearchText
1071
1299
  );
1072
- const [isFullScreen, setIsFullScreen] = useState3(false);
1073
- const containerRef = useRef2(null);
1074
- const [isPasswordDialogOpen, setIsPasswordDialogOpen] = useState3(false);
1075
- const [passwordError, setPasswordError] = useState3("");
1076
- const [passwordResolve, setPasswordResolve] = useState3(null);
1077
- const hasExecutedInitialSearch = useRef2(false);
1300
+ const [isFullScreen, setIsFullScreen] = useState4(false);
1301
+ const containerRef = useRef3(null);
1302
+ const [isPasswordDialogOpen, setIsPasswordDialogOpen] = useState4(false);
1303
+ const [passwordError, setPasswordError] = useState4("");
1304
+ const [isVerifyingPassword, setIsVerifyingPassword] = useState4(false);
1305
+ const [passwordResolve, setPasswordResolve] = useState4(null);
1306
+ const passwordTimeoutRef = useRef3(null);
1307
+ const hasExecutedInitialSearch = useRef3(false);
1078
1308
  const handleToggleFullScreen = useCallback(() => {
1079
1309
  if (!isFullScreen && containerRef.current?.requestFullscreen) {
1080
1310
  containerRef.current.requestFullscreen();
@@ -1084,6 +1314,16 @@ var PDFViewerContent = forwardRef(
1084
1314
  setIsFullScreen(false);
1085
1315
  }
1086
1316
  }, [isFullScreen]);
1317
+ useEffect4(() => {
1318
+ const handleFullscreenChange = () => {
1319
+ const isCurrentlyFullscreen = !!document.fullscreenElement;
1320
+ setIsFullScreen(isCurrentlyFullscreen);
1321
+ };
1322
+ document.addEventListener("fullscreenchange", handleFullscreenChange);
1323
+ return () => {
1324
+ document.removeEventListener("fullscreenchange", handleFullscreenChange);
1325
+ };
1326
+ }, []);
1087
1327
  const handleSidebarClose = useCallback(() => {
1088
1328
  setIsSidebarOpen(false);
1089
1329
  setSearchQuery("");
@@ -1208,11 +1448,54 @@ var PDFViewerContent = forwardRef(
1208
1448
  handleRotateRight: () => {
1209
1449
  pdfViewerRef.current?.rotate?.rotateForward();
1210
1450
  },
1451
+ handlePrint: () => {
1452
+ pdfViewerRef.current?.print?.print();
1453
+ },
1454
+ handlePrintWithAnnotations: async () => {
1455
+ console.log("\u{1F5A8}\uFE0F Print with Annotations clicked");
1456
+ console.log("pdfViewerRef.current:", pdfViewerRef.current);
1457
+ console.log("pdfViewerRef.current?.print:", pdfViewerRef.current?.print);
1458
+ await pdfViewerRef.current?.print?.printWithAnnotations?.();
1459
+ },
1460
+ handlePrintWithoutAnnotations: async () => {
1461
+ console.log("\u{1F5A8}\uFE0F Print without Annotations clicked");
1462
+ console.log("pdfViewerRef.current:", pdfViewerRef.current);
1463
+ console.log("pdfViewerRef.current?.print:", pdfViewerRef.current?.print);
1464
+ await pdfViewerRef.current?.print?.printWithoutAnnotations?.();
1465
+ },
1466
+ handleHighlighterClick: () => {
1467
+ if (highlighterActive) {
1468
+ pdfViewerRef.current?.annotation?.deactivateHighlighter();
1469
+ setInternalHighlighterActive(false);
1470
+ } else {
1471
+ if (stampActive) {
1472
+ pdfViewerRef.current?.annotation?.deactivateStamp();
1473
+ setInternalStampActive(false);
1474
+ }
1475
+ pdfViewerRef.current?.annotation?.activateHighlighter();
1476
+ setInternalHighlighterActive(true);
1477
+ }
1478
+ },
1479
+ handleStampClick: () => {
1480
+ if (stampActive) {
1481
+ pdfViewerRef.current?.annotation?.deactivateStamp();
1482
+ setInternalStampActive(false);
1483
+ } else {
1484
+ if (highlighterActive) {
1485
+ pdfViewerRef.current?.annotation?.deactivateHighlighter();
1486
+ setInternalHighlighterActive(false);
1487
+ }
1488
+ pdfViewerRef.current?.annotation?.activateStamp("");
1489
+ setInternalStampActive(true);
1490
+ }
1491
+ },
1492
+ handleSignatureClick: () => {
1493
+ },
1211
1494
  handleToggleFullScreen
1212
1495
  }),
1213
- [isSidebarOpen, totalPages, handleToggleFullScreen]
1496
+ [isSidebarOpen, totalPages, handleToggleFullScreen, highlighterActive, stampActive]
1214
1497
  );
1215
- useEffect3(() => {
1498
+ useEffect4(() => {
1216
1499
  console.log(
1217
1500
  "came",
1218
1501
  initialSearchText,
@@ -1255,7 +1538,7 @@ var PDFViewerContent = forwardRef(
1255
1538
  initialSearchText,
1256
1539
  initialSearchPages
1257
1540
  ]);
1258
- useEffect3(() => {
1541
+ useEffect4(() => {
1259
1542
  setSearchQuery("");
1260
1543
  setSearchResults([]);
1261
1544
  setCurrentSearchResultIndex(0);
@@ -1270,7 +1553,7 @@ var PDFViewerContent = forwardRef(
1270
1553
  setError(null);
1271
1554
  setPdfBuffer(null);
1272
1555
  }, [file]);
1273
- useEffect3(() => {
1556
+ useEffect4(() => {
1274
1557
  if (state !== "ready") return;
1275
1558
  const container = document.querySelector(
1276
1559
  '[data-pdf-viewer], .embedpdf-viewport, [role="document"]'
@@ -1291,7 +1574,7 @@ var PDFViewerContent = forwardRef(
1291
1574
  observer.observe(document.body, { childList: true, subtree: true });
1292
1575
  return () => observer.disconnect();
1293
1576
  }, [state]);
1294
- useEffect3(() => {
1577
+ useEffect4(() => {
1295
1578
  if (state !== "ready" || totalPages > 0) return;
1296
1579
  const initializePageCount = async () => {
1297
1580
  const waitForViewer = async (maxAttempts = 10) => {
@@ -1361,7 +1644,7 @@ var PDFViewerContent = forwardRef(
1361
1644
  };
1362
1645
  initializePageCount();
1363
1646
  }, [state, totalPages]);
1364
- useEffect3(() => {
1647
+ useEffect4(() => {
1365
1648
  if (state === "ready" && pdfViewerRef.current) {
1366
1649
  const updateInfo = () => {
1367
1650
  const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
@@ -1453,7 +1736,20 @@ var PDFViewerContent = forwardRef(
1453
1736
  clearSelection: () => pdfViewerRef.current?.selection.clearSelection(),
1454
1737
  rotateForward: () => pdfViewerRef.current?.rotate?.rotateForward(),
1455
1738
  rotateBackward: () => pdfViewerRef.current?.rotate?.rotateBackward(),
1456
- getRotation: () => pdfViewerRef.current?.rotate?.getRotation() || 0
1739
+ getRotation: () => pdfViewerRef.current?.rotate?.getRotation() || 0,
1740
+ print: () => pdfViewerRef.current?.print?.print(),
1741
+ printWithAnnotations: async () => {
1742
+ await pdfViewerRef.current?.print?.printWithAnnotations?.();
1743
+ },
1744
+ printWithoutAnnotations: async () => {
1745
+ await pdfViewerRef.current?.print?.printWithoutAnnotations?.();
1746
+ },
1747
+ get annotation() {
1748
+ return pdfViewerRef.current?.annotation;
1749
+ },
1750
+ get download() {
1751
+ return pdfViewerRef.current?.download;
1752
+ }
1457
1753
  }),
1458
1754
  []
1459
1755
  );
@@ -1608,7 +1904,7 @@ var PDFViewerContent = forwardRef(
1608
1904
  }
1609
1905
  }
1610
1906
  };
1611
- useEffect3(() => {
1907
+ useEffect4(() => {
1612
1908
  if (!file) {
1613
1909
  setState("error");
1614
1910
  setError("No file provided");
@@ -1645,10 +1941,14 @@ var PDFViewerContent = forwardRef(
1645
1941
  loadPDF();
1646
1942
  }, [file, onLoad, onError]);
1647
1943
  const handlePasswordRequest = useCallback(
1648
- async (fileName2) => {
1944
+ async (fileName2, isRetry) => {
1649
1945
  return new Promise((resolve) => {
1650
1946
  setPasswordResolve(() => resolve);
1651
- setPasswordError("");
1947
+ if (isRetry) {
1948
+ setPasswordError("Incorrect password. Please try again.");
1949
+ } else {
1950
+ setPasswordError("");
1951
+ }
1652
1952
  setIsPasswordDialogOpen(true);
1653
1953
  });
1654
1954
  },
@@ -1658,10 +1958,10 @@ var PDFViewerContent = forwardRef(
1658
1958
  (password) => {
1659
1959
  if (passwordResolve) {
1660
1960
  passwordResolve(password);
1661
- setPasswordResolve(null);
1662
- setIsPasswordDialogOpen(false);
1663
- setPasswordError("");
1664
1961
  }
1962
+ setIsPasswordDialogOpen(false);
1963
+ setPasswordResolve(null);
1964
+ setPasswordError("");
1665
1965
  },
1666
1966
  [passwordResolve]
1667
1967
  );
@@ -1778,7 +2078,7 @@ var PDFViewerContent = forwardRef(
1778
2078
  showTags: !toolbar.isHidden("tags"),
1779
2079
  showHistory: !toolbar.isHidden("history"),
1780
2080
  disabledRotateLeft: toolbar.isDisabled("rotateLeft"),
1781
- disabledRotateRight: toolbar.isDisabled("rotateRight"),
2081
+ disabledRotateRight: false,
1782
2082
  disabledMetadata: toolbar.isDisabled("metadata"),
1783
2083
  disabledTags: toolbar.isDisabled("tags"),
1784
2084
  disabledProperties: toolbar.isDisabled("properties"),
@@ -1800,14 +2100,29 @@ var PDFViewerContent = forwardRef(
1800
2100
  onRotateLeft: toolbarHandlers.handleRotateLeft,
1801
2101
  onRotateRight: toolbarHandlers.handleRotateRight,
1802
2102
  onDownloadClick: toolbar.getHandler("download", onDownloadClick),
1803
- onPrintClick: toolbar.getHandler("print", onPrintClick),
2103
+ onPrintClick: toolbar.getHandler("print", onPrintClick || toolbarHandlers.handlePrint),
2104
+ onPrintWithAnnotations: toolbarHandlers.handlePrintWithAnnotations,
2105
+ onPrintWithoutAnnotations: toolbarHandlers.handlePrintWithoutAnnotations,
1804
2106
  onMetadataClick: toolbar.getHandler("metadata", onMetadataClick),
1805
2107
  onPropertiesClick: toolbar.getHandler(
1806
2108
  "properties",
1807
2109
  onPropertiesClick
1808
2110
  ),
1809
2111
  onTagsClick: toolbar.getHandler("tags", onTagsClick),
1810
- onHistoryClick: toolbar.getHandler("history", onHistoryClick)
2112
+ onHistoryClick: toolbar.getHandler("history", onHistoryClick),
2113
+ showAnnotations,
2114
+ isHighlighterActive: highlighterActive,
2115
+ isStampActive: stampActive,
2116
+ disabledHighlighter: toolbar.isDisabled("highlighter"),
2117
+ disabledStamp: toolbar.isDisabled("stamp"),
2118
+ disabledSignature: toolbar.isDisabled("signature"),
2119
+ onHighlighterClick: toolbar.getHandler("highlighter", onHighlighterClick || toolbarHandlers.handleHighlighterClick),
2120
+ onStampClick: toolbar.getHandler("stamp", onStampClick || toolbarHandlers.handleStampClick),
2121
+ onSignatureClick: toolbar.getHandler("signature", onSignatureClick || toolbarHandlers.handleSignatureClick),
2122
+ hasUnsavedAnnotations,
2123
+ isSavingAnnotations,
2124
+ canSaveAnnotations,
2125
+ onSaveAnnotations
1811
2126
  }
1812
2127
  ),
1813
2128
  /* @__PURE__ */ jsxs5("div", { className: "pdf-viewer-main", children: [
@@ -1816,7 +2131,16 @@ var PDFViewerContent = forwardRef(
1816
2131
  {
1817
2132
  pdfBuffer,
1818
2133
  onPasswordRequest: handlePasswordRequest,
1819
- pdfViewerRef
2134
+ pdfViewerRef,
2135
+ showAnnotations,
2136
+ userDetails,
2137
+ annotationSelectionMenu,
2138
+ isHighlighterActive: highlighterActive,
2139
+ isStampActive: stampActive,
2140
+ onHighlighterClick: onHighlighterClick || toolbarHandlers.handleHighlighterClick,
2141
+ onStampClick: onStampClick || toolbarHandlers.handleStampClick,
2142
+ onSignatureClick: onSignatureClick || toolbarHandlers.handleSignatureClick,
2143
+ permissions: props.permissions
1820
2144
  }
1821
2145
  ) }),
1822
2146
  /* @__PURE__ */ jsx6(
@@ -1843,7 +2167,8 @@ var PDFViewerContent = forwardRef(
1843
2167
  fileName: resolvedFileName,
1844
2168
  onSubmit: handlePasswordSubmit,
1845
2169
  onCancel: handlePasswordCancel,
1846
- error: passwordError
2170
+ error: passwordError,
2171
+ isLoading: isVerifyingPassword
1847
2172
  }
1848
2173
  )
1849
2174
  ] });
@@ -1860,4 +2185,4 @@ PDFViewer.displayName = "PDFViewer";
1860
2185
  export {
1861
2186
  PDFViewer
1862
2187
  };
1863
- //# sourceMappingURL=chunk-TQXRQCS4.mjs.map
2188
+ //# sourceMappingURL=chunk-IY5EEUCU.mjs.map