"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");
require("../../hooks/useRoomSidePanel.js");
;/* empty css                                    */
;/* empty css                                        */
;/* empty css                                            */
require("tuikit-atomicx-vue3/chat");
require("../../utils/utils.js");
;/* empty css                                         */
;/* empty css                                     */
const index$7 = require("../../components/CallButtonH5/index.vue2.js");
;/* empty css                                       */
const index$6 = require("../../components/CameraButtonH5/index.vue2.js");
;/* empty css                                          */
const index$3 = require("../../components/ExpandFooterH5/index.vue2.js");
;/* empty css                                         */
;/* empty css                                           */
;/* empty css                                         */
;/* empty css                                       */
require("@tencentcloud/tuiroom-engine-js");
;/* empty css                                                  */
;/* empty css                                                 */
const index$1 = require("../../components/LeaveRoomButtonH5/index.vue2.js");
;/* empty css                                         */
;/* empty css                                           */
;/* empty css                                        */
;/* empty css                                        */
;/* empty css                                          */
;/* empty css                                        */
;/* empty css                                    */
const index$5 = require("../../components/MicButtonH5/index.vue2.js");
;/* empty css                                     */
const index$4 = require("../../components/ParticipantButtonH5/index.vue2.js");
;/* empty css                                         */
const index$8 = require("../../components/PasswordDialogH5/index.vue2.js");
;/* empty css                                           */
require("tuikit-atomicx-vue3/live");
;/* empty css                                            */
;/* empty css                                           */
;/* empty css                                            */
;/* empty css                                   */
const ChatButton = require("../../components/RoomChatH5/ChatButton.vue2.js");
;/* empty css                                                      */
const index = require("../../components/RoomITitleH5/index.vue2.js");
;/* empty css                                                                               */
;/* empty css                                                                               */
;/* empty css                                                                  */
const index$2 = require("../../components/RoomLayoutViewH5/index.vue2.js");
;/* empty css                                        */
;/* empty css                                                                */
;/* empty css                                              */
;/* empty css                                            */
;/* empty css                                                */
;/* empty css                                                 */
const index_vue_vue_type_script_setup_true_lang$1 = ;/* empty css                                          */
;/* empty css                                          */
;/* empty css                                            */
const index_vue_vue_type_script_setup_true_lang = ;/* empty css                                               */
;/* empty css                                      */
;/* empty css                                                  */
;/* empty css                                         */
const useCustomizedAutoPlayDialog = require("../../hooks/useCustomizedAutoPlayDialog.js");
const useRoomTips = require("../../hooks/useRoomTips.js");
const useRoomToolbarH5 = require("../../hooks/useRoomToolbarH5.js");
const useRoomLifeCycle = require("../../hooks/useRoomLifeCycle.js");
const eventCenter = require("../../utils/eventCenter.js");
const type = require("../../adapter/type.js");
const _hoisted_1 = {
  id: "roomPage",
  class: "room-page"
};
const _hoisted_2 = { class: "room-container" };
const _hoisted_3 = { class: "header" };
const _hoisted_4 = { class: "header-left" };
const _hoisted_5 = { class: "header-center" };
const _hoisted_6 = { class: "header-right" };
const _hoisted_7 = { class: "room-footer" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "index",
  setup(__props) {
    const { t } = uikitBaseComponentVue3.useUIKit();
    const { showToolbar, toggleToolbar } = useRoomToolbarH5.useRoomToolbarH5();
    useCustomizedAutoPlayDialog.default();
    useRoomTips.useRoomTips();
    const { loginUserInfo } = room.useLoginState();
    const { currentRoom } = room.useRoomState();
    const {
      getParticipantList,
      participantListCursor,
      subscribeEvent: subscribeRoomParticipantEvent,
      unsubscribeEvent: unsubscribeRoomParticipantEvent
    } = room.useRoomParticipantState();
    const {
      subscribeEvent: subscribeRoomEvent,
      unsubscribeEvent: unsubscribeRoomEvent
    } = room.useRoomState();
    const {
      isJoiningRoom,
      joiningRoomId,
      roomPasswordVisible,
      handleJoinRoomError
    } = useRoomLifeCycle.default();
    vue.watch(
      () => {
        var _a;
        return (_a = currentRoom.value) == null ? void 0 : _a.roomId;
      },
      async (roomId, oldRoomId) => {
        if (!oldRoomId && roomId) {
          await getParticipantList({ cursor: participantListCursor.value });
        }
      },
      { 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, {});
    };
    vue.onMounted(() => {
      subscribeRoomEvent(room.RoomEvent.onRoomEnded, onRoomEnded);
      subscribeRoomParticipantEvent(
        room.RoomParticipantEvent.onKickedFromRoom,
        onKickedFromRoom
      );
    });
    vue.onUnmounted(() => {
      unsubscribeRoomEvent(room.RoomEvent.onRoomEnded, onRoomEnded);
      unsubscribeRoomParticipantEvent(
        room.RoomParticipantEvent.onKickedFromRoom,
        onKickedFromRoom
      );
    });
    return (_ctx, _cache) => {
      var _a, _b;
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createElementVNode("div", _hoisted_2, [
          vue.withDirectives(vue.createElementVNode("header", _hoisted_3, [
            vue.createElementVNode("div", _hoisted_4, [
              vue.createVNode(vue.unref(index_vue_vue_type_script_setup_true_lang.default))
            ]),
            vue.createElementVNode("div", _hoisted_5, [
              vue.createVNode(vue.unref(index.default))
            ]),
            vue.createElementVNode("div", _hoisted_6, [
              vue.createVNode(vue.unref(index$1.default), {
                onLeave: handleLeaveRoom,
                onEnd: handleEndRoom
              })
            ])
          ], 512), [
            [vue.vShow, vue.unref(showToolbar)]
          ]),
          vue.withDirectives((vue.openBlock(), vue.createElementBlock("main", {
            class: "room-main",
            onClick: _cache[0] || (_cache[0] = //@ts-ignore
            (...args) => vue.unref(toggleToolbar) && vue.unref(toggleToolbar)(...args))
          }, [
            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) || ""
              ],
              gap: [0, 100]
            }, {
              default: vue.withCtx(() => [
                vue.createVNode(vue.unref(index$2.default))
              ]),
              _: 1
            }, 8, ["content"])
          ])), [
            [vue.unref(uikitBaseComponentVue3.vTuiLoading), {
              visible: vue.unref(isJoiningRoom),
              text: vue.unref(t)("Room.EnteringRoom"),
              background: "transparent"
            }]
          ]),
          vue.withDirectives(vue.createElementVNode("footer", _hoisted_7, [
            vue.createVNode(vue.unref(index$3.default), null, {
              default: vue.withCtx(() => [
                vue.createVNode(vue.unref(index$4.default)),
                vue.createVNode(vue.unref(index$5.default)),
                vue.createVNode(vue.unref(index$6.default)),
                vue.createVNode(vue.unref(index$7.default)),
                vue.createVNode(vue.unref(ChatButton.default)),
                vue.createVNode(vue.unref(index_vue_vue_type_script_setup_true_lang$1.default))
              ]),
              _: 1
            })
          ], 512), [
            [vue.vShow, vue.unref(showToolbar)]
          ]),
          vue.createVNode(vue.unref(index$8.default), {
            modelValue: vue.unref(roomPasswordVisible),
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($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"])
        ])
      ]);
    };
  }
});
exports.default = _sfc_main;
