"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importStar(require("react"));
const components_1 = require("../themes/components");
const MediaRoomService_1 = require("../services/MediaRoomService");
const react_redux_1 = require("react-redux");
const roomSlice_1 = require("../store/roomSlice");
const styled_components_1 = require("styled-components");
const react_native_user_avatar_1 = __importDefault(require("react-native-user-avatar"));
function HostWaitingListModal({ isOpen, peers }) {
    const { mediaRoom } = react_1.useContext(MediaRoomService_1.MediaRoomContext);
    const dispatch = react_redux_1.useDispatch();
    const acceptRequest = (peerId) => {
        dispatch(roomSlice_1.removeWaitListPeer({ id: peerId }));
        mediaRoom.acceptWaitingRequest(peerId);
    };
    const { colors } = react_1.useContext(styled_components_1.ThemeContext);
    const rejectRequest = (peerId) => {
        dispatch(roomSlice_1.removeWaitListPeer({ id: peerId }));
        mediaRoom.rejectWaitingRequest(peerId);
    };
    return (react_1.default.createElement(components_1.Modal, { isVisible: isOpen, backdropOpacity: 0.8, backdropColor: colors.secondary[800] },
        react_1.default.createElement(components_1.Text, { fontWeight: "bold" }, "Waiting Requests"),
        react_1.default.createElement(components_1.Stack, { spacing: 6, height: "80" }, peers.map((peer) => (react_1.default.createElement(components_1.Flex, { direction: "row", alignItems: "center" },
            react_1.default.createElement(react_native_user_avatar_1.default, { name: peer.name.replace(/[^\w\s]/gi, ''), bgColor: colors.primary[700] }),
            react_1.default.createElement(components_1.Flex, { marginLeft: 3, flexGrow: 1, alignItems: "center", paddingY: 2, borderBottom: `1px solid ${colors.secondary[800]}` },
                react_1.default.createElement(components_1.Text, { color: colors.textPrimary[200], fontSize: "lg" }, peer.name),
                react_1.default.createElement(components_1.Flex, { marginLeft: "auto" },
                    react_1.default.createElement(components_1.Button, { _hover: { borderColor: colors.danger[500] }, onClick: () => rejectRequest(peer.id) },
                        react_1.default.createElement(components_1.Box, { bg: "secondary.700", p: 4 },
                            react_1.default.createElement(components_1.Icon, { boxSize: "16", name: "close" }))),
                    react_1.default.createElement(components_1.Button, { _hover: { borderColor: colors.danger[500] }, onClick: () => rejectRequest(peer.id) },
                        react_1.default.createElement(components_1.Box, { bg: "primary.500", p: 4 },
                            react_1.default.createElement(components_1.Icon, { boxSize: "16", name: "check" })))))))))));
}
exports.default = HostWaitingListModal;
//# sourceMappingURL=HostWaitlistManagerModal.js.map