@cannyminds/dms-file-viewers 0.6.0 → 0.8.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.
@@ -287,6 +287,7 @@ PDFHeader.displayName = "PDFHeader";
287
287
 
288
288
 
289
289
 
290
+
290
291
  var _material = require('@mui/material');
291
292
 
292
293
  var _Close = require('@mui/icons-material/Close'); var _Close2 = _interopRequireDefault(_Close);
@@ -389,10 +390,10 @@ var SearchSidebar = ({
389
390
  }, []);
390
391
  _react.useLayoutEffect.call(void 0, () => {
391
392
  setSearchTerm(searchKeyword || "");
392
- if (searchKeyword) {
393
+ if (searchKeyword || searchResults.length > 0) {
393
394
  setHasSearched(true);
394
395
  }
395
- }, [searchKeyword]);
396
+ }, [searchKeyword, searchResults]);
396
397
  const handleSearchSubmit = (e) => {
397
398
  if (e) e.preventDefault();
398
399
  if (searchTerm.trim()) {
@@ -608,7 +609,7 @@ var SearchSidebar = ({
608
609
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Search in Document" }),
609
610
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: "Enter keywords to find text within the PDF document" })
610
611
  ] }),
611
- searchTerm && !hasSearched && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
612
+ searchTerm && !hasSearched && !isSearching && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
612
613
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
613
614
  _material.Box,
614
615
  {
@@ -650,6 +651,27 @@ var SearchSidebar = ({
650
651
  }
651
652
  )
652
653
  ] }),
654
+ isSearching && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
655
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
656
+ _material.Box,
657
+ {
658
+ sx: {
659
+ display: "flex",
660
+ alignItems: "center",
661
+ justifyContent: "center",
662
+ margin: "0 auto",
663
+ mb: 3
664
+ },
665
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.CircularProgress, { size: 60, thickness: 4 })
666
+ }
667
+ ),
668
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body1", sx: { color: "text.primary", fontWeight: 500, mb: 1 }, children: "Searching..." }),
669
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Typography, { variant: "body2", sx: { color: "text.secondary", lineHeight: 1.6 }, children: [
670
+ 'Finding matches for "',
671
+ searchTerm,
672
+ '"'
673
+ ] })
674
+ ] }),
653
675
  hasSearched && totalResults === 0 && !isSearching && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _material.Box, { sx: { p: 4, textAlign: "center", mt: 6 }, children: [
654
676
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
655
677
  _material.Box,
@@ -984,6 +1006,14 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
984
1006
  setIsFullScreen(false);
985
1007
  }
986
1008
  }, [isFullScreen]);
1009
+ const handleSidebarClose = _react.useCallback.call(void 0, () => {
1010
+ setIsSidebarOpen(false);
1011
+ setSearchQuery("");
1012
+ setSearchResults([]);
1013
+ setTotalSearchResults(0);
1014
+ setCurrentSearchResultIndex(0);
1015
+ _optionalChain([pdfViewerRef, 'access', _3 => _3.current, 'optionalAccess', _4 => _4.search, 'access', _5 => _5.stopSearch, 'call', _6 => _6()]);
1016
+ }, []);
987
1017
  const toolbar = _chunkFA5L62Y5js.mergeToolbarConfig.call(void 0, {
988
1018
  showDownload,
989
1019
  showPrint,
@@ -997,70 +1027,76 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
997
1027
  });
998
1028
  const toolbarHandlers = _react.useMemo.call(void 0, () => ({
999
1029
  handleZoomIn: () => {
1000
- _optionalChain([pdfViewerRef, 'access', _3 => _3.current, 'optionalAccess', _4 => _4.zoom, 'access', _5 => _5.zoomIn, 'call', _6 => _6()]);
1030
+ _optionalChain([pdfViewerRef, 'access', _7 => _7.current, 'optionalAccess', _8 => _8.zoom, 'access', _9 => _9.zoomIn, 'call', _10 => _10()]);
1001
1031
  requestAnimationFrame(() => {
1002
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _7 => _7.current, 'optionalAccess', _8 => _8.zoom, 'access', _9 => _9.getZoom, 'call', _10 => _10()]);
1032
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _11 => _11.current, 'optionalAccess', _12 => _12.zoom, 'access', _13 => _13.getZoom, 'call', _14 => _14()]);
1003
1033
  if (typeof zoomValue === "number") {
1004
1034
  setZoom(Math.round(zoomValue * 100));
1005
1035
  }
1006
1036
  });
1007
1037
  },
1008
1038
  handleZoomOut: () => {
1009
- _optionalChain([pdfViewerRef, 'access', _11 => _11.current, 'optionalAccess', _12 => _12.zoom, 'access', _13 => _13.zoomOut, 'call', _14 => _14()]);
1039
+ _optionalChain([pdfViewerRef, 'access', _15 => _15.current, 'optionalAccess', _16 => _16.zoom, 'access', _17 => _17.zoomOut, 'call', _18 => _18()]);
1010
1040
  requestAnimationFrame(() => {
1011
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _15 => _15.current, 'optionalAccess', _16 => _16.zoom, 'access', _17 => _17.getZoom, 'call', _18 => _18()]);
1041
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _19 => _19.current, 'optionalAccess', _20 => _20.zoom, 'access', _21 => _21.getZoom, 'call', _22 => _22()]);
1012
1042
  if (typeof zoomValue === "number") {
1013
1043
  setZoom(Math.round(zoomValue * 100));
1014
1044
  }
1015
1045
  });
1016
1046
  },
1017
1047
  handleFitToWidth: () => {
1018
- _optionalChain([pdfViewerRef, 'access', _19 => _19.current, 'optionalAccess', _20 => _20.zoom, 'access', _21 => _21.fitToWidth, 'call', _22 => _22()]);
1048
+ _optionalChain([pdfViewerRef, 'access', _23 => _23.current, 'optionalAccess', _24 => _24.zoom, 'access', _25 => _25.fitToWidth, 'call', _26 => _26()]);
1019
1049
  requestAnimationFrame(() => {
1020
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _23 => _23.current, 'optionalAccess', _24 => _24.zoom, 'access', _25 => _25.getZoom, 'call', _26 => _26()]);
1050
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.zoom, 'access', _29 => _29.getZoom, 'call', _30 => _30()]);
1021
1051
  if (typeof zoomValue === "number") {
1022
1052
  setZoom(Math.round(zoomValue * 100));
1023
1053
  }
