'use strict';

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

const index$1 = require('./index-2e5758b6.js');
const uiStore = require('./ui-store-583d205a.js');
const index$2 = require('./index-6f8c1928.js');
const index = require('./index-3f8e5441.js');

const rtkParticipantsStageListCss = ":host{line-height:initial;font-family:var(--rtk-font-family, sans-serif);font-feature-settings:normal;font-variation-settings:normal}p{margin:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}:host{display:flex;width:100%;flex-direction:column;font-size:14px}.participants-container{margin-bottom:var(--rtk-space-4, 16px);height:100%;width:100%}h3,.heading-count{margin:var(--rtk-space-0, 0px);display:flex;align-items:center;justify-content:center;padding:var(--rtk-space-0, 0px);font-size:16px;font-weight:400;color:rgb(var(--rtk-colors-text-900, 255 255 255 / 0.88));text-align:center}.heading-count{font-size:14px}.participants{margin-top:var(--rtk-space-2, 8px);margin-bottom:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}.empty-stage-list{margin-top:var(--rtk-space-4, 16px);margin-bottom:var(--rtk-space-4, 16px);text-align:center;font-size:12px;color:rgb(var(--rtk-colors-text-700, 255 255 255 / 0.64))}rtk-participant{width:100%}";
const RtkParticipantsStageListStyle0 = rtkParticipantsStageListCss;

var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        r = Reflect.decorate(decorators, target, key, desc);
    else
        for (var i = decorators.length - 1; i >= 0; i--)
            if (d = decorators[i])
                r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const RtkParticipants = class {
    constructor(hostRef) {
        index$1.registerInstance(this, hostRef);
        /** Config */
        this.config = uiStore.createDefaultConfig();
        /** Hide Stage Participants Count Header */
        this.hideHeader = false;
        /** Icon pack */
        this.iconPack = uiStore.defaultIconPack;
        /** View mode for participants list */
        this.view = 'sidebar';
        /** Language */
        this.t = uiStore.useLanguage();
        /** Search */
        this.search = '';
        this.participants = [];
        this.createParticipantNode = (participant) => {
            const defaults = {
                meeting: this.meeting,
                view: this.view,
                t: this.t,
                config: this.config,
                states: this.states,
                size: this.size,
                iconPack: this.iconPack,
            };
            return (index$1.h("div", null, index$1.h(index$2.Render, { element: "rtk-participant", defaults: defaults, props: { role: 'listitem', participant, key: participant.id }, childProps: Object.assign(Object.assign({}, defaults), { participant, size: this.size }), deepProps: true })));
        };
        this.updateStageList = () => {
            this.getParticipants(this.search);
        };
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
        this.searchChanged(this.search);
    }
    disconnectedCallback() {
        if (!this.meeting)
            return;
        const { participants, stage } = this.meeting;
        this.participantJoinedListener &&
            this.meeting.participants.joined.removeListener('participantJoined', this.participantJoinedListener);
        this.participantLeftListener &&
            this.meeting.participants.joined.removeListener('participantLeft', this.participantLeftListener);
        participants.joined.removeListener('stageStatusUpdate', this.updateStageList);
        stage === null || stage === void 0 ? void 0 : stage.removeListener('stageStatusUpdate', this.updateStageList);
    }
    meetingChanged(meeting) {
        if (!meeting)
            return;
        this.participantJoinedListener = (participant) => {
            if (participant.stageStatus !== 'ON_STAGE')
                return;
            // Do not append if participant name or id does not match search query
            const lowerCaseSearch = this.search.toLowerCase();
            if (!participant.name.toLowerCase().includes(lowerCaseSearch) ||
                !participant.id.toLowerCase().includes(lowerCaseSearch))
                return;
            this.participants = [
                ...this.participants.filter((p) => p.id !== participant.id),
                participant,
            ];
        };
        this.participantLeftListener = (participant) => {
            this.participants = this.participants.filter((p) => p.id !== participant.id);
        };
        meeting.participants.joined.addListener('participantJoined', this.participantJoinedListener);
        meeting.participants.joined.addListener('participantLeft', this.participantLeftListener);
        this.updateStageList();
        meeting === null || meeting === void 0 ? void 0 : meeting.participants.joined.on('stageStatusUpdate', this.updateStageList);
        meeting === null || meeting === void 0 ? void 0 : meeting.stage.on('stageStatusUpdate', this.updateStageList);
    }
    searchChanged(search) {
        this.getParticipants(search);
    }
    getParticipants(search = this.search) {
        let list = this.meeting.stage.status === 'ON_STAGE' ? [this.meeting.self] : [];
        list = [
            ...list,
            ...this.meeting.participants.joined.toArray().filter((p) => p.stageStatus === 'ON_STAGE'),
        ];
        if (search === '')
            this.participants = list;
        else {
            this.participants = list.filter((p) => { var _a; return ((_a = p.name) !== null && _a !== void 0 ? _a : p.id).toLowerCase().includes(search.toLowerCase()); });
        }
    }
    render() {
        return (index$1.h(index$1.Host, { key: '1beca8f05d4f78a269317b333a00946ac642af00' }, index$1.h("div", { key: '7d54d4187eb8478ddfdc632b42af4875afd1a158', class: "participants-container" }, !this.hideHeader && (index$1.h("div", { key: 'ecaa9721738cc020fe4aa1f966d2450f0f9d8e01', class: "heading-count", part: "heading-count" }, this.t('participants'), " (", this.participants.length, ")")), index$1.h("rtk-virtualized-participant-list", { key: '8d12273242c1f9081e199fd189060addf28c45a6', items: this.participants, renderItem: this.createParticipantNode, part: "participants", class: "participants", emptyListElement: index$1.h("div", { class: "empty-stage-list" }, this.search.length > 0 ? this.t('search.could_not_find') : this.t('search.empty')) }))));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"],
        "search": ["searchChanged"]
    }; }
};
__decorate$3([
    index.SyncWithStore()
], RtkParticipants.prototype, "meeting", void 0);
__decorate$3([
    index.SyncWithStore()
], RtkParticipants.prototype, "states", void 0);
__decorate$3([
    index.SyncWithStore()
], RtkParticipants.prototype, "config", void 0);
__decorate$3([
    index.SyncWithStore()
], RtkParticipants.prototype, "iconPack", void 0);
__decorate$3([
    index.SyncWithStore()
], RtkParticipants.prototype, "t", void 0);
RtkParticipants.style = RtkParticipantsStageListStyle0;

