"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const DeviceSelect = require("./DeviceSelect.vue.js");
const VideoProfile = require("./VideoProfile.vue.js");
const TuiSwitch = require("./base/TuiSwitch.vue.js");
const basic = require("../../stores/basic.js");
const index = require("../../locales/index.js");
const useRoomEngine = require("../../hooks/useRoomEngine.js");
const TUIRoomEngine = require("@tencentcloud/tuiroom-engine-js");
const environment = require("../../utils/environment.js");
const pinia = require("pinia");
const _hoisted_1 = { class: "item-setting" };
const _hoisted_2 = { class: "title" };
const _hoisted_3 = {
  key: 0,
  class: "item-setting"
};
const _hoisted_4 = { class: "title" };
const _hoisted_5 = { class: "item-setting" };
const _hoisted_6 = { class: "title" };
const _hoisted_7 = { class: "mirror-container" };
const _hoisted_8 = {
  key: 1,
  class: "item-setting"
};
const _sfc_main = /* @__PURE__ */ Vue.defineComponent({
  __name: "VideoSettingTab",
  props: {
    withPreview: { type: Boolean },
    withMore: { type: Boolean },
    withMirror: { type: Boolean },
    theme: {}
  },
  setup(__props) {
    const roomEngine = useRoomEngine.default();
    const props = __props;
    const basicStore = basic.useBasicStore();
    const { isLocalStreamMirror } = pinia.storeToRefs(basicStore);
    const themeClass = Vue.computed(
      () => props.theme ? `tui-theme-${props.theme}` : ""
    );
    Vue.watch(isLocalStreamMirror, async (val) => {
      var _a;
      const trtcCloud = (_a = roomEngine.instance) == null ? void 0 : _a.getTRTCCloud();
      if (!environment.isMobile) {
        await (trtcCloud == null ? void 0 : trtcCloud.setLocalRenderParams({
          mirrorType: val ? TUIRoomEngine.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable : TUIRoomEngine.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable,
          rotation: TUIRoomEngine.TRTCVideoRotation.TRTCVideoRotation0,
          fillMode: TUIRoomEngine.TRTCVideoFillMode.TRTCVideoFillMode_Fill
        }));
      }
    });
    const { t } = index.useI18n();
    function handleMoreCameraSetting() {
      basicStore.setShowSettingDialog(true);
      basicStore.setActiveSettingTab("video");
    }
    if (props.withPreview) {
      Vue.onMounted(async () => {
        var _a, _b;
        (_a = roomEngine.instance) == null ? void 0 : _a.startCameraDeviceTest({ view: "test-camera-preview" });
        if (environment.isElectron) {
          const trtcCloud = (_b = roomEngine.instance) == null ? void 0 : _b.getTRTCCloud();
          await (trtcCloud == null ? void 0 : trtcCloud.setLocalRenderParams({
            mirrorType: isLocalStreamMirror.value ? TUIRoomEngine.TRTCVideoMirrorType.TRTCVideoMirrorType_Enable : TUIRoomEngine.TRTCVideoMirrorType.TRTCVideoMirrorType_Disable,
            rotation: TUIRoomEngine.TRTCVideoRotation.TRTCVideoRotation0,
            fillMode: TUIRoomEngine.TRTCVideoFillMode.TRTCVideoFillMode_Fill
          }));
        }
      });
      Vue.onUnmounted(() => {
        var _a;
        (_a = roomEngine.instance) == null ? void 0 : _a.stopCameraDeviceTest();
      });
    }
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createElementBlock("div", {
        class: Vue.normalizeClass(["video-tab", themeClass.value])
      }, [
        Vue.createElementVNode("div", _hoisted_1, [
          Vue.createElementVNode("span", _hoisted_2, Vue.toDisplayString(Vue.unref(t)("Camera")), 1),
          Vue.createVNode(DeviceSelect.default, { "device-type": "camera" })
        ]),
        _ctx.withPreview ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_3, [
          Vue.createElementVNode("span", _hoisted_4, Vue.toDisplayString(Vue.unref(t)("Preview")), 1),
          _cache[1] || (_cache[1] = Vue.createElementVNode("div", { class: "video-preview-container" }, [
            Vue.createElementVNode("div", {
              id: "test-camera-preview",
              class: "video-preview"
            })
          ], -1))
        ])) : Vue.createCommentVNode("", true),
        Vue.createElementVNode("div", _hoisted_5, [
          Vue.createElementVNode("span", _hoisted_6, Vue.toDisplayString(Vue.unref(t)("Resolution")), 1),
          Vue.createVNode(VideoProfile.default)
        ]),
        Vue.createElementVNode("div", _hoisted_7, [
          Vue.createElementVNode("span", null, Vue.toDisplayString(Vue.unref(t)("Mirror")), 1),
          Vue.createVNode(TuiSwitch.default, {
            modelValue: Vue.unref(isLocalStreamMirror),
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(isLocalStreamMirror) ? isLocalStreamMirror.value = $event : null)
          }, null, 8, ["modelValue"])
        ]),
        _ctx.withMore ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_8, [
          Vue.createElementVNode("div", {
            class: "item",
            onClick: handleMoreCameraSetting
          }, Vue.toDisplayString(Vue.unref(t)("More Camera Settings")), 1)
        ])) : Vue.createCommentVNode("", true)
      ], 2);
    };
  }
});
exports.default = _sfc_main;