1024
1054
  });
1025
1055
  },
1026
1056
  handleFitToPage: () => {
1027
- _optionalChain([pdfViewerRef, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.zoom, 'access', _29 => _29.fitToPage, 'call', _30 => _30()]);
1057
+ _optionalChain([pdfViewerRef, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.zoom, 'access', _33 => _33.fitToPage, 'call', _34 => _34()]);
1028
1058
  requestAnimationFrame(() => {
1029
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.zoom, 'access', _33 => _33.getZoom, 'call', _34 => _34()]);
1059
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.zoom, 'access', _37 => _37.getZoom, 'call', _38 => _38()]);
1030
1060
  if (typeof zoomValue === "number") {
1031
1061
  setZoom(Math.round(zoomValue * 100));
1032
1062
  }
1033
1063
  });
1034
1064
  },
1035
1065
  handlePreviousPage: () => {
1036
- _optionalChain([pdfViewerRef, 'access', _35 => _35.current, 'optionalAccess', _36 => _36.navigation, 'access', _37 => _37.previousPage, 'call', _38 => _38()]);
1066
+ _optionalChain([pdfViewerRef, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.navigation, 'access', _41 => _41.previousPage, 'call', _42 => _42()]);
1037
1067
  requestAnimationFrame(() => {
1038
- const current = _optionalChain([pdfViewerRef, 'access', _39 => _39.current, 'optionalAccess', _40 => _40.navigation, 'access', _41 => _41.getCurrentPage, 'call', _42 => _42()]) || 1;
1068
+ const current = _optionalChain([pdfViewerRef, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.navigation, 'access', _45 => _45.getCurrentPage, 'call', _46 => _46()]) || 1;
1039
1069
  setCurrentPage(current);
1040
1070
  });
1041
1071
  },
1042
1072
  handleNextPage: () => {
1043
- _optionalChain([pdfViewerRef, 'access', _43 => _43.current, 'optionalAccess', _44 => _44.navigation, 'access', _45 => _45.nextPage, 'call', _46 => _46()]);
1073
+ _optionalChain([pdfViewerRef, 'access', _47 => _47.current, 'optionalAccess', _48 => _48.navigation, 'access', _49 => _49.nextPage, 'call', _50 => _50()]);
1044
1074
  requestAnimationFrame(() => {
1045
- const current = _optionalChain([pdfViewerRef, 'access', _47 => _47.current, 'optionalAccess', _48 => _48.navigation, 'access', _49 => _49.getCurrentPage, 'call', _50 => _50()]) || 1;
1075
+ const current = _optionalChain([pdfViewerRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.navigation, 'access', _53 => _53.getCurrentPage, 'call', _54 => _54()]) || 1;
1046
1076
  setCurrentPage(current);
1047
1077
  });
1048
1078
  },
1049
1079
  handleFirstPage: () => {
1050
- _optionalChain([pdfViewerRef, 'access', _51 => _51.current, 'optionalAccess', _52 => _52.navigation, 'access', _53 => _53.goToFirstPage, 'call', _54 => _54()]);
1080
+ _optionalChain([pdfViewerRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.navigation, 'access', _57 => _57.goToFirstPage, 'call', _58 => _58()]);
1051
1081
  requestAnimationFrame(() => {
1052
- const current = _optionalChain([pdfViewerRef, 'access', _55 => _55.current, 'optionalAccess', _56 => _56.navigation, 'access', _57 => _57.getCurrentPage, 'call', _58 => _58()]) || 1;
1082
+ const current = _optionalChain([pdfViewerRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.navigation, 'access', _61 => _61.getCurrentPage, 'call', _62 => _62()]) || 1;
1053
1083
  setCurrentPage(current);
1054
1084
  });
1055
1085
  },
1056
1086
  handleLastPage: () => {
1057
- _optionalChain([pdfViewerRef, 'access', _59 => _59.current, 'optionalAccess', _60 => _60.navigation, 'access', _61 => _61.goToLastPage, 'call', _62 => _62()]);
1087
+ _optionalChain([pdfViewerRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.navigation, 'access', _65 => _65.goToLastPage, 'call', _66 => _66()]);
1058
1088
  requestAnimationFrame(() => {
1059
- const current = _optionalChain([pdfViewerRef, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.navigation, 'access', _65 => _65.getCurrentPage, 'call', _66 => _66()]) || 1;
1089
+ const current = _optionalChain([pdfViewerRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.navigation, 'access', _69 => _69.getCurrentPage, 'call', _70 => _70()]) || 1;
1060
1090
  setCurrentPage(current);
1061
1091
  });
1062
1092
  },
1063
- toggleSidebar: () => setIsSidebarOpen(!isSidebarOpen),
1093
+ toggleSidebar: () => {
1094
+ if (isSidebarOpen) {
1095
+ handleSidebarClose();
1096
+ } else {
1097
+ setIsSidebarOpen(true);
1098
+ }
1099
+ },
1064
1100
  handlePageInput: (e) => {
1065
1101
  const value = e.target.value;
1066
1102
  if (/^\d*$/.test(value)) {
@@ -1068,7 +1104,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1068
1104
  }
1069
1105
  const page = parseInt(value, 10);
1070
1106
  if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1071
- _optionalChain([pdfViewerRef, 'access', _67 => _67.current, 'optionalAccess', _68 => _68.navigation, 'access', _69 => _69.goToPage, 'call', _70 => _70(page)]);
1107
+ _optionalChain([pdfViewerRef, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.navigation, 'access', _73 => _73.goToPage, 'call', _74 => _74(page)]);
1072
1108
  setCurrentPage(page);
1073
1109
  }
