@cannyminds/dms-file-viewers 0.4.0 → 0.5.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.
@@ -6,7 +6,30 @@ import {
6
6
 
7
7
  // src/components/viewers/PDFViewer.tsx
8
8
  import { useCallback, useEffect as useEffect3, useMemo, useRef as useRef2, useState as useState3, forwardRef, useImperativeHandle } from "react";
9
+
10
+ // src/components/viewers/pdf/StablePDFViewer.tsx
11
+ import React from "react";
9
12
  import { PDFViewer as HeadlessPDFViewerImport } from "@cannyminds/pdf-viewer";
13
+ import { jsx } from "react/jsx-runtime";
14
+ var HeadlessPDFViewer = HeadlessPDFViewerImport;
15
+ var StablePDFViewer = React.memo(({
16
+ pdfBuffer,
17
+ onPasswordRequest,
18
+ pdfViewerRef
19
+ }) => {
20
+ return /* @__PURE__ */ jsx(
21
+ HeadlessPDFViewer,
22
+ {
23
+ ref: pdfViewerRef,
24
+ pdfBuffer,
25
+ onPasswordRequest
26
+ }
27
+ );
28
+ });
29
+ StablePDFViewer.displayName = "StablePDFViewer";
30
+
31
+ // src/components/viewers/pdf/PDFToolbar.tsx
32
+ import React2 from "react";
10
33
  import FirstPageIcon from "@mui/icons-material/FirstPage";
11
34
  import LastPageIcon from "@mui/icons-material/LastPage";
12
35
  import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
@@ -15,11 +38,219 @@ import ZoomInIcon from "@mui/icons-material/ZoomIn";
15
38
  import ZoomOutIcon from "@mui/icons-material/ZoomOut";
16
39
  import FitScreenIcon from "@mui/icons-material/FitScreen";
17
40
  import AspectRatioIcon from "@mui/icons-material/AspectRatio";
18
- import SearchIcon2 from "@mui/icons-material/Search";
41
+ import SearchIcon from "@mui/icons-material/Search";
19
42
  import DownloadIcon from "@mui/icons-material/Download";
20
43
  import PrintIcon from "@mui/icons-material/Print";
21
44
  import InfoIcon from "@mui/icons-material/Info";
22
45
  import DescriptionIcon from "@mui/icons-material/Description";
46
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
47
+ var PDFToolbar = React2.memo(({
48
+ currentPage,
49
+ totalPages,
50
+ zoom,
51
+ isSidebarOpen,
52
+ showPageNavigation,
53
+ showPageCount,
54
+ showZoomControls,
55
+ showSearch,
56
+ showMetadata,
57
+ showProperties,
58
+ showDownload,
59
+ showPrint,
60
+ onFirstPage,
61
+ onPreviousPage,
62
+ onNextPage,
63
+ onLastPage,
64
+ onPageInput,
65
+ onPageInputKeyPress,
66
+ onZoomIn,
67
+ onZoomOut,
68
+ onFitToWidth,
69
+ onFitToPage,
70
+ onToggleSidebar,
71
+ onDownloadClick,
72
+ onPrintClick,
73
+ onMetadataClick,
74
+ onPropertiesClick
75
+ }) => {
76
+ return /* @__PURE__ */ jsxs("div", { className: "pdf-viewer-toolbar", children: [
77
+ showPageNavigation && /* @__PURE__ */ jsxs(Fragment, { children: [
78
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
79
+ /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
80
+ /* @__PURE__ */ jsx2(
81
+ "button",
82
+ {
83
+ className: "toolbar-button",
84
+ onClick: onFirstPage,
85
+ disabled: currentPage <= 1,
86
+ title: "First Page",
87
+ children: /* @__PURE__ */ jsx2(FirstPageIcon, { fontSize: "small" })
88
+ }
89
+ ),
90
+ /* @__PURE__ */ jsx2(
91
+ "button",
92
+ {
93
+ className: "toolbar-button",
94
+ onClick: onPreviousPage,
95
+ disabled: currentPage <= 1,
96
+ title: "Previous Page",
97
+ children: /* @__PURE__ */ jsx2(ChevronLeftIcon, { fontSize: "small" })
98
+ }
99
+ ),
100
+ /* @__PURE__ */ jsx2(
101
+ "input",
102
+ {
103
+ type: "number",
104
+ className: "page-input",
105
+ value: currentPage,
106
+ onChange: onPageInput,
107
+ onKeyPress: onPageInputKeyPress,
108
+ min: 1,
109
+ max: totalPages || void 0
110
+ }
111
+ ),
112
+ showPageCount && /* @__PURE__ */ jsxs("span", { className: "page-info", children: [
113
+ "of ",
114
+ totalPages || "..."
115
+ ] }),
116
+ /* @__PURE__ */ jsx2(
117
+ "button",
118
+ {
119
+ className: "toolbar-button",
120
+ onClick: onNextPage,
121
+ disabled: currentPage >= totalPages,
122
+ title: "Next Page",
123
+ children: /* @__PURE__ */ jsx2(ChevronRightIcon, { fontSize: "small" })
124
+ }
125
+ ),
126
+ /* @__PURE__ */ jsx2(
127
+ "button",
128
+ {
129
+ className: "toolbar-button",
130
+ onClick: onLastPage,
131
+ disabled: currentPage >= totalPages,
132
+ title: "Last Page",
133
+ children: /* @__PURE__ */ jsx2(LastPageIcon, { fontSize: "small" })
134
+ }
135
+ )
136
+ ] })
137
+ ] }),
138
+ showZoomControls && /* @__PURE__ */ jsxs(Fragment, { children: [
139
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
140
+ /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
141
+ /* @__PURE__ */ jsx2(
142
+ "button",
143
+ {
144
+ className: "toolbar-button",
145
+ onClick: onZoomOut,
146
+ title: "Zoom Out",
147
+ children: /* @__PURE__ */ jsx2(ZoomOutIcon, { fontSize: "small" })
148
+ }
149
+ ),
150
+ /* @__PURE__ */ jsxs("span", { className: "zoom-display", children: [
151
+ zoom,
152
+ "%"
153
+ ] }),
154
+ /* @__PURE__ */ jsx2(
155
+ "button",
156
+ {
157
+ className: "toolbar-button",
158
+ onClick: onZoomIn,
159
+ title: "Zoom In",
160
+ children: /* @__PURE__ */ jsx2(ZoomInIcon, { fontSize: "small" })
161
+ }
162
+ ),
163
+ /* @__PURE__ */ jsx2(
164
+ "button",
165
+ {
166
+ className: "toolbar-button",
167
+ onClick: onFitToWidth,
168
+ title: "Fit to Width",
169
+ children: /* @__PURE__ */ jsx2(AspectRatioIcon, { fontSize: "small" })
170
+ }
171
+ ),
172
+ /* @__PURE__ */ jsx2(
173
+ "button",
174
+ {
175
+ className: "toolbar-button",
176
+ onClick: onFitToPage,
177
+ title: "Fit to Page",
178
+ children: /* @__PURE__ */ jsx2(FitScreenIcon, { fontSize: "small" })
179
+ }
180
+ )
181
+ ] })
182
+ ] }),
183
+ showSearch && /* @__PURE__ */ jsxs(Fragment, { children: [
184
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
185
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-section", children: /* @__PURE__ */ jsx2(
186
+ "button",
187
+ {
188
+ className: "toolbar-button",
189
+ onClick: onToggleSidebar,
190
+ title: "Search in PDF",
191
+ style: {
192
+ backgroundColor: isSidebarOpen ? "#e3f2fd" : "transparent",
193
+ color: isSidebarOpen ? "#1976d2" : "inherit"
194
+ },
195
+ children: /* @__PURE__ */ jsx2(SearchIcon, { fontSize: "small" })
196
+ }
197
+ ) })
198
+ ] }),
199
+ (showMetadata || showProperties || showDownload || showPrint) && /* @__PURE__ */ jsxs(Fragment, { children: [
200
+ /* @__PURE__ */ jsx2("div", { className: "toolbar-separator" }),
201
+ /* @__PURE__ */ jsxs("div", { className: "toolbar-section", children: [
202
+ showDownload && /* @__PURE__ */ jsx2(
203
+ "button",
204
+ {
205
+ className: "toolbar-button",
206
+ onClick: onDownloadClick,
207
+ title: "Download PDF",
208
+ children: /* @__PURE__ */ jsx2(DownloadIcon, { fontSize: "small" })
209
+ }
210
+ ),
211
+ showPrint && /* @__PURE__ */ jsx2(
212
+ "button",
213
+ {
214
+ className: "toolbar-button",
215
+ onClick: onPrintClick,
216
+ title: "Print PDF",
217
+ children: /* @__PURE__ */ jsx2(PrintIcon, { fontSize: "small" })
218
+ }
219
+ ),
220
+ showMetadata && /* @__PURE__ */ jsx2(
221
+ "button",
222
+ {
223
+ className: "toolbar-button",
224
+ onClick: onMetadataClick,
225
+ title: "Document Metadata",
226
+ children: /* @__PURE__ */ jsx2(InfoIcon, { fontSize: "small" })
227
+ }
228
+ ),
229
+ showProperties && /* @__PURE__ */ jsx2(
230
+ "button",
231
+ {
232
+ className: "toolbar-button",
233
+ onClick: onPropertiesClick,
234
+ title: "Document Properties",
235
+ children: /* @__PURE__ */ jsx2(DescriptionIcon, { fontSize: "small" })
236
+ }
237
+ )
238
+ ] })
239
+ ] })
240
+ ] });
241
+ });
242
+ PDFToolbar.displayName = "PDFToolbar";
243
+
244
+ // src/components/viewers/pdf/PDFHeader.tsx
245
+ import React3 from "react";
246
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
247
+ var PDFHeader = React3.memo(({ fileName, fileExtension }) => {
248
+ return /* @__PURE__ */ jsxs2("div", { className: "pdf-viewer-header", children: [
249
+ /* @__PURE__ */ jsx3(FileIcon_default, { ext: fileExtension, size: 26 }),
250
+ /* @__PURE__ */ jsx3("div", { className: "header-file-name", title: fileName, children: fileName })
251
+ ] });
252
+ });
253
+ PDFHeader.displayName = "PDFHeader";
23
254
 