const rtkParticipantsStageQueueCss = ":host{line-height:initial;font-family:var(--rtk-font-family, sans-serif);font-feature-settings:normal;font-variation-settings:normal}p{margin:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}:host{margin-top:var(--rtk-space-2, 8px);display:flex;width:100%;flex-direction:column;font-size:14px}.stage-requested-participants{margin-bottom:var(--rtk-space-8, 32px)}.stage-requested-participants .bulk-actions{display:flex;gap:var(--rtk-space-2, 8px)}.stage-requested-participants .bulk-actions .accept-all-button{--tw-text-opacity:1;color:rgba(var(--rtk-colors-success, 98 165 4) / var(--tw-text-opacity))}.stage-requested-participants .bulk-actions rtk-button{flex:1 1 0%}h3,.heading-count{margin:var(--rtk-space-0, 0px);display:flex;align-items:center;justify-content:center;padding:var(--rtk-space-0, 0px);font-size:16px;font-weight:400;color:rgb(var(--rtk-colors-text-900, 255 255 255 / 0.88));text-align:center}.heading-count{font-size:14px}.participants{margin-top:var(--rtk-space-2, 8px);padding:var(--rtk-space-0, 0px)}.waiting-participant{margin-top:var(--rtk-space-2, 8px);margin-bottom:var(--rtk-space-2, 8px);display:flex;align-items:center}.waiting-participant .participant-details{margin-right:auto;display:flex;align-items:center}.waiting-participant .participant-details rtk-avatar{margin-right:var(--rtk-space-2, 8px);height:var(--rtk-space-8, 32px);width:var(--rtk-space-8, 32px);flex-shrink:0;font-size:14px}.waiting-participant .participant-details .name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:rgb(var(--rtk-colors-text-900, 255 255 255 / 0.88))}@media (min-width: 1080px){.waiting-participant .participant-details .name{max-width:var(--rtk-space-40, 160px)}}.waiting-participant .waitlist-controls{display:flex}.waiting-participant .waitlist-controls rtk-button{margin-left:var(--rtk-space-2, 8px);cursor:pointer;border-radius:var(--rtk-border-radius-sm, 4px)}.waiting-participant .waitlist-controls rtk-icon.accept{--tw-text-opacity:1;color:rgba(var(--rtk-colors-success, 98 165 4) / var(--tw-text-opacity))}.waiting-participant .waitlist-controls rtk-icon.deny{--tw-text-opacity:1;color:rgba(var(--rtk-colors-danger, 255 45 45) / var(--tw-text-opacity))}";
const RtkParticipantsStageQueueStyle0 = rtkParticipantsStageQueueCss;

