@cannyminds/dms-file-viewers 0.6.0 → 0.7.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 = 10;
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,11 +1202,11 @@ 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
  }
@@ -1190,10 +1237,10 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1190
1237
  _react.useEffect.call(void 0, () => {
1191
1238
  if (state === "ready" && pdfViewerRef.current) {
1192
1239
  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()]);
1240
+ const current = _optionalChain([pdfViewerRef, 'access', _95 => _95.current, 'optionalAccess', _96 => _96.navigation, 'access', _97 => _97.getCurrentPage, 'call', _98 => _98()]) || 1;
1241
+ const total = _optionalChain([pdfViewerRef, 'access', _99 => _99.current, 'optionalAccess', _100 => _100.navigation, 'access', _101 => _101.getTotalPages, 'call', _102 => _102()]) || 0;
1242
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _103 => _103.current, 'optionalAccess', _104 => _104.zoom, 'access', _105 => _105.getZoom, 'call', _106 => _106()]);
1243
+ const currentSearchState = _optionalChain([pdfViewerRef, 'access', _107 => _107.current, 'optionalAccess', _108 => _108.search, 'access', _109 => _109.getSearchState, 'call', _110 => _110()]);
1197
1244
  setCurrentPage(current);
1198
1245
  if (total > 0 && total !== totalPages) {
1199
1246
  setTotalPages(total);
@@ -1209,125 +1256,95 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1209
1256
  }, [state, totalPages]);