24
255
  // src/components/viewers/pdf/SearchSidebar.tsx
25
256
  import { useState, useLayoutEffect, useEffect, useRef } from "react";
@@ -31,13 +262,13 @@ import {
31
262
  InputAdornment,
32
263
  Divider
33
264
  } from "@mui/material";
34
- import SearchIcon from "@mui/icons-material/Search";
265
+ import SearchIcon2 from "@mui/icons-material/Search";
35
266
  import CloseIcon from "@mui/icons-material/Close";
36
267
  import KeyboardArrowUpIcon from "@mui/icons-material/KeyboardArrowUp";
37
268
  import KeyboardArrowDownIcon from "@mui/icons-material/KeyboardArrowDown";
38
269
  import ClearIcon from "@mui/icons-material/Clear";
39
270
  import FindInPageIcon from "@mui/icons-material/FindInPage";
40
- import { jsx, jsxs } from "react/jsx-runtime";
271
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
41
272
  var SearchSidebar = ({
42
273
  isOpen,
43
274
  onClose,
@@ -172,7 +403,7 @@ var SearchSidebar = ({
172
403
  const regex = new RegExp(`(${escapedKeyword})`, "gi");
173
404
  const parts = textString.split(regex);
174
405
  return parts.map(
175
- (part, index) => regex.test(part) ? /* @__PURE__ */ jsx(
406
+ (part, index) => regex.test(part) ? /* @__PURE__ */ jsx4(
176
407
  Box,
177
408
  {
178
409
  component: "span",
@@ -191,7 +422,7 @@ var SearchSidebar = ({
191
422
  }
192
423
  };
193
424
  if (!isOpen) return null;
194
- return /* @__PURE__ */ jsxs(
425
+ return /* @__PURE__ */ jsxs3(
195
426
  Box,
196
427
  {
197
428
  sx: {
@@ -205,10 +436,10 @@ var SearchSidebar = ({
205
436
  overflow: "hidden"
206
437
  },
207
438
  children: [
208
- /* @__PURE__ */ jsxs(Box, { sx: { px: 3, py: 2.5, backgroundColor: "background.default" }, children: [
209
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2 }, children: [
210
- /* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { fontSize: "1.125rem", fontWeight: 600, color: "text.primary" }, children: "Search" }),
211
- /* @__PURE__ */ jsx(
439
+ /* @__PURE__ */ jsxs3(Box, { sx: { px: 3, py: 2.5, backgroundColor: "background.default" }, children: [
440
+ /* @__PURE__ */ jsxs3(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between", mb: 2 }, children: [
441
+ /* @__PURE__ */ jsx4(Typography, { variant: "h6", sx: { fontSize: "1.125rem", fontWeight: 600, color: "text.primary" }, children: "Search" }),
442
+ /* @__PURE__ */ jsx4(
212
443
  IconButton,
213
444
  {
214
445
  size: "small",
@@ -217,11 +448,11 @@ var SearchSidebar = ({
217
448
  color: "text.secondary",
218
449
  padding: "6px"
219
450
  },
220
- children: /* @__PURE__ */ jsx(CloseIcon, { fontSize: "small" })
451
+ children: /* @__PURE__ */ jsx4(CloseIcon, { fontSize: "small" })
221
452
  }
222
453
  )
223
454
  ] }),
224
- /* @__PURE__ */ jsx("form", { onSubmit: handleSearchSubmit, children: /* @__PURE__ */ jsx(
455
+ /* @__PURE__ */ jsx4("form", { onSubmit: handleSearchSubmit, children: /* @__PURE__ */ jsx4(
225
456
  TextField,
226
457
  {
227
458
  fullWidth: true,
@@ -231,8 +462,8 @@ var SearchSidebar = ({
231
462
  onChange: handleSearchChange,
232
463
  autoComplete: "off",
233
464
  InputProps: {
234
- startAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx(SearchIcon, { sx: { color: "text.disabled", fontSize: 20 } }) }),
235
- endAdornment: searchTerm && /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx(
465
+ startAdornment: /* @__PURE__ */ jsx4(InputAdornment, { position: "start", children: /* @__PURE__ */ jsx4(SearchIcon2, { sx: { color: "text.disabled", fontSize: 20 } }) }),
466
+ endAdornment: searchTerm && /* @__PURE__ */ jsx4(InputAdornment, { position: "end", children: /* @__PURE__ */ jsx4(
236
467
  IconButton,
237
468
  {
238
469
  size: "small",
@@ -244,7 +475,7 @@ var SearchSidebar = ({
244
475
  backgroundColor: "action.hover"
245
476
  }
246
477
  },
247
- children: /* @__PURE__ */ jsx(ClearIcon, { sx: { fontSize: 18 } })
478
+ children: /* @__PURE__ */ jsx4(ClearIcon, { sx: { fontSize: 18 } })
248
479
  }
249
480
  ) })
250
481
  },
@@ -267,7 +498,7 @@ var SearchSidebar = ({
267
498
  }
268
499
  }
269
500
  ) }),
270
- totalResults > 0 && /* @__PURE__ */ jsxs(
501
+ totalResults > 0 && /* @__PURE__ */ jsxs3(
271
502
  Box,
272
503
  {
273
504
  sx: {
@@ -280,14 +511,14 @@ var SearchSidebar = ({
280
511
  borderColor: "divider"
281
512
  },
282
513
  children: [
283
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", sx: { color: "text.secondary", fontSize: "0.875rem", fontWeight: 500 }, children: [
514
+ /* @__PURE__ */ jsxs3(Typography, { variant: "body2", sx: { color: "text.secondary", fontSize: "0.875rem", fontWeight: 500 }, children: [
284
515
  currentResultIndex + 1,
285
516
  " of ",
286
517
  totalResults,
287
518
  " results"
288
519
  ] }),
289
- /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
290
- /* @__PURE__ */ jsx(
520
+ /* @__PURE__ */ jsxs3(Box, { sx: { display: "flex", alignItems: "center", gap: 0.5 }, children: [
521
+ /* @__PURE__ */ jsx4(
291
522
  IconButton,
292
523
  {
293
524
  size: "small",
@@ -300,10 +531,10 @@ var SearchSidebar = ({
300
531
  border: "1px solid",
301
532
  borderColor: currentResultIndex <= 0 ? "divider" : "primary.main"
302
533
  },
303
- children: /* @__PURE__ */ jsx(KeyboardArrowUpIcon, { sx: { fontSize: 20 } })
534
+ children: /* @__PURE__ */ jsx4(KeyboardArrowUpIcon, { sx: { fontSize: 20 } })
304
535
  }
305
536
  ),
306
- /* @__PURE__ */ jsx(
537
+ /* @__PURE__ */ jsx4(
307
538
  IconButton,
308
539
  {
309
540
  size: "small",
@@ -316,7 +547,7 @@ var SearchSidebar = ({
316
547
  border: "1px solid",
317
548
  borderColor: currentResultIndex >= totalResults - 1 ? "divider" : "primary.main"
318
549
  },
319
- children: /* @__PURE__ */ jsx(KeyboardArrowDownIcon, { sx: { fontSize: 20 } })
550
+ children: /* @__PURE__ */ jsx4(KeyboardArrowDownIcon, { sx: { fontSize: 20 } })
320
551
  }
321
552
  )
322
553
  ] })
@@ -324,14 +555,14 @@ var SearchSidebar = ({
324
555
  }
325
556
  )
326
557
  ] }),
327
- /* @__PURE__ */ jsx(Divider, {}),
328
- /* @__PURE__ */ jsxs(Box, { ref: contentRef, className: "search-sidebar-content", sx: {
558
+ /* @__PURE__ */ jsx4(Divider, {}),
559
+ /* @__PURE__ */ jsxs3(Box, { ref: contentRef, className: "search-sidebar-content", sx: {
329
560
  flex: 1,
330
561
  overflow: "auto",
331
562
  backgroundColor: "background.default"
332
563
  }, children: [
333
- !searchTerm && !hasSearched && /* @__PURE__ */ jsxs(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
334
- /* @__PURE__ */ jsx(
564
+ !searchTerm && !hasSearched && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
565
+ /* @__PURE__ */ jsx4(
335
566
  Box,
336
567
  {
337
568
  sx: {
@@ -345,14 +576,14 @@ var SearchSidebar = ({
345
576
  margin: "0 auto",
346
577
  mb: 3
347
578
  },
348
- children: /* @__PURE__ */ jsx(SearchIcon, { sx: { fontSize: 40, color: "text.disabled" } })
579
+ children: /* @__PURE__ */ jsx4(SearchIcon2, { sx: { fontSize: 40, color: "text.disabled" } })
349
580
  }
350
581
  ),
351
- /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Search in Document" }),
352
- /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: "Enter keywords to find text within the PDF document" })
582
+ /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Search in Document" }),
583
+ /* @__PURE__ */ jsx4(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: "Enter keywords to find text within the PDF document" })
353
584
  ] }),
354
- searchTerm && !hasSearched && /* @__PURE__ */ jsxs(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
355
- /* @__PURE__ */ jsx(
585
+ searchTerm && !hasSearched && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
586
+ /* @__PURE__ */ jsx4(
356
587
  Box,
357
588
  {
358
589
  sx: {
@@ -367,12 +598,12 @@ var SearchSidebar = ({
367
598
  mb: 3,
368
599
  opacity: 0.2
369
600
  },
370
- children: /* @__PURE__ */ jsx(FindInPageIcon, { sx: { fontSize: 40, color: "primary.main" } })
601
+ children: /* @__PURE__ */ jsx4(FindInPageIcon, { sx: { fontSize: 40, color: "primary.main" } })
371
602
  }
372
603
  ),
373
- /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Ready to Search" }),
374
- /* @__PURE__ */ jsx(Typography, { variant: "body2", sx: { color: "text.secondary", mb: 2, lineHeight: 1.6 }, children: "Press Enter to find" }),
375
- /* @__PURE__ */ jsxs(
604
+ /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Ready to Search" }),
605
+ /* @__PURE__ */ jsx4(Typography, { variant: "body2", sx: { color: "text.secondary", mb: 2, lineHeight: 1.6 }, children: "Press Enter to find" }),
606
+ /* @__PURE__ */ jsxs3(
376
607
  Typography,
377
608
  {
378
609
  variant: "body2",
@@ -393,8 +624,8 @@ var SearchSidebar = ({
393
624
  }
394
625
  )
395
626
  ] }),
396
- hasSearched && totalResults === 0 && !isSearching && /* @__PURE__ */ jsxs(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
397
- /* @__PURE__ */ jsx(
627
+ hasSearched && totalResults === 0 && !isSearching && /* @__PURE__ */ jsxs3(Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
628
+ /* @__PURE__ */ jsx4(
398
629
  Box,
399
630
  {
400
631
  sx: {
@@ -409,24 +640,24 @@ var SearchSidebar = ({
409
640
  mb: 3,
410
641
  opacity: 0.6
411
642
  },
412
- children: /* @__PURE__ */ jsx(SearchIcon, { sx: { fontSize: 40, color: "warning.main" } })
643
+ children: /* @__PURE__ */ jsx4(SearchIcon2, { sx: { fontSize: 40, color: "warning.main" } })
413
644
  }
414
645
  ),
415
- /* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "No Results Found" }),
416
- /* @__PURE__ */ jsxs(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
646
+ /* @__PURE__ */ jsx4(Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "No Results Found" }),
647
+ /* @__PURE__ */ jsxs3(Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
417
648
  "No matches found for ",
418
- /* @__PURE__ */ jsxs("strong", { children: [
649
+ /* @__PURE__ */ jsxs3("strong", { children: [
419
650
  '"',
420
651
  searchTerm,
421
652
  '"'
422
653
  ] })
423
654
  ] })
424
655
  ] }),
425
- totalResults > 0 && /* @__PURE__ */ jsx(Box, { sx: { p: 2 }, children: Object.keys(resultsByPage).sort((a, b) => parseInt(a) - parseInt(b)).map((pageNum) => {
656
+ totalResults > 0 && /* @__PURE__ */ jsx4(Box, { sx: { p: 2 }, children: Object.keys(resultsByPage).sort((a, b) => parseInt(a) - parseInt(b)).map((pageNum) => {
426
657
  const pageNumber = parseInt(pageNum);
427
658
  const pageResults = resultsByPage[pageNumber];
428
- return /* @__PURE__ */ jsxs(Box, { sx: { mb: 3 }, children: [
429
- /* @__PURE__ */ jsxs(
659
+ return /* @__PURE__ */ jsxs3(Box, { sx: { mb: 3 }, children: [
660
+ /* @__PURE__ */ jsxs3(
430
661
  Typography,
431
662
  {
432
663
  variant: "subtitle2",
@@ -445,7 +676,7 @@ var SearchSidebar = ({
445
676
  ]
446
677
  }
447
678
  ),
448
- pageResults.map((result, index) => /* @__PURE__ */ jsx(
679
+ pageResults.map((result, index) => /* @__PURE__ */ jsx4(
449
680
  Box,
450
681
  {
451
682
  onClick: () => onSearchResultClick(result.pageNumber, result.index),
@@ -466,7 +697,7 @@ var SearchSidebar = ({
466
697
  transform: "translateY(-1px)"
467
698
  }
468
699
  },
469
- children: /* @__PURE__ */ jsx(
700
+ children: /* @__PURE__ */ jsx4(
470
701
  Typography,
471
702
  {
472
703
  variant: "body2",
@@ -509,7 +740,7 @@ import CloseIcon2 from "@mui/icons-material/Close";
509
740
  import LockIcon from "@mui/icons-material/Lock";
510
741
  import VisibilityIcon from "@mui/icons-material/Visibility";
511
742
  import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
512
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
743
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
513
744
  var PasswordDialog = ({
514
745
  open,
515
746
  fileName,
@@ -539,7 +770,7 @@ var PasswordDialog = ({
539
770
  handleSubmit(e);
540
771
  }
541
772
  };
542
- return /* @__PURE__ */ jsxs2(
773
+ return /* @__PURE__ */ jsxs4(
543
774
  Dialog,
544
775
  {
545
776
  open,
@@ -552,9 +783,9 @@ var PasswordDialog = ({
552
783
  }
553
784
  },
554
785
  children: [
555
- /* @__PURE__ */ jsx2(DialogTitle, { sx: { pb: 1 }, children: /* @__PURE__ */ jsxs2(Box2, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
556
- /* @__PURE__ */ jsxs2(Box2, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
557
- /* @__PURE__ */ jsx2(
786
+ /* @__PURE__ */ jsx5(DialogTitle, { sx: { pb: 1 }, children: /* @__PURE__ */ jsxs4(Box2, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
787
+ /* @__PURE__ */ jsxs4(Box2, { sx: { display: "flex", alignItems: "center", gap: 1.5 }, children: [
788
+ /* @__PURE__ */ jsx5(
558
789
  Box2,
559
790
  {
560
791
  sx: {
@@ -567,34 +798,34 @@ var PasswordDialog = ({
567
798
  justifyContent: "center",
568
799
  opacity: 0.9
569
800
  },
570
- children: /* @__PURE__ */ jsx2(LockIcon, { sx: { color: "white", fontSize: 20 } })
801
+ children: /* @__PURE__ */ jsx5(LockIcon, { sx: { color: "white", fontSize: 20 } })
571
802
  }
572
803
  ),
573
- /* @__PURE__ */ jsx2(Typography2, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
804
+ /* @__PURE__ */ jsx5(Typography2, { variant: "h6", component: "div", sx: { fontWeight: 600 }, children: "Password Protected" })
574
805
  ] }),
575
- /* @__PURE__ */ jsx2(
806
+ /* @__PURE__ */ jsx5(
576
807
  IconButton2,
577
808
  {
578
809
  size: "small",
579
810
  onClick: onCancel,
580
811
  sx: { color: "text.secondary" },
581
812
  "aria-label": "Close dialog",
582
- children: /* @__PURE__ */ jsx2(CloseIcon2, { fontSize: "small" })
813
+ children: /* @__PURE__ */ jsx5(CloseIcon2, { fontSize: "small" })
583
814
  }
584
815
  )
585
816
  ] }) }),
586
- /* @__PURE__ */ jsxs2(DialogContent, { sx: { pt: 2 }, children: [
587
- /* @__PURE__ */ jsxs2(Typography2, { variant: "body2", sx: { color: "text.secondary", mb: 3 }, children: [
817
+ /* @__PURE__ */ jsxs4(DialogContent, { sx: { pt: 2 }, children: [
818
+ /* @__PURE__ */ jsxs4(Typography2, { variant: "body2", sx: { color: "text.secondary", mb: 3 }, children: [
588
819
  "This PDF is password protected. Please enter the password to view",
589
820
  " ",
590
- fileName && /* @__PURE__ */ jsxs2("strong", { children: [
821
+ fileName && /* @__PURE__ */ jsxs4("strong", { children: [
591
822
  '"',
592
823
  fileName,
593
824
  '"'
594
825
  ] })
595
826
  ] }),
596
- error && /* @__PURE__ */ jsx2(Alert, { severity: "error", sx: { mb: 2 }, children: error }),
597
- /* @__PURE__ */ jsx2("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsx2(
827
+ error && /* @__PURE__ */ jsx5(Alert, { severity: "error", sx: { mb: 2 }, children: error }),
828
+ /* @__PURE__ */ jsx5("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsx5(
598
829
  TextField2,
599
830
  {
600
831
  fullWidth: true,
@@ -607,14 +838,14 @@ var PasswordDialog = ({
607
838
  onKeyPress: handleKeyPress,
608
839
  error: Boolean(error),
609
840
  InputProps: {
610
- endAdornment: /* @__PURE__ */ jsx2(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx2(
841
+ endAdornment: /* @__PURE__ */ jsx5(InputAdornment2, { position: "end", children: /* @__PURE__ */ jsx5(
611
842
  IconButton2,
612
843
  {
613
844
  onClick: handleTogglePasswordVisibility,
614
845
  edge: "end",
615
846
  size: "small",
616
847
  "aria-label": showPassword ? "Hide password" : "Show password",
617
- children: showPassword ? /* @__PURE__ */ jsx2(VisibilityOffIcon, {}) : /* @__PURE__ */ jsx2(VisibilityIcon, {})
848
+ children: showPassword ? /* @__PURE__ */ jsx5(VisibilityOffIcon, {}) : /* @__PURE__ */ jsx5(VisibilityIcon, {})
618
849
  }
619
850
  ) })
620
851
  },
@@ -626,8 +857,8 @@ var PasswordDialog = ({
626
857
  }
627
858
  ) })
628
859
  ] }),
629
- /* @__PURE__ */ jsxs2(DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: [
630
- /* @__PURE__ */ jsx2(
860
+ /* @__PURE__ */ jsxs4(DialogActions, { sx: { px: 3, pb: 3, pt: 2 }, children: [
861
+ /* @__PURE__ */ jsx5(
631
862
  Button,
632
863
  {
633
864
  onClick: onCancel,
@@ -640,7 +871,7 @@ var PasswordDialog = ({
640
871
  children: "Cancel"
641
872
  }
642
873
  ),
643
- /* @__PURE__ */ jsx2(
874
+ /* @__PURE__ */ jsx5(
644
875
  Button,
645
876
  {
646
877
  onClick: handleSubmit,
@@ -661,19 +892,17 @@ var PasswordDialog = ({
661
892
  );
662
893
  };
663
894
 
664
- // src/components/viewers/PDFViewer.tsx
665
- import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
666
- var HeadlessPDFViewer = HeadlessPDFViewerImport;
895
+ // src/components/viewers/pdf/PDFStyles.tsx
667
896
  var toolbarStyles = `
668
897
  @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;500;600;700&family=Noto+Sans+Devanagari:wght@400;500;600;700&display=swap');
669
-
898
+
670
899
  * {
671
900
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
672
901
  'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
673
- 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
902
+ 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
674
903
  'Arial Unicode MS', sans-serif !important;
675
904
  }
676
-
905
+
677
906
  /* Target PDF.js text layer */
678
907
  .textLayer,
679
908
  .textLayer span,
@@ -686,10 +915,10 @@ var toolbarStyles = `
686
915
  [role="document"] * {
687
916
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
688
917
  'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
689
- 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
918
+ 'Noto Sans Tamil', 'Noto Sans Devanagari', 'Lohit Tamil', 'Tamil MN',
690
919
  'Arial Unicode MS', sans-serif !important;
691
920
  }
692
-
921
+
693
922
  .pdf-viewer-header {
694
923
  display: flex;
695
924
  align-items: center;
@@ -815,6 +1044,9 @@ var toolbarStyles = `
815
1044
  -ms-user-select: text !important;
816
1045
  }
817
1046
  `;
1047
+
1048
+ // src/components/viewers/PDFViewer.tsx
1049
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
818
1050
  var PDFViewerContent = forwardRef((props, ref) => {
819
1051
  const {
820
1052
  file,
@@ -867,6 +1099,111 @@ var PDFViewerContent = forwardRef((props, ref) => {
867
1099
  const [isPasswordDialogOpen, setIsPasswordDialogOpen] = useState3(false);
868
1100
  const [passwordError, setPasswordError] = useState3("");
869
1101
  const [passwordResolve, setPasswordResolve] = useState3(null);
1102
+ const hasExecutedInitialSearch = useRef2(false);
1103
+ const toolbarHandlers = useMemo(() => ({
1104
+ handleZoomIn: () => {
1105
+ pdfViewerRef.current?.zoom.zoomIn();
1106
+ requestAnimationFrame(() => {
1107
+ const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1108
+ if (typeof zoomValue === "number") {
1109
+ setZoom(Math.round(zoomValue * 100));
1110
+ }
1111
+ });
1112
+ },
1113
+ handleZoomOut: () => {
1114
+ pdfViewerRef.current?.zoom.zoomOut();
1115
+ requestAnimationFrame(() => {
1116
+ const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1117
+ if (typeof zoomValue === "number") {
1118
+ setZoom(Math.round(zoomValue * 100));
1119
+ }
1120
+ });
1121
+ },
1122
+ handleFitToWidth: () => {
1123
+ pdfViewerRef.current?.zoom.fitToWidth();
1124
+ requestAnimationFrame(() => {
1125
+ const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1126
+ if (typeof zoomValue === "number") {
1127
+ setZoom(Math.round(zoomValue * 100));
1128
+ }
1129
+ });
1130
+ },
1131
+ handleFitToPage: () => {
1132
+ pdfViewerRef.current?.zoom.fitToPage();
1133
+ requestAnimationFrame(() => {
1134
+ const zoomValue = pdfViewerRef.current?.zoom.getZoom();
1135
+ if (typeof zoomValue === "number") {
1136
+ setZoom(Math.round(zoomValue * 100));
1137
+ }
1138
+ });
1139
+ },
1140
+ handlePreviousPage: () => {
1141
+ pdfViewerRef.current?.navigation.previousPage();
1142
+ requestAnimationFrame(() => {
1143
+ const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1144
+ setCurrentPage(current);
1145
+ });
1146
+ },
1147
+ handleNextPage: () => {
1148
+ pdfViewerRef.current?.navigation.nextPage();
1149
+ requestAnimationFrame(() => {
1150
+ const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1151
+ setCurrentPage(current);
1152
+ });
1153
+ },
1154
+ handleFirstPage: () => {
1155
+ pdfViewerRef.current?.navigation.goToFirstPage();
1156
+ requestAnimationFrame(() => {
1157
+ const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1158
+ setCurrentPage(current);
1159
+ });
1160
+ },
1161
+ handleLastPage: () => {
1162
+ pdfViewerRef.current?.navigation.goToLastPage();
1163
+ requestAnimationFrame(() => {
1164
+ const current = pdfViewerRef.current?.navigation.getCurrentPage() || 1;
1165
+ setCurrentPage(current);
1166
+ });
1167
+ },
1168
+ toggleSidebar: () => setIsSidebarOpen(!isSidebarOpen),
1169
+ handlePageInput: (e) => {
1170
+ const value = e.target.value;
1171
+ if (/^\d*$/.test(value)) {
1172
+ return;
1173
+ }
1174
+ const page = parseInt(value, 10);
1175
+ if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1176
+ pdfViewerRef.current?.navigation.goToPage(page);
1177
+ setCurrentPage(page);
1178
+ }
1179
+ },
1180
+ handlePageInputKeyPress: (e) => {
1181
+ if (e.key === "Enter") {
1182
+ const value = e.target.value;
1183
+ const page = parseInt(value, 10);
1184
+ if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1185
+ pdfViewerRef.current?.navigation.goToPage(page);
1186
+ setCurrentPage(page);
1187
+ }
1188
+ }
1189
+ }
1190
+ }), [isSidebarOpen, totalPages]);
1191
+ useEffect3(() => {
1192
+ console.log("came", initialSearchText, pdfViewerRef.current, hasExecutedInitialSearch.current);
1193
+ if (pdfViewerRef.current && !hasExecutedInitialSearch.current && initialSearchText) {
1194
+ hasExecutedInitialSearch.current = true;
1195
+ setIsSidebarOpen(true);
1196
+ setSearchQuery(initialSearchText);
1197
+ handleSidebarSearch(initialSearchText, initialSearchPages);
1198
+ setAutoExecuteSearch(false);
1199
+ pdfViewerRef.current.search.searchText(initialSearchText).then((results) => {
1200
+ console.log("results", results);
1201
+ if (results?.results?.length > 0) {
1202
+ pdfViewerRef.current?.navigation.goToPage(results.results[0].pageIndex + 1);
1203
+ }
1204
+ });
1205
+ }
1206
+ }, [pdfViewerRef.current, initialSearchText]);
870
1207
  useEffect3(() => {
871
1208
  setSearchQuery("");
872
1209
  setSearchResults([]);
@@ -954,23 +1291,6 @@ var PDFViewerContent = forwardRef((props, ref) => {
954
1291
  };
955
1292
  initializePageCount();
956
1293
  }, [state, totalPages]);
957
- useEffect3(() => {
958
- if (state !== "ready" || !autoExecuteSearch || !initialSearchText) return;
959
- const scheduleSearch = (callback) => {
960
- if ("requestIdleCallback" in window) {
961
- requestIdleCallback(callback, { timeout: 2e3 });
962
- } else {
963
- requestAnimationFrame(() => setTimeout(callback, 0));
964
- }
965
- };
966
- scheduleSearch(() => {
967
- if (!pdfViewerRef.current) return;
968
- setIsSidebarOpen(true);
969
- setSearchQuery(initialSearchText);
970
- handleSidebarSearch(initialSearchText, initialSearchPages);
971
- setAutoExecuteSearch(false);
972
- });
973
- }, [state, autoExecuteSearch, initialSearchText, initialSearchPages]);
974
1294
  useEffect3(() => {
975
1295
  if (state === "ready" && pdfViewerRef.current) {
976
1296
  const updateInfo = () => {
@@ -1072,59 +1392,6 @@ var PDFViewerContent = forwardRef((props, ref) => {
1072
1392
  }
1073
1393
  });
1074
1394
  };
1075
- const handleZoomIn = () => {
1076
- pdfViewerRef.current?.zoom.zoomIn();
1077
- updateZoomDisplay();
1078
- };
1079
- const handleZoomOut = () => {
1080
- pdfViewerRef.current?.zoom.zoomOut();
1081
- updateZoomDisplay();
1082
- };
1083
- const handleFitToWidth = () => {
1084
- pdfViewerRef.current?.zoom.fitToWidth();
1085
- updateZoomDisplay();
1086
- };
1087
- const handleFitToPage = () => {
1088
- pdfViewerRef.current?.zoom.fitToPage();
1089
- updateZoomDisplay();
1090
- };
1091
- const handlePreviousPage = () => {
1092
- pdfViewerRef.current?.navigation.previousPage();
1093
- updatePageDisplay();
1094
- };
1095
- const handleNextPage = () => {
1096
- pdfViewerRef.current?.navigation.nextPage();
1097
- updatePageDisplay();
1098
- };
1099
- const handleFirstPage = () => {
1100
- pdfViewerRef.current?.navigation.goToFirstPage();
1101
- updatePageDisplay();
1102
- };
1103
- const handleLastPage = () => {
1104
- pdfViewerRef.current?.navigation.goToLastPage();
1105
- updatePageDisplay();
1106
- };
1107
- const handlePageInput = (e) => {
1108
- const value = e.target.value;
1109
- const page = parseInt(value, 10);
1110
- if (/^\d*$/.test(value)) {
1111
- return;
1112
- }
1113
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1114
- pdfViewerRef.current?.navigation.goToPage(page);
1115
- setCurrentPage(page);
1116
- }
1117
- };
1118
- const handlePageInputKeyPress = (e) => {
1119
- if (e.key === "Enter") {
1120
- const value = e.target.value;
1121
- const page = parseInt(value, 10);
1122
- if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1123
- pdfViewerRef.current?.navigation.goToPage(page);
1124
- setCurrentPage(page);
1125
- }
1126
- }
1127
- };
1128
1395
  const handleSearch = async () => {
1129
1396
  if (searchQuery.trim()) {
1130
1397
  setIsSearching(true);
@@ -1240,9 +1507,6 @@ var PDFViewerContent = forwardRef((props, ref) => {
1240
1507
  setCurrentPage(pageNumber);
1241
1508
  pdfViewerRef.current?.search.goToResult(resultIndex);
1242
1509
  };
1243
- const toggleSidebar = () => {
1244
- setIsSidebarOpen(!isSidebarOpen);
1245
- };
1246
1510
  const handleNextSearchResult = () => {
1247
1511
  if (currentSearchResultIndex < totalSearchResults - 1) {
1248
1512
  const nextIndex = currentSearchResultIndex + 1;
@@ -1267,69 +1531,6 @@ var PDFViewerContent = forwardRef((props, ref) => {
1267
1531
  }
1268
1532
  }
1269
1533
  };
1270
- const handlePrint = () => {
1271
- if (onPrintClick) {
1272
- onPrintClick();
1273
- return;
1274
- }
1275
- if (!pdfBuffer) return;
1276
- const blob = new Blob([pdfBuffer], { type: "application/pdf" });
1277
- const blobUrl = URL.createObjectURL(blob);
1278
- const iframe = document.createElement("iframe");
1279
- iframe.style.position = "fixed";
1280
- iframe.style.right = "0";
1281
- iframe.style.bottom = "0";
1282
- iframe.style.width = "0";
1283
- iframe.style.height = "0";
1284
- iframe.style.border = "0";
1285
- document.body.appendChild(iframe);
1286
- iframe.onload = () => {
1287
- try {
1288
- requestAnimationFrame(() => {
1289
- const iframeWindow = iframe.contentWindow;
1290
- if (!iframeWindow) return;
1291
- iframeWindow.focus();
1292
- iframeWindow.print();
1293
- const cleanup = () => {
1294
- requestAnimationFrame(() => {
1295
- try {
1296
- if (document.body.contains(iframe)) {
1297
- document.body.removeChild(iframe);
1298
- }
1299
- URL.revokeObjectURL(blobUrl);
1300
- } catch (e) {
1301
- }
1302
- });
1303
- };
1304
- if ("onafterprint" in iframeWindow) {
1305
- iframeWindow.onafterprint = cleanup;
1306
- } else {
1307
- const visibilityHandler = () => {
1308
- if (!document.hidden) {
1309
- cleanup();
1310
- document.removeEventListener("visibilitychange", visibilityHandler);
1311
- }
1312
- };
1313
- document.addEventListener("visibilitychange", visibilityHandler);
1314
- setTimeout(() => {
1315
- cleanup();
1316
- document.removeEventListener("visibilitychange", visibilityHandler);
1317
- }, 5e3);
1318
- }
1319
- });
1320
- } catch (error2) {
1321
- if (document.body.contains(iframe)) {
1322
- document.body.removeChild(iframe);
1323
- }
1324
- URL.revokeObjectURL(blobUrl);
1325
- }
1326
- };
1327
- iframe.onerror = () => {
1328
- document.body.removeChild(iframe);
1329
- URL.revokeObjectURL(blobUrl);
1330
- };
1331
- iframe.src = blobUrl;
1332
- };
1333
1534
  useEffect3(() => {
1334
1535
  if (!file) {
1335
1536
  setState("error");
@@ -1390,7 +1591,7 @@ var PDFViewerContent = forwardRef((props, ref) => {
1390
1591
  }
1391
1592
  }, [passwordResolve]);
1392
1593
  if (state === "loading") {
1393
- return /* @__PURE__ */ jsxs3("div", { style: {
1594
+ return /* @__PURE__ */ jsxs5("div", { style: {
1394
1595
  display: "flex",
1395
1596
  flexDirection: "column",
1396
1597
  alignItems: "center",
@@ -1398,7 +1599,7 @@ var PDFViewerContent = forwardRef((props, ref) => {
1398
1599
  height: "100%",
1399
1600
  gap: "16px"
1400
1601
  }, children: [
1401
- /* @__PURE__ */ jsx3("div", { className: "spinner", style: {
1602
+ /* @__PURE__ */ jsx6("div", { className: "spinner", style: {
1402
1603
  width: "48px",
1403
1604
  height: "48px",
1404
1605
  border: "4px solid #f3f3f3",
@@ -1406,8 +1607,8 @@ var PDFViewerContent = forwardRef((props, ref) => {
1406
1607
  borderRadius: "50%",
1407
1608
  animation: "spin 1s linear infinite"
1408
1609
  } }),
1409
- /* @__PURE__ */ jsx3("p", { children: "Loading PDF..." }),
1410
- /* @__PURE__ */ jsx3("style", { children: `
1610
+ /* @__PURE__ */ jsx6("p", { children: "Loading PDF..." }),
1611
+ /* @__PURE__ */ jsx6("style", { children: `
1411
1612
  @keyframes spin {
1412
1613
  0% { transform: rotate(0deg); }
1413
1614
  100% { transform: rotate(360deg); }
@@ -1416,213 +1617,83 @@ var PDFViewerContent = forwardRef((props, ref) => {
1416
1617
  ] });
1417
1618
  }
1418
1619
  if (state === "error" || error) {
1419
- return /* @__PURE__ */ jsx3("div", { style: {
1620
+ return /* @__PURE__ */ jsx6("div", { style: {
1420
1621
  display: "flex",
1421
1622
  flexDirection: "column",
1422
1623
  alignItems: "center",
1423
1624
  justifyContent: "center",
1424
1625
  height: "100%",
1425
1626
  padding: "24px"
1426
- }, children: /* @__PURE__ */ jsxs3("div", { style: {
1627
+ }, children: /* @__PURE__ */ jsxs5("div", { style: {
1427
1628
  maxWidth: "400px",
1428
1629
  padding: "16px",
1429
1630
  backgroundColor: "#fee",
1430
1631
  border: "1px solid #fcc",
1431
1632
  borderRadius: "4px"
1432
1633
  }, children: [
1433
- /* @__PURE__ */ jsx3("h3", { style: { marginTop: 0 }, children: "Failed to Load PDF" }),
1434
- /* @__PURE__ */ jsx3("p", { children: error || "Unknown error occurred" })
1634
+ /* @__PURE__ */ jsx6("h3", { style: { marginTop: 0 }, children: "Failed to Load PDF" }),
1635
+ /* @__PURE__ */ jsx6("p", { children: error || "Unknown error occurred" })
1435
1636
  ] }) });
1436
1637
  }
1437
1638
  if (!pdfBuffer || state !== "ready") {
1438
- return /* @__PURE__ */ jsx3("div", { style: {
1639
+ return /* @__PURE__ */ jsx6("div", { style: {
1439
1640
  display: "flex",
1440
1641
  alignItems: "center",
1441
1642
  justifyContent: "center",
1442
1643
  height: "100%"
1443
- }, children: /* @__PURE__ */ jsx3("p", { children: "Preparing PDF..." }) });
1644
+ }, children: /* @__PURE__ */ jsx6("p", { children: "Preparing PDF..." }) });
1444
1645
  }
1445
- return /* @__PURE__ */ jsxs3("div", { className: "pdf-viewer-container", children: [
1446
- /* @__PURE__ */ jsx3("style", { children: toolbarStyles }),
1447
- /* @__PURE__ */ jsxs3("div", { className: "pdf-viewer-header", children: [
1448
- /* @__PURE__ */ jsx3(FileIcon_default, { ext: fileExtension, size: 26 }),
1449
- /* @__PURE__ */ jsx3("div", { className: "header-file-name", title: resolvedFileName, children: resolvedFileName })
1450
- ] }),
1451
- /* @__PURE__ */ jsxs3("div", { className: "pdf-viewer-toolbar", children: [
1452
- showPageNavigation && /* @__PURE__ */ jsxs3(Fragment, { children: [
1453
- /* @__PURE__ */ jsx3("div", { className: "toolbar-separator" }),
1454
- /* @__PURE__ */ jsxs3("div", { className: "toolbar-section", children: [
1455
- /* @__PURE__ */ jsx3(
1456
- "button",
1457
- {
1458
- className: "toolbar-button",
1459
- onClick: handleFirstPage,
1460
- disabled: currentPage <= 1,
1461
- title: "First Page",
1462
- children: /* @__PURE__ */ jsx3(FirstPageIcon, { fontSize: "small" })
1463
- }
1464
- ),
1465
- /* @__PURE__ */ jsx3(
1466
- "button",
1467
- {
1468
- className: "toolbar-button",
1469
- onClick: handlePreviousPage,
1470
- disabled: currentPage <= 1,
1471
- title: "Previous Page",
1472
- children: /* @__PURE__ */ jsx3(ChevronLeftIcon, { fontSize: "small" })
1473
- }
1474
- ),
1475
- /* @__PURE__ */ jsx3(
1476
- "input",
1477
- {
1478
- type: "number",
1479
- className: "page-input",
1480
- value: currentPage,
1481
- onChange: handlePageInput,
1482
- onKeyPress: handlePageInputKeyPress,
1483
- min: 1,
1484
- max: totalPages || void 0
1485
- }
1486
- ),
1487
- showPageCount && /* @__PURE__ */ jsxs3("span", { className: "page-info", children: [
1488
- "of ",
1489
- totalPages || "..."
1490
- ] }),
1491
- /* @__PURE__ */ jsx3(
1492
- "button",
1493
- {
1494
- className: "toolbar-button",
1495
- onClick: handleNextPage,
1496
- disabled: currentPage >= totalPages,
1497
- title: "Next Page",
1498
- children: /* @__PURE__ */ jsx3(ChevronRightIcon, { fontSize: "small" })
1499
- }
1500
- ),
1501
- /* @__PURE__ */ jsx3(
1502
- "button",
1503
- {
1504
- className: "toolbar-button",
1505
- onClick: handleLastPage,
1506
- disabled: currentPage >= totalPages,
1507
- title: "Last Page",
1508
- children: /* @__PURE__ */ jsx3(LastPageIcon, { fontSize: "small" })
1509
- }
1510
- )
1511
- ] })
1512
- ] }),
1513
- showZoomControls && /* @__PURE__ */ jsxs3(Fragment, { children: [
1514
- /* @__PURE__ */ jsx3("div", { className: "toolbar-separator" }),
1515
- /* @__PURE__ */ jsxs3("div", { className: "toolbar-section", children: [
1516
- /* @__PURE__ */ jsx3(
1517
- "button",
1518
- {
1519
- className: "toolbar-button",
1520
- onClick: handleZoomOut,
1521
- title: "Zoom Out",
1522
- children: /* @__PURE__ */ jsx3(ZoomOutIcon, { fontSize: "small" })
1523
- }
1524
- ),
1525
- /* @__PURE__ */ jsxs3("span", { className: "zoom-display", children: [
1526
- zoom,
1527
- "%"
1528
- ] }),
1529
- /* @__PURE__ */ jsx3(
1530
- "button",
1531
- {
1532
- className: "toolbar-button",
1533
- onClick: handleZoomIn,
1534
- title: "Zoom In",
1535
- children: /* @__PURE__ */ jsx3(ZoomInIcon, { fontSize: "small" })
1536
- }
1537
- ),
1538
- /* @__PURE__ */ jsx3(
1539
- "button",
1540
- {
1541
- className: "toolbar-button",
1542
- onClick: handleFitToWidth,
1543
- title: "Fit to Width",
1544
- children: /* @__PURE__ */ jsx3(AspectRatioIcon, { fontSize: "small" })
1545
- }
1546
- ),
1547
- /* @__PURE__ */ jsx3(
1548
- "button",
1549
- {
1550
- className: "toolbar-button",
1551
- onClick: handleFitToPage,
1552
- title: "Fit to Page",
1553
- children: /* @__PURE__ */ jsx3(FitScreenIcon, { fontSize: "small" })
1554
- }
1555
- )
1556
- ] })
1557
- ] }),
1558
- showSearch && /* @__PURE__ */ jsxs3(Fragment, { children: [
1559
- /* @__PURE__ */ jsx3("div", { className: "toolbar-separator" }),
1560
- /* @__PURE__ */ jsx3("div", { className: "toolbar-section", children: /* @__PURE__ */ jsx3(
1561
- "button",
1562
- {
1563
- className: "toolbar-button",
1564
- onClick: toggleSidebar,
1565
- title: "Search in PDF",
1566
- style: {
1567
- backgroundColor: isSidebarOpen ? "#e3f2fd" : "transparent",
1568
- color: isSidebarOpen ? "#1976d2" : "inherit"
1569
- },
1570
- children: /* @__PURE__ */ jsx3(SearchIcon2, { fontSize: "small" })
1571
- }
1572
- ) })
1573
- ] }),
1574
- (showMetadata || showProperties || showDownload || showPrint) && /* @__PURE__ */ jsxs3(Fragment, { children: [
1575
- /* @__PURE__ */ jsx3("div", { className: "toolbar-separator" }),
1576
- /* @__PURE__ */ jsxs3("div", { className: "toolbar-section", children: [
1577
- showDownload && /* @__PURE__ */ jsx3(
1578
- "button",
1579
- {
1580
- className: "toolbar-button",
1581
- onClick: onDownloadClick,
1582
- title: "Download PDF",
1583
- children: /* @__PURE__ */ jsx3(DownloadIcon, { fontSize: "small" })
1584
- }
1585
- ),
1586
- showPrint && /* @__PURE__ */ jsx3(
1587
- "button",
1588
- {
1589
- className: "toolbar-button",
1590
- onClick: onPrintClick,
1591
- title: "Print PDF",
1592
- children: /* @__PURE__ */ jsx3(PrintIcon, { fontSize: "small" })
1593
- }
1594
- ),
1595
- showMetadata && /* @__PURE__ */ jsx3(
1596
- "button",
1597
- {
1598
- className: "toolbar-button",
1599
- onClick: onMetadataClick,
1600
- title: "Document Metadata",
1601
- children: /* @__PURE__ */ jsx3(InfoIcon, { fontSize: "small" })
1602
- }
1603
- ),
1604
- showProperties && /* @__PURE__ */ jsx3(
1605
- "button",
1606
- {
1607
- className: "toolbar-button",
1608
- onClick: onPropertiesClick,
1609
- title: "Document Properties",
1610
- children: /* @__PURE__ */ jsx3(DescriptionIcon, { fontSize: "small" })
1611
- }
1612
- )
1613
- ] })
1614
- ] })
1615
- ] }),
1616
- /* @__PURE__ */ jsxs3("div", { className: "pdf-viewer-main", children: [
1617
- /* @__PURE__ */ jsx3("div", { className: "pdf-viewer-viewer-area", children: /* @__PURE__ */ jsx3(
1618
- HeadlessPDFViewer,
1646
+ return /* @__PURE__ */ jsxs5("div", { className: "pdf-viewer-container", children: [
1647
+ /* @__PURE__ */ jsx6("style", { children: toolbarStyles }),
1648
+ /* @__PURE__ */ jsx6(
1649
+ PDFHeader,
1650
+ {
1651
+ fileName: resolvedFileName,
1652
+ fileExtension
1653
+ }
1654
+ ),
1655
+ /* @__PURE__ */ jsx6(
1656
+ PDFToolbar,
1657
+ {
1658
+ currentPage,
1659
+ totalPages,
1660
+ zoom,
1661
+ isSidebarOpen,
1662
+ showPageNavigation,
1663
+ showPageCount,
1664
+ showZoomControls,
1665
+ showSearch,
1666
+ showMetadata,
1667
+ showProperties,
1668
+ showDownload,
1669
+ showPrint,
1670
+ onFirstPage: toolbarHandlers.handleFirstPage,
1671
+ onPreviousPage: toolbarHandlers.handlePreviousPage,
1672
+ onNextPage: toolbarHandlers.handleNextPage,
1673
+ onLastPage: toolbarHandlers.handleLastPage,
1674
+ onPageInput: toolbarHandlers.handlePageInput,
1675
+ onPageInputKeyPress: toolbarHandlers.handlePageInputKeyPress,
1676
+ onZoomIn: toolbarHandlers.handleZoomIn,
1677
+ onZoomOut: toolbarHandlers.handleZoomOut,
1678
+ onFitToWidth: toolbarHandlers.handleFitToWidth,
1679
+ onFitToPage: toolbarHandlers.handleFitToPage,
1680
+ onToggleSidebar: toolbarHandlers.toggleSidebar,
1681
+ onDownloadClick,
1682
+ onPrintClick,
1683
+ onMetadataClick,
1684
+ onPropertiesClick
1685
+ }
1686
+ ),
1687
+ /* @__PURE__ */ jsxs5("div", { className: "pdf-viewer-main", children: [
1688
+ /* @__PURE__ */ jsx6("div", { className: "pdf-viewer-viewer-area", children: /* @__PURE__ */ jsx6(
1689
+ StablePDFViewer,
1619
1690
  {
1620
- ref: pdfViewerRef,
1621
1691
  pdfBuffer,
1622
- onPasswordRequest: handlePasswordRequest
1692
+ onPasswordRequest: handlePasswordRequest,
1693
+ pdfViewerRef
1623
1694
  }
1624
1695
  ) }),
1625
- /* @__PURE__ */ jsx3(
1696
+ /* @__PURE__ */ jsx6(
1626
1697
  SearchSidebar,
1627
1698
  {
1628
1699
  isOpen: isSidebarOpen,
@@ -1639,7 +1710,7 @@ var PDFViewerContent = forwardRef((props, ref) => {
1639
1710
  }
1640
1711
  )
1641
1712
  ] }),
1642
- /* @__PURE__ */ jsx3(
1713
+ /* @__PURE__ */ jsx6(
1643
1714
  PasswordDialog,
1644
1715
  {
1645
1716
  open: isPasswordDialogOpen,
@@ -1653,11 +1724,11 @@ var PDFViewerContent = forwardRef((props, ref) => {
1653
1724
  });
1654
1725
  PDFViewerContent.displayName = "PDFViewerContent";
1655
1726
  var PDFViewer = forwardRef((props, ref) => {
1656
- return /* @__PURE__ */ jsx3(PDFViewerContent, { ...props, sourceDescription: "doc.pdf", ref });
1727
+ return /* @__PURE__ */ jsx6(PDFViewerContent, { ...props, sourceDescription: "doc.pdf", ref });
1657
1728
  });
1658
1729
  PDFViewer.displayName = "PDFViewer";
1659
1730
 
1660
1731
  export {
1661
1732
  PDFViewer
1662
1733
  };
1663
- //# sourceMappingURL=chunk-J2YW5DHC.mjs.map
1734
+ //# sourceMappingURL=chunk-K5SKH4SD.mjs.map