import { defineComponent, ref, watch, computed, openBlock, createBlock, unref, withCtx, createElementVNode, createVNode, createTextVNode, toDisplayString, createElementBlock, Fragment, renderList } from "vue";
import { storeToRefs } from "pinia";
import { useI18n } from "../../locales/index.mjs";
import Dialog from "../common/base/Dialog/index.mjs";
import TuiButton from "../common/base/Button.vue.mjs";
import SuccessIcon from "../common/icons/SuccessIcon.vue.mjs";
import copyIcon from "../common/icons/CopyIcon.vue.mjs";
import SvgIcon from "../common/base/SvgIcon.vue.mjs";
import useRoomInfo from "../RoomHeader/RoomInfo/useRoomInfoHooks.mjs";
import { getUrlWithRoomId } from "../../utils/utils.mjs";
import { useBasicStore } from "../../stores/basic.mjs";
import "../../services/main.mjs";
import { roomService } from "../../services/roomService.mjs";
import "@tencentcloud/tuiroom-engine-js";
import "mitt";
import "../../services/manager/roomActionManager.mjs";
import "@tencentcloud/tui-core";
const _hoisted_1 = { class: "invite-member" };
const _hoisted_2 = { class: "invite-member-title" };
const _hoisted_3 = { class: "invite-member-item" };
const _hoisted_4 = { class: "invite-member-content" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "ShareLink",
  props: {
    conferenceInfo: {},
    scheduleParams: {},
    visible: { type: Boolean }
  },
  emits: ["input", "close"],
  setup(__props, { emit: __emit }) {
    const basicStore = useBasicStore();
    const { isRoomLinkVisible } = storeToRefs(basicStore);
    const roomLinkConfig = roomService.getComponentConfig("RoomLink");
    const { t } = useI18n();
    const { onCopy } = useRoomInfo();
    const props = __props;
    const emit = __emit;
    const showRoomInvite = ref(false);
    watch(
      () => props.visible,
      (val) => {
        showRoomInvite.value = val;
      },
      {
        immediate: true
      }
    );
    const updateVisible = (val) => {
      emit("input", val);
    };
    const roomType = computed(
      () => props.scheduleParams.isSeatEnabled ? `${t("On-stage Speaking Room")}` : `${t("Free Speech Room")}`
    );
    const isShowPassword = computed(() => !!props.scheduleParams.password);
    function copyRoomIdAndRoomLink() {
      const invitationList = [
        `${props.scheduleParams.roomName}`,
        `${t("Room Type")}: ${roomType.value}`,
        `${t("Room ID")}: ${props.scheduleParams.roomId}`
      ];
      if (isShowPassword.value) {
        invitationList.push(
          `${t("Room Password")}: ${props.scheduleParams.password}`
        );
      }
      if (isRoomLinkVisible.value && roomLinkConfig.visible) {
        invitationList.push(
          `${t("Room Link")}: ${getUrlWithRoomId(props.scheduleParams.roomId)}`
        );
      }
      const invitation = invitationList.join("\n");
      onCopy(invitation);
    }
    const scheduleInviteList = computed(() => [
      {
        id: 1,
        title: `${t("Invitation by room ID")}`,
        content: props.scheduleParams.roomId
      },
      {
        id: 2,
        title: `${t("Invitation via room link")}`,
        content: getUrlWithRoomId(props.scheduleParams.roomId)
      }
    ]);
    watch(
      showRoomInvite,
      (val) => {
        updateVisible(val);
      },
      { immediate: true }
    );
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Dialog), {
        modelValue: showRoomInvite.value,
        "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => showRoomInvite.value = $event),
        title: unref(t)("Schedule successful, invite members to join"),
        modal: true,
        "show-close": true,
        "close-on-click-modal": true,
        width: "540px",
        "append-to-body": true,
        "title-icon": SuccessIcon
      }, {
        footer: withCtx(() => [
          createElementVNode("span", null, [
            createVNode(TuiButton, {
              class: "dialog-button",
              size: "default",
              onClick: _cache[0] || (_cache[0] = ($event) => copyRoomIdAndRoomLink())
            }, {
              default: withCtx(() => [
                createTextVNode(toDisplayString(unref(t)("Copy the conference number and link")), 1)
              ]),
              _: 1
            })
          ])
        ]),
        default: withCtx(() => [
          createElementVNode("div", _hoisted_1, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(scheduleInviteList.value, (item) => {
              return openBlock(), createElementBlock("div", {
                key: item.id,
                class: "invite-member-container"
              }, [
                createElementVNode("div", _hoisted_2, toDisplayString(unref(t)(item.title)), 1),
                createElementVNode("div", _hoisted_3, [
                  createElementVNode("span", _hoisted_4, toDisplayString(item.content), 1),
                  createVNode(SvgIcon, {
                    class: "copy",
                    icon: copyIcon,
                    onClick: ($event) => unref(onCopy)(item.content)
                  }, null, 8, ["onClick"])
                ])
              ]);
            }), 128))
          ])
        ]),
        _: 1
      }, 8, ["modelValue", "title"]);
    };
  }
});
export {
  _sfc_main as default
};
