'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _tslib = require('../../chunks/bundle-HGbi-rCv.js');
var React = require('react');
var FileViewerView = require('../../chunks/bundle-X03vJTEw.js');
var GroupChannel_context = require('../context.js');
var useSendbirdStateContext = require('../../useSendbirdStateContext.js');
require('react-dom');
require('../../chunks/bundle-DxSB9NRz.js');
require('../../ui/ImageRenderer.js');
require('../../chunks/bundle-BoLhr7Ko.js');
require('../../chunks/bundle-C93-onMF.js');
require('../../ui/Icon.js');
require('../../chunks/bundle-5_kPn4wU.js');
require('../../chunks/bundle-gtkPlUrw.js');
require('../../chunks/bundle-wl1uuzU7.js');
require('@sendbird/chat/groupChannel');
require('../../utils/message/getOutgoingMessageState.js');
require('../../chunks/bundle-CZfcXYaX.js');
require('../../chunks/bundle-oeWNUdCB.js');
require('../../chunks/bundle-BWGOXLHb.js');
require('../../chunks/bundle-BwQ4BJif.js');
require('../../ui/IconButton.js');
require('../../ui/Button.js');
require('@sendbird/uikit-tools');
require('../../withSendbird.js');
require('css-vars-ponyfill');
require('@sendbird/chat');
require('../../chunks/bundle-1XtsxT8L.js');
require('@sendbird/chat/openChannel');
require('../../chunks/bundle-L3FEqZsK.js');
require('../../chunks/bundle-DfcEln0Z.js');
require('../../chunks/bundle-BTU876jx.js');
require('@sendbird/chat/message');
require('../../chunks/bundle-CAUMYdVU.js');
require('../../chunks/bundle-BaQc9oOW.js');
require('../../chunks/bundle-BjgfoBVC.js');
require('../../chunks/bundle-DQy218lT.js');
require('../../chunks/bundle-C1XVsHlE.js');
require('../../chunks/bundle-CE6bFQmu.js');
require('../../chunks/bundle-Com-Z-XI.js');
require('../../chunks/bundle-BOkZUm8a.js');
require('../../chunks/bundle-Dehhi1FZ.js');
require('../../chunks/bundle-Dww6fCVQ.js');

var FileViewer = function (props) {
    var _a = GroupChannel_context.useGroupChannelContext(), deleteMessage = _a.deleteMessage, onBeforeDownloadFileMessage = _a.onBeforeDownloadFileMessage;
    var config = useSendbirdStateContext.useSendbirdStateContext().config;
    var logger = config.logger;
    return (React.createElement(FileViewerView.FileViewerView, _tslib.__assign({}, props, { deleteMessage: deleteMessage, onDownloadClick: function (e) { return _tslib.__awaiter(void 0, void 0, void 0, function () {
            var allowDownload, err_1;
            var _a, _b;
            return _tslib.__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*/];
                }
            });
        }); } })));
};

exports.FileViewer = FileViewer;
exports.default = FileViewer;
//# sourceMappingURL=FileViewer.js.map
