"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const uikitBaseComponentVue3 = require("@tencentcloud/uikit-base-component-vue3");
const room = require("tuikit-atomicx-vue3/room");
const conference = require("../../adapter/conference.js");
const type = require("../../adapter/type.js");
const index$c = require("../../components/AIToolsButton/index.vue2.js");
const index_vue_vue_type_script_setup_true_lang$4 = require("../../components/BasicBeautyButton/index.vue2.js");
;/* empty css                                            */
const index$a = require("../../components/CallButton/index.vue2.js");
require("tuikit-atomicx-vue3/chat");
;/* empty css                                      */
;/* empty css                                        */
require("../../utils/utils.js");
;/* empty css                                           */
;/* empty css                                       */
const index$7 = require("../../components/CameraButton/index.vue2.js");
;/* empty css                                         */
const index$3 = require("../../components/CurrentRoomInfo/index.vue2.js");
;/* empty css                                              */
;/* empty css                                         */
;/* empty css                                         */
;/* empty css                                           */
const index$4 = require("../../components/LanguageButton/index.vue2.js");
const index$1 = require("../../components/LayoutButton/index.vue2.js");
const index_vue_vue_type_script_setup_true_lang$6 = ;/* empty css                                          */
require("@tencentcloud/tuiroom-engine-js");
;/* empty css                                            */
;/* empty css                                         */
const index$2 = require("../../components/LocalNetworkInfo/index.vue2.js");
const index$5 = require("../../components/LoginUserInfo/index.vue2.js");
;/* empty css                                          */
const index$6 = require("../../components/MicButton/index.vue2.js");
;/* empty css                                          */
;/* empty css                                      */
const index$b = require("../../components/MoreButton/index.vue2.js");
const index_vue_vue_type_script_setup_true_lang$2 = ;/* empty css                                            */
;/* empty css                                              */
const index$d = require("../../components/PasswordDialog/index.vue2.js");
;/* empty css                                           */
const index$8 = require("../../components/RaiseHandsButton/index.vue2.js");
const BarrageButton_vue_vue_type_script_setup_true_lang = require("../../components/RoomBarrage/BarrageButton.vue.js");
const RoomBarrage = require("../../components/RoomBarrage/RoomBarrage.vue2.js");
const ChatButton_vue_vue_type_script_setup_true_lang = ;/* empty css                                        */
const index$f = require("../../components/RoomChat/index.vue2.js");
;/* empty css                                             */
;/* empty css                                              */
;/* empty css                                        */
;/* empty css                                          */
;/* empty css                                                      */
;/* empty css                                                 */
;/* empty css                                       */
const index_vue_vue_type_script_setup_true_lang = ;/* empty css                                         */
;/* empty css                                                             */
;/* empty css                                           */
const index$e = require("../../components/RoomSidePanel/index.vue2.js");
;/* empty css                                                                */
;/* empty css                                              */
const index$9 = require("../../components/ScreenShareButton/index.vue2.js");
const index_vue_vue_type_script_setup_true_lang$5 = ;/* empty css                                        */
;/* empty css                                                 */
;/* empty css                                          */
;/* empty css                                            */
const index = require("../../components/ThemeButton/index.vue2.js");
const index_vue_vue_type_script_setup_true_lang$3 = require("../../components/VirtualBackgroundButton/index.vue2.js");
;/* empty css                                                  */
const index_vue_vue_type_script_setup_true_lang$1 = require("../../components/RaiseHandsList/index.vue2.js");
;/* empty css                                         */
const useCustomizedAutoPlayDialog = require("../../hooks/useCustomizedAutoPlayDialog.js");
const useRoomLifeCycle = require("../../hooks/useRoomLifeCycle.js");
const useRoomSidePanel = require("../../hooks/useRoomSidePanel.js");
const useRoomTips = require("../../hooks/useRoomTips.js");
const useRoomToolbar = require("../../hooks/useRoomToolbar.js");
const eventCenter = require("../../utils/eventCenter.js");
const _hoisted_1 = { class: "header" };
const _hoisted_2 = { class: "header-left" };
const _hoisted_3 = { class: "header-center" };
const _hoisted_4 = { class: "header-right" };
const _hoisted_5 = { class: "room-main" };
const _hoisted_6 = { class: "control-bar" };
const _hoisted_7 = {
  key: 0,
  class: "control-left"
};
const _hoisted_8 = {
  key: 1,
  class: "control-left"
};
const _hoisted_9 = { class: "control-center" };
const _hoisted_10 = { class: "control-right" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "index",
  setup(__props) {
    const AIToolsButtonConfig = conference.conference.getComponentConfig(type.ComponentName.AIToolsButton);
    const { t } = uikitBaseComponentVue3.useUIKit();
    const roomPageRef = vue.ref(null);
    const { showToolbar } = useRoomToolbar.useRoomToolbar(roomPageRef);
    const { activeTab, sidePanelTitle, toggleSidePanel, closePanel } = useRoomSidePanel.useRoomSidePanel();
    useCustomizedAutoPlayDialog.default();
    useRoomTips.useRoomTips();
    const { loginUserInfo } = room.useLoginState();
    const {
      currentRoom,
      subscribeEvent: subscribeRoomEvent,
      unsubscribeEvent: unsubscribeRoomEvent
    } = room.useRoomState();
    const {
      localParticipant,
      participantList,
      audienceListCursor,
      participantListCursor,
      getParticipantList,
      getAudienceList,
      subscribeEvent: subscribeRoomParticipantEvent,
      unsubscribeEvent: unsubscribeRoomParticipantEvent
    } = room.useRoomParticipantState();
    const { startRealtimeTranscriber } = room.useAITranscriberState();
    const {
      isJoiningRoom,
      joiningRoomId,
      roomPasswordVisible,
      handleJoinRoomError
    } = useRoomLifeCycle.default();
    const isWebinar = vue.computed(() => {
      var _a;
      return ((_a = currentRoom.value) == null ? void 0 : _a.roomType) === room.RoomType.Webinar;
    });
    const isOwner = vue.computed(() => {
      var _a;
      return ((_a = localParticipant.value) == null ? void 0 : _a.role) === room.RoomParticipantRole.Owner;
    });
    const isGuest = vue.computed(() => participantList.value.some((participant) => {
      var _a;
      return participant.userId === ((_a = localParticipant.value) == null ? void 0 : _a.userId);
    }));
    const isAudience = vue.computed(() => !participantList.value.some((participant) => {
      var _a;
      return participant.userId === ((_a = localParticipant.value) == null ? void 0 : _a.userId);
    }));
    const participantViewLayout = vue.ref(void 0);
    function handleLayoutUpdate(layout) {
      participantViewLayout.value = layout;
    }
    vue.watch(() => {
      var _a;
      return (_a = currentRoom.value) == null ? void 0 : _a.roomType;
    }, (newRoomType) => {
      if (newRoomType === room.RoomType.Webinar) {
        participantViewLayout.value = void 0;
      } else {
        participantViewLayout.value = room.RoomLayoutTemplate.GridLayout;
      }
    }, { immediate: true });
    vue.watch(
      () => {
        var _a;
        return (_a = currentRoom.value) == null ? void 0 : _a.roomId;
      },
      async (roomId, oldRoomId) => {
        if (!oldRoomId && roomId) {
          await getParticipantList({ cursor: participantListCursor.value });
          await getAudienceList({ cursor: audienceListCursor.value });
          if (isOwner.value && (AIToolsButtonConfig == null ? void 0 : AIToolsButtonConfig.visible)) {
            await startRealtimeTranscriber({
              sourceLanguage: "zh",
              translationLanguages: ["en"]
            });
          }
        }
      },
      { immediate: true }
    );
    const handlePasswordCancel = () => {
      eventCenter.eventCenter.emit(type.RoomEvent.ROOM_ERROR);
    };
    const handleLeaveRoom = () => {
      eventCenter.eventCenter.emit(type.RoomEvent.ROOM_LEAVE);
    };
    const handleEndRoom = () => {
      eventCenter.eventCenter.emit(type.RoomEvent.ROOM_DISMISS);
    };
    const onRoomEnded = () => {
      eventCenter.eventCenter.emit(type.RoomEvent.ROOM_DISMISS, {});
    };
    const onKickedFromRoom = (eventInfo) => {
      eventCenter.eventCenter.emit(type.RoomEvent.KICKED_OUT, eventInfo);
    };
    vue.onMounted(() => {
      subscribeRoomEvent(room.RoomEvent.onRoomEnded, onRoomEnded);
      subscribeRoomParticipantEvent(
        room.RoomParticipantEvent.onKickedFromRoom,
        onKickedFromRoom
      );
    });
    vue.onUnmounted(() => {
      unsubscribeRoomEvent(room.RoomEvent.onRoomEnded, onRoomEnded);
      unsubscribeRoomParticipantEvent(
        room.RoomParticipantEvent.onKickedFromRoom,
        onKickedFromRoom
      );
      closePanel();
    });
    return (_ctx, _cache) => {
      var _a, _b;
      return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
        id: "roomPage",
        ref_key: "roomPageRef",
        ref: roomPageRef,
        class: "room-page"
      }, [
        vue.createElementVNode("div", {
          class: vue.normalizeClass(["room-container", { "has-side-panel": vue.unref(activeTab) }])
        }, [
          vue.withDirectives(vue.createElementVNode("header", _hoisted_1, [
            vue.createElementVNode("div", _hoisted_2, [
              vue.createVNode(vue.unref(index.default)),
              !isWebinar.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$1.default), {
                key: 0,
                layout: participantViewLayout.value,
                "onUpdate:layout": handleLayoutUpdate
              }, null, 8, ["layout"])) : vue.createCommentVNode("", true),
              vue.createVNode(vue.unref(index$2.default))
            ]),
            vue.createElementVNode("div", _hoisted_3, [
              vue.createVNode(vue.unref(index$3.default))
            ]),
            vue.createElementVNode("div", _hoisted_4, [
              vue.createVNode(vue.unref(index$4.default)),
              vue.createVNode(vue.unref(index$5.default), { "show-logout": false })
            ])
          ], 512), [
            [vue.vShow, vue.unref(showToolbar)]
          ]),
          vue.createElementVNode("main", _hoisted_5, [
            vue.createVNode(vue.unref(uikitBaseComponentVue3.TUIWatermark), {
              font: { fontSize: 16 },
              content: [
                ((_a = vue.unref(loginUserInfo)) == null ? void 0 : _a.userName) || "",
                ((_b = vue.unref(loginUserInfo)) == null ? void 0 : _b.userId) || ""
              ]
            }, {
              default: vue.withCtx(() => [
                vue.createVNode(vue.unref(index_vue_vue_type_script_setup_true_lang.default), {
                  "layout-template": participantViewLayout.value,
                  "onUpdate:layoutTemplate": handleLayoutUpdate
                }, null, 8, ["layout-template"])
              ]),
              _: 1
            }, 8, ["content"])
          ]),
          vue.withDirectives(vue.createElementVNode("footer", _hoisted_6, [
            isWebinar.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
              isGuest.value || isOwner.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$6.default), { key: 0 })) : vue.createCommentVNode("", true),
              isOwner.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$7.default), { key: 1 })) : vue.createCommentVNode("", true),
              isAudience.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$8.default), { key: 2 })) : vue.createCommentVNode("", true)
            ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [
              vue.createVNode(vue.unref(index$6.default)),
              vue.createVNode(vue.unref(index$7.default))
            ])),
            vue.createElementVNode("div", _hoisted_9, [
              !isWebinar.value || isOwner.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$9.default), { key: 0 })) : vue.createCommentVNode("", true),
              !isWebinar.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$a.default), { key: 1 })) : vue.createCommentVNode("", true),
              isWebinar.value ? (vue.openBlock(), vue.createBlock(vue.unref(BarrageButton_vue_vue_type_script_setup_true_lang.default), {
                key: 2,
                "is-chat-open": vue.unref(activeTab) === vue.unref(useRoomSidePanel.RoomTabKey).Barrage,
                onClick: _cache[0] || (_cache[0] = ($event) => vue.unref(toggleSidePanel)(vue.unref(useRoomSidePanel.RoomTabKey).Barrage))
              }, null, 8, ["is-chat-open"])) : vue.createCommentVNode("", true),
              isWebinar.value && isOwner.value ? (vue.openBlock(), vue.createBlock(vue.unref(index_vue_vue_type_script_setup_true_lang$1.default), { key: 3 })) : vue.createCommentVNode("", true),
              !isWebinar.value ? (vue.openBlock(), vue.createBlock(vue.unref(ChatButton_vue_vue_type_script_setup_true_lang.default), {
                key: 4,
                "is-chat-open": vue.unref(activeTab) === vue.unref(useRoomSidePanel.RoomTabKey).Chat,
                onClick: _cache[1] || (_cache[1] = ($event) => vue.unref(toggleSidePanel)(vue.unref(useRoomSidePanel.RoomTabKey).Chat))
              }, null, 8, ["is-chat-open"])) : vue.createCommentVNode("", true),
              vue.createVNode(vue.unref(index_vue_vue_type_script_setup_true_lang$2.default), {
                onClick: _cache[2] || (_cache[2] = ($event) => vue.unref(toggleSidePanel)(vue.unref(useRoomSidePanel.RoomTabKey).ParticipantList))
              }),
              !isWebinar.value || isOwner.value ? (vue.openBlock(), vue.createBlock(vue.unref(index$b.default), { key: 5 }, {
                default: vue.withCtx(() => {
                  var _a2;
                  return [
                    !isWebinar.value ? (vue.openBlock(), vue.createBlock(vue.unref(index_vue_vue_type_script_setup_true_lang$3.default), { key: 0 })) : vue.createCommentVNode("", true),
                    !isWebinar.value || isOwner.value ? (vue.openBlock(), vue.createBlock(vue.unref(index_vue_vue_type_script_setup_true_lang$4.default), { key: 1 })) : vue.createCommentVNode("", true),
                    !isWebinar.value && ((_a2 = vue.unref(AIToolsButtonConfig)) == null ? void 0 : _a2.visible) ? (vue.openBlock(), vue.createBlock(vue.unref(index$c.default), { key: 2 })) : vue.createCommentVNode("", true),
                    !isWebinar.value || isOwner.value ? (vue.openBlock(), vue.createBlock(vue.unref(index_vue_vue_type_script_setup_true_lang$5.default), { key: 3 })) : vue.createCommentVNode("", true)
                  ];
                }),
                _: 1
              })) : vue.createCommentVNode("", true)
            ]),
            vue.createElementVNode("div", _hoisted_10, [
              vue.createVNode(vue.unref(index_vue_vue_type_script_setup_true_lang$6.default), {
                onLeave: handleLeaveRoom,
                onEnd: handleEndRoom
              })
            ])
          ], 512), [
            [vue.vShow, vue.unref(showToolbar)]
          ]),
          vue.createVNode(vue.unref(index$d.default), {
            modelValue: vue.unref(roomPasswordVisible),
            "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => vue.isRef(roomPasswordVisible) ? roomPasswordVisible.value = $event : null),
            "room-id": vue.unref(joiningRoomId),
            onCancel: handlePasswordCancel,
            onError: vue.unref(handleJoinRoomError)
          }, null, 8, ["modelValue", "room-id", "onError"])
        ], 2),
        vue.createVNode(vue.unref(index$e.default), {
          class: vue.normalizeClass(["side-panel", { "side-panel-visible": vue.unref(activeTab) }]),
          title: vue.unref(sidePanelTitle),
          onClose: vue.unref(closePanel)
        }, {
          default: vue.withCtx(() => [
            vue.unref(activeTab) === vue.unref(useRoomSidePanel.RoomTabKey).ParticipantList ? (vue.openBlock(), vue.createBlock(vue.unref(room.RoomParticipantList), { key: 0 })) : vue.createCommentVNode("", true),
            !isWebinar.value ? vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(index$f.default), {
              key: 1,
              "is-chat-open": vue.unref(activeTab) === vue.unref(useRoomSidePanel.RoomTabKey).Chat
            }, null, 8, ["is-chat-open"])), [
              [vue.vShow, vue.unref(activeTab) === vue.unref(useRoomSidePanel.RoomTabKey).Chat]
            ]) : vue.createCommentVNode("", true),
            vue.withDirectives(vue.createVNode(RoomBarrage.default, {
              "is-chat-open": vue.unref(activeTab) === vue.unref(useRoomSidePanel.RoomTabKey).Barrage
            }, null, 8, ["is-chat-open"]), [
              [vue.vShow, isWebinar.value && vue.unref(activeTab) === vue.unref(useRoomSidePanel.RoomTabKey).Barrage]
            ]),
            vue.unref(activeTab) === vue.unref(useRoomSidePanel.RoomTabKey).AIToolsRealtimeMessageList ? (vue.openBlock(), vue.createBlock(vue.unref(room.RealtimeMessageList), { key: 2 })) : vue.createCommentVNode("", true)
          ]),
          _: 1
        }, 8, ["class", "title", "onClose"])
      ])), [
        [vue.unref(uikitBaseComponentVue3.vTuiLoading), {
          visible: vue.unref(isJoiningRoom),
          text: vue.unref(t)("Room.EnteringRoom"),
          background: "var(--bg-color-topbar)"
        }]
      ]);
    };
  }
});
exports.default = _sfc_main;
