import { r as registerInstance, h, a as Host, d as createEvent } from './index-55463a54.js';
import { c as createDefaultConfig, e as defaultIconPack, i as useLanguage } from './ui-store-76bb0e8e.js';
import { S as SyncWithStore } from './index-dafb4b7f.js';
import { s as smoothScrollToBottom } from './scroll-2d8e810c.js';

const rtkAiCss = ":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{position:relative;box-sizing:border-box;display:flex;width:100%;flex-direction:column;--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-1000, 8 8 8) / var(--tw-bg-opacity));color:rgb(var(--rtk-colors-text-1000, 255 255 255));overflow:hidden}.close{position:absolute;top:var(--rtk-space-3, 12px);left:var(--rtk-space-3, 12px)}.title{margin-left:var(--rtk-space-0, 0px);margin-right:var(--rtk-space-0, 0px);margin-top:var(--rtk-space-4, 16px);margin-bottom:var(--rtk-space-2, 8px);-webkit-user-select:none;-moz-user-select:none;user-select:none;padding:var(--rtk-space-0, 0px);text-align:center;font-size:14px;font-weight:400}rtk-ai-transcriptions{flex:1}:host([view='sidebar']){--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-900, 26 26 26) / var(--tw-bg-opacity))}:host([view='full-screen']){position:absolute;top:var(--rtk-space-0, 0px);right:var(--rtk-space-0, 0px);bottom:var(--rtk-space-0, 0px);left:var(--rtk-space-0, 0px);z-index:50;max-width:100%;border:none}";
const RtkAiStyle0 = rtkAiCss;

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 RtkAi = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        /** Config */
        this.config = createDefaultConfig();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        /** View type */
        this.view = 'sidebar';
    }
    render() {
        if (!this.meeting)
            return null;
        const defaults = {
            meeting: this.meeting,
            config: this.config,
            states: this.states,
            size: this.size,
            t: this.t,
            iconPack: this.iconPack,
        };
        return (h(Host, null, h("rtk-ai-transcriptions", Object.assign({}, defaults))));
    }
};
__decorate$2([
    SyncWithStore()
], RtkAi.prototype, "meeting", void 0);
__decorate$2([
    SyncWithStore()
], RtkAi.prototype, "states", void 0);
__decorate$2([
    SyncWithStore()
], RtkAi.prototype, "config", void 0);
__decorate$2([
    SyncWithStore()
], RtkAi.prototype, "iconPack", void 0);
__decorate$2([
    SyncWithStore()
], RtkAi.prototype, "t", void 0);
RtkAi.style = RtkAiStyle0;

