@cannyminds/dms-file-viewers 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/chunk-42VHR3EK.mjs +714 -0
  2. package/dist/chunk-42VHR3EK.mjs.map +1 -0
  3. package/dist/{chunk-J3JKVSAM.js → chunk-AYVTSFZA.js} +2 -1
  4. package/dist/chunk-AYVTSFZA.js.map +1 -0
  5. package/dist/chunk-C4L2R2QY.mjs +277 -0
  6. package/dist/chunk-C4L2R2QY.mjs.map +1 -0
  7. package/dist/chunk-DBXSX2B6.js +277 -0
  8. package/dist/chunk-DBXSX2B6.js.map +1 -0
  9. package/dist/chunk-DPSRGULQ.mjs +247 -0
  10. package/dist/chunk-DPSRGULQ.mjs.map +1 -0
  11. package/dist/chunk-FK6RYOAZ.mjs +297 -0
  12. package/dist/chunk-FK6RYOAZ.mjs.map +1 -0
  13. package/dist/chunk-FZVXQGA7.mjs +466 -0
  14. package/dist/chunk-FZVXQGA7.mjs.map +1 -0
  15. package/dist/chunk-GSRAK2YV.js +266 -0
  16. package/dist/chunk-GSRAK2YV.js.map +1 -0
  17. package/dist/chunk-HYRQBGAX.js +466 -0
  18. package/dist/chunk-HYRQBGAX.js.map +1 -0
  19. package/dist/chunk-RKDOWWQD.js +247 -0
  20. package/dist/chunk-RKDOWWQD.js.map +1 -0
  21. package/dist/chunk-TMAHQICY.mjs +1842 -0
  22. package/dist/chunk-TMAHQICY.mjs.map +1 -0
  23. package/dist/chunk-VBJVOB45.mjs +266 -0
  24. package/dist/chunk-VBJVOB45.mjs.map +1 -0
  25. package/dist/{chunk-DFBVN4MO.mjs → chunk-WR5SJ3LM.mjs} +2 -1
  26. package/dist/chunk-WR5SJ3LM.mjs.map +1 -0
  27. package/dist/chunk-XSXOX4MV.js +297 -0
  28. package/dist/chunk-XSXOX4MV.js.map +1 -0
  29. package/dist/chunk-XWWMHRVU.js +1842 -0
  30. package/dist/chunk-XWWMHRVU.js.map +1 -0
  31. package/dist/chunk-YU535XRJ.js +714 -0
  32. package/dist/chunk-YU535XRJ.js.map +1 -0
  33. package/dist/components/viewers/AudioViewer.d.mts +1 -1
  34. package/dist/components/viewers/AudioViewer.d.ts +1 -1
  35. package/dist/components/viewers/AudioViewer.js +3 -3
  36. package/dist/components/viewers/AudioViewer.mjs +2 -2
  37. package/dist/components/viewers/DefaultViewer.d.mts +1 -1
  38. package/dist/components/viewers/DefaultViewer.d.ts +1 -1
  39. package/dist/components/viewers/DefaultViewer.js +3 -3
  40. package/dist/components/viewers/DefaultViewer.mjs +2 -2
  41. package/dist/components/viewers/ImageViewer.d.mts +1 -1
  42. package/dist/components/viewers/ImageViewer.d.ts +1 -1
  43. package/dist/components/viewers/ImageViewer.js +3 -3
  44. package/dist/components/viewers/ImageViewer.mjs +2 -2
  45. package/dist/components/viewers/PDFViewer.d.mts +1 -1
  46. package/dist/components/viewers/PDFViewer.d.ts +1 -1
  47. package/dist/components/viewers/PDFViewer.js +3 -3
  48. package/dist/components/viewers/PDFViewer.mjs +2 -2
  49. package/dist/components/viewers/TIFFViewer.d.mts +1 -1
  50. package/dist/components/viewers/TIFFViewer.d.ts +1 -1
  51. package/dist/components/viewers/TIFFViewer.js +3 -3
  52. package/dist/components/viewers/TIFFViewer.mjs +2 -2
  53. package/dist/components/viewers/TextViewer.d.mts +1 -1
  54. package/dist/components/viewers/TextViewer.d.ts +1 -1
  55. package/dist/components/viewers/TextViewer.js +3 -3
  56. package/dist/components/viewers/TextViewer.mjs +2 -2
  57. package/dist/components/viewers/VideoViewer.d.mts +1 -1
  58. package/dist/components/viewers/VideoViewer.d.ts +1 -1
  59. package/dist/components/viewers/VideoViewer.js +3 -3
  60. package/dist/components/viewers/VideoViewer.mjs +2 -2
  61. package/dist/index.d.mts +2 -2
  62. package/dist/index.d.ts +2 -2
  63. package/dist/index.js +9 -9
  64. package/dist/index.mjs +8 -8
  65. package/dist/{types-DNrkDJdK.d.mts → types-DxRCbIFP.d.mts} +4 -2
  66. package/dist/{types-DNrkDJdK.d.ts → types-DxRCbIFP.d.ts} +4 -2
  67. package/package.json +1 -1
  68. package/dist/chunk-7QRYWFCO.js +0 -639
  69. package/dist/chunk-7QRYWFCO.js.map +0 -1
  70. package/dist/chunk-7R2KG3PE.mjs +0 -210
  71. package/dist/chunk-7R2KG3PE.mjs.map +0 -1
  72. package/dist/chunk-CFYOPDCG.mjs +0 -235
  73. package/dist/chunk-CFYOPDCG.mjs.map +0 -1
  74. package/dist/chunk-D74R4IKW.mjs +0 -341
  75. package/dist/chunk-D74R4IKW.mjs.map +0 -1
  76. package/dist/chunk-DFBVN4MO.mjs.map +0 -1
  77. package/dist/chunk-EXZCEYLI.js +0 -247
  78. package/dist/chunk-EXZCEYLI.js.map +0 -1
  79. package/dist/chunk-J3JKVSAM.js.map +0 -1
  80. package/dist/chunk-NXVIRFGL.mjs +0 -247
  81. package/dist/chunk-NXVIRFGL.mjs.map +0 -1
  82. package/dist/chunk-P2VNW6OE.mjs +0 -180
  83. package/dist/chunk-P2VNW6OE.mjs.map +0 -1
  84. package/dist/chunk-P5FH7LK7.mjs +0 -639
  85. package/dist/chunk-P5FH7LK7.mjs.map +0 -1
  86. package/dist/chunk-PZJSY6OF.mjs +0 -1736
  87. package/dist/chunk-PZJSY6OF.mjs.map +0 -1
  88. package/dist/chunk-RVHIXSUP.js +0 -235
  89. package/dist/chunk-RVHIXSUP.js.map +0 -1
  90. package/dist/chunk-TGVFAAIP.js +0 -341
  91. package/dist/chunk-TGVFAAIP.js.map +0 -1
  92. package/dist/chunk-VOLQW3NF.js +0 -1736
  93. package/dist/chunk-VOLQW3NF.js.map +0 -1
  94. package/dist/chunk-VSGX22FQ.js +0 -180
  95. package/dist/chunk-VSGX22FQ.js.map +0 -1
  96. package/dist/chunk-WCAXWJE7.js +0 -210
  97. package/dist/chunk-WCAXWJE7.js.map +0 -1