var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        r = Reflect.decorate(decorators, target, key, desc);
    else
        for (var i = decorators.length - 1; i >= 0; i--)
            if (d = decorators[i])
                r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const RtkParticipantsStaged = class {
    constructor(hostRef) {
        index$1.registerInstance(this, hostRef);
        /** Config */
        this.config = uiStore.createDefaultConfig();
        /** Icon pack */
        this.iconPack = uiStore.defaultIconPack;
        /** View mode for participants list */
        this.view = 'sidebar';
        /** Language */
        this.t = uiStore.useLanguage();
        this.stageRequestedParticipants = [];
        this.updateStageRequestedParticipants = () => {
            this.stageRequestedParticipants = this.meeting.participants.joined
                .toArray()
                .filter((p) => p.stageStatus === 'REQUESTED_TO_JOIN_STAGE');
        };
        this.acceptStageRequest = async (p) => {
            const { userId } = p;
            await this.meeting.stage.grantAccess([userId]);
        };
        this.rejectStageRequest = async (p) => {
            const { userId } = p;
            await this.meeting.stage.denyAccess([userId]);
        };
        this.acceptAllStageRequest = async () => {
            await this.meeting.stage.grantAccess(this.stageRequestedParticipants.map((p) => p.userId));
        };
        this.denyAllStageRequest = async () => {
            var _a;
            await ((_a = this.meeting.stage) === null || _a === void 0 ? void 0 : _a.denyAccess(this.stageRequestedParticipants.map((p) => p.userId)));
        };
        this.shouldShowStageRequests = () => {
            return (this.meeting.self.permissions.stageEnabled &&
                this.meeting.self.permissions.acceptStageRequests &&
                this.stageRequestedParticipants.length > 0);
        };
        this.updateRequestList = async (stageRequests) => {
            var _a, _b, _c, _d, _e, _f, _g;
            if (!this.meeting.self.permissions.acceptStageRequests ||
                !this.meeting.self.permissions.stageEnabled) {
                this.stageRequestedParticipants = [];
                return;
            }
            if (this.meeting.meta.viewType === 'LIVESTREAM' ||
                ((_c = (_b = (_a = this.meeting) === null || _a === void 0 ? void 0 : _a.self) === null || _b === void 0 ? void 0 : _b.permissions) === null || _c === void 0 ? void 0 : _c.mediaRoomType) === 'HIVE') {
                if (!stageRequests) {
                    stageRequests = (_f = (_e = (await ((_d = this.meeting.stage) === null || _d === void 0 ? void 0 : _d.getAccessRequests()))) === null || _e === void 0 ? void 0 : _e.stageRequests) !== null && _f !== void 0 ? _f : [];
                }
                /**
                 * NOTE(ishita1805): Temporarily mapping `displayName` to `name` till socket service sends the correct key.
                 */
                this.stageRequestedParticipants = stageRequests.map((p) => {
                    return Object.assign(Object.assign({}, p), { name: p.displayName });
                });
            }
            else {
                this.stageRequestedParticipants = (_g = [
                    this.meeting.self,
                    ...this.meeting.participants.joined.toArray(),
                ]) === null || _g === void 0 ? void 0 : _g.filter((p) => p.stageStatus === 'REQUESTED_TO_JOIN_STAGE');
            }
        };
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
    }
    disconnectedCallback() {
        var _a;
        const { stage } = this.meeting;
        stage === null || stage === void 0 ? void 0 : stage.removeListener('stageAccessRequestUpdate', this.updateRequestList);
        (_a = this.meeting.participants.joined) === null || _a === void 0 ? void 0 : _a.removeListener('stageStatusUpdate', this.updateStageRequestedParticipants);
    }
    meetingChanged(meeting) {
        var _a;
        if (!meeting)
            return;
        this.updateRequestList();
        meeting.participants.joined.on('stageStatusUpdate', this.updateStageRequestedParticipants);
        (_a = meeting.stage) === null || _a === void 0 ? void 0 : _a.on('stageAccessRequestUpdate', this.updateRequestList);
    }
    render() {
        if (!this.meeting)
            return null;
        if (this.view !== 'sidebar' || !this.shouldShowStageRequests())
            return;
        return (index$1.h("div", { class: "stage-requested-participants" }, index$1.h("div", { class: "heading-count", part: "staged-heading-count" }, this.t('stage_request.header_title'), " (", this.stageRequestedParticipants.length, ")"), index$1.h("ul", { class: "participants", part: "staged-participants" }, this.stageRequestedParticipants.map((participant) => (index$1.h("li", { class: "waiting-participant", key: participant.id }, index$1.h("div", { class: "participant-details" }, index$1.h("rtk-avatar", { participant: participant, size: "sm", iconPack: this.iconPack, t: this.t }), index$1.h("p", { class: "name", title: participant.name }, participant.name)), index$1.h("div", { class: "waitlist-controls" }, index$1.h("rtk-tooltip", { label: this.t('stage_request.deny_request'), variant: "secondary" }, index$1.h("rtk-button", { variant: "secondary", kind: "icon", onClick: () => this.rejectStageRequest(participant) }, index$1.h("rtk-icon", { class: "deny", icon: this.iconPack.dismiss }))), index$1.h("rtk-tooltip", { label: this.t('stage_request.accept_request'), variant: "secondary" }, index$1.h("rtk-button", { variant: "secondary", kind: "icon", onClick: () => this.acceptStageRequest(participant) }, index$1.h("rtk-icon", { class: "accept", icon: this.iconPack.checkmark })))))))), index$1.h("div", { class: "bulk-actions" }, index$1.h("rtk-button", { class: "accept-all-button", variant: "secondary", onClick: this.acceptAllStageRequest }, this.t('stage_request.accept_all')), index$1.h("rtk-button", { class: "deny-all-button", variant: "danger", onClick: this.denyAllStageRequest }, this.t('stage_request.deny_all')))));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"]
    }; }
};
__decorate$2([
    index.SyncWithStore()
], RtkParticipantsStaged.prototype, "meeting", void 0);
__decorate$2([
    index.SyncWithStore()
], RtkParticipantsStaged.prototype, "config", void 0);
__decorate$2([
    index.SyncWithStore()
], RtkParticipantsStaged.prototype, "iconPack", void 0);
__decorate$2([
    index.SyncWithStore()
], RtkParticipantsStaged.prototype, "t", void 0);
RtkParticipantsStaged.style = RtkParticipantsStageQueueStyle0;