1210
1257
  _react.useImperativeHandle.call(void 0, ref, () => ({
1211
1258
  zoomIn: () => {
1212
- _optionalChain([pdfViewerRef, 'access', _107 => _107.current, 'optionalAccess', _108 => _108.zoom, 'access', _109 => _109.zoomIn, 'call', _110 => _110()]);
1259
+ _optionalChain([pdfViewerRef, 'access', _111 => _111.current, 'optionalAccess', _112 => _112.zoom, 'access', _113 => _113.zoomIn, 'call', _114 => _114()]);
1213
1260
  updateZoomDisplay();
1214
1261
  },
1215
1262
  zoomOut: () => {
1216
- _optionalChain([pdfViewerRef, 'access', _111 => _111.current, 'optionalAccess', _112 => _112.zoom, 'access', _113 => _113.zoomOut, 'call', _114 => _114()]);
1263
+ _optionalChain([pdfViewerRef, 'access', _115 => _115.current, 'optionalAccess', _116 => _116.zoom, 'access', _117 => _117.zoomOut, 'call', _118 => _118()]);
1217
1264
  updateZoomDisplay();
1218
1265
  },
1219
1266
  setZoom: (level) => {
1220
- _optionalChain([pdfViewerRef, 'access', _115 => _115.current, 'optionalAccess', _116 => _116.zoom, 'access', _117 => _117.setZoom, 'call', _118 => _118(level)]);
1267
+ _optionalChain([pdfViewerRef, 'access', _119 => _119.current, 'optionalAccess', _120 => _120.zoom, 'access', _121 => _121.setZoom, 'call', _122 => _122(level)]);
1221
1268
  updateZoomDisplay();
1222
1269
  },
1223
1270
  resetZoom: () => {
1224
- _optionalChain([pdfViewerRef, 'access', _119 => _119.current, 'optionalAccess', _120 => _120.zoom, 'access', _121 => _121.resetZoom, 'call', _122 => _122()]);
1271
+ _optionalChain([pdfViewerRef, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.zoom, 'access', _125 => _125.resetZoom, 'call', _126 => _126()]);
1225
1272
  updateZoomDisplay();
1226
1273
  },
1227
1274
  getZoom: () => {
1228
- const zoom2 = _optionalChain([pdfViewerRef, 'access', _123 => _123.current, 'optionalAccess', _124 => _124.zoom, 'access', _125 => _125.getZoom, 'call', _126 => _126()]);
1275
+ const zoom2 = _optionalChain([pdfViewerRef, 'access', _127 => _127.current, 'optionalAccess', _128 => _128.zoom, 'access', _129 => _129.getZoom, 'call', _130 => _130()]);
1229
1276
  return typeof zoom2 === "number" ? zoom2 : 1;
1230
1277
  },
1231
1278
  goToPage: (page) => {
1232
- _optionalChain([pdfViewerRef, 'access', _127 => _127.current, 'optionalAccess', _128 => _128.navigation, 'access', _129 => _129.goToPage, 'call', _130 => _130(page)]);
1279
+ _optionalChain([pdfViewerRef, 'access', _131 => _131.current, 'optionalAccess', _132 => _132.navigation, 'access', _133 => _133.goToPage, 'call', _134 => _134(page)]);
1233
1280
  setCurrentPage(page);
1234
1281
  },
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,
1282
+ getCurrentPage: () => _optionalChain([pdfViewerRef, 'access', _135 => _135.current, 'optionalAccess', _136 => _136.navigation, 'access', _137 => _137.getCurrentPage, 'call', _138 => _138()]) || 1,
1283
+ getTotalPages: () => _optionalChain([pdfViewerRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.navigation, 'access', _141 => _141.getTotalPages, 'call', _142 => _142()]) || 0,
1237
1284
  nextPage: () => {
1238
- _optionalChain([pdfViewerRef, 'access', _139 => _139.current, 'optionalAccess', _140 => _140.navigation, 'access', _141 => _141.nextPage, 'call', _142 => _142()]);
1285
+ _optionalChain([pdfViewerRef, 'access', _143 => _143.current, 'optionalAccess', _144 => _144.navigation, 'access', _145 => _145.nextPage, 'call', _146 => _146()]);
1239
1286
  updatePageDisplay();
1240
1287
  },
1241
1288
  previousPage: () => {
1242
- _optionalChain([pdfViewerRef, 'access', _143 => _143.current, 'optionalAccess', _144 => _144.navigation, 'access', _145 => _145.previousPage, 'call', _146 => _146()]);
1289
+ _optionalChain([pdfViewerRef, 'access', _147 => _147.current, 'optionalAccess', _148 => _148.navigation, 'access', _149 => _149.previousPage, 'call', _150 => _150()]);
1243
1290
  updatePageDisplay();
1244
1291
  },
1245
1292
  goToFirstPage: () => {
1246
- _optionalChain([pdfViewerRef, 'access', _147 => _147.current, 'optionalAccess', _148 => _148.navigation, 'access', _149 => _149.goToFirstPage, 'call', _150 => _150()]);
1293
+ _optionalChain([pdfViewerRef, 'access', _151 => _151.current, 'optionalAccess', _152 => _152.navigation, 'access', _153 => _153.goToFirstPage, 'call', _154 => _154()]);
1247
1294
  updatePageDisplay();
1248
1295
  },
1249
1296
  goToLastPage: () => {
1250
- _optionalChain([pdfViewerRef, 'access', _151 => _151.current, 'optionalAccess', _152 => _152.navigation, 'access', _153 => _153.goToLastPage, 'call', _154 => _154()]);
1297
+ _optionalChain([pdfViewerRef, 'access', _155 => _155.current, 'optionalAccess', _156 => _156.navigation, 'access', _157 => _157.goToLastPage, 'call', _158 => _158()]);
1251
1298
  updatePageDisplay();
1252
1299
  },
1253
1300
  searchText: async (keyword) => {
1254
1301
  setIsSearching(true);
1255
- const results = await _optionalChain([pdfViewerRef, 'access', _155 => _155.current, 'optionalAccess', _156 => _156.search, 'access', _157 => _157.searchText, 'call', _158 => _158(keyword)]);
1302
+ const results = await _optionalChain([pdfViewerRef, 'access', _159 => _159.current, 'optionalAccess', _160 => _160.search, 'access', _161 => _161.searchText, 'call', _162 => _162(keyword)]);
1256
1303
  setIsSearching(false);
1257
1304
  setSearchQuery(keyword);
1258
1305
  return results;
1259
1306
  },
1260
1307
  nextResult: () => {
1261
- const index = _optionalChain([pdfViewerRef, 'access', _159 => _159.current, 'optionalAccess', _160 => _160.search, 'access', _161 => _161.nextResult, 'call', _162 => _162()]) || -1;
1308
+ const index = _optionalChain([pdfViewerRef, 'access', _163 => _163.current, 'optionalAccess', _164 => _164.search, 'access', _165 => _165.nextResult, 'call', _166 => _166()]) || -1;
1262
1309
  return index;
1263
1310
  },
1264
1311
  previousResult: () => {
1265
- const index = _optionalChain([pdfViewerRef, 'access', _163 => _163.current, 'optionalAccess', _164 => _164.search, 'access', _165 => _165.previousResult, 'call', _166 => _166()]) || -1;
1312
+ const index = _optionalChain([pdfViewerRef, 'access', _167 => _167.current, 'optionalAccess', _168 => _168.search, 'access', _169 => _169.previousResult, 'call', _170 => _170()]) || -1;
1266
1313
  return index;
1267
1314
  },
1268
- goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _167 => _167.current, 'optionalAccess', _168 => _168.search, 'access', _169 => _169.goToResult, 'call', _170 => _170(index)]) || -1,
1315
+ goToResult: (index) => _optionalChain([pdfViewerRef, 'access', _171 => _171.current, 'optionalAccess', _172 => _172.search, 'access', _173 => _173.goToResult, 'call', _174 => _174(index)]) || -1,
1269
1316
  stopSearch: () => {
1270
- _optionalChain([pdfViewerRef, 'access', _171 => _171.current, 'optionalAccess', _172 => _172.search, 'access', _173 => _173.stopSearch, 'call', _174 => _174()]);
1317
+ _optionalChain([pdfViewerRef, 'access', _175 => _175.current, 'optionalAccess', _176 => _176.search, 'access', _177 => _177.stopSearch, 'call', _178 => _178()]);
1271
1318
  setSearchQuery("");
1272
1319
  },
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()])
1320
+ getSearchState: () => _optionalChain([pdfViewerRef, 'access', _179 => _179.current, 'optionalAccess', _180 => _180.search, 'access', _181 => _181.getSearchState, 'call', _182 => _182()]) || null,
1321
+ getSelectedText: () => _optionalChain([pdfViewerRef, 'access', _183 => _183.current, 'optionalAccess', _184 => _184.selection, 'access', _185 => _185.getSelectedText, 'call', _186 => _186()]) || "",
1322
+ clearSelection: () => _optionalChain([pdfViewerRef, 'access', _187 => _187.current, 'optionalAccess', _188 => _188.selection, 'access', _189 => _189.clearSelection, 'call', _190 => _190()])
1276
1323
  }), []);