1074
1110
  },
@@ -1077,7 +1113,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1077
1113
  const value = e.target.value;
1078
1114
  const page = parseInt(value, 10);
1079
1115
  if (!isNaN(page) && page >= 1 && (totalPages === 0 || page <= totalPages)) {
1080
- _optionalChain([pdfViewerRef, 'access', _71 => _71.current, 'optionalAccess', _72 => _72.navigation, 'access', _73 => _73.goToPage, 'call', _74 => _74(page)]);
1116
+ _optionalChain([pdfViewerRef, 'access', _75 => _75.current, 'optionalAccess', _76 => _76.navigation, 'access', _77 => _77.goToPage, 'call', _78 => _78(page)]);
1081
1117
  setCurrentPage(page);
1082
1118
  }
1083
1119
  }
@@ -1085,21 +1121,31 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1085
1121
  handleToggleFullScreen
1086
1122
  }), [isSidebarOpen, totalPages, handleToggleFullScreen]);
1087
1123
  _react.useEffect.call(void 0, () => {
1088
- console.log("came", initialSearchText, pdfViewerRef.current, hasExecutedInitialSearch.current);
1089
- if (pdfViewerRef.current && !hasExecutedInitialSearch.current && initialSearchText) {
1090
- hasExecutedInitialSearch.current = true;
1091
- setIsSidebarOpen(true);
1092
- setSearchQuery(initialSearchText);
1093
- handleSidebarSearch(initialSearchText, initialSearchPages);
1094
- setAutoExecuteSearch(false);
1095
- pdfViewerRef.current.search.searchText(initialSearchText).then((results) => {
1096
- console.log("results", results);
1097
- if (_optionalChain([results, 'optionalAccess', _75 => _75.results, 'optionalAccess', _76 => _76.length]) > 0) {
1098
- _optionalChain([pdfViewerRef, 'access', _77 => _77.current, 'optionalAccess', _78 => _78.navigation, 'access', _79 => _79.goToPage, 'call', _80 => _80(results.results[0].pageIndex + 1)]);
1099
- }
1124
+ console.log("came", initialSearchText, pdfViewerRef.current, hasExecutedInitialSearch.current, "state:", state, "totalPages:", totalPages);
1125
+ if (!initialSearchText || hasExecutedInitialSearch.current) return;
1126
+ const isPDFReady = state === "ready";
1127
+ const isPagesInitialized = totalPages > 0;
1128
+ const isViewerAvailable = !!pdfViewerRef.current;
1129
+ const isSearchAPIReady = !!_optionalChain([pdfViewerRef, 'access', _79 => _79.current, 'optionalAccess', _80 => _80.search, 'optionalAccess', _81 => _81.searchText]);
1130
+ const canExecuteSearch = isPDFReady && isPagesInitialized && isViewerAvailable && isSearchAPIReady;
1131
+ if (!canExecuteSearch) return;
1132
+ hasExecutedInitialSearch.current = true;
1133
+ const SEARCH_INITIALIZATION_DELAY = 100;
1134
+ setTimeout(() => {
1135
+ if (!_optionalChain([pdfViewerRef, 'access', _82 => _82.current, 'optionalAccess', _83 => _83.search, 'optionalAccess', _84 => _84.searchText])) {
1136
+ console.warn("Search API became unavailable, skipping initial search");
1137
+ hasExecutedInitialSearch.current = false;
1138
+ return;
1139
+ }
1140
+ requestAnimationFrame(() => {
1141
+ requestAnimationFrame(() => {
1142
+ setIsSidebarOpen(true);
1143
+ handleSidebarSearch(initialSearchText, initialSearchPages);
1144
+ setAutoExecuteSearch(false);
1145
+ });
1100
1146
  });
1101
- }
1102
- }, [pdfViewerRef.current, initialSearchText]);
1147
+ }, SEARCH_INITIALIZATION_DELAY);
1148
+ }, [state, totalPages, pdfViewerRef.current, initialSearchText, initialSearchPages]);
1103
1149
  _react.useEffect.call(void 0, () => {
1104
1150
  setSearchQuery("");
1105
1151
  setSearchResults([]);
@@ -1107,6 +1153,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1107
1153
  setTotalSearchResults(0);
1108
1154
  setIsSearching(false);
1109
1155
  setIsSidebarOpen(false);
1156
+ hasExecutedInitialSearch.current = false;
1110
1157
  setCurrentPage(1);
1111
1158
  setTotalPages(0);
1112
1159
  setZoom(100);
@@ -1147,7 +1194,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1147
1194
  if (!viewer) return;
1148
1195
  await new Promise((resolve) => requestAnimationFrame(resolve));
1149
1196
  try {
1150
- const count = _optionalChain([viewer, 'access', _81 => _81.navigation, 'optionalAccess', _82 => _82.getTotalPages, 'optionalCall', _83 => _83()]);
1197
+ const count = _optionalChain([viewer, 'access', _85 => _85.navigation, 'optionalAccess', _86 => _86.getTotalPages, 'optionalCall', _87 => _87()]);
1151
1198
  if (count && count > 1) {
1152
1199
  setTotalPages(count);
1153
1200
  return;
@@ -1155,16 +1202,17 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1155
1202
  } catch (e) {
1156
1203
  }
1157
1204
  try {
1158
- const results = await _optionalChain([viewer, 'access', _84 => _84.search, 'optionalAccess', _85 => _85.searchText, 'optionalCall', _86 => _86("e")]);
1159
- if (_optionalChain([results, 'optionalAccess', _87 => _87.results]) && results.results.length > 0) {
1205
+ const results = await _optionalChain([viewer, 'access', _88 => _88.search, 'optionalAccess', _89 => _89.searchText, 'optionalCall', _90 => _90("e")]);
1206
+ if (_optionalChain([results, 'optionalAccess', _91 => _91.results]) && results.results.length > 0) {
1160
1207
  const pageIndices = results.results.map((m) => m.pageIndex).filter((idx) => typeof idx === "number");
1161
1208
  const count = Math.max(...pageIndices) + 1;
1162
- _optionalChain([viewer, 'access', _88 => _88.search, 'optionalAccess', _89 => _89.stopSearch, 'optionalCall', _90 => _90()]);
1209
+ _optionalChain([viewer, 'access', _92 => _92.search, 'optionalAccess', _93 => _93.stopSearch, 'optionalCall', _94 => _94()]);
1163
1210
  setTotalPages(count);
1164
1211
  return;
1165
1212
  }
1166
1213
  } catch (error2) {
1167
1214
  }
1215
+ await new Promise((resolve) => setTimeout(resolve, 200));
1168
1216
  try {
1169
1217
  const selectors = [
1170
1218
  "[data-page-index]",
@@ -1183,6 +1231,15 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1183
1231
  }
1184
1232
  } catch (error2) {
1185
1233
  }
1234
+ try {
1235
+ const count = _optionalChain([viewer, 'access', _95 => _95.navigation, 'optionalAccess', _96 => _96.getTotalPages, 'optionalCall', _97 => _97()]);
1236
+ if (count && count > 0) {
1237
+ setTotalPages(count);
1238
+ return;
1239
+ }
1240
+ } catch (e) {
1241
+ }
1242
+ console.warn("Could not determine total pages, using fallback value of 1");
1186
1243
  setTotalPages(1);
1187
1244
  };
1188
1245
  initializePageCount();
@@ -1190,10 +1247,10 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1190
1247
  _react.useEffect.call(void 0, () => {
1191
1248
  if (state === "ready" && pdfViewerRef.current) {
1192
1249
  const updateInfo = () => {
1193
- const current = _optionalChain([pdfViewerRef, 'access', _91 => _91.current, 'optionalAccess', _92 => _92.navigation, 'access', _93 => _93.getCurrentPage, 'call', _94 => _94()]) || 1;
1194
- const total = _optionalChain([pdfViewerRef, 'access', _95 => _95.current, 'optionalAccess', _96 => _96.navigation, 'access', _97 => _97.getTotalPages, 'call', _98 => _98()]) || 0;
1195
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _99 => _99.current, 'optionalAccess', _100 => _100.zoom, 'access', _101 => _101.getZoom, 'call', _102 => _102()]);
1196
- const currentSearchState = _optionalChain([pdfViewerRef, 'access', _103 => _103.current, 'optionalAccess', _104 => _104.search, 'access', _105 => _105.getSearchState, 'call', _106 => _106()]);
1250
+ const current = _optionalChain([pdfViewerRef, 'access', _98 => _98.current, 'optionalAccess', _99 => _99.navigation, 'access', _100 => _100.getCurrentPage, 'call', _101 => _101()]) || 1;
1251
+ const total = _optionalChain([pdfViewerRef, 'access', _102 => _102.current, 'optionalAccess', _103 => _103.navigation, 'access', _104 => _104.getTotalPages, 'call', _105 => _105()]) || 0;
1252
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _106 => _106.current, 'optionalAccess', _107 => _107.zoom, 'access', _108 => _108.getZoom, 'call', _109 => _109()]);
1253
+ const currentSearchState = _optionalChain([pdfViewerRef, 'access', _110 => _110.current, 'optionalAccess', _111 => _111.search, 'access', _112 => _112.getSearchState, 'call', _113 => _113()]);
1197
1254
  setCurrentPage(current);
1198
1255
  if (total > 0 && total !== totalPages) {
1199
1256
  setTotalPages(total);
@@ -1209,125 +1266,95 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1209
1266
  }, [state, totalPages]);
1210
1267
  _react.useImperativeHandle.call(void 0, ref, () => ({
1211
1268
  zoomIn: () => {
1212
- _optionalChain([pdfViewerRef, 'access', _107 => _107.current, 'optionalAccess', _108 => _108.zoom, 'access', _109 => _109.zoomIn, 'call', _110 => _110()]);
1269
+ _optionalChain([pdfViewerRef, 'access', _114 => _114.current, 'optionalAccess', _115 => _115.zoom, 'access', _116 => _116.zoomIn, 'call', _117 => _117()]);
1213
1270
  updateZoomDisplay();
1214
1271
  },
1215
1272
  zoomOut: () => {
1216
- _optionalChain([pdfViewerRef, 'access', _111 => _111.current, 'optionalAccess', _112 => _112.zoom, 'access', _113 => _113.zoomOut, 'call', _114 => _114()]);
1273
+ _optionalChain([pdfViewerRef, 'access', _118 => _118.current, 'optionalAccess', _119 => _119.zoom, 'access', _120 => _120.zoomOut, 'call', _121 => _121()]);
1217
1274
  updateZoomDisplay();
1218
1275
  },
1219
1276
  setZoom: (level) => {
1220
- _optionalChain([pdfViewerRef, 'access', _115 => _115.current, 'optionalAccess', _116 => _116.zoom, 'access', _117 => _117.setZoom, 'call', _118 => _118(level)]);
1277
+ _optionalChain([pdfViewerRef, 'access', _122 => _122.current, 'optionalAccess', _123 => _123.zoom, 'access', _124 => _124.setZoom, 'call', _125 => _125(level)]);
1221
1278
  updateZoomDisplay();
1222
1279
  },
1223
1280
  resetZoom: () => {
1224
- _optionalChain([pdfViewerRef, 'access', _119 => _119.current, 'optionalAccess', _120 => _120.zoom, 'access', _121 => _121.resetZoom, 'call', _122 => _122()]);
1281
+ _optionalChain([pdfViewerRef, 'access', _126 => _126.current, 'optionalAccess', _127 => _127.zoom, 'access', _128 => _128.resetZoom, 'call', _129 => _129()]);
1225
1282
  updateZoomDisplay();
1226
1283
  },
1227
1284
  getZoom: () => {
1228
- const zoom2 = _optionalChain([pdfViewerRef, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.zoom, 'access', _125 => _125.getZoom, 'call', _126 => _126()]);
1285
+ const zoom2 = _optionalChain([pdfViewerRef, 'access', _130 => _130.current, 'optionalAccess', _131 => _131.zoom, 'access', _132 => _132.getZoom, 'call', _133 => _133()]);
1229
1286
  return typeof zoom2 === "number" ? zoom2 : 1;
1230
1287
  },
1231
1288
  goToPage: (page) => {
1232
- _optionalChain([pdfViewerRef, 'access', _127 => _127.current, 'optionalAccess', _128 => _128.navigation, 'access', _129 => _129.goToPage, 'call', _130 => _130(page)]);
1289
+ _optionalChain([pdfViewerRef, 'access', _134 => _134.current, 'optionalAccess', _135 => _135.navigation, 'access', _136 => _136.goToPage, 'call', _137 => _137(page)]);
1233
1290
  setCurrentPage(page);
1234
1291
  },
1235
- getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _131 => _131.current, 'optionalAccess', _132 => _132.navigation, 'access', _133 => _133.getCurrentPage, 'call', _134 => _134()]) || 1,
1236
- getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _135 => _135.current, 'optionalAccess', _136 => _136.navigation, 'access', _137 => _137.getTotalPages, 'call', _138 => _138()]) || 0,
1292
+ getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _138 => _138.current, 'optionalAccess', _139 => _139.navigation, 'access', _140 => _140.getCurrentPage, 'call', _141 => _141()]) || 1,
1293
+ getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _142 => _142.current, 'optionalAccess', _143 => _143.navigation, 'access', _144 => _144.getTotalPages, 'call', _145 => _145()]) || 0,
1237
1294
  nextPage: () => {
1238
- _optionalChain([pdfViewerRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.navigation, 'access', _141 => _141.nextPage, 'call', _142 => _142()]);
1295
+ _optionalChain([pdfViewerRef, 'access', _146 => _146.current, 'optionalAccess', _147 => _147.navigation, 'access', _148 => _148.nextPage, 'call', _149 => _149()]);
1239
1296
  updatePageDisplay();
1240
1297
  },
