import { defineComponent, ref, computed, watch, createElementBlock, openBlock, createVNode, unref } from "vue";
import { useUIKit } from "@tencentcloud/uikit-base-component-vue3";
import { useMessageActions, MessageList, MessageInput } from "tuikit-atomicx-vue3/chat";
import { useRoomParticipantState } from "tuikit-atomicx-vue3/room";
import CustomMessage from "./CustomMessage.vue3.mjs";
const _hoisted_1 = { class: "room-chat" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    isChatOpen: { type: Boolean, default: false }
  },
  setup(__props) {
    const props = __props;
    const messageListRef = ref(null);
    const { t } = useUIKit();
    const { localParticipant } = useRoomParticipantState();
    const placeholder = computed(
      () => {
        var _a;
        return ((_a = localParticipant.value) == null ? void 0 : _a.isMessageDisabled) ? t("RoomChat.disabled_placeholder") : t("RoomChat.input_placeholder");
      }
    );
    const messageActionList = useMessageActions(["copy", "recall", "delete"]);
    watch(() => props.isChatOpen, (newVal, oldVal) => {
      var _a;
      if (newVal && !oldVal && messageListRef.value) {
        (_a = messageListRef.value) == null ? void 0 : _a.scrollToBottom({ behavior: "instant" });
      }
    });
    return (_ctx, _cache) => {
      var _a;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(unref(MessageList), {
          ref_key: "messageListRef",
          ref: messageListRef,
          class: "room-message-list",
          messageActionList: unref(messageActionList),
          Message: CustomMessage
        }, null, 8, ["messageActionList"]),
        createVNode(unref(MessageInput), {
          class: "room-message-input",
          hideSendButton: "",
          placeholder: placeholder.value,
          disabled: (_a = unref(localParticipant)) == null ? void 0 : _a.isMessageDisabled
        }, null, 8, ["placeholder", "disabled"])
      ]);
    };
  }
});
export {
  _sfc_main as default
};
