import { defineComponent, computed, createElementBlock, openBlock, withModifiers, normalizeClass, createCommentVNode, createElementVNode, unref, createVNode, createBlock, normalizeStyle, toDisplayString } from "vue";
import { useUIKit, IconUser, IconMicOff, IconMicOn, IconScreenOpen } from "@tencentcloud/uikit-base-component-vue3";
import { useRoomParticipantState, VideoStreamType, DeviceStatus, RoomParticipantRole, Avatar } from "tuikit-atomicx-vue3/room";
const _hoisted_1 = {
  key: 0,
  class: "center-user-info-container"
};
const _hoisted_2 = { class: "corner-user-info-container" };
const _hoisted_3 = {
  key: 1,
  class: /* @__PURE__ */ normalizeClass(["audio-icon-container"])
};
const _hoisted_4 = { class: "audio-level-container" };
const _hoisted_5 = ["title"];
const _hoisted_6 = {
  key: 3,
  class: "screen-info"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    participant: {},
    streamType: {}
  },
  setup(__props) {
    const { t } = useUIKit();
    const props = __props;
    const { speakingUsers } = useRoomParticipantState();
    const activeSpeaking = computed(() => {
      const hasSpeakVolume = speakingUsers.value.get(props.participant.userId);
      if (!hasSpeakVolume) {
        return false;
      } else
        return hasSpeakVolume > 0 && props.streamType === VideoStreamType.Camera && props.participant.microphoneStatus !== DeviceStatus.Off;
    });
    const speakingAudioVolume = computed(
      () => speakingUsers.value.get(props.participant.userId) || 0
    );
    const audioLevelStyle = computed(() => {
      if (props.participant.microphoneStatus === DeviceStatus.Off || !activeSpeaking.value) {
        return "";
      }
      return `height: ${speakingAudioVolume.value * 4}%`;
    });
    const displayName = computed(
      () => props.participant.nameCard || props.participant.userName || props.participant.userId
    );
    const showMasterIcon = computed(() => {
      const { role } = props.participant;
      return role === RoomParticipantRole.Owner && props.streamType === VideoStreamType.Camera;
    });
    const showAdminIcon = computed(() => {
      const { role } = props.participant;
      return role === RoomParticipantRole.Admin && props.streamType === VideoStreamType.Camera;
    });
    const showIcon = computed(() => showMasterIcon.value || showAdminIcon.value);
    const isScreenStream = computed(
      () => props.streamType === VideoStreamType.Screen
    );
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(["stream-cover-container", { border: activeSpeaking.value }]),
        onContextmenu: _cache[0] || (_cache[0] = withModifiers(() => {
        }, ["prevent"]))
      }, [
        __props.streamType === unref(VideoStreamType).Camera && __props.participant.cameraStatus === unref(DeviceStatus).Off ? (openBlock(), createElementBlock("div", _hoisted_1, [
          createVNode(unref(Avatar), {
            class: "avatar-region",
            size: "xl",
            src: __props.participant.avatarUrl,
            "user-id": __props.participant.userId
          }, null, 8, ["src", "user-id"])
        ])) : createCommentVNode("", true),
        createElementVNode("div", _hoisted_2, [
          showIcon.value ? (openBlock(), createElementBlock("div", {
            key: 0,
            class: normalizeClass(showMasterIcon.value ? "master-icon" : "admin-icon")
          }, [
            createVNode(unref(IconUser))
          ], 2)) : createCommentVNode("", true),
          !isScreenStream.value ? (openBlock(), createElementBlock("div", _hoisted_3, [
            createElementVNode("div", _hoisted_4, [
              createElementVNode("div", {
                class: "audio-level",
                style: normalizeStyle(audioLevelStyle.value)
              }, null, 4)
            ]),
            __props.participant.microphoneStatus === unref(DeviceStatus).Off ? (openBlock(), createBlock(unref(IconMicOff), {
              key: 0,
              class: "audio-icon",
              size: "20"
            })) : (openBlock(), createBlock(unref(IconMicOn), {
              key: 1,
              class: "audio-icon",
              size: "20"
            }))
          ])) : createCommentVNode("", true),
          isScreenStream.value ? (openBlock(), createBlock(unref(IconScreenOpen), {
            key: 2,
            class: "screen-icon",
            size: "18"
          })) : createCommentVNode("", true),
          createElementVNode("span", {
            class: normalizeClass(["user-name", "is-pc"]),
            title: displayName.value
          }, toDisplayString(displayName.value), 9, _hoisted_5),
          isScreenStream.value ? (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString(unref(t)("RoomView.IsSharingTheirScreen")), 1)) : createCommentVNode("", true)
        ])
      ], 34);
    };
  }
});
export {
  _sfc_main as default
};