1241
1298
  previousPage: () => {
1242
- _optionalChain([pdfViewerRef, 'access', _143 => _143.current, 'optionalAccess', _144 => _144.navigation, 'access', _145 => _145.previousPage, 'call', _146 => _146()]);
1299
+ _optionalChain([pdfViewerRef, 'access', _150 => _150.current, 'optionalAccess', _151 => _151.navigation, 'access', _152 => _152.previousPage, 'call', _153 => _153()]);
1243
1300
  updatePageDisplay();
1244
1301
  },
1245
1302
  goToFirstPage: () => {
1246
- _optionalChain([pdfViewerRef, 'access', _147 => _147.current, 'optionalAccess', _148 => _148.navigation, 'access', _149 => _149.goToFirstPage, 'call', _150 => _150()]);
1303
+ _optionalChain([pdfViewerRef, 'access', _154 => _154.current, 'optionalAccess', _155 => _155.navigation, 'access', _156 => _156.goToFirstPage, 'call', _157 => _157()]);
1247
1304
  updatePageDisplay();
1248
1305
  },
1249
1306
  goToLastPage: () => {
1250
- _optionalChain([pdfViewerRef, 'access', _151 => _151.current, 'optionalAccess', _152 => _152.navigation, 'access', _153 => _153.goToLastPage, 'call', _154 => _154()]);
1307
+ _optionalChain([pdfViewerRef, 'access', _158 => _158.current, 'optionalAccess', _159 => _159.navigation, 'access', _160 => _160.goToLastPage, 'call', _161 => _161()]);
1251
1308
  updatePageDisplay();
1252
1309
  },
