import { _ as __assign, a as __awaiter, b as __generator } from '../../chunks/bundle-CMZSpHeh.js';
import React__default from 'react';
import { F as FileViewerView } from '../../chunks/bundle-Cg3QkAp8.js';
import { useGroupChannelContext } from '../context.js';
import { useSendbirdStateContext } from '../../useSendbirdStateContext.js';
import 'react-dom';
import '../../chunks/bundle-BlN1UcdM.js';
import '../../ui/ImageRenderer.js';
import '../../chunks/bundle-DRN8Ufbc.js';
import '../../chunks/bundle-Bzds2Ucm.js';
import '../../ui/Icon.js';
import '../../chunks/bundle-CIcpyYvw.js';
import '../../chunks/bundle-XCQLW6rR.js';
import '../../chunks/bundle-BdOcjdmg.js';
import '@sendbird/chat/groupChannel';
import '../../utils/message/getOutgoingMessageState.js';
import '../../chunks/bundle-DI-PfZ0q.js';
import '../../hooks/useModal.js';
import '../../chunks/bundle-DYAiU0qn.js';
import '../../chunks/bundle-Aca68v_Z.js';
import '../../chunks/bundle-eddZycld.js';
import '../../chunks/bundle-CAdHlM56.js';
import '../../ui/IconButton.js';
import '../../ui/Button.js';
import '@sendbird/chat/message';
import '@sendbird/uikit-tools';
import '../../chunks/bundle-BH6pGtIL.js';
import '../../chunks/bundle-DoMztHB5.js';
import '../../chunks/bundle-BOnWRs_F.js';
import '../../chunks/bundle-DseK7HAq.js';
import '../../chunks/bundle-C6iM_9qC.js';
import '../../chunks/bundle-Csv255vx.js';
import '../../chunks/bundle-9-bZdwX6.js';
import '../../chunks/bundle-DehMr9Ib.js';
import '../../chunks/bundle-5Yi0S6u0.js';
import '../../chunks/bundle-DQ2TqmPV.js';
import '../../chunks/bundle-DWLEk8wY.js';
import '../../withSendbird.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
