import { r as registerInstance, d as createEvent, h, a as Host } 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';

const rtkCaptionToggleCss = ":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 RtkCaptionToggleStyle0 = rtkCaptionToggleCss;

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 RtkCaptionToggle = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.stateUpdate = createEvent(this, "rtkStateUpdate", 7);
        /** Variant */
        this.variant = 'button';
        /** Config */
        this.config = createDefaultConfig();
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.captionEnabled = false;
        this.permissionsUpdateListener = () => {
            var _a;
            this.captionEnabled =
                (_a = this.meeting.self.permissions.transcriptionEnabled) !== null && _a !== void 0 ? _a : false;
        };
    }
    connectedCallback() {
        this.meetingChanged(this.meeting);
    }
    meetingChanged(meeting) {
        if (!meeting)
            return;
        this.permissionsUpdateListener();
        this.meeting.self.permissions.addListener('permissionsUpdate', this.permissionsUpdateListener);
    }
    disconnectedCallback() {
        var _a;
        (_a = this.meeting) === null || _a === void 0 ? void 0 : _a.self.permissions.removeListener('permissionsUpdate', this.permissionsUpdateListener);
    }
    toggleCaptions() {
        this.stateUpdate.emit({ activeCaptions: !this.states.activeCaptions, activeMoreMenu: false });
    }
    render() {
        if (!this.meeting)
            return null;
        if (!this.captionEnabled)
            return null;
        const captionsEnabled = this.states.activeCaptions;
        return (h(Host, { tabIndex: 0, role: "log", "aria-label": `Picture-in-Picture mode` }, h("rtk-controlbar-button", { part: "controlbar-button", size: this.size, iconPack: this.iconPack, onClick: () => this.toggleCaptions(), icon: captionsEnabled ? this.iconPack.captionsOff : this.iconPack.captionsOn, label: captionsEnabled ? this.t('transcript.off') : this.t('transcript.on'), variant: this.variant })));
    }
    static get watchers() { return {
        "meeting": ["meetingChanged"]
    }; }
};
__decorate([
    SyncWithStore()
], RtkCaptionToggle.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkCaptionToggle.prototype, "states", void 0);
__decorate([
    SyncWithStore()
], RtkCaptionToggle.prototype, "config", void 0);
__decorate([
    SyncWithStore()
], RtkCaptionToggle.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkCaptionToggle.prototype, "t", void 0);
RtkCaptionToggle.style = RtkCaptionToggleStyle0;

export { RtkCaptionToggle as rtk_caption_toggle };
