'use strict';

var React = require('react');
var LocalizationContext = require('../chunks/bundle-DDNdw3A9.js');
var UserProfileContext = require('../chunks/bundle-DeyX1dvY.js');
var sendbirdSelectors = require('../sendbirdSelectors.js');
var ui_Avatar = require('../chunks/bundle-CLL-nCFU.js');
var ui_Label = require('../chunks/bundle-B0UICprZ.js');
var ui_Button = require('./Button.js');
var useSendbird = require('../chunks/bundle-LI9JjqG2.js');
require('../chunks/bundle-CxoFSSXv.js');
require('../chunks/bundle-EhtiN7UV.js');
require('../chunks/bundle-BV7y6VDn.js');
require('../chunks/bundle-BPWJgESF.js');
require('../chunks/bundle-DQNu-S6D.js');
require('./ImageRenderer.js');
require('../chunks/bundle-C8MACRPO.js');
require('./Icon.js');
require('../chunks/bundle-AAO7jUU2.js');
require('../chunks/bundle-yU9Mr2pS.js');
require('@sendbird/chat');
require('@sendbird/chat/groupChannel');
require('@sendbird/chat/openChannel');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefaultCompat(React);

function UserProfile(_a) {
    var _b, _c;
    var user = _a.user, currentUserId = _a.currentUserId, _d = _a.disableMessaging, disableMessaging = _d === void 0 ? false : _d, onSuccess = _a.onSuccess;
    var state = useSendbird.useSendbird().state;
    var createChannel = sendbirdSelectors.getCreateGroupChannel(state);
    var logger = (_b = state === null || state === void 0 ? void 0 : state.config) === null || _b === void 0 ? void 0 : _b.logger;
    var stringSet = React.useContext(LocalizationContext.LocalizationContext).stringSet;
    var currentUserId_ = currentUserId || ((_c = state === null || state === void 0 ? void 0 : state.config) === null || _c === void 0 ? void 0 : _c.userId);
    var onStartDirectMessage = UserProfileContext.useUserProfileContext().onStartDirectMessage;
    return (React__default.default.createElement("div", { className: "sendbird__user-profile" },
        React__default.default.createElement("section", { className: "sendbird__user-profile-avatar" },
            React__default.default.createElement(ui_Avatar.Avatar, { height: "80px", width: "80px", src: user === null || user === void 0 ? void 0 : user.profileUrl })),
        React__default.default.createElement("section", { className: "sendbird__user-profile-name" },
            React__default.default.createElement(ui_Label.Label, { type: ui_Label.LabelTypography.H_2, color: ui_Label.LabelColors.ONBACKGROUND_1 }, (user === null || user === void 0 ? void 0 : user.nickname) || stringSet.NO_NAME)),
        ((user === null || user === void 0 ? void 0 : user.userId) !== currentUserId_) && !disableMessaging && (React__default.default.createElement("section", { className: "sendbird__user-profile-message" },
            React__default.default.createElement(ui_Button.default, { type: ui_Button.ButtonTypes.SECONDARY, onClick: function () {
                    // Create 1:1 channel
                    var params = {
                        isDistinct: false,
                        invitedUserIds: (user === null || user === void 0 ? void 0 : user.userId) ? [user === null || user === void 0 ? void 0 : user.userId] : [],
                        operatorUserIds: [currentUserId_],
                    };
                    onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
                    createChannel(params)
                        .then(function (groupChannel) {
                        logger.info('UserProfile, channel create', groupChannel);
                        onStartDirectMessage === null || onStartDirectMessage === void 0 ? void 0 : onStartDirectMessage(groupChannel);
                    });
                } }, stringSet.USER_PROFILE__MESSAGE))),
        React__default.default.createElement("div", { className: "sendbird__user-profile-separator" }),
        React__default.default.createElement("section", { className: "sendbird__user-profile-userId" },
            React__default.default.createElement(ui_Label.Label, { className: "sendbird__user-profile-userId--label", type: ui_Label.LabelTypography.CAPTION_2, color: ui_Label.LabelColors.ONBACKGROUND_2 }, stringSet.USER_PROFILE__USER_ID),
            React__default.default.createElement(ui_Label.Label, { className: "sendbird__user-profile-userId--value", type: ui_Label.LabelTypography.BODY_1, color: ui_Label.LabelColors.ONBACKGROUND_1 }, user === null || user === void 0 ? void 0 : user.userId))));
}

module.exports = UserProfile;
//# sourceMappingURL=UserProfile.js.map
