import { _ as __assign, a as __awaiter, b as __generator } from '../../chunks/bundle-CyKcXwxv.js';
import React__default from 'react';
import { F as FileViewerView } from '../../chunks/bundle-DMP0TlRl.js';
import { useGroupChannelContext } from '../context.js';
import { useSendbirdStateContext } from '../../useSendbirdStateContext.js';
import 'react-dom';
import '../../chunks/bundle-BUD_vgZ5.js';
import '../../ui/ImageRenderer.js';
import '../../chunks/bundle-B43BrwWe.js';
import '../../chunks/bundle-Dmj05jBl.js';
import '../../ui/Icon.js';
import '../../chunks/bundle-bz4PqMYo.js';
import '../../chunks/bundle-xzHlqm91.js';
import '../../chunks/bundle-DCvGHvPz.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-BFKFmP-d.js';
import '../../chunks/bundle-DAYMi6vw.js';
import '../../chunks/bundle-vddg8rUR.js';
import '../../chunks/bundle-DIM08oup.js';
import '../../chunks/bundle-C_RTy-wB.js';
import '../../chunks/bundle-yFfkfO0O.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-BUQ58hWb.js';
import '@sendbird/chat/openChannel';
import '../../chunks/bundle-CKwMZR9c.js';
import '../../chunks/bundle-Bien0gJP.js';
import '../../ui/SortByRow.js';
import '@sendbird/chat/message';
import '../../chunks/bundle-DV19ISeX.js';
import '../../chunks/bundle-GyANJ9jq.js';
import '../../chunks/bundle-By4qJA7N.js';
import '../../chunks/bundle-zh5Jl1yd.js';
import '../../chunks/bundle-N7XRO_Ma.js';
import '../../chunks/bundle-BH8KNCSz.js';
import '../../chunks/bundle-BCRvYX9G.js';
import '../../chunks/bundle-DmBEox5Y.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*/];
                        _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