1277
1324
  const updatePageDisplay = () => {
1278
1325
  requestAnimationFrame(() => {
1279
- const current = _optionalChain([pdfViewerRef, 'access', _187 => _187.current, 'optionalAccess', _188 => _188.navigation, 'access', _189 => _189.getCurrentPage, 'call', _190 => _190()]) || 1;
1326
+ const current = _optionalChain([pdfViewerRef, 'access', _191 => _191.current, 'optionalAccess', _192 => _192.navigation, 'access', _193 => _193.getCurrentPage, 'call', _194 => _194()]) || 1;
1280
1327
  setCurrentPage(current);
1281
1328
  });
1282
1329
  };
1283
1330
  const updateZoomDisplay = () => {
1284
1331
  requestAnimationFrame(() => {
1285
- const zoomValue = _optionalChain([pdfViewerRef, 'access', _191 => _191.current, 'optionalAccess', _192 => _192.zoom, 'access', _193 => _193.getZoom, 'call', _194 => _194()]);
1332
+ const zoomValue = _optionalChain([pdfViewerRef, 'access', _195 => _195.current, 'optionalAccess', _196 => _196.zoom, 'access', _197 => _197.getZoom, 'call', _198 => _198()]);
1286
1333
  if (typeof zoomValue === "number") {
1287
1334
  setZoom(Math.round(zoomValue * 100));
1288
1335
  }
1289
1336
  });
1290
1337
  };
1291
1338
  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
- }
1339
+ if (!searchQuery.trim()) return;
1340
+ setIsSearching(true);
1341
+ const results = await _optionalChain([pdfViewerRef, 'access', _199 => _199.current, 'optionalAccess', _200 => _200.search, 'access', _201 => _201.searchText, 'call', _202 => _202(searchQuery)]);
1342
+ setIsSearching(false);
1343
+ if (_optionalChain([results, 'optionalAccess', _203 => _203.results]) && Array.isArray(results.results) && results.results.length > 0) {
1344
+ const formattedResults = formatSearchResults(results.results);
1345
+ updateSearchState(formattedResults);
1346
+ } else {
1347
+ clearSearchResults();
1331
1348
  }
1332
1349
  };
1333
1350
  const handleSearchKeyPress = (e) => {
@@ -1337,80 +1354,106 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1337
1354
  };
1338
1355
  const handleSidebarSearch = async (keyword, pageNumbers) => {
1339
1356
  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)]);
