import { defineComponent, ref, createElementBlock, openBlock, createVNode, unref, withCtx, createTextVNode, toDisplayString, createElementVNode } from "vue";
import { useUIKit, TUIButton, IconScheduleRoom, TUIDialog, TUIToast } from "@tencentcloud/uikit-base-component-vue3";
import { useLoginState, RoomType, ScheduleRoomPanel } from "tuikit-atomicx-vue3/room";
import RoomInviteSuccessDialog from "./RoomInviteSuccessDialog.vue2.mjs";
const _hoisted_1 = { class: "room-button" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  setup(__props) {
    const { t } = useUIKit();
    const { loginUserInfo } = useLoginState();
    const showSchedulePanel = ref(false);
    const showSuccessDialog = ref(false);
    const scheduledRoomId = ref("");
    const scheduledPassword = ref("");
    const scheduledRoomType = ref(RoomType.Standard);
    const handleScheduleRoom = () => {
      var _a;
      if (!((_a = loginUserInfo.value) == null ? void 0 : _a.userId)) {
        TUIToast.error({ message: t("Button.PleaseLoginFirst") });
        return;
      }
      showSchedulePanel.value = true;
    };
    const handleCancel = () => {
      showSchedulePanel.value = false;
    };
    const handleConfirm = async (roomId, scheduleOptions) => {
      showSchedulePanel.value = false;
      scheduledRoomId.value = roomId;
      scheduledPassword.value = scheduleOptions.password || "";
      showSuccessDialog.value = true;
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(unref(TUIButton), {
          class: "button",
          size: "large",
          type: "primary",
          icon: unref(IconScheduleRoom),
          onClick: handleScheduleRoom
        }, {
          default: withCtx(() => [
            createTextVNode(toDisplayString(unref(t)("Button.ScheduleRoom")), 1)
          ]),
          _: 1
        }, 8, ["icon"]),
        createVNode(unref(TUIDialog), {
          visible: showSchedulePanel.value,
          "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => showSchedulePanel.value = $event),
          title: unref(t)("Button.ScheduleMeeting")
        }, {
          footer: withCtx(() => [..._cache[2] || (_cache[2] = [
            createElementVNode("div", null, null, -1)
          ])]),
          default: withCtx(() => [
            createVNode(unref(ScheduleRoomPanel), {
              onCancel: handleCancel,
              onConfirm: handleConfirm
            })
          ]),
          _: 1
        }, 8, ["visible", "title"]),
        createVNode(RoomInviteSuccessDialog, {
          visible: showSuccessDialog.value,
          "onUpdate:visible": _cache[1] || (_cache[1] = ($event) => showSuccessDialog.value = $event),
          "room-id": scheduledRoomId.value,
          password: scheduledPassword.value,
          "room-type": scheduledRoomType.value
        }, null, 8, ["visible", "room-id", "password", "room-type"])
      ]);
    };
  }
});
export {
  _sfc_main as default
};
