"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 chat = require("tuikit-atomicx-vue3/chat");
const room = require("tuikit-atomicx-vue3/room");
const CustomMessage = require("./CustomMessage.vue3.js");
const _hoisted_1 = { class: "room-chat" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
  __name: "RoomChat",
  setup(__props) {
    const messageListRef = vue.ref(null);
    const messageInputRef = vue.ref(null);
    const { t } = uikitBaseComponentVue3.useUIKit();
    const { localParticipant } = room.useRoomParticipantState();
    const placeholder = vue.computed(
      () => {
        var _a;
        return ((_a = localParticipant.value) == null ? void 0 : _a.isMessageDisabled) ? t("RoomChat.disabled_placeholder") : t("RoomChat.input_placeholder");
      }
    );
    const messageActionList = chat.useMessageActions(["copy", "recall", "delete"]);
    function handleInputAreaExpand() {
      var _a;
      (_a = messageListRef.value) == null ? void 0 : _a.scrollToBottom({ behavior: "instant" });
    }
    function handleMessageListClick(event) {
      var _a;
      const target = event.target;
      if (!target.closest(".message-bubble")) {
        (_a = messageInputRef.value) == null ? void 0 : _a.collapsePanel();
      }
    }
    return (_ctx, _cache) => {
      var _a;
      return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
        vue.createVNode(vue.unref(chat.MessageList), {
          ref_key: "messageListRef",
          ref: messageListRef,
          class: "room-message-list",
          messageActionList: vue.unref(messageActionList),
          Message: CustomMessage.default,
          onClick: handleMessageListClick
        }, null, 8, ["messageActionList"]),
        vue.createVNode(vue.unref(chat.MessageInputH5), {
          ref_key: "messageInputRef",
          ref: messageInputRef,
          class: "room-message-input",
          placeholder: placeholder.value,
          disabled: (_a = vue.unref(localParticipant)) == null ? void 0 : _a.isMessageDisabled,
          onInputAreaExpand: handleInputAreaExpand
        }, null, 8, ["placeholder", "disabled"])
      ]);
    };
  }
});
exports.default = _sfc_main;