1253
1310
  searchText: async (keyword) => {
1254
1311
  setIsSearching(true);
1255
- const results = await _optionalChain([pdfViewerRef, 'access', _155 => _155.current, 'optionalAccess', _156 => _156.search, 'access', _157 => _157.searchText, 'call', _158 => _158(keyword)]);
1312
+ const results = await _optionalChain([pdfViewerRef, 'access', _162 => _162.current, 'optionalAccess', _163 => _163.search, 'access', _164 => _164.searchText, 'call', _165 => _165(keyword)]);
1256
1313
  setIsSearching(false);
1257
1314
  setSearchQuery(keyword);
1258
1315
  return results;
1259
1316
  },
1260
1317
  nextResult: () => {
1261
- const index = _optionalChain([pdfViewerRef, 'access', _159 => _159.current, 'optionalAccess', _160 => _160.search, 'access', _161 => _161.nextResult, 'call', _162 => _162()]) || -1;
1318
+ const index = _optionalChain([pdfViewerRef, 'access', _166 => _166.current, 'optionalAccess', _167 => _167.search, 'access', _168 => _168.nextResult, 'call', _169 => _169()]) || -1;
1262
1319
  return index;
1263
1320
  },
1264
1321
  previousResult: () => {
1265
- const index = _optionalChain([pdfViewerRef, 'access', _163 => _163.current, 'optionalAccess', _164 => _164.search, 'access', _165 => _165.previousResult, 'call', _166 => _166()]) || -1;
1322
+ const index = _optionalChain([pdfViewerRef, 'access', _170 => _170.current, 'optionalAccess', _171 => _171.search, 'access', _172 => _172.previousResult, 'call', _173 => _173()]) || -1;
1266
1323
  return index;
1267
1324
  },
1268
- goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _167 => _167.current, 'optionalAccess', _168 => _168.search, 'access', _169 => _169.goToResult, 'call', _170 => _170(index)]) || -1,
1325
+ goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _174 => _174.current, 'optionalAccess', _175 => _175.search, 'access', _176 => _176.goToResult, 'call', _177 => _177(index)]) || -1,
1269
1326
  stopSearch: () => {
1270
- _optionalChain([pdfViewerRef, 'access', _171 => _171.current, 'optionalAccess', _172 => _172.search, 'access', _173 => _173.stopSearch, 'call', _174 => _174()]);
1327
+ _optionalChain([pdfViewerRef, 'access', _178 => _178.current, 'optionalAccess', _179 => _179.search, 'access', _180 => _180.stopSearch, 'call', _181 => _181()]);
1271
1328
  setSearchQuery("");
1272
1329
  },
