"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const IconButton = require("../common/base/IconButton.vue.js");
const FullScreenIcon = require("../common/icons/FullScreenIcon.vue.js");
const utils = require("../../utils/utils.js");
const index = require("../../locales/index.js");
const constants = require("../../utils/constants.js");
require("../../services/main.js");
const roomService = require("../../services/roomService.js");
require("@tencentcloud/tuiroom-engine-js");
require("mitt");
require("../../services/manager/roomActionManager.js");
require("@tencentcloud/tui-core");
const _hoisted_1 = {
  key: 0,
  class: "fullscreen-control-container"
};
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
  __name: "FullScreenControl",
  setup(__props) {
    const { t } = index.useI18n();
    const fullScreenConfig = roomService.roomService.getComponentConfig("FullScreen");
    const isFullScreen = Vue.ref(false);
    const title = Vue.computed(
      () => isFullScreen.value ? t("Exit") : t("Full screen")
    );
    function toggleScreen() {
      if (isFullScreen.value) {
        utils.exitFullScreen();
      } else {
        if (constants.isVue27) {
          const roomContainer = document.body;
          roomContainer && utils.setFullScreen(roomContainer);
        } else {
          const roomContainer = document.getElementById("roomContainer");
          roomContainer && utils.setFullScreen(roomContainer);
        }
      }
    }
    function handleFullScreenChange() {
      isFullScreen.value = !!document.fullscreenElement;
    }
    Vue.onMounted(() => {
      [
        "fullscreenchange",
        "webkitfullscreenchange",
        "mozfullscreenchange",
        "msfullscreenchange"
      ].forEach((item) => {
        window.addEventListener(item, handleFullScreenChange);
      });
    });
    Vue.onUnmounted(() => {
      [
        "fullscreenchange",
        "webkitfullscreenchange",
        "mozfullscreenchange",
        "msfullscreenchange"
      ].forEach((item) => {
        window.removeEventListener(item, handleFullScreenChange);
      });
    });
    return (_ctx, _cache) => {
      return Vue.unref(fullScreenConfig).visible ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        Vue.createVNode(IconButton.default, {
          "is-active": isFullScreen.value,
          title: title.value,
          onClickIcon: toggleScreen
        }, {
          default: Vue.withCtx(() => [
            Vue.createVNode(FullScreenIcon.default)
          ]),
          _: 1
        }, 8, ["is-active", "title"])
      ])) : Vue.createCommentVNode("", true);
    };
  }
});
exports.default = _sfc_main;
