import { defineComponent, ref, watch, openBlock, createElementBlock, createElementVNode, createVNode, toDisplayString, unref, createCommentVNode, createBlock, withCtx, createTextVNode } from "vue";
import Avatar from "../../common/Avatar.vue.mjs";
import TuiButton from "../../common/base/Button.vue.mjs";
import { useI18n } from "../../../locales/index.mjs";
import "../../../services/main.mjs";
import { roomService } from "../../../services/roomService.mjs";
import { TUIInvitationStatus } from "@tencentcloud/tuiroom-engine-js";
import "mitt";
import "../../../services/manager/roomActionManager.mjs";
import "@tencentcloud/tui-core";
import renderMsg from "../../common/base/Message/Message.mjs";
import { MESSAGE_DURATION } from "../../../constants/message.mjs";
const _hoisted_1 = { class: "member-invite-container" };
const _hoisted_2 = { class: "member-invite-item" };
const _hoisted_3 = { class: "user-name" };
const _hoisted_4 = {
  key: 0,
  class: "member-invite-reject"
};
const _hoisted_5 = {
  key: 1,
  class: "member-invite-calling"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "MemberInvite",
  props: {
    userInfo: {}
  },
  setup(__props) {
    const { t } = useI18n();
    const showReject = ref(false);
    const handleInvite = () => {
      roomService.conferenceInvitationManager.inviteUsers({
        userIdList: [props.userInfo.userId]
      });
      renderMsg({
        type: "success",
        message: t("Invitation sent, waiting for members to join."),
        duration: MESSAGE_DURATION.NORMAL
      });
    };
    const props = __props;
    watch(props.userInfo, (val) => {
      if (val.status === TUIInvitationStatus.kRejected) {
        showReject.value = true;
        setTimeout(() => {
          showReject.value = false;
        }, 3e3);
      }
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          createVNode(Avatar, {
            class: "avatar-url",
            "img-src": _ctx.userInfo.avatarUrl
          }, null, 8, ["img-src"]),
          createElementVNode("div", _hoisted_3, toDisplayString(_ctx.userInfo.userId || _ctx.userInfo.userName), 1)
        ]),
        showReject.value ? (openBlock(), createElementBlock("span", _hoisted_4, toDisplayString(unref(t)("Not joining for now")), 1)) : createCommentVNode("", true),
        _ctx.userInfo.status === unref(TUIInvitationStatus).kPending ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(unref(t)("Calling...")), 1)) : (openBlock(), createBlock(TuiButton, {
          key: 2,
          class: "button",
          size: "default",
          onClick: handleInvite
        }, {
          default: withCtx(() => [
            createTextVNode(toDisplayString(unref(t)("Call")), 1)
          ]),
          _: 1
        }))
      ]);
    };
  }
});
export {
  _sfc_main as default
};
