import { r as registerInstance, d as createEvent, h, a as Host } from './index-55463a54.js';
import { e as defaultIconPack, i as useLanguage } from './ui-store-76bb0e8e.js';
import { i as isFullScreenEnabled, r as requestFullScreen, e as exitFullScreen, a as isFullScreenSupported } from './full-screen-d36ffc68.js';
import { S as SyncWithStore } from './index-dafb4b7f.js';

const rtkFullscreenToggleCss = ":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}:host([data-hidden]){display:none}";
const RtkFullscreenToggleStyle0 = rtkFullscreenToggleCss;

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 RtkFullscreenToggle = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.stateUpdate = createEvent(this, "rtkStateUpdate", 7);
        /** Variant */
        this.variant = 'button';
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.fullScreenActive = false;
        this.isFullScreenSupported = true;
        this.onFullScreenchange = () => {
            this.fullScreenActive = isFullScreenEnabled();
        };
        this.toggleFullScreen = () => {
            let fullScreenElement = this.targetElement || document.querySelector('rtk-meeting');
            if (!fullScreenElement)
                return;
            if (!this.fullScreenActive) {
                requestFullScreen(fullScreenElement);
                this.fullScreenActive = true;
            }
            else {
                exitFullScreen();
                this.fullScreenActive = false;
            }
            this.stateUpdate.emit({ activeMoreMenu: false });
        };
    }
    connectedCallback() {
        this.isFullScreenSupported = isFullScreenSupported();
        this.onFullScreenchange();
        window.addEventListener('webkitfullscreenchange', this.onFullScreenchange);
        window.addEventListener('fullscreenchange', this.onFullScreenchange);
    }
    disconnectedCallback() {
        window.removeEventListener('webkitfullscreenchange', this.onFullScreenchange);
        window.removeEventListener('fullscreenchange', this.onFullScreenchange);
    }
    render() {
        if (!this.isFullScreenSupported) {
            return h(Host, { "data-hidden": true });
        }
        return (h(Host, { title: this.t('full_screen') }, h("rtk-controlbar-button", { size: this.size, iconPack: this.iconPack, onClick: this.toggleFullScreen, icon: this.fullScreenActive
                ? this.iconPack.full_screen_minimize
                : this.iconPack.full_screen_maximize, label: this.fullScreenActive ? this.t('full_screen.exit') : this.t('full_screen'), variant: this.variant })));
    }
};
__decorate([
    SyncWithStore()
], RtkFullscreenToggle.prototype, "states", void 0);
__decorate([
    SyncWithStore()
], RtkFullscreenToggle.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkFullscreenToggle.prototype, "t", void 0);
RtkFullscreenToggle.style = RtkFullscreenToggleStyle0;

export { RtkFullscreenToggle as rtk_fullscreen_toggle };
