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