@@ -0,0 +1,714 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
2
+
3
+
4
+ var _chunkYEPEMLM3js = require('./chunk-YEPEMLM3.js');
5
+
6
+
7
+
8
+ var _chunkAYVTSFZAjs = require('./chunk-AYVTSFZA.js');
9
+
10
+ // src/components/viewers/TIFFViewer.tsx
11
+
12
+
13
+
14
+
15
+
16
+
17
+ var _react = require('react');
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+ var _material = require('@mui/material');
29
+ var _Download = require('@mui/icons-material/Download'); var _Download2 = _interopRequireDefault(_Download);
30
+ var _Print = require('@mui/icons-material/Print'); var _Print2 = _interopRequireDefault(_Print);
31
+ var _Fullscreen = require('@mui/icons-material/Fullscreen'); var _Fullscreen2 = _interopRequireDefault(_Fullscreen);
32
+ var _FirstPage = require('@mui/icons-material/FirstPage'); var _FirstPage2 = _interopRequireDefault(_FirstPage);
33
+ var _LastPage = require('@mui/icons-material/LastPage'); var _LastPage2 = _interopRequireDefault(_LastPage);
34
+ var _ChevronLeft = require('@mui/icons-material/ChevronLeft'); var _ChevronLeft2 = _interopRequireDefault(_ChevronLeft);
35
+ var _ChevronRight = require('@mui/icons-material/ChevronRight'); var _ChevronRight2 = _interopRequireDefault(_ChevronRight);
36
+ var _ZoomIn = require('@mui/icons-material/ZoomIn'); var _ZoomIn2 = _interopRequireDefault(_ZoomIn);
37
+ var _ZoomOut = require('@mui/icons-material/ZoomOut'); var _ZoomOut2 = _interopRequireDefault(_ZoomOut);
38
+ var _FitScreen = require('@mui/icons-material/FitScreen'); var _FitScreen2 = _interopRequireDefault(_FitScreen);
39
+ var _AspectRatio = require('@mui/icons-material/AspectRatio'); var _AspectRatio2 = _interopRequireDefault(_AspectRatio);
40
+ var _Info = require('@mui/icons-material/Info'); var _Info2 = _interopRequireDefault(_Info);
41
+ var _Description = require('@mui/icons-material/Description'); var _Description2 = _interopRequireDefault(_Description);
42
+ var _jsxruntime = require('react/jsx-runtime');
43
+ var resolveDocumentName = (file, fileName, url) => {
44
+ if (_optionalChain([file, 'optionalAccess', _ => _.name])) {
45
+ return file.name;
46
+ }
47
+ if (fileName) {
48
+ return fileName;
49
+ }
50
+ if (url) {
51
+ const parts = _nullishCoalesce(_optionalChain([url, 'access', _2 => _2.split, 'call', _3 => _3("?"), 'access', _4 => _4[0], 'optionalAccess', _5 => _5.split, 'call', _6 => _6("#"), 'access', _7 => _7[0], 'optionalAccess', _8 => _8.split, 'call', _9 => _9("/")]), () => ( []));
52
+ return parts[parts.length - 1] || "document.tiff";
53
+ }
54
+ return "document.tiff";
55
+ };
56
+ var TIFFViewerContent = ({
57
+ sourceDescription,
58
+ file,
59
+ url,
60
+ fileName,
61
+ totalPages = 1,
62
+ className = "",
63
+ style = {},
64
+ width = "100%",
65
+ height = "100%",
66
+ onLoad,
67
+ onError,
68
+ onDownloadClick,
69
+ onPrintClick,
70
+ onTagsClick,
71
+ onMetadataClick,
72
+ onPropertiesClick,
73
+ pageLoader,
74
+ showDownload = true,
75
+ showPrint = true,
76
+ showMetadata = false,
77
+ showTags = false,
78
+ showProperties = false,
79
+ // Extract props that shouldn't be passed to DOM elements
80
+ mimeType,
81
+ fileSize,
82
+ showPageCount,
83
+ showPageNavigation,
84
+ showZoomControls,
85
+ showSearch,
86
+ customRegistry,
87
+ initialSearchText,
88
+ initialSearchPages,
89
+ autoOpenSearch,
90
+ autoExecuteSearch,
91
+ onSearchComplete,
92
+ toolbarActions,
93
+ ...props
94
+ }) => {
95
+ const [currentPage, setCurrentPage] = _react.useState.call(void 0, 1);
96
+ const [isLoading, setIsLoading] = _react.useState.call(void 0, false);
97
+ const [error, setError] = _react.useState.call(void 0, null);
98
+ const [fitMode, setFitMode] = _react.useState.call(void 0,
99
+ "fit-page"
100
+ );
101
+ const [zoom, setZoom] = _react.useState.call(void 0, 100);
102
+ const [viewportWidth, setViewportWidth] = _react.useState.call(void 0, 0);
103
+ const [viewportHeight, setViewportHeight] = _react.useState.call(void 0, 0);
104
+ const [isFullScreen, setIsFullScreen] = _react.useState.call(void 0, false);
105
+ const [imageUrl, setImageUrl] = _react.useState.call(void 0, null);
106
+ const [pageImages, setPageImages] = _react.useState.call(void 0, /* @__PURE__ */ new Map());
107
+ const [internalLoading, setInternalLoading] = _react.useState.call(void 0, false);
108
+ const [imageSize, setImageSize] = _react.useState.call(void 0, null);
109
+ const viewportRef = _react.useRef.call(void 0, null);
110
+ const containerRef = _react.useRef.call(void 0, null);
111
+ const imgRef = _react.useRef.call(void 0, null);
112
+ const pageLoaderRef = _react.useRef.call(void 0, pageLoader);
113
+ _react.useEffect.call(void 0, () => {
114
+ pageLoaderRef.current = pageLoader;
115
+ }, [pageLoader]);
116
+ const updatePageImage = _react.useCallback.call(void 0,
117
+ (pageData, pageNumber) => {
118
+ const blob = new Blob([pageData]);
119
+ const imageUrl2 = URL.createObjectURL(blob);
120
+ setPageImages((prev) => {
121
+ const oldUrl = prev.get(pageNumber);
122
+ if (oldUrl && oldUrl !== imageUrl2) {
123
+ URL.revokeObjectURL(oldUrl);
124
+ }
125
+ return new Map(prev).set(pageNumber, imageUrl2);
126
+ });
127
+ setCurrentPage(pageNumber);
128
+ setImageUrl(imageUrl2);
129
+ },
130
+ []
131
+ );
132
+ _react.useEffect.call(void 0, () => {
133
+ const loadInitialPage = async () => {
134
+ if (pageLoaderRef.current && !pageImages.has(1) && currentPage === 1) {
135
+ setInternalLoading(true);
136
+ setError(null);
137
+ try {
138
+ const pageData = await pageLoaderRef.current(1);
139
+ if (pageData) {
140
+ updatePageImage(pageData, 1);
141
+ } else {
142
+ setError("Failed to load page 1");
143
+ }
144
+ } catch (err) {
145
+ const message = err instanceof Error ? err.message : "Unable to load page 1";
146
+ setError(message);
147
+ _optionalChain([onError, 'optionalCall', _10 => _10(new Error(message))]);
148
+ } finally {
149
+ setInternalLoading(false);
150
+ }
151
+ }
152
+ };
153
+ loadInitialPage();
154
+ }, [pageImages, currentPage, updatePageImage, onError]);
155
+ const handlePageChange = _react.useCallback.call(void 0,
156
+ async (newPageNumber) => {
157
+ if (!pageLoaderRef.current) {
158
+ console.warn("pageLoader not provided - page navigation disabled");
159
+ return;
160
+ }
161
+ const cachedUrl = pageImages.get(newPageNumber);
162
+ if (cachedUrl) {
163
+ setCurrentPage(newPageNumber);
164
+ setImageUrl(cachedUrl);
165
+ return;
166
+ }
167
+ setInternalLoading(true);
168
+ setError(null);
169
+ try {
170
+ const pageData = await pageLoaderRef.current(newPageNumber);
171
+ if (pageData) {
172
+ updatePageImage(pageData, newPageNumber);
173
+ } else {
174
+ setError(`Failed to load page ${newPageNumber}`);
175
+ }
176
+ } catch (err) {
177
+ const message = err instanceof Error ? err.message : `Unable to load page ${newPageNumber}`;
178
+ setError(message);
179
+ _optionalChain([onError, 'optionalCall', _11 => _11(new Error(message))]);
180
+ } finally {
181
+ setInternalLoading(false);
182
+ }
183
+ },
184
+ [pageImages, onError, updatePageImage]
185
+ );
186
+ const resolvedFileName = _react.useMemo.call(void 0,
187
+ () => fileName || sourceDescription,
188
+ [fileName, sourceDescription]
189
+ );
190
+ const fileExtension = _react.useMemo.call(void 0,
191
+ () => _chunkYEPEMLM3js.getFileExtension.call(void 0, resolvedFileName || ""),
192
+ [resolvedFileName]
193
+ );
194
+ const loadImage = _react.useCallback.call(void 0,
195
+ async (resetPage = false) => {
196
+ if (!file && !url) {
197
+ setImageUrl(null);
198
+ if (resetPage) setCurrentPage(1);
199
+ setError(null);
200
+ return;
201
+ }
202
+ setIsLoading(true);
203
+ setError(null);
204
+ try {
205
+ let imageDataUrl;
206
+ if (file) {
207
+ imageDataUrl = URL.createObjectURL(file);
208
+ } else if (url) {
209
+ imageDataUrl = url;
210
+ } else {
211
+ throw new Error("No file or URL provided");
212
+ }
213
+ setImageUrl(imageDataUrl);
214
+ if (resetPage) {
215
+ setCurrentPage(1);
216
+ setFitMode("fit-page");
217
+ setZoom(100);
218
+ }
219
+ _optionalChain([onLoad, 'optionalCall', _12 => _12()]);
220
+ } catch (err) {
221
+ const message = err instanceof Error ? err.message : "Unable to load image file";
222
+ setError(message);
223
+ setImageUrl(null);
224
+ if (resetPage) {
225
+ setCurrentPage(1);
226
+ setFitMode("fit-width");
227
+ setZoom(100);
228
+ }
229
+ _optionalChain([onError, 'optionalCall', _13 => _13(new Error(message))]);
230
+ } finally {
231
+ setIsLoading(false);
232
+ }
233
+ },
234
+ [file, url, onLoad, onError]
235
+ );
236
+ const [previousFileSource, setPreviousFileSource] = _react.useState.call(void 0, {});
237
+ _react.useEffect.call(void 0, () => {
238
+ const currentFileSource = { file, url };
239
+ const isNewFile = previousFileSource.file !== file || previousFileSource.url !== url;
240
+ if (isNewFile) {
241
+ setPreviousFileSource(currentFileSource);
242
+ void loadImage(true);
243
+ } else {
244
+ void loadImage(false);
245
+ }
246
+ }, [file, url, loadImage, previousFileSource.file, previousFileSource.url]);
247
+ _react.useEffect.call(void 0, () => {
248
+ return () => {
249
+ pageImages.forEach((url2) => {
250
+ URL.revokeObjectURL(url2);
251
+ });
252
+ if (imageUrl && file && !pageImages.has(currentPage)) {
253
+ URL.revokeObjectURL(imageUrl);
254
+ }
255
+ };
256
+ }, []);
257
+ const hasImage = !!imageUrl;
258
+ const hasMultiplePages = totalPages > 1;
259
+ const MARGIN = 40;
260
+ const MIN_ZOOM = 25;
261
+ const MAX_ZOOM = 400;
262
+ const ZOOM_LEVELS = [25, 50, 75, 100, 125, 150, 200, 300, 400];
263
+ const calculateFitZoom = _react.useCallback.call(void 0,
264
+ (mode) => {
265
+ if (!imageSize || viewportWidth <= 0) return null;
266
+ const availableWidth = viewportWidth - MARGIN;
267
+ if (mode === "fit-width") {
268
+ const calculatedZoom = Math.round(
269
+ availableWidth / imageSize.width * 100
270
+ );
271
+ return Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, calculatedZoom));
272
+ }
273
+ if (mode === "fit-page" && viewportHeight > 0) {
274
+ const availableHeight = viewportHeight - MARGIN;
275
+ const scaleW = availableWidth / imageSize.width;
276
+ const scaleH = availableHeight / imageSize.height;
277
+ const calculatedZoom = Math.round(Math.min(scaleW, scaleH) * 100);
278
+ return Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, calculatedZoom));
279
+ }
280
+ return null;
281
+ },
282
+ [imageSize, viewportWidth, viewportHeight]
283
+ );
284
+ _react.useEffect.call(void 0, () => {
285
+ if (!hasImage || !imageSize) return;
286
+ const newZoom = calculateFitZoom(fitMode);
287
+ if (newZoom !== null) {
288
+ setZoom(newZoom);
289
+ }
290
+ }, [currentPage, hasImage, imageSize, fitMode, calculateFitZoom]);
291
+ _react.useEffect.call(void 0, () => {
292
+ if (typeof window === "undefined" || typeof ResizeObserver === "undefined") {
293
+ return void 0;
294
+ }
295
+ if (!viewportRef.current) {
296
+ return void 0;
297
+ }
298
+ const updateSize = () => {
299
+ const bounds = _optionalChain([viewportRef, 'access', _14 => _14.current, 'optionalAccess', _15 => _15.getBoundingClientRect, 'call', _16 => _16()]);
300
+ if (bounds) {
301
+ setViewportWidth(bounds.width);
302
+ setViewportHeight(bounds.height);
303
+ }
304
+ };
305
+ updateSize();
306
+ const observer = new ResizeObserver(updateSize);
307
+ observer.observe(viewportRef.current);
308
+ return () => {
309
+ observer.disconnect();
310
+ };
311
+ }, []);
312
+ const handleZoomIn = _react.useCallback.call(void 0, () => {
313
+ setFitMode("zoom");
314
+ setZoom((value) => {
315
+ const nextLevel = ZOOM_LEVELS.find((level) => level > value);
316
+ return nextLevel || MAX_ZOOM;
317
+ });
318
+ }, []);
319
+ const handleZoomOut = _react.useCallback.call(void 0, () => {
320
+ setFitMode("zoom");
321
+ setZoom((value) => {
322
+ const prevLevel = [...ZOOM_LEVELS].reverse().find((level) => level < value);
323
+ return prevLevel || MIN_ZOOM;
324
+ });
325
+ }, []);
326
+ const handleFitWidth = _react.useCallback.call(void 0, () => {
327
+ setFitMode("fit-width");
328
+ const newZoom = calculateFitZoom("fit-width");
329
+ if (newZoom !== null) {
330
+ setZoom(newZoom);
331
+ }
332
+ }, [calculateFitZoom]);
333
+ const handleFitPage = _react.useCallback.call(void 0, () => {
334
+ setFitMode("fit-page");
335
+ const newZoom = calculateFitZoom("fit-page");
336
+ if (newZoom !== null) {
337
+ setZoom(newZoom);
338
+ }
339
+ }, [calculateFitZoom]);
340
+ const handleFirstPage = _react.useCallback.call(void 0, () => {
341
+ handlePageChange(1);
342
+ }, [handlePageChange]);
343
+ const handleLastPage = _react.useCallback.call(void 0, () => {
344
+ handlePageChange(totalPages);
345
+ }, [handlePageChange, totalPages]);
346
+ const handlePreviousPage = _react.useCallback.call(void 0, () => {
347
+ const newPage = Math.max(currentPage - 1, 1);
348
+ if (newPage !== currentPage) {
349
+ handlePageChange(newPage);
350
+ }
351
+ }, [currentPage, handlePageChange]);
352
+ const handleNextPage = _react.useCallback.call(void 0, () => {
353
+ const newPage = Math.min(currentPage + 1, totalPages);
354
+ if (newPage !== currentPage) {
355
+ handlePageChange(newPage);
356
+ }
357
+ }, [currentPage, totalPages, handlePageChange]);
358
+ const handleToggleFullScreen = _react.useCallback.call(void 0, () => {
359
+ if (!isFullScreen && _optionalChain([containerRef, 'access', _17 => _17.current, 'optionalAccess', _18 => _18.requestFullscreen])) {
360
+ containerRef.current.requestFullscreen();
361
+ setIsFullScreen(true);
362
+ } else if (isFullScreen && document.exitFullscreen) {
363
+ document.exitFullscreen();
364
+ setIsFullScreen(false);
365
+ }
366
+ }, [isFullScreen]);
367
+ const toolbar = _chunkAYVTSFZAjs.mergeToolbarConfig.call(void 0, {
368
+ showDownload,
369
+ showPrint,
370
+ showMetadata,
371
+ showTags,
372
+ showProperties,
373
+ onDownloadClick,
374
+ onPrintClick,
375
+ onTagsClick,
376
+ onMetadataClick,
377
+ onPropertiesClick,
378
+ toolbarActions
379
+ });
380
+ const displayScale = zoom;
381
+ const handleImageLoad = _react.useCallback.call(void 0,
382
+ (e) => {
383
+ const img = e.currentTarget;
384
+ setImageSize({ width: img.naturalWidth, height: img.naturalHeight });
385
+ if (!hasImage) {
386
+ _optionalChain([onLoad, 'optionalCall', _19 => _19()]);
387
+ }
388
+ },
389
+ [hasImage, onLoad]
390
+ );
391
+ const renderImage = () => {
392
+ if (!imageUrl) {
393
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "body2", color: "text.secondary", children: "No image available." });
394
+ }
395
+ let imgStyle = {
396
+ display: "block",
397
+ borderRadius: "4px"
398
+ };
399
+ if (imageSize) {
400
+ const zoomFactor = zoom / 100;
401
+ const scaledWidth = imageSize.width * zoomFactor;
402
+ const scaledHeight = imageSize.height * zoomFactor;
403
+ imgStyle = {
404
+ ...imgStyle,
405
+ width: `${scaledWidth}px`,
406
+ height: `${scaledHeight}px`,
407
+ maxWidth: "none",
408
+ maxHeight: "none"
409
+ };
410
+ }
411
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
412
+ _material.Box,
413
+ {
414
+ component: "img",
415
+ ref: imgRef,
416
+ src: imageUrl,
417
+ alt: `${resolvedFileName} page ${currentPage}`,
418
+ onLoad: handleImageLoad,
419
+ onError: () => {
420
+ setError("Failed to load image");
421
+ _optionalChain([onError, 'optionalCall', _20 => _20(new Error("Failed to load image"))]);
422
+ },
423
+ sx: {
424
+ ...imgStyle,
425
+ boxShadow: 1,
426
+ backgroundColor: "#fff",
427
+ margin: "20px"
428
+ }
429
+ }
430
+ );
431
+ };
432
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
433
+ _material.Box,
434
+ {
435
+ ref: containerRef,
436
+ className: `tiff-viewer ${className}`,
437
+ sx: {
438
+ width,
439
+ height,
440
+ display: "flex",
441
+ flexDirection: "column",
442
+ overflow: "hidden",
443
+ ...style
444
+ },
445
+ ...props,
446
+ children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
447
+ _material.Card,
448
+ {
449
+ sx: {
450
+ height: "100%",
451
+ width: "100%",
452
+ display: "flex",
453
+ flexDirection: "column",
454
+ overflow: "hidden"
455
+ },
456
+ elevation: 1,
457
+ children: [
458
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
459
+ _material.CardHeader,
460
+ {
461
+ avatar: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _chunkAYVTSFZAjs.FileIcon_default, { ext: fileExtension, size: 32 }),
462
+ title: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { variant: "subtitle1", fontWeight: 500, children: resolvedFileName }),
463
+ sx: { pb: 1 }
464
+ }
465
+ ),
466
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Box, { sx: { px: 2, pb: 1, display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
467
+ _material.Stack,
468
+ {
469
+ direction: "row",
470
+ spacing: 1,
471
+ alignItems: "center",
472
+ flexWrap: "wrap",
473
+ gap: 1,
474
+ children: [
475
+ hasMultiplePages && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
476
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
477
+ _material.IconButton,
478
+ {
479
+ size: "small",
480
+ onClick: handleFirstPage,
481
+ disabled: currentPage === 1,
482
+ title: "First Page",
483
+ "aria-label": "Go to first page",
484
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FirstPage2.default, { fontSize: "small" })
485
+ }
486
+ ),
487
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
488
+ _material.IconButton,
489
+ {
490
+ size: "small",
491
+ onClick: handlePreviousPage,
492
+ disabled: currentPage === 1,
493
+ title: "Previous Page",
494
+ "aria-label": "Go to previous page",
495
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronLeft2.default, { fontSize: "small" })
496
+ }
497
+ ),
498
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
499
+ _material.Typography,
500
+ {
501
+ variant: "body2",
502
+ color: "text.secondary",
503
+ sx: { minWidth: 100, textAlign: "center" },
504
+ children: [
505
+ "Page ",
506
+ currentPage,
507
+ " of ",
508
+ totalPages
509
+ ]
510
+ }
511
+ ),
512
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
513
+ _material.IconButton,
514
+ {
515
+ size: "small",
516
+ onClick: handleNextPage,
517
+ disabled: currentPage === totalPages,
518
+ title: "Next Page",
519
+ "aria-label": "Go to next page",
520
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ChevronRight2.default, { fontSize: "small" })
521
+ }
522
+ ),
523
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
524
+ _material.IconButton,
525
+ {
526
+ size: "small",
527
+ onClick: handleLastPage,
528
+ disabled: currentPage === totalPages,
529
+ title: "Last Page",
530
+ "aria-label": "Go to last page",
531
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _LastPage2.default, { fontSize: "small" })
532
+ }
533
+ ),
534
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Divider, { orientation: "vertical", flexItem: true, sx: { mx: 1 } })
535
+ ] }),
536
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
537
+ _material.IconButton,
538
+ {
539
+ size: "small",
540
+ onClick: handleZoomOut,
541
+ disabled: !hasImage || zoom <= 25,
542
+ title: "Zoom Out",
543
+ "aria-label": "Zoom out",
544
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomOut2.default, { fontSize: "small" })
545
+ }
546
+ ),
547
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
548
+ _material.Typography,
549
+ {
550
+ variant: "body2",
551
+ color: "text.secondary",
552
+ sx: { minWidth: 64, textAlign: "center" },
553
+ children: hasImage ? `${displayScale}%` : "\u2014"
554
+ }
555
+ ),
556
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
557
+ _material.IconButton,
558
+ {
559
+ size: "small",
560
+ onClick: handleZoomIn,
561
+ disabled: !hasImage || zoom >= 400,
562
+ title: "Zoom In",
563
+ "aria-label": "Zoom in",
564
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZoomIn2.default, { fontSize: "small" })
565
+ }
566
+ ),
567
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
568
+ _material.IconButton,
569
+ {
570
+ size: "small",
571
+ onClick: handleFitWidth,
572
+ disabled: !hasImage,
573
+ title: "Fit to Width",
574
+ "aria-label": "Fit to width",
575
+ color: fitMode === "fit-width" ? "primary" : "default",
576
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _AspectRatio2.default, { fontSize: "small" })
577
+ }
578
+ ),
579
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
580
+ _material.IconButton,
581
+ {
582
+ size: "small",
583
+ onClick: handleFitPage,
584
+ disabled: !hasImage,
585
+ title: "Fit to Page",
586
+ "aria-label": "Fit to page",
587
+ color: fitMode === "fit-page" ? "primary" : "default",
588
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _FitScreen2.default, { fontSize: "small" })
589
+ }
590
+ ),
591
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Divider, { orientation: "vertical", flexItem: true, sx: { mx: 1 } }),
592
+ !toolbar.isHidden("download") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
593
+ _material.IconButton,
594
+ {
595
+ size: "small",
596
+ onClick: toolbar.getHandler("download", onDownloadClick),
597
+ disabled: toolbar.isDisabled("download"),
598
+ title: toolbar.getLabel("download") || "Download",
599
+ "aria-label": "Download TIFF",
600
+ children: toolbar.getIcon("download") || /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Download2.default, { fontSize: "small" })
601
+ }
602
+ ),
603
+ !toolbar.isHidden("print") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
604
+ _material.IconButton,
605
+ {
606
+ size: "small",
607
+ onClick: toolbar.getHandler("print", onPrintClick),
608
+ disabled: toolbar.isDisabled("print"),
609
+ title: toolbar.getLabel("print") || "Print",
610
+ "aria-label": "Print TIFF",
611
+ children: toolbar.getIcon("print") || /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Print2.default, { fontSize: "small" })
612
+ }
613
+ ),
614
+ !toolbar.isHidden("fullscreen") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
615
+ _material.IconButton,
616
+ {
617
+ size: "small",
618
+ onClick: toolbar.getHandler(
619
+ "fullscreen",
620
+ handleToggleFullScreen
621
+ ),
622
+ disabled: toolbar.isDisabled("fullscreen"),
623
+ title: toolbar.getLabel("fullscreen") || "Fullscreen",
624
+ "aria-label": "Toggle fullscreen",
625
+ children: toolbar.getIcon("fullscreen") || /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Fullscreen2.default, { fontSize: "small" })
626
+ }
627
+ ),
628
+ !toolbar.isHidden("metadata") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
629
+ _material.IconButton,
630
+ {
631
+ size: "small",
632
+ onClick: toolbar.getHandler("metadata", onMetadataClick),
633
+ disabled: toolbar.isDisabled("metadata"),
634
+ title: toolbar.getLabel("metadata") || "Document Metadata",
635
+ "aria-label": "View document metadata",
636
+ children: toolbar.getIcon("metadata") || /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Description2.default, { fontSize: "small" })
637
+ }
638
+ ),
639
+ !toolbar.isHidden("properties") && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
640
+ _material.IconButton,
641
+ {
642
+ size: "small",
643
+ onClick: toolbar.getHandler("properties", onPropertiesClick),
644
+ disabled: toolbar.isDisabled("properties"),
645
+ title: toolbar.getLabel("properties") || "Document Properties",
646
+ "aria-label": "View document properties",
647
+ children: toolbar.getIcon("properties") || /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _Info2.default, { fontSize: "small" })
648
+ }
649
+ )
650
+ ]
651
+ }
652
+ ) }),
653
+ (isLoading || internalLoading) && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.LinearProgress, { sx: { mx: 3, mb: 1 } }),
654
+ error && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Typography, { color: "error", variant: "body2", sx: { px: 3, pb: 1 }, children: error }),
655
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _material.Divider, {}),
656
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
657
+ _material.CardContent,
658
+ {
659
+ sx: {
660
+ flexGrow: 1,
661
+ flexShrink: 1,
662
+ minHeight: 0,
663
+ p: 0,
664
+ overflow: "hidden",
665
+ backgroundColor: "#f6f8fa",
666
+ position: "relative"
667
+ },
668
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
669
+ _material.Box,
670
+ {
671
+ ref: viewportRef,
672
+ sx: {
673
+ position: "absolute",
674
+ top: 0,
675
+ left: 0,
676
+ right: 0,
677
+ bottom: 0,
678
+ overflow: "auto"
679
+ },
680
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
681
+ _material.Box,
682
+ {
683
+ sx: {
684
+ minWidth: "100%",
685
+ minHeight: "100%",
686
+ display: "flex",
687
+ alignItems: "center",
688
+ justifyContent: "center"
689
+ },
690
+ children: renderImage()
691
+ }
692
+ )
693
+ }
694
+ )
695
+ }
696
+ )
697
+ ]
698
+ }
699
+ )
700
+ }
701
+ );
702
+ };
703
+ var TIFFViewer = (props) => {
704
+ const sourceDescription = _react.useMemo.call(void 0,
705
+ () => resolveDocumentName(props.file, props.fileName, props.url),
706
+ [props.file, props.fileName, props.url]
707
+ );
708
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TIFFViewerContent, { ...props, sourceDescription });
709
+ };
710
+
711
+
712
+
713
+ exports.TIFFViewer = TIFFViewer;
714
+ //# sourceMappingURL=chunk-YU535XRJ.js.map