import { p as proxyCustomElement, H, e as createEvent, h, c as Host } from './p-ae373651.js';
import { c as createDefaultConfig, e as defaultIconPack, i as useLanguage } from './p-5b3a7f00.js';
import { S as SyncWithStore } from './p-070aa695.js';
import { R as Render } from './p-88bd1053.js';
import { d as defineCustomElement$n } from './p-a3bf84d7.js';
import { d as defineCustomElement$m } from './p-c5ef686a.js';
import { d as defineCustomElement$l } from './p-f4a5c8ff.js';
import { d as defineCustomElement$k } from './p-f74bd10e.js';
import { d as defineCustomElement$j } from './p-477d076c.js';
import { d as defineCustomElement$i } from './p-85587a5c.js';
import { d as defineCustomElement$h } from './p-5ba840d9.js';
import { d as defineCustomElement$g } from './p-cb6f4d4b.js';
import { d as defineCustomElement$f } from './p-a9e7fa80.js';
import { d as defineCustomElement$e } from './p-b350d09f.js';
import { d as defineCustomElement$d } from './p-4c3d522b.js';
import { d as defineCustomElement$c } from './p-bd5c9c89.js';
import { d as defineCustomElement$b } from './p-7071c775.js';
import { d as defineCustomElement$a } from './p-6fa03a7f.js';
import { d as defineCustomElement$9 } from './p-3e0452c4.js';
import { d as defineCustomElement$8 } from './p-4594b213.js';
import { d as defineCustomElement$7 } from './p-d414fa54.js';
import { d as defineCustomElement$6 } from './p-32b624f9.js';
import { d as defineCustomElement$5 } from './p-13a05c55.js';
import { d as defineCustomElement$4 } from './p-165dddf4.js';
import { d as defineCustomElement$3 } from './p-e6245534.js';
import { d as defineCustomElement$2 } from './p-bece0226.js';