const rtkPluginsCss = ":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)}.scrollbar{scrollbar-width:thin;scrollbar-color:var(--rtk-scrollbar-color, rgb(var(--rtk-colors-background-600, 60 60 60)))\n    var(--rtk-scrollbar-background, transparent)}.scrollbar::-webkit-scrollbar{height:var(--rtk-space-1\\.5, 6px);width:var(--rtk-space-1\\.5, 6px);border-radius:9999px;background-color:var(--rtk-scrollbar-background, transparent)}.scrollbar::-webkit-scrollbar-thumb{border-radius:9999px;background-color:var(--rtk-scrollbar-color, rgb(var(--rtk-colors-background-600, 60 60 60)))}:host{margin-top:var(--rtk-space-2, 8px);margin-bottom:var(--rtk-space-2, 8px);display:flex;height:100%;width:100%;flex-direction:column;font-size:14px;color:rgb(var(--rtk-colors-text-1000, 255 255 255))}h3{margin-left:var(--rtk-space-0, 0px);margin-right:var(--rtk-space-0, 0px);margin-top:var(--rtk-space-4, 16px);margin-bottom:var(--rtk-space-4, 16px);display:block;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}ul{overflow-y:auto;padding:var(--rtk-space-0, 0px);flex-grow:1;flex-basis:0}.metadata{display:flex;align-items:center}.metadata img{height:var(--rtk-space-8, 32px);width:var(--rtk-space-8, 32px);border-radius:var(--rtk-border-radius-sm, 4px)}.metadata .name{margin-left:var(--rtk-space-2, 8px);font-weight:500}.plugin{display:flex;align-items:center;justify-content:space-between;padding-left:var(--rtk-space-4, 16px);padding-right:var(--rtk-space-4, 16px);padding-top:var(--rtk-space-2, 8px);padding-bottom:var(--rtk-space-2, 8px)}.plugin .buttons{display:flex;align-items:center}.empty-plugins{display:flex;height:100%;width:100%;align-items:center;justify-content:center;padding-left:var(--rtk-space-4, 16px);padding-right:var(--rtk-space-4, 16px);color:rgb(var(--rtk-colors-text-700, 255 255 255 / 0.64))}rtk-button:hover{--tw-ring-offset-shadow:var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow:var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);--tw-ring-opacity:1;--tw-ring-color:rgba(var(--rtk-colors-brand-500, 33 96 253) / var(--tw-ring-opacity));--tw-ring-offset-width:2px;--tw-ring-offset-color:rgb(var(--rtk-colors-background-1000, 8 8 8))}";
const RtkPluginsStyle0 = rtkPluginsCss;

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 RtkPlugins = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.stateUpdate = createEvent(this, "rtkStateUpdate", 7);
        this.updateActivePlugins = () => {
            if (!this.meeting)
                return;
            this.activatedPluginsId = this.meeting.plugins.active.toArray().map((p) => p.id);
        };
        /** Config */
        this.config = createDefaultConfig();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.plugins = [];
        this.activatedPluginsId = [];
        this.close = () => {
            this.stateUpdate.emit({ activeSidebar: false, sidebar: undefined });
        };
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
    }
    disconnectedCallback() {
        var _a;
        (_a = this.meeting) === null || _a === void 0 ? void 0 : _a.plugins.all.removeListener('stateUpdate', this.updateActivePlugins);
    }
    meetingChanged(meeting, oldMeeting) {
        if (oldMeeting) {
            oldMeeting.plugins.all.removeListener('stateUpdate', this.updateActivePlugins);
        }
        if (meeting != null) {
            this.plugins = meeting.plugins.all.toArray();
            this.updateActivePlugins();
            meeting.plugins.all.addListener('stateUpdate', this.updateActivePlugins);
        }
    }
    render() {
        return (h(Host, { key: '9a0c98a1c3313bae757ecdc7c2c6932456c2d924' }, this.plugins.length === 0 && h("div", { key: 'ea6629a4739c87842bb0fa7cb0c73d0dc9511f51', class: "empty-plugins" }, this.t('plugins.empty')), h("ul", { key: '9632e9183e3c1dbbaa5adb80b81cb66096b6742f', class: "scrollbar" }, this.plugins.map((plugin) => {
            var _a, _b;
            return (h("li", { key: plugin.name, class: "plugin" }, h("div", { class: "metadata" }, h("img", { src: plugin.icon, alt: plugin.name }), h("div", { class: "name" }, plugin.name)), !this.activatedPluginsId.includes(plugin.id) && ((_a = plugin === null || plugin === void 0 ? void 0 : plugin.permissions) === null || _a === void 0 ? void 0 : _a.canActivate) && (h("div", { class: "buttons" }, h("rtk-button", { kind: "icon", size: "lg", onClick: () => {
                    plugin.activate();
                    this.close();
                }, "aria-label": `${this.t('activate')} ${plugin.name}` }, h("rtk-icon", { icon: this.iconPack.rocket, tabIndex: -1, "aria-hidden": true })))), this.activatedPluginsId.includes(plugin.id) &&
                ((_b = plugin === null || plugin === void 0 ? void 0 : plugin.permissions) === null || _b === void 0 ? void 0 : _b.canDeactivate) && (h("div", { class: "buttons" }, h("rtk-button", { kind: "icon", size: "lg", onClick: () => {
                    plugin.deactivate();
                }, "aria-label": `${this.t('close')} ${plugin.name}` }, h("rtk-icon", { icon: this.iconPack.dismiss, tabIndex: -1, "aria-hidden": true }))))));
        }))));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"]
    }; }
};
__decorate$1([
    SyncWithStore()
], RtkPlugins.prototype, "meeting", void 0);
__decorate$1([
    SyncWithStore()
], RtkPlugins.prototype, "config", void 0);
__decorate$1([
    SyncWithStore()
], RtkPlugins.prototype, "iconPack", void 0);
__decorate$1([
    SyncWithStore()
], RtkPlugins.prototype, "t", void 0);
RtkPlugins.style = RtkPluginsStyle0;