1273
- getSearchState: () => _optionalChain([pdfViewerRef, 'access', _175 => _175.current, 'optionalAccess', _176 => _176.search, 'access', _177 => _177.getSearchState, 'call', _178 => _178()]) || null,
1274
- getSelectedText: () => _optionalChain([pdfViewerRef, 'access', _179 => _179.current, 'optionalAccess', _180 => _180.selection, 'access', _181 => _181.getSelectedText, 'call', _182 => _182()]) || "",
1275
- clearSelection: () => _optionalChain([pdfViewerRef, 'access', _183 => _183.current, 'optionalAccess', _184 => _184.selection, 'access', _185 => _185.clearSelection, 'call', _186 => _186()])
1330
+ getSearchState: () => _optionalChain([pdfViewerRef, 'access', _182 => _182.current, 'optionalAccess', _183 => _183.search, 'access', _184 => _184.getSearchState, 'call', _185 => _185()]) || null,
1331
+ getSelectedText: () => _optionalChain([pdfViewerRef, 'access', _186 => _186.current, 'optionalAccess', _187 => _187.selection, 'access', _188 => _188.getSelectedText, 'call', _189 => _189()]) || "",
1332
+ clearSelection: () => _optionalChain([pdfViewerRef, 'access', _190 => _190.current, 'optionalAccess', _191 => _191.selection, 'access', _192 => _192.clearSelection, 'call', _193 => _193()])
1276
1333
  }), []);
1277
1334
  const updatePageDisplay = () => {
1278
1335
  requestAnimationFrame(() => {
1279
- const current = _optionalChain([pdfViewerRef, 'access', _187 => _187.current, 'optionalAccess', _188 => _188.navigation, 'access', _189 => _189.getCurrentPage, 'call', _190 => _190()]) || 1;
1336
+ const current = _optionalChain([pdfViewerRef, 'access', _194 => _194.current, 'optionalAccess', _195 => _195.navigation, 'access', _196 => _196.getCurrentPage, 'call', _197 => _197()]) || 1;
1280
1337
  setCurrentPage(current);
1281
1338
  });
1282
1339
  };
1283
1340
  const updateZoomDisplay = () => {
1284
1341
  requestAnimationFrame(() => {
1285
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _191 => _191.current, 'optionalAccess', _192 => _192.zoom, 'access', _193 => _193.getZoom, 'call', _194 => _194()]);
1342
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _198 => _198.current, 'optionalAccess', _199 => _199.zoom, 'access', _200 => _200.getZoom, 'call', _201 => _201()]);
1286
1343
  if (typeof zoomValue === "number") {
1287
1344
  setZoom(Math.round(zoomValue * 100));
1288
1345
  }
1289
1346
  });
1290
1347
  };