const rtkDialogManagerCss = ":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:block}";
const RtkDialogManagerStyle0 = rtkDialogManagerCss;

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 RtkDialogManager$1 = /*@__PURE__*/ proxyCustomElement(class RtkDialogManager extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.stateUpdate = createEvent(this, "rtkStateUpdate", 7);
        /** UI Config */
        this.config = createDefaultConfig();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.updateStoreState = (state, value) => {
            this.stateUpdate.emit({ [state]: value });
        };
        this.cancelJoinStage = async () => {
            var _a, _b, _c;
            if (((_a = this.meeting.stage) === null || _a === void 0 ? void 0 : _a.status) === 'ACCEPTED_TO_JOIN_STAGE') {
                await ((_c = (_b = this.meeting) === null || _b === void 0 ? void 0 : _b.stage) === null || _c === void 0 ? void 0 : _c.leave());
            }
            this.updateStoreState('activeJoinStage', false);
        };
        this.joinStage = async () => {
            await this.meeting.stage.join();
            /** NOTE(ishita1805): We close the modal once the status has changed */
        };
        this.stageStatusUpdateListener = (status) => {
            var _a;
            if (!((_a = this.states) === null || _a === void 0 ? void 0 : _a.activeJoinStage))
                return;
            if (status === 'ON_STAGE')
                this.updateStoreState('activeJoinStage', false);
        };
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
    }
    disconnectedCallback() {
        var _a;
        (_a = this.meeting.stage) === null || _a === void 0 ? void 0 : _a.removeListener('stageStatusUpdate', this.stageStatusUpdateListener);
    }
    meetingChanged(meeting) {
        if (!meeting)
            return;
        const { stage } = meeting;
        stage === null || stage === void 0 ? void 0 : stage.addListener('stageStatusUpdate', this.stageStatusUpdateListener);
    }
    render() {
        var _a, _b, _c, _d;
        if (!this.meeting) {
            return;
        }
        const defaults = {
            meeting: this.meeting,
            states: this.states,
            config: this.config,
            size: this.size,
            iconPack: this.iconPack,
            t: this.t,
        };
        const states = this.states;
        if ((states === null || states === void 0 ? void 0 : states.image) != null) {
            const image = states.image;
            const onImageClose = () => {
                this.stateUpdate.emit({ image: null });
            };
            return (h(Host, null, h("rtk-dialog", { open: true, onRtkDialogClose: onImageClose, hideCloseButton: true, iconPack: this.iconPack, t: this.t }, h(Render, { element: "rtk-image-viewer", defaults: defaults, props: { image, onClose: onImageClose } }))));
        }
        else if ((states === null || states === void 0 ? void 0 : states.activeSettings) === true) {
            return (h(Host, null, h("rtk-dialog", { open: true, onRtkDialogClose: () => this.updateStoreState('activeSettings', false), iconPack: this.iconPack, t: this.t }, h(Render, { element: "rtk-settings", defaults: defaults }))));
        }
        else if ((states === null || states === void 0 ? void 0 : states.activeDebugger) === true) {
            return (h(Host, null, h("rtk-dialog", { open: true, onRtkDialogClose: () => this.updateStoreState('activeDebugger', false), iconPack: this.iconPack, t: this.t }, h("rtk-debugger", Object.assign({}, defaults)))));
        }
        else if ((states === null || states === void 0 ? void 0 : states.activeLeaveConfirmation) === true) {
            return (h(Host, null, h("rtk-dialog", { open: true, onRtkDialogClose: () => this.updateStoreState('activeLeaveConfirmation', false), iconPack: this.iconPack, t: this.t }, h("rtk-leave-meeting", Object.assign({}, defaults)))));
        }
        else if (((_a = states === null || states === void 0 ? void 0 : states.activePermissionsMessage) === null || _a === void 0 ? void 0 : _a.enabled) === true) {
            return (h(Host, null, h("rtk-dialog", { open: true, hideCloseButton: true, iconPack: this.iconPack, t: this.t }, h("rtk-permissions-message", Object.assign({}, defaults)))));
        }
        else if (((_b = states === null || states === void 0 ? void 0 : states.activeBreakoutRoomsManager) === null || _b === void 0 ? void 0 : _b.active) === true) {
            return (h(Host, null, h("rtk-dialog", { open: true, onRtkDialogClose: () => this.updateStoreState('activeBreakoutRoomsManager', {
                    active: false,
                    data: undefined,
                }), iconPack: this.iconPack, t: this.t }, h("rtk-breakout-rooms-manager", Object.assign({}, defaults)))));
        }
        else if (((_c = states === null || states === void 0 ? void 0 : states.activeConfirmationModal) === null || _c === void 0 ? void 0 : _c.active) === true) {
            return (h(Host, null, h("rtk-dialog", { open: true, onRtkDialogClose: () => this.updateStoreState('activeConfirmationModal', false), iconPack: this.iconPack, t: this.t }, h("rtk-confirmation-modal", Object.assign({}, defaults)))));
        }
        else if (((_d = states === null || states === void 0 ? void 0 : states.activeOverlayModal) === null || _d === void 0 ? void 0 : _d.active) === true) {
            return (h(Host, null, h("rtk-overlay-modal", { meeting: this.meeting, states: this.states, iconPack: this.iconPack, t: this.t })));
        }
        else if (states === null || states === void 0 ? void 0 : states.activeBroadcastMessageModal) {
            return (h(Host, null, h("rtk-dialog", { open: true, onRtkDialogClose: () => this.updateStoreState('activeBroadcastMessageModal', false), iconPack: this.iconPack, t: this.t }, h("rtk-broadcast-message-modal", Object.assign({}, defaults)))));
        }
        else if ((states === null || states === void 0 ? void 0 : states.activeJoinStage) === true) {
            const dataState = {
                title: this.t('stage.join_title'),
                label: {
                    accept: this.t('stage.join_confirm'),
                    reject: this.t('stage.join_cancel'),
                },
                description: this.t('stage.join_summary'),
            };
            return (h(Host, null, h("rtk-dialog", { open: true, onRtkDialogClose: this.cancelJoinStage, iconPack: this.iconPack, t: this.t }, h("rtk-join-stage", Object.assign({ dataConfig: dataState, onRtkJoinStage: this.joinStage, onRtkLeaveStage: this.cancelJoinStage }, defaults)))));
        }
        else if ((states === null || states === void 0 ? void 0 : states.activeMuteAllConfirmation) === true) {
            return (h(Host, null, h("rtk-dialog", { open: true, onRtkDialogClose: () => {
                    this.updateStoreState('activeMuteAllConfirmation', false);
                }, iconPack: this.iconPack, t: this.t }, h("rtk-mute-all-confirmation", Object.assign({}, defaults)))));
        }
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"]
    }; }
    static get style() { return RtkDialogManagerStyle0; }
}, [1, "rtk-dialog-manager", {
        "meeting": [16],
        "config": [16],
        "states": [16],
        "size": [513],
        "iconPack": [16],
        "t": [16]
    }, undefined, {
        "meeting": ["meetingChanged"]
    }]);