const rtkPollsCss = ":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)}.scrollbar{scrollbar-width:thin;scrollbar-color:var(--rtk-scrollbar-color, rgb(var(--rtk-colors-background-600, 60 60 60)))\n    var(--rtk-scrollbar-background, transparent)}.scrollbar::-webkit-scrollbar{height:var(--rtk-space-1\\.5, 6px);width:var(--rtk-space-1\\.5, 6px);border-radius:9999px;background-color:var(--rtk-scrollbar-background, transparent)}.scrollbar::-webkit-scrollbar-thumb{border-radius:9999px;background-color:var(--rtk-scrollbar-color, rgb(var(--rtk-colors-background-600, 60 60 60)))}:host{margin-top:var(--rtk-space-2, 8px);display:flex;height:100%;width:100%;flex-direction:column;font-size:14px}*{box-sizing:border-box}.ctr{box-sizing:border-box;padding:var(--rtk-space-3, 12px);padding-top:var(--rtk-space-0, 0px);display:flex;flex:1 1 0%;flex-direction:column}.polls-view{overflow-y:auto;flex:1 1 0%;flex-basis:0}.empty-polls{display:flex;height:100%;width:100%;align-items:center;justify-content:center}";
const RtkPollsStyle0 = rtkPollsCss;

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 RtkPolls = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        /** Config */
        this.config = createDefaultConfig();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        /** Create State */
        this.create = false;
        /** Polls */
        this.polls = [];
        this.onPollsUpdate = (data) => {
            this.polls = [...data.polls];
        };
        this.onUpdatePermissions = () => {
            this.permissions = this.meeting.self.permissions;
        };
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
    }
    disconnectedCallback() {
        var _a;
        if (!this.meeting)
            return;
        (_a = this.meeting.polls) === null || _a === void 0 ? void 0 : _a.removeListener('pollsUpdate', this.onPollsUpdate);
        this.meeting.self.permissions.removeListener('pollsUpdate', this.onUpdatePermissions);
    }
    meetingChanged(meeting) {
        if (!meeting)
            return;
        if (!meeting.polls)
            return;
        this.permissions = this.meeting.self.permissions;
        this.polls = [...meeting.polls.items];
        meeting.polls.addListener('pollsUpdate', this.onPollsUpdate);
        this.meeting.self.permissions.addListener('pollsUpdate', this.onUpdatePermissions);
        this.onCreate = async (data) => {
            this.create = false;
            await meeting.polls.create(data.question, data.options, data.anonymous, data.hideVotes);
        };
        this.onVote = async (id, index) => {
            await meeting.polls.vote(id, index);
        };
    }
    toggleCreateState() {
        this.create = !this.create;
    }
    componentDidRender() {
        smoothScrollToBottom(this.pollEl);
    }
    render() {
        var _a, _b;
        return (h(Host, { key: '0e868573a28a637e9df91a0c2e10bc1a73da2848' }, h("div", { key: '63cf282074f7c9eb248c4a645f6798001379907b', class: "ctr", part: "container" }, h("div", { key: '3237128bcbff4b513970e9832f26326a8be1cf56', class: "polls-view scrollbar", ref: (el) => (this.pollEl = el), part: "polls" }, this.polls.length == 0 && this.create !== true && (h("div", { key: '12b3c463d0f63f0a62ab33f17c0f18bb44fa0408', class: "empty-polls" }, this.t('polls.empty'))), this.polls.map((item) => {
            var _a;
            return (h("rtk-poll", { key: item.id, poll: item, onRtkVotePoll: (e) => {
                    this.onVote(e.detail.id, e.detail.index);
                }, self: (_a = this.meeting) === null || _a === void 0 ? void 0 : _a.self.userId, iconPack: this.iconPack, t: this.t, permissions: this.permissions }));
        }), this.create && (h("rtk-poll-form", { key: 'fb8b90bb86654aa8742ced745f88e5fbdc9282bf', part: "poll-form", onRtkCreatePoll: (e) => {
                this.onCreate(e.detail);
            }, iconPack: this.iconPack, t: this.t }))), ((_b = (_a = this.permissions) === null || _a === void 0 ? void 0 : _a.polls) === null || _b === void 0 ? void 0 : _b.canCreate) && (h("rtk-button", { key: '7fffe35088db7620b4301145c6efa2f6da05153c', kind: "wide", onClick: () => this.toggleCreateState(), variant: this.create ? 'secondary' : 'primary', part: "button" }, this.create ? this.t('polls.cancel') : this.t('polls.create'))))));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"]
    }; }
};
__decorate([
    SyncWithStore()
], RtkPolls.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkPolls.prototype, "config", void 0);
__decorate([
    SyncWithStore()
], RtkPolls.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkPolls.prototype, "t", void 0);
RtkPolls.style = RtkPollsStyle0;

export { RtkAi as rtk_ai, RtkPlugins as rtk_plugins, RtkPolls as rtk_polls };