1291
1348
  const handleSearch = async () => {
1292
- if (searchQuery.trim()) {
1293
- setIsSearching(true);
1294
- const results = await _optionalChain([pdfViewerRef, 'access', _195 => _195.current, 'optionalAccess', _196 => _196.search, 'access', _197 => _197.searchText, 'call', _198 => _198(searchQuery)]);
1295
- setIsSearching(false);
1296
- if (results && results.results) {
1297
- const formattedResults = results.results.map((result, index) => {
1298
- let textContent = "";
1299
- let contextContent = "";
1300
- if (typeof result === "string") {
1301
- textContent = result;
1302
- contextContent = result;
1303
- } else if (result.text) {
1304
- textContent = String(result.text);
1305
- contextContent = result.context ? String(result.context) : String(result.text);
1306
- } else if (result.str) {
1307
- textContent = String(result.str);
1308
- contextContent = String(result.str);
1309
- } else if (result.match) {
1310
- textContent = String(result.match);
1311
- contextContent = String(result.match);
1312
- } else {
1313
- textContent = JSON.stringify(result);
1314
- contextContent = textContent;
1315
- }
1316
- return {
1317
- pageNumber: (_nullishCoalesce(_nullishCoalesce(result.pageIndex, () => ( result.pageNumber)), () => ( 0))) + 1,
1318
- text: textContent,
1319
- context: contextContent,
1320
- index
1321
- };
1322
- });
1323
- setSearchResults(formattedResults);
1324
- setTotalSearchResults(formattedResults.length);
1325
- setCurrentSearchResultIndex(0);
1326
- } else {
1327
- setSearchResults([]);
1328
- setTotalSearchResults(0);
1329
- setCurrentSearchResultIndex(0);
1330
- }
1349
+ if (!searchQuery.trim()) return;
1350
+ setIsSearching(true);
1351
+ const results = await _optionalChain([pdfViewerRef, 'access', _202 => _202.current, 'optionalAccess', _203 => _203.search, 'access', _204 => _204.searchText, 'call', _205 => _205(searchQuery)]);
1352
+ setIsSearching(false);
1353
+ if (_optionalChain([results, 'optionalAccess', _206 => _206.results]) && Array.isArray(results.results) && results.results.length > 0) {
1354
+ const formattedResults = formatSearchResults(results.results);
1355
+ updateSearchState(formattedResults);
1356
+ } else {
1357
+ clearSearchResults();
1331
1358
  }
1332
1359
  };
1333
1360
  const handleSearchKeyPress = (e) => {
@@ -1337,80 +1364,106 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1337
1364
  };
1338
1365
  const handleSidebarSearch = async (keyword, pageNumbers) => {
1339
1366
  setSearchQuery(keyword);
1340
- if (keyword.trim()) {
1341
- setIsSearching(true);
1342
- const results = await _optionalChain([pdfViewerRef, 'access', _199 => _199.current, 'optionalAccess', _200 => _200.search, 'access', _201 => _201.searchText, 'call', _202 => _202(keyword)]);
1367
+ if (!keyword.trim()) {
1368
+ setSearchResults([]);
1369
+ setTotalSearchResults(0);
1370
+ setCurrentSearchResultIndex(0);
1371
+ _optionalChain([pdfViewerRef, 'access', _207 => _207.current, 'optionalAccess', _208 => _208.search, 'access', _209 => _209.stopSearch, 'call', _210 => _210()]);
1372
+ return;
1373
+ }
1374
+ if (!_optionalChain([pdfViewerRef, 'access', _211 => _211.current, 'optionalAccess', _212 => _212.search, 'optionalAccess', _213 => _213.searchText])) {
1375
+ console.warn("Search functionality not yet available");
1376
+ return;
1377
+ }
1378
+ setIsSearching(true);
1379
+ try {
1380
+ const results = await pdfViewerRef.current.search.searchText(keyword);
1381
+ console.log("Search completed:", results);
1343
1382
  setIsSearching(false);
1344
- if (results && results.results && results.results.length > 0) {
1345
- const formattedResults = results.results.map((result, index) => {
1346
- let textContent = "";
1347
- let contextContent = "";
1348
- if (result.context && typeof result.context === "object") {
1349
- const before = result.context.before || "";
1350
- const match = result.context.match || "";
1351
- const after = result.context.after || "";
1352
- textContent = match;
1353
- contextContent = `${before}${match}${after}`;
1354
- } else if (typeof result === "string") {
1355
- textContent = result;
1356
- contextContent = result;
1357
- } else {
1358
- textContent = String(result.match || result.text || "");
1359
- contextContent = textContent;
1360
- }
1361
- return {
1362
- pageNumber: (_nullishCoalesce(_nullishCoalesce(result.pageIndex, () => ( result.pageNumber)), () => ( 0))) + 1,
1363
- text: textContent,
1364
- context: contextContent,
1365
- index
1366
- };
1367
- });
1368
- setSearchResults(formattedResults);
1369
- setTotalSearchResults(formattedResults.length);
1370
- setCurrentSearchResultIndex(0);
1371
- if (formattedResults.length > 0) {
1372
- const firstPageNumber = formattedResults[0].pageNumber;
1373
- _optionalChain([pdfViewerRef, 'access', _203 => _203.current, 'optionalAccess', _204 => _204.navigation, 'access', _205 => _205.goToPage, 'call', _206 => _206(firstPageNumber)]);
1374
- setCurrentPage(firstPageNumber);
1375
- }
1383
+ const hasValidResults = _optionalChain([results, 'optionalAccess', _214 => _214.results]) && Array.isArray(results.results) && results.results.length > 0;
1384
+ if (hasValidResults) {
1385
+ const formattedResults = formatSearchResults(results.results);
1386
+ updateSearchState(formattedResults);
1387
+ navigateToFirstResult(formattedResults);
1376
1388
  } else if (pageNumbers && pageNumbers.length > 0) {
1377
- const fallbackResults = pageNumbers.map((pageNum, index) => ({
1378
- pageNumber: pageNum,
1379
- text: keyword,
1380
- context: `"${keyword}" found on this page ${pageNum}`,
1381
- index
1382
- }));
1383
- setSearchResults(fallbackResults);
1384
- setTotalSearchResults(fallbackResults.length);
1385
- setCurrentSearchResultIndex(0);
1386
- _optionalChain([pdfViewerRef, 'access', _207 => _207.current, 'optionalAccess', _208 => _208.navigation, 'access', _209 => _209.goToPage, 'call', _210 => _210(pageNumbers[0])]);
1387
- setCurrentPage(pageNumbers[0]);
1389
+ const fallbackResults = createFallbackResults(pageNumbers, keyword);
1390
+ updateSearchState(fallbackResults);
1391
+ navigateToPage(pageNumbers[0]);
1388
1392
  } else {
1389
- setSearchResults([]);
1390
- setTotalSearchResults(0);
1391
- setCurrentSearchResultIndex(0);
1393
+ clearSearchResults();
1392
1394
  }
1393
- } else {
1394
- setSearchResults([]);
1395
- _optionalChain([pdfViewerRef, 'access', _211 => _211.current, 'optionalAccess', _212 => _212.search, 'access', _213 => _213.stopSearch, 'call', _214 => _214()]);
1396
- setTotalSearchResults(0);
1397
- setCurrentSearchResultIndex(0);
1395
+ } catch (error2) {
1396
+ console.error("Search failed:", error2);
1397
+ setIsSearching(false);
1398
+ clearSearchResults();
1399
+ }
1400
+ };
1401
+ const formatSearchResults = (results) => {
1402
+ return results.map((result, index) => {
1403
+ let textContent = "";
1404
+ let contextContent = "";
1405
+ if (result.context && typeof result.context === "object") {
1406
+ const { before = "", match = "", after = "" } = result.context;
1407
+ textContent = match;
1408
+ contextContent = `${before}${match}${after}`;
1409
+ } else if (typeof result === "string") {
1410
+ textContent = result;
1411
+ contextContent = result;
1412
+ } else {
1413
+ textContent = String(result.match || result.text || "");
1414
+ contextContent = textContent;
1415
+ }
1416
+ return {
1417
+ pageNumber: (_nullishCoalesce(_nullishCoalesce(result.pageIndex, () => ( result.pageNumber)), () => ( 0))) + 1,
1418
+ text: textContent,
1419
+ context: contextContent,
1420
+ index
1421
+ };
1422
+ });
1423
+ };
1424
+ const createFallbackResults = (pageNumbers, keyword) => {
1425
+ return pageNumbers.map((pageNum, index) => ({
1426
+ pageNumber: pageNum,
1427
+ text: keyword,
1428
+ context: `"${keyword}" found on this page ${pageNum}`,
1429
+ index
1430
+ }));
1431
+ };
1432
+ const updateSearchState = (results) => {
1433
+ setSearchResults(results);
1434
+ setTotalSearchResults(results.length);
1435
+ setCurrentSearchResultIndex(0);
1436
+ };
1437
+ const clearSearchResults = () => {
1438
+ setSearchResults([]);
1439
+ setTotalSearchResults(0);
1440
+ setCurrentSearchResultIndex(0);
1441
+ };
1442
+ const navigateToFirstResult = (results) => {
1443
+ if (results.length > 0) {
1444
+ navigateToPage(results[0].pageNumber);
1398
1445
  }
1399
1446
  };
1447
+ const navigateToPage = (pageNumber) => {
1448
+ requestAnimationFrame(() => {
1449
+ _optionalChain([pdfViewerRef, 'access', _215 => _215.current, 'optionalAccess', _216 => _216.navigation, 'access', _217 => _217.goToPage, 'call', _218 => _218(pageNumber)]);
1450
+ setCurrentPage(pageNumber);
1451
+ });
1452
+ };
1400
1453
  const handleSearchResultClick = (pageNumber, resultIndex) => {
1401
- _optionalChain([pdfViewerRef, 'access', _215 => _215.current, 'optionalAccess', _216 => _216.navigation, 'access', _217 => _217.goToPage, 'call', _218 => _218(pageNumber)]);
1454
+ _optionalChain([pdfViewerRef, 'access', _219 => _219.current, 'optionalAccess', _220 => _220.navigation, 'access', _221 => _221.goToPage, 'call', _222 => _222(pageNumber)]);
1402
1455
  setCurrentSearchResultIndex(resultIndex);
1403
1456
  setCurrentPage(pageNumber);
1404
- _optionalChain([pdfViewerRef, 'access', _219 => _219.current, 'optionalAccess', _220 => _220.search, 'access', _221 => _221.goToResult, 'call', _222 => _222(resultIndex)]);
1457
+ _optionalChain([pdfViewerRef, 'access', _223 => _223.current, 'optionalAccess', _224 => _224.search, 'access', _225 => _225.goToResult, 'call', _226 => _226(resultIndex)]);
1405
1458
  };
1406
1459
  const handleNextSearchResult = () => {
1407
1460
  if (currentSearchResultIndex < totalSearchResults - 1) {
1408
1461
  const nextIndex = currentSearchResultIndex + 1;
1409
1462
  setCurrentSearchResultIndex(nextIndex);
1410
- _optionalChain([pdfViewerRef, 'access', _223 => _223.current, 'optionalAccess', _224 => _224.search, 'access', _225 => _225.nextResult, 'call', _226 => _226()]);
1463
+ _optionalChain([pdfViewerRef, 'access', _227 => _227.current, 'optionalAccess', _228 => _228.search, 'access', _229 => _229.nextResult, 'call', _230 => _230()]);
1411
1464
  if (searchResults[nextIndex]) {
1412
1465
  const pageNumber = searchResults[nextIndex].pageNumber;
1413
- _optionalChain([pdfViewerRef, 'access', _227 => _227.current, 'optionalAccess', _228 => _228.navigation, 'access', _229 => _229.goToPage, 'call', _230 => _230(pageNumber)]);
1466
+ _optionalChain([pdfViewerRef, 'access', _231 => _231.current, 'optionalAccess', _232 => _232.navigation, 'access', _233 => _233.goToPage, 'call', _234 => _234(pageNumber)]);
1414
1467
  setCurrentPage(pageNumber);
1415
1468
  }
1416
1469
  }
@@ -1419,10 +1472,10 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1419
1472
  if (currentSearchResultIndex > 0) {
1420
1473
  const prevIndex = currentSearchResultIndex - 1;
1421
1474
  setCurrentSearchResultIndex(prevIndex);
1422
- _optionalChain([pdfViewerRef, 'access', _231 => _231.current, 'optionalAccess', _232 => _232.search, 'access', _233 => _233.previousResult, 'call', _234 => _234()]);
1475
+ _optionalChain([pdfViewerRef, 'access', _235 => _235.current, 'optionalAccess', _236 => _236.search, 'access', _237 => _237.previousResult, 'call', _238 => _238()]);
1423
1476
  if (searchResults[prevIndex]) {
1424
1477
  const pageNumber = searchResults[prevIndex].pageNumber;
1425
- _optionalChain([pdfViewerRef, 'access', _235 => _235.current, 'optionalAccess', _236 => _236.navigation, 'access', _237 => _237.goToPage, 'call', _238 => _238(pageNumber)]);
1478
+ _optionalChain([pdfViewerRef, 'access', _239 => _239.current, 'optionalAccess', _240 => _240.navigation, 'access', _241 => _241.goToPage, 'call', _242 => _242(pageNumber)]);
1426
1479
  setCurrentPage(pageNumber);
1427
1480
  }
1428
1481
  }
@@ -1453,12 +1506,12 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1453
1506
  }
1454
1507
  setPdfBuffer(arrayBuffer);
1455
1508
  setState("ready");
1456
- _optionalChain([onLoad, 'optionalCall', _239 => _239()]);
1509
+ _optionalChain([onLoad, 'optionalCall', _243 => _243()]);
1457
1510
  } catch (err) {
1458
1511
  const errorMessage = err.message || "Failed to load PDF";
1459
1512
  setState("error");
1460
1513
  setError(errorMessage);
1461
- _optionalChain([onError, 'optionalCall', _240 => _240(err)]);
1514
+ _optionalChain([onError, 'optionalCall', _244 => _244(err)]);
1462
1515
  }
1463
1516
  };
1464
1517
  loadPDF();
@@ -1598,7 +1651,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1598
1651
  SearchSidebar,
1599
1652
  {
1600
1653
  isOpen: isSidebarOpen,
1601
- onClose: () => setIsSidebarOpen(false),
1654
+ onClose: handleSidebarClose,
1602
1655
  onSearch: handleSidebarSearch,
1603
1656
  onSearchResultClick: handleSearchResultClick,
1604
1657
  onNextResult: handleNextSearchResult,
@@ -1632,4 +1685,4 @@ PDFViewer.displayName = "PDFViewer";
1632
1685
 
1633
1686
 
1634
1687
  exports.PDFViewer = PDFViewer;
1635
- //# sourceMappingURL=chunk-D7LXG67Z.js.map
1688
+ //# sourceMappingURL=chunk-RSCUIGVW.js.map