'use strict';

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

const index$1 = require('./index-2e5758b6.js');
const uiStore = require('./ui-store-583d205a.js');
const fullScreen = require('./full-screen-b02d13dd.js');
const index = require('./index-3f8e5441.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) {
        index$1.registerInstance(this, hostRef);
        this.stateUpdate = index$1.createEvent(this, "rtkStateUpdate", 7);
        /** Variant */
        this.variant = 'button';
        /** Icon pack */
        this.iconPack = uiStore.defaultIconPack;
        /** Language */
        this.t = uiStore.useLanguage();
        this.fullScreenActive = false;
        this.isFullScreenSupported = true;
        this.onFullScreenchange = () => {
            this.fullScreenActive = fullScreen.isFullScreenEnabled();
        };
        this.toggleFullScreen = () => {
            let fullScreenElement = this.targetElement || document.querySelector('rtk-meeting');
            if (!fullScreenElement)
                return;
            if (!this.fullScreenActive) {
                fullScreen.requestFullScreen(fullScreenElement);
                this.fullScreenActive = true;
            }
            else {
                fullScreen.exitFullScreen();
                this.fullScreenActive = false;
            }
            this.stateUpdate.emit({ activeMoreMenu: false });
        };
    }
    connectedCallback() {
        this.isFullScreenSupported = fullScreen.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 index$1.h(index$1.Host, { "data-hidden": true });
        }
        return (index$1.h(index$1.Host, { title: this.t('full_screen') }, index$1.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([
    index.SyncWithStore()
], RtkFullscreenToggle.prototype, "states", void 0);
__decorate([
    index.SyncWithStore()
], RtkFullscreenToggle.prototype, "iconPack", void 0);
__decorate([
    index.SyncWithStore()
], RtkFullscreenToggle.prototype, "t", void 0);
RtkFullscreenToggle.style = RtkFullscreenToggleStyle0;

exports.rtk_fullscreen_toggle = RtkFullscreenToggle;
