"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 IconButton = require("../base/IconButton.vue2.js");
const _hoisted_1 = { class: "pending-device-invitations" };
const _hoisted_2 = {
  key: 0,
  class: "pending-device-invitation-empty"
};
const _hoisted_3 = { class: "user-info" };
const _hoisted_4 = { class: "user-name" };
const _hoisted_5 = { class: "action-area" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "index",
  setup(__props) {
    const { t } = uikitBaseComponentVue3.useUIKit();
    const {
      pendingDeviceApplications,
      approveOpenDeviceRequest,
      rejectOpenDeviceRequest,
      promoteToParticipant
    } = room.useRoomParticipantState();
    const unreadCount = vue.computed(() => pendingDeviceApplications.value.length);
    const dialogVisible = vue.ref(false);
    const handleClick = () => {
      dialogVisible.value = true;
    };
    const handleAccept = (invitation) => {
      approveOpenDeviceRequest({ device: invitation.deviceType, userId: invitation.senderUserId });
      promoteToParticipant({ userId: invitation.senderUserId });
    };
    const handleReject = (invitation) => {
      rejectOpenDeviceRequest({ device: invitation.deviceType, userId: invitation.senderUserId });
    };
    return (_ctx, _cache) => {
      return vue.openBlock(), vue.createElementBlock("div", null, [
        vue.createVNode(IconButton.default, {
          title: vue.unref(t)("RaiseHands.List"),
          onClick: handleClick
        }, {
          default: vue.withCtx(() => [
            vue.createVNode(vue.unref(uikitBaseComponentVue3.Badge), {
              value: unreadCount.value,
              hidden: !unreadCount.value
            }, {
              default: vue.withCtx(() => [
                vue.createVNode(vue.unref(uikitBaseComponentVue3.IconApplyManage), { size: 24 })
              ]),
              _: 1
            }, 8, ["value", "hidden"])
          ]),
          _: 1
        }, 8, ["title"]),
        vue.createVNode(vue.unref(uikitBaseComponentVue3.TUIDialog), {
          visible: dialogVisible.value,
          "onUpdate:visible": _cache[0] || (_cache[0] = ($event) => dialogVisible.value = $event),
          title: vue.unref(t)("RaiseHands.List"),
          "custom-classes": ["raise-hands-list-dialog"],
          appendTo: "#roomPage"
        }, {
          footer: vue.withCtx(() => [..._cache[1] || (_cache[1] = [
            vue.createElementVNode("div", null, null, -1)
          ])]),
          default: vue.withCtx(() => [
            vue.createElementVNode("div", _hoisted_1, [
              vue.unref(pendingDeviceApplications).length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2, [
                vue.createElementVNode("span", null, vue.toDisplayString(vue.unref(t)("RaiseHands.Empty")), 1)
              ])) : vue.createCommentVNode("", true),
              (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(pendingDeviceApplications), (invitation) => {
                return vue.openBlock(), vue.createElementBlock("div", {
                  key: invitation.timestamp,
                  class: "pending-device-invitation"
                }, [
                  vue.createElementVNode("div", _hoisted_3, [
                    vue.createVNode(vue.unref(room.Avatar), {
                      src: invitation.senderAvatarUrl,
                      size: 40
                    }, null, 8, ["src"]),
                    vue.createElementVNode("span", _hoisted_4, vue.toDisplayString(invitation.senderUserName || invitation.senderUserId), 1)
                  ]),
                  vue.createElementVNode("div", _hoisted_5, [
                    vue.createVNode(vue.unref(uikitBaseComponentVue3.TUIButton), {
                      type: "primary",
                      onClick: ($event) => handleAccept(invitation)
                    }, {
                      default: vue.withCtx(() => [
                        vue.createTextVNode(vue.toDisplayString(vue.unref(t)("RaiseHands.Agree")), 1)
                      ]),
                      _: 1
                    }, 8, ["onClick"]),
                    vue.createVNode(vue.unref(uikitBaseComponentVue3.TUIButton), {
                      onClick: ($event) => handleReject(invitation)
                    }, {
                      default: vue.withCtx(() => [
                        vue.createTextVNode(vue.toDisplayString(vue.unref(t)("RaiseHands.Reject")), 1)
                      ]),
                      _: 1
                    }, 8, ["onClick"])
                  ])
                ]);
              }), 128))
            ])
          ]),
          _: 1
        }, 8, ["visible", "title"])
      ]);
    };
  }
});
exports.default = _sfc_main;