1357
+ if (!keyword.trim()) {
1358
+ setSearchResults([]);
1359
+ setTotalSearchResults(0);
1360
+ setCurrentSearchResultIndex(0);
1361
+ _optionalChain([pdfViewerRef, 'access', _204 => _204.current, 'optionalAccess', _205 => _205.search, 'access', _206 => _206.stopSearch, 'call', _207 => _207()]);
1362
+ return;
1363
+ }
1364
+ if (!_optionalChain([pdfViewerRef, 'access', _208 => _208.current, 'optionalAccess', _209 => _209.search, 'optionalAccess', _210 => _210.searchText])) {
1365
+ console.warn("Search functionality not yet available");
1366
+ return;
1367
+ }
1368
+ setIsSearching(true);
1369
+ try {
1370
+ const results = await pdfViewerRef.current.search.searchText(keyword);
1371
+ console.log("Search completed:", results);
1343
1372
  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
- }
1373
+ const hasValidResults = _optionalChain([results, 'optionalAccess', _211 => _211.results]) && Array.isArray(results.results) && results.results.length > 0;
1374
+ if (hasValidResults) {
1375
+ const formattedResults = formatSearchResults(results.results);
1376
+ updateSearchState(formattedResults);
1377
+ navigateToFirstResult(formattedResults);
1376
1378
  } 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]);
1379
+ const fallbackResults = createFallbackResults(pageNumbers, keyword);
1380
+ updateSearchState(fallbackResults);
1381
+ navigateToPage(pageNumbers[0]);
1388
1382
  } else {
1389
- setSearchResults([]);
1390
- setTotalSearchResults(0);
1391
- setCurrentSearchResultIndex(0);
1383
+ clearSearchResults();
1392
1384
  }
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);
1385
+ } catch (error2) {
1386
+ console.error("Search failed:", error2);
1387
+ setIsSearching(false);
1388
+ clearSearchResults();
1398
1389
  }
1399
1390
  };
1391
+ const formatSearchResults = (results) => {
1392
+ return results.map((result, index) => {
1393
+ let textContent = "";
1394
+ let contextContent = "";
1395
+ if (result.context && typeof result.context === "object") {
1396
+ const { before = "", match = "", after = "" } = result.context;
1397
+ textContent = match;
1398
+ contextContent = `${before}${match}${after}`;
1399
+ } else if (typeof result === "string") {
1400
+ textContent = result;
1401
+ contextContent = result;
1402
+ } else {
1403
+ textContent = String(result.match || result.text || "");
1404
+ contextContent = textContent;
1405
+ }
1406
+ return {
1407
+ pageNumber: (_nullishCoalesce(_nullishCoalesce(result.pageIndex, () => ( result.pageNumber)), () => ( 0))) + 1,
1408
+ text: textContent,
1409
+ context: contextContent,
1410
+ index
1411
+ };
1412
+ });
1413
+ };
1414
+ const createFallbackResults = (pageNumbers, keyword) => {
1415
+ return pageNumbers.map((pageNum, index) => ({
1416
+ pageNumber: pageNum,
1417
+ text: keyword,
1418
+ context: `"${keyword}" found on this page ${pageNum}`,
1419
+ index
1420
+ }));
1421
+ };
1422
+ const updateSearchState = (results) => {
1423
+ setSearchResults(results);
1424
+ setTotalSearchResults(results.length);
1425
+ setCurrentSearchResultIndex(0);
1426
+ };
1427
+ const clearSearchResults = () => {
1428
+ setSearchResults([]);
1429
+ setTotalSearchResults(0);
1430
+ setCurrentSearchResultIndex(0);
1431
+ };
1432
+ const navigateToFirstResult = (results) => {
1433
+ if (results.length > 0) {
1434
+ navigateToPage(results[0].pageNumber);
1435
+ }
1436
+ };
1437
+ const navigateToPage = (pageNumber) => {
1438
+ requestAnimationFrame(() => {
1439
+ _optionalChain([pdfViewerRef, 'access', _212 => _212.current, 'optionalAccess', _213 => _213.navigation, 'access', _214 => _214.goToPage, 'call', _215 => _215(pageNumber)]);
1440
+ setCurrentPage(pageNumber);
1441
+ });
1442
+ };
1400
1443
  const handleSearchResultClick = (pageNumber, resultIndex) => {
1401
- _optionalChain([pdfViewerRef, 'access', _215 => _215.current, 'optionalAccess', _216 => _216.navigation, 'access', _217 => _217.goToPage, 'call', _218 => _218(pageNumber)]);
1444
+ _optionalChain([pdfViewerRef, 'access', _216 => _216.current, 'optionalAccess', _217 => _217.navigation, 'access', _218 => _218.goToPage, 'call', _219 => _219(pageNumber)]);
1402
1445
  setCurrentSearchResultIndex(resultIndex);
1403
1446
  setCurrentPage(pageNumber);
1404
- _optionalChain([pdfViewerRef, 'access', _219 => _219.current, 'optionalAccess', _220 => _220.search, 'access', _221 => _221.goToResult, 'call', _222 => _222(resultIndex)]);
1447
+ _optionalChain([pdfViewerRef, 'access', _220 => _220.current, 'optionalAccess', _221 => _221.search, 'access', _222 => _222.goToResult, 'call', _223 => _223(resultIndex)]);
1405
1448
  };