const rtkParticipantsViewerListCss = ":host{line-height:initial;font-family:var(--rtk-font-family, sans-serif);font-feature-settings:normal;font-variation-settings:normal}p{margin:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}:host{display:flex;height:100%;width:100%;flex-direction:column;font-size:14px}.list{margin-bottom:var(--rtk-space-4, 16px);display:flex;height:100%;flex-direction:column}h3,.heading-count{margin:var(--rtk-space-0, 0px);align-items:center;justify-content:center;padding:var(--rtk-space-0, 0px);font-size:16px;font-weight:400;color:rgb(var(--rtk-colors-text-900, 255 255 255 / 0.88));text-align:center}.heading-count{font-size:14px}.participants{margin-top:var(--rtk-space-2, 8px);margin-bottom:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}.empty-viewers-list{margin-top:var(--rtk-space-2, 8px);margin-bottom:var(--rtk-space-2, 8px);text-align:center;font-size:12px;color:rgb(var(--rtk-colors-text-700, 255 255 255 / 0.64))}";
const RtkParticipantsViewerListStyle0 = rtkParticipantsViewerListCss;

var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        r = Reflect.decorate(decorators, target, key, desc);
    else
        for (var i = decorators.length - 1; i >= 0; i--)
            if (d = decorators[i])
                r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const RtkParticipantsViewers = class {
    constructor(hostRef) {
        index$1.registerInstance(this, hostRef);
        this.updateStageViewers = () => {
            this.getViewers(this.search);
        };
        /** Config */
        this.config = uiStore.createDefaultConfig();
        /** Hide Viewer Count Header */
        this.hideHeader = false;
        /** Icon pack */
        this.iconPack = uiStore.defaultIconPack;
        /** View mode for participants list */
        this.view = 'sidebar';
        /** Search */
        this.search = '';
        /** Language */
        this.t = uiStore.useLanguage();
        this.stageViewers = [];
        this.createParticipantNode = (participant) => {
            return (index$1.h("rtk-participant", { role: "listitem", key: participant.id, meeting: this.meeting, participant: participant, view: this.view, iconPack: this.iconPack, config: this.config, t: this.t }));
        };
        // TODO: (ishita1805) Remove viewtype check when we start supporting viewers in livestream.
        this.shouldShowViewers = () => {
            var _a, _b, _c;
            return (_c = (_b = (_a = this.meeting) === null || _a === void 0 ? void 0 : _a.self) === null || _b === void 0 ? void 0 : _b.permissions) === null || _c === void 0 ? void 0 : _c.stageEnabled;
        };
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
        this.searchChanged(this.search);
    }
    meetingChanged(meeting) {
        if (!meeting)
            return;
        this.participantJoinedListener = (participant) => {
            if (participant.stageStatus === 'ON_STAGE')
                return;
            // Do not append if participant name or id does not match search query
            const lowerCaseSearch = this.search.toLowerCase();
            if (lowerCaseSearch.length > 0 && !participant.name.toLowerCase().includes(lowerCaseSearch))
                return;
            this.stageViewers = [
                ...this.stageViewers.filter((p) => p.id !== participant.id),
                participant,
            ];
        };
        this.participantLeftListener = (participant) => {
            this.stageViewers = this.stageViewers.filter((p) => p.id !== participant.id);
        };
        meeting.participants.joined.addListener('participantJoined', this.participantJoinedListener);
        meeting.participants.joined.addListener('participantLeft', this.participantLeftListener);
        meeting.participants.joined.on('stageStatusUpdate', this.updateStageViewers);
        meeting.stage.on('stageStatusUpdate', this.updateStageViewers);
    }
    searchChanged(search) {
        this.getViewers(search);
    }
    disconnectedCallback() {
        const { participants, stage } = this.meeting;
        this.participantJoinedListener &&
            this.meeting.participants.joined.removeListener('participantJoined', this.participantJoinedListener);
        this.participantLeftListener &&
            this.meeting.participants.joined.removeListener('participantLeft', this.participantLeftListener);
        participants.joined.removeListener('stageStatusUpdate', this.updateStageViewers);
        stage.removeListener('stageStatusUpdate', this.updateStageViewers);
    }
    getViewers(search) {
        let list = this.meeting.stage.status === 'ON_STAGE' ? [] : [this.meeting.self];
        list = [...list, ...this.meeting.participants.joined.toArray()].filter((p) => p.stageStatus !== 'ON_STAGE');
        if (search === '') {
            this.stageViewers = list;
        }
        else {
            this.stageViewers = list.filter((p) => { var _a; return ((_a = p.name) !== null && _a !== void 0 ? _a : p.id).toLowerCase().includes(search.toLowerCase()); });
        }
    }
    render() {
        if (!this.meeting)
            return null;
        if (this.view !== 'sidebar' || !this.shouldShowViewers())
            return;
        return (index$1.h("div", { class: "list" }, !this.hideHeader && (index$1.h("div", { class: "heading-count", part: "heading-count" }, this.t('viewers'), " (", this.stageViewers.length, ")")), index$1.h("rtk-virtualized-participant-list", { items: this.stageViewers, renderItem: this.createParticipantNode, class: "participants", part: "participants", style: { height: '100%' }, emptyListElement: index$1.h("div", { class: "empty-viewers-list" }, this.search.length > 0
                ? this.t('participants.errors.empty_results')
                : this.t('participants.empty_list')) })));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"],
        "search": ["searchChanged"]
    }; }
};
__decorate$1([
    index.SyncWithStore()
], RtkParticipantsViewers.prototype, "meeting", void 0);
__decorate$1([
    index.SyncWithStore()
], RtkParticipantsViewers.prototype, "config", void 0);
__decorate$1([
    index.SyncWithStore()
], RtkParticipantsViewers.prototype, "iconPack", void 0);
__decorate$1([
    index.SyncWithStore()
], RtkParticipantsViewers.prototype, "t", void 0);
RtkParticipantsViewers.style = RtkParticipantsViewerListStyle0;

