"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const pinia = require("pinia");
const index = require("../../locales/index.js");
const index$1 = require("../common/base/Dialog/index.js");
const Button = require("../common/base/Button.vue.js");
const SuccessIcon = require("../common/icons/SuccessIcon.vue.js");
const CopyIcon = require("../common/icons/CopyIcon.vue.js");
const SvgIcon = require("../common/base/SvgIcon.vue.js");
const useRoomInfoHooks = require("../RoomHeader/RoomInfo/useRoomInfoHooks.js");
const utils = require("../../utils/utils.js");
const basic = require("../../stores/basic.js");
require("../../services/main.js");
const roomService = require("../../services/roomService.js");
require("@tencentcloud/tuiroom-engine-js");
require("mitt");
require("../../services/manager/roomActionManager.js");
require("@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__ */ Vue.defineComponent({
  __name: "ShareLink",
  props: {
    conferenceInfo: {},
    scheduleParams: {},
    visible: { type: Boolean }
  },
  emits: ["input", "close"],
  setup(__props, { emit: __emit }) {
    const basicStore = basic.useBasicStore();
    const { isRoomLinkVisible } = pinia.storeToRefs(basicStore);
    const roomLinkConfig = roomService.roomService.getComponentConfig("RoomLink");
    const { t } = index.useI18n();
    const { onCopy } = useRoomInfoHooks.default();
    const props = __props;
    const emit = __emit;
    const showRoomInvite = Vue.ref(false);
    Vue.watch(
      () => props.visible,
      (val) => {
        showRoomInvite.value = val;
      },
      {
        immediate: true
      }
    );
    const updateVisible = (val) => {
      emit("input", val);
    };
    const roomType = Vue.computed(
      () => props.scheduleParams.isSeatEnabled ? `${t("On-stage Speaking Room")}` : `${t("Free Speech Room")}`
    );
    const isShowPassword = Vue.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")}: ${utils.getUrlWithRoomId(props.scheduleParams.roomId)}`
        );
      }
      const invitation = invitationList.join("\n");
      onCopy(invitation);
    }
    const scheduleInviteList = Vue.computed(() => [
      {
        id: 1,
        title: `${t("Invitation by room ID")}`,
        content: props.scheduleParams.roomId
      },
      {
        id: 2,
        title: `${t("Invitation via room link")}`,
        content: utils.getUrlWithRoomId(props.scheduleParams.roomId)
      }
    ]);
    Vue.watch(
      showRoomInvite,
      (val) => {
        updateVisible(val);
      },
      { immediate: true }
    );
    return (_ctx, _cache) => {
      return Vue.openBlock(), Vue.createBlock(Vue.unref(index$1.default), {
        modelValue: showRoomInvite.value,
        "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => showRoomInvite.value = $event),
        title: Vue.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.default
      }, {
        footer: Vue.withCtx(() => [
          Vue.createElementVNode("span", null, [
            Vue.createVNode(Button.default, {
              class: "dialog-button",
              size: "default",
              onClick: _cache[0] || (_cache[0] = ($event) => copyRoomIdAndRoomLink())
            }, {
              default: Vue.withCtx(() => [
                Vue.createTextVNode(Vue.toDisplayString(Vue.unref(t)("Copy the conference number and link")), 1)
              ]),
              _: 1
            })
          ])
        ]),
        default: Vue.withCtx(() => [
          Vue.createElementVNode("div", _hoisted_1, [
            (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(scheduleInviteList.value, (item) => {
              return Vue.openBlock(), Vue.createElementBlock("div", {
                key: item.id,
                class: "invite-member-container"
              }, [
                Vue.createElementVNode("div", _hoisted_2, Vue.toDisplayString(Vue.unref(t)(item.title)), 1),
                Vue.createElementVNode("div", _hoisted_3, [
                  Vue.createElementVNode("span", _hoisted_4, Vue.toDisplayString(item.content), 1),
                  Vue.createVNode(SvgIcon.default, {
                    class: "copy",
                    icon: CopyIcon.default,
                    onClick: ($event) => Vue.unref(onCopy)(item.content)
                  }, null, 8, ["onClick"])
                ])
              ]);
            }), 128))
          ])
        ]),
        _: 1
      }, 8, ["modelValue", "title"]);
    };
  }
});
exports.default = _sfc_main;
