import { _ as __assign, a as __awaiter, b as __generator } from '../../chunks/bundle-7oF7KbGv.js';
import React__default from 'react';
import { F as FileViewerView } from '../../chunks/bundle-BAvMd_j0.js';
import { useGroupChannelContext } from '../context.js';
import { useSendbirdStateContext } from '../../useSendbirdStateContext.js';
import 'react-dom';
import '../../chunks/bundle-CNJMLyGJ.js';
import '../../ui/ImageRenderer.js';
import '../../chunks/bundle-ByvmbZD0.js';
import '../../chunks/bundle-CT8ZXUi2.js';
import '../../ui/Icon.js';
import '../../chunks/bundle-LYAWKk4n.js';
import '../../chunks/bundle-C8im5l9B.js';
import '../../chunks/bundle-BWCGFXhj.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-C4Z-NWqF.js';
import '../../chunks/bundle-Bx5vhTbU.js';
import '../../chunks/bundle-C1ds4cil.js';
import '../../chunks/bundle-Diqj6For.js';
import '../../ui/IconButton.js';
import '../../ui/Button.js';
import '@sendbird/uikit-tools';
import '../../withSendbird.js';
import 'css-vars-ponyfill';
import '@sendbird/chat';
import '../../chunks/bundle-BJ46V6XQ.js';
import '@sendbird/chat/openChannel';
import '../../chunks/bundle-CIwVkd-E.js';
import '../../chunks/bundle-CD9AzC6s.js';
import '../../chunks/bundle-BbWD2VuS.js';
import '@sendbird/chat/message';
import '../../chunks/bundle-B7barEsR.js';
import '../../chunks/bundle-oCSRGy9i.js';
import '../../chunks/bundle-BtY8jyVv.js';
import '../../chunks/bundle-BvG71y_P.js';
import '../../chunks/bundle-DaoHZIZy.js';
import '../../chunks/bundle-DDkUg3Os.js';
import '../../chunks/bundle-uBJzoaNT.js';
import '../../chunks/bundle-2uJIsyo2.js';
import '../../chunks/bundle-BWuyd0AD.js';
import '../../chunks/bundle-Jir4hfa9.js';

var FileViewer = function (props) {
    var _a = useGroupChannelContext(), deleteMessage = _a.deleteMessage, onBeforeDownloadFileMessage = _a.onBeforeDownloadFileMessage;
    var config = useSendbirdStateContext().config;
    var logger = config.logger;
    return (React__default.createElement(FileViewerView, __assign({}, props, { deleteMessage: deleteMessage, onDownloadClick: function (e) { return __awaiter(void 0, void 0, void 0, function () {
            var allowDownload, err_1;
            var _a, _b;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        if (!onBeforeDownloadFileMessage) {
                            return [2 /*return*/, null];
                        }
                        _c.label = 1;
                    case 1:
                        _c.trys.push([1, 3, , 4]);
                        return [4 /*yield*/, onBeforeDownloadFileMessage({ message: props.message })];
                    case 2:
                        allowDownload = _c.sent();
                        if (!allowDownload) {
                            e.preventDefault();
                            (_a = logger.info) === null || _a === void 0 ? void 0 : _a.call(logger, 'FileViewer: Not allowed to download.');
                        }
                        return [3 /*break*/, 4];
                    case 3:
                        err_1 = _c.sent();
                        (_b = logger.error) === null || _b === void 0 ? void 0 : _b.call(logger, 'FileViewer: Error occurred while determining download continuation:', err_1);
                        return [3 /*break*/, 4];
                    case 4: return [2 /*return*/];
                }
            });
        }); } })));
};

export { FileViewer, FileViewer as default };
//# sourceMappingURL=FileViewer.js.map