__decorate([
    SyncWithStore()
], RtkDialogManager$1.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkDialogManager$1.prototype, "config", void 0);
__decorate([
    SyncWithStore()
], RtkDialogManager$1.prototype, "states", void 0);
__decorate([
    SyncWithStore()
], RtkDialogManager$1.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkDialogManager$1.prototype, "t", void 0);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-dialog-manager", "rtk-avatar", "rtk-breakout-room-manager", "rtk-breakout-room-participants", "rtk-breakout-rooms-manager", "rtk-broadcast-message-modal", "rtk-button", "rtk-confirmation-modal", "rtk-counter", "rtk-debugger", "rtk-debugger-audio", "rtk-debugger-screenshare", "rtk-debugger-system", "rtk-debugger-video", "rtk-dialog", "rtk-icon", "rtk-join-stage", "rtk-leave-meeting", "rtk-mute-all-confirmation", "rtk-overlay-modal", "rtk-permissions-message", "rtk-spinner", "rtk-tooltip"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-dialog-manager":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkDialogManager$1);
            }
            break;
        case "rtk-avatar":
            if (!customElements.get(tagName)) {
                defineCustomElement$n();
            }
            break;
        case "rtk-breakout-room-manager":
            if (!customElements.get(tagName)) {
                defineCustomElement$m();
            }
            break;
        case "rtk-breakout-room-participants":
            if (!customElements.get(tagName)) {
                defineCustomElement$l();
            }
            break;
        case "rtk-breakout-rooms-manager":
            if (!customElements.get(tagName)) {
                defineCustomElement$k();
            }
            break;
        case "rtk-broadcast-message-modal":
            if (!customElements.get(tagName)) {
                defineCustomElement$j();
            }
            break;
        case "rtk-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$i();
            }
            break;
        case "rtk-confirmation-modal":
            if (!customElements.get(tagName)) {
                defineCustomElement$h();
            }
            break;
        case "rtk-counter":
            if (!customElements.get(tagName)) {
                defineCustomElement$g();
            }
            break;
        case "rtk-debugger":
            if (!customElements.get(tagName)) {
                defineCustomElement$f();
            }
            break;
        case "rtk-debugger-audio":
            if (!customElements.get(tagName)) {
                defineCustomElement$e();
            }
            break;
        case "rtk-debugger-screenshare":
            if (!customElements.get(tagName)) {
                defineCustomElement$d();
            }
            break;
        case "rtk-debugger-system":
            if (!customElements.get(tagName)) {
                defineCustomElement$c();
            }
            break;
        case "rtk-debugger-video":
            if (!customElements.get(tagName)) {
                defineCustomElement$b();
            }
            break;
        case "rtk-dialog":
            if (!customElements.get(tagName)) {
                defineCustomElement$a();
            }
            break;
        case "rtk-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$9();
            }
            break;
        case "rtk-join-stage":
            if (!customElements.get(tagName)) {
                defineCustomElement$8();
            }
            break;
        case "rtk-leave-meeting":
            if (!customElements.get(tagName)) {
                defineCustomElement$7();
            }
            break;
        case "rtk-mute-all-confirmation":
            if (!customElements.get(tagName)) {
                defineCustomElement$6();
            }
            break;
        case "rtk-overlay-modal":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "rtk-permissions-message":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "rtk-spinner":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "rtk-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}
defineCustomElement$1();

const RtkDialogManager = RtkDialogManager$1;
const defineCustomElement = defineCustomElement$1;

export { RtkDialogManager, defineCustomElement };
