import { defineComponent, computed, openBlock, createBlock, unref, withCtx, createVNode, createCommentVNode } from "vue";
import "../../adapter-vue.mjs";
import TUIChatEngine, { TUIStore } from "@tencentcloud/chat-uikit-engine";
import { isCallMessage, isRoomCardMessage } from "./index.mjs";
import MessagePluginLayout from "./message-plugin-layout.vue.mjs";
import MessageCallGroup from "./message-call/message-call-group.vue.mjs";
import MessageCallC2C from "./message-call/message-call-c2c.vue.mjs";
import MessageCustomerService from "./message-customer/message-customer-service.vue.mjs";
import MessageRoom from "./message-room/message-room-default.vue.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "message-plugin",
  props: {
    message: { default: () => ({}) },
    blinkMessageIDList: { default: () => [] }
  },
  emits: ["resendMessage", "handleToggleMessageItem", "handleH5LongPress"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const messageModel = computed(() => TUIStore.getMessageModel(props.message.ID));
    const messageSignalingInfo = computed(() => {
      var _a;
      return (_a = messageModel == null ? void 0 : messageModel.value) == null ? void 0 : _a.getSignalingInfo();
    });
    const messageCustomContent = computed(() => {
      var _a;
      return (_a = messageModel == null ? void 0 : messageModel.value) == null ? void 0 : _a.getMessageContent();
    });
    const pluginMessageType = computed(() => {
      var _a;
      let typeObj = { pluginType: "", showStyle: "" };
      if (isCallMessage(messageModel.value)) {
        typeObj = {
          pluginType: "call",
          showStyle: ((_a = messageModel.value) == null ? void 0 : _a.conversationType) === TUIChatEngine.TYPES.CONV_GROUP ? "tip" : "bubble"
        };
      } else if (isRoomCardMessage(messageModel.value)) {
        typeObj = {
          pluginType: "room",
          showStyle: "bubble"
        };
      }
      return typeObj;
    });
    const resendMessage = (message) => {
      emits("resendMessage", message);
    };
    const handleToggleMessageItem = (e, message, isLongpress = false) => {
      emits("handleToggleMessageItem", e, message, isLongpress);
    };
    const handleH5LongPress = (e, message, type) => {
      emits("handleH5LongPress", e, message, type);
    };
    return (_ctx, _cache) => {
      return openBlock(), createBlock(MessagePluginLayout, {
        message: props.message,
        showStyle: unref(pluginMessageType).showStyle,
        bubbleClassNameList: [unref(pluginMessageType).pluginType === "room" ? "message-bubble-room" : ""],
        onResendMessage: resendMessage,
        onHandleToggleMessageItem: handleToggleMessageItem,
        onHandleH5LongPress: handleH5LongPress
      }, {
        messageTip: withCtx(() => [
          createVNode(MessageCallGroup, {
            message: props.message,
            signalingInfo: unref(messageSignalingInfo),
            customContent: unref(messageCustomContent),
            blinkMessageIDList: props.blinkMessageIDList
          }, null, 8, ["message", "signalingInfo", "customContent", "blinkMessageIDList"])
        ]),
        messageBubble: withCtx(() => [
          unref(pluginMessageType).pluginType === "call" ? (openBlock(), createBlock(MessageCallC2C, {
            key: 0,
            message: props.message,
            signalingInfo: unref(messageSignalingInfo),
            customContent: unref(messageCustomContent)
          }, null, 8, ["message", "signalingInfo", "customContent"])) : createCommentVNode("", true),
          unref(pluginMessageType).pluginType === "customer" ? (openBlock(), createBlock(MessageCustomerService, {
            key: 1,
            message: props.message
          }, null, 8, ["message"])) : createCommentVNode("", true),
          unref(pluginMessageType).pluginType === "room" ? (openBlock(), createBlock(MessageRoom, {
            key: 2,
            message: props.message
          }, null, 8, ["message"])) : createCommentVNode("", true)
        ]),
        _: 1
      }, 8, ["message", "showStyle", "bubbleClassNameList"]);
    };
  }
});
export {
  _sfc_main as default
};