const rtkParticipantsWaitingListCss = ":host{line-height:initial;font-family:var(--rtk-font-family, sans-serif);font-feature-settings:normal;font-variation-settings:normal}p{margin:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}:host{margin-top:var(--rtk-space-4, 16px);margin-bottom:calc(var(--rtk-space-2, 8px) * -1);display:flex;width:100%;flex-direction:column;font-size:14px}.waiting-participants{margin-bottom:var(--rtk-space-8, 32px)}.waiting-participants .accept-all-button{--tw-text-opacity:1;color:rgba(var(--rtk-colors-success, 98 165 4) / var(--tw-text-opacity))}h3,.heading-count{margin:var(--rtk-space-0, 0px);display:flex;align-items:center;justify-content:center;padding:var(--rtk-space-0, 0px);font-size:16px;font-weight:400;color:rgb(var(--rtk-colors-text-900, 255 255 255 / 0.88));text-align:center}.heading-count{font-size:14px}.participants{margin-top:var(--rtk-space-2, 8px);padding:var(--rtk-space-0, 0px)}.waiting-participant{margin-top:var(--rtk-space-2, 8px);margin-bottom:var(--rtk-space-2, 8px);display:flex;align-items:center}.waiting-participant .participant-details{margin-right:auto;display:flex;align-items:center}.waiting-participant .participant-details rtk-avatar{margin-right:var(--rtk-space-2, 8px);height:var(--rtk-space-8, 32px);width:var(--rtk-space-8, 32px);flex-shrink:0;font-size:14px}.waiting-participant .participant-details .name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media (min-width: 1080px){.waiting-participant .participant-details .name{max-width:var(--rtk-space-40, 160px)}}.waiting-participant .waitlist-controls{display:flex}.waiting-participant .waitlist-controls rtk-button{margin-left:var(--rtk-space-2, 8px);cursor:pointer;border-radius:var(--rtk-border-radius-sm, 4px)}.waiting-participant .waitlist-controls rtk-icon.accept{--tw-text-opacity:1;color:rgba(var(--rtk-colors-success, 98 165 4) / var(--tw-text-opacity))}.waiting-participant .waitlist-controls rtk-icon.deny{--tw-text-opacity:1;color:rgba(var(--rtk-colors-danger, 255 45 45) / var(--tw-text-opacity))}";
const RtkParticipantsWaitingListStyle0 = rtkParticipantsWaitingListCss;

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        r = Reflect.decorate(decorators, target, key, desc);
    else
        for (var i = decorators.length - 1; i >= 0; i--)
            if (d = decorators[i])
                r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const RtkParticipantsWaitlisted = class {
    constructor(hostRef) {
        index$1.registerInstance(this, hostRef);
        /** Config */
        this.config = uiStore.createDefaultConfig();
        /** Icon pack */
        this.iconPack = uiStore.defaultIconPack;
        /** View mode for participants list */
        this.view = 'sidebar';
        /** Language */
        this.t = uiStore.useLanguage();
        this.acceptWaitingRoomRequest = async (id) => {
            await this.meeting.participants.acceptWaitingRoomRequest(id);
        };
        this.waitlistedParticipants = [];
        this.acceptAllWaitingRoomRequests = async () => {
            await this.meeting.participants.acceptAllWaitingRoomRequest(this.waitlistedParticipants.map((p) => p.id));
        };
        this.rejectWaitingRoomRequest = async (id) => {
            await this.meeting.participants.rejectWaitingRoomRequest(id);
        };
        this.shouldShowWaitlist = () => {
            if (this.meeting.meta.viewType === 'LIVESTREAM')
                return false;
            return (this.meeting.self.permissions.acceptWaitingRequests &&
                this.waitlistedParticipants.length !== 0);
        };
    }
    disconnectedCallback() {
        const { participants } = this.meeting;
        this.waitlistedParticipantJoinedListener &&
            participants.waitlisted.removeListener('participantJoined', this.waitlistedParticipantJoinedListener);
        this.waitlistedParticipantLeftListener &&
            participants.waitlisted.removeListener('participantLeft', this.waitlistedParticipantLeftListener);
        this.waitlistedParticipantsClearedListener &&
            participants.waitlisted.removeListener('participantsCleared', this.waitlistedParticipantsClearedListener);
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
    }
    meetingChanged(meeting) {
        if (!meeting)
            return;
        this.waitlistedParticipants = meeting.participants.waitlisted.toArray();
        this.waitlistedParticipantJoinedListener = (participant) => {
            if (!this.waitlistedParticipants.some((p) => p.id === participant.id)) {
                this.waitlistedParticipants = [...this.waitlistedParticipants, participant];
            }
        };
        this.waitlistedParticipantLeftListener = (participant) => {
            this.waitlistedParticipants = this.waitlistedParticipants.filter((p) => p.id !== participant.id);
        };
        this.waitlistedParticipantsClearedListener = () => {
            this.waitlistedParticipants = [];
        };
        meeting.participants.waitlisted.addListener('participantJoined', this.waitlistedParticipantJoinedListener);
        meeting.participants.waitlisted.addListener('participantLeft', this.waitlistedParticipantLeftListener);
        meeting.participants.waitlisted.addListener('participantsCleared', this.waitlistedParticipantsClearedListener);
    }
    render() {
        if (this.view !== 'sidebar' || !this.shouldShowWaitlist())
            return;
        return (index$1.h("div", { class: "waiting-participants" }, index$1.h("div", { class: "heading-count", part: "waitlisted-heading-count" }, this.t('waitlist.header_title'), " (", this.waitlistedParticipants.length, ")"), index$1.h("ul", { class: "participants", part: "waitlisted-participants" }, this.waitlistedParticipants.map((participant) => (index$1.h("li", { class: "waiting-participant", key: participant.id }, index$1.h("div", { class: "participant-details" }, index$1.h("rtk-avatar", { participant: participant, size: "sm", iconPack: this.iconPack, t: this.t }), index$1.h("p", { class: "name", title: participant.name }, participant.name)), index$1.h("div", { class: "waitlist-controls" }, index$1.h("rtk-tooltip", { label: this.t('waitlist.deny_request'), variant: "secondary" }, index$1.h("rtk-button", { variant: "secondary", kind: "icon", onClick: () => this.rejectWaitingRoomRequest(participant.id) }, index$1.h("rtk-icon", { class: "deny", icon: this.iconPack.dismiss }))), index$1.h("rtk-tooltip", { label: this.t('waitlist.accept_request'), variant: "secondary" }, index$1.h("rtk-button", { variant: "secondary", kind: "icon", onClick: () => this.acceptWaitingRoomRequest(participant.id) }, index$1.h("rtk-icon", { class: "accept", icon: this.iconPack.checkmark })))))))), index$1.h("rtk-button", { class: "accept-all-button", variant: "secondary", kind: "wide", onClick: this.acceptAllWaitingRoomRequests }, this.t('waitlist.accept_all'))));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"]
    }; }
};
__decorate([
    index.SyncWithStore()
], RtkParticipantsWaitlisted.prototype, "meeting", void 0);
__decorate([
    index.SyncWithStore()
], RtkParticipantsWaitlisted.prototype, "config", void 0);
__decorate([
    index.SyncWithStore()
], RtkParticipantsWaitlisted.prototype, "iconPack", void 0);
__decorate([
    index.SyncWithStore()
], RtkParticipantsWaitlisted.prototype, "t", void 0);
RtkParticipantsWaitlisted.style = RtkParticipantsWaitingListStyle0;

exports.rtk_participants_stage_list = RtkParticipants;
exports.rtk_participants_stage_queue = RtkParticipantsStaged;
exports.rtk_participants_viewer_list = RtkParticipantsViewers;
exports.rtk_participants_waiting_list = RtkParticipantsWaitlisted;