1406
1449
  const handleNextSearchResult = () => {
1407
1450
  if (currentSearchResultIndex < totalSearchResults - 1) {
1408
1451
  const nextIndex = currentSearchResultIndex + 1;
1409
1452
  setCurrentSearchResultIndex(nextIndex);
1410
- _optionalChain([pdfViewerRef, 'access', _223 => _223.current, 'optionalAccess', _224 => _224.search, 'access', _225 => _225.nextResult, 'call', _226 => _226()]);
1453
+ _optionalChain([pdfViewerRef, 'access', _224 => _224.current, 'optionalAccess', _225 => _225.search, 'access', _226 => _226.nextResult, 'call', _227 => _227()]);
1411
1454
  if (searchResults[nextIndex]) {
1412
1455
  const pageNumber = searchResults[nextIndex].pageNumber;
1413
- _optionalChain([pdfViewerRef, 'access', _227 => _227.current, 'optionalAccess', _228 => _228.navigation, 'access', _229 => _229.goToPage, 'call', _230 => _230(pageNumber)]);
1456
+ _optionalChain([pdfViewerRef, 'access', _228 => _228.current, 'optionalAccess', _229 => _229.navigation, 'access', _230 => _230.goToPage, 'call', _231 => _231(pageNumber)]);
1414
1457
  setCurrentPage(pageNumber);
1415
1458
  }
1416
1459
  }
@@ -1419,10 +1462,10 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1419
1462
  if (currentSearchResultIndex > 0) {
1420
1463
  const prevIndex = currentSearchResultIndex - 1;
1421
1464
  setCurrentSearchResultIndex(prevIndex);
1422
- _optionalChain([pdfViewerRef, 'access', _231 => _231.current, 'optionalAccess', _232 => _232.search, 'access', _233 => _233.previousResult, 'call', _234 => _234()]);
1465
+ _optionalChain([pdfViewerRef, 'access', _232 => _232.current, 'optionalAccess', _233 => _233.search, 'access', _234 => _234.previousResult, 'call', _235 => _235()]);
1423
1466
  if (searchResults[prevIndex]) {
1424
1467
  const pageNumber = searchResults[prevIndex].pageNumber;
1425
- _optionalChain([pdfViewerRef, 'access', _235 => _235.current, 'optionalAccess', _236 => _236.navigation, 'access', _237 => _237.goToPage, 'call', _238 => _238(pageNumber)]);
1468
+ _optionalChain([pdfViewerRef, 'access', _236 => _236.current, 'optionalAccess', _237 => _237.navigation, 'access', _238 => _238.goToPage, 'call', _239 => _239(pageNumber)]);
1426
1469
  setCurrentPage(pageNumber);
1427
1470
  }
1428
1471
  }
@@ -1453,12 +1496,12 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1453
1496
  }
1454
1497
  setPdfBuffer(arrayBuffer);
1455
1498
  setState("ready");
1456
- _optionalChain([onLoad, 'optionalCall', _239 => _239()]);
1499
+ _optionalChain([onLoad, 'optionalCall', _240 => _240()]);
1457
1500
  } catch (err) {
1458
1501
  const errorMessage = err.message || "Failed to load PDF";
1459
1502
  setState("error");
1460
1503
  setError(errorMessage);
1461
- _optionalChain([onError, 'optionalCall', _240 => _240(err)]);
1504
+ _optionalChain([onError, 'optionalCall', _241 => _241(err)]);
1462
1505
  }
1463
1506
  };
1464
1507
  loadPDF();
@@ -1598,7 +1641,7 @@ var PDFViewerContent = _react.forwardRef.call(void 0, (props, ref) => {
1598
1641
  SearchSidebar,
1599
1642
  {
1600
1643
  isOpen: isSidebarOpen,
1601
- onClose: () => setIsSidebarOpen(false),
1644
+ onClose: handleSidebarClose,
1602
1645
  onSearch: handleSidebarSearch,
1603
1646
  onSearchResultClick: handleSearchResultClick,
1604
1647
  onNextResult: handleNextSearchResult,
@@ -1632,4 +1675,4 @@ PDFViewer.displayName = "PDFViewer";
1632
1675
 
1633
1676
 
1634
1677
  exports.PDFViewer = PDFViewer;
1635
- //# sourceMappingURL=chunk-D7LXG67Z.js.map
1678
+ //# sourceMappingURL=chunk-HQJPMN53.js.map