import { defineComponent, computed, openBlock, createElementBlock, renderSlot, unref, withModifiers, createVNode, withCtx, createCommentVNode } from "vue";
import "../../adapter-vue.mjs";
import { TUIStore } from "@tencentcloud/chat-uikit-engine";
import MessageBubble from "../../components/TUIChat/message-list/message-elements/message-bubble.vue.mjs";
import { isUniFrameWork } from "../../utils/env.mjs";
const _hoisted_1 = { class: "message-plugin" };
const _hoisted_2 = {
  key: 0,
  class: "message-plugin-tip"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "message-plugin-layout",
  props: {
    message: { default: () => ({}) },
    showStyle: { default: "" },
    bubbleClassNameList: { default: () => [] },
    blinkMessageIDList: { default: () => [] }
  },
  emits: ["resendMessage", "handleToggleMessageItem", "handleH5LongPress"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const messageModel = computed(() => {
      var _a;
      return TUIStore.getMessageModel((_a = props.message) == null ? void 0 : _a.ID);
    });
    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(), createElementBlock("div", _hoisted_1, [
        props.showStyle === "tip" ? (openBlock(), createElementBlock("div", _hoisted_2, [
          renderSlot(_ctx.$slots, "messageTip", {}, void 0, true)
        ])) : props.showStyle === "bubble" ? (openBlock(), createElementBlock("div", {
          key: 1,
          class: "message-plugin-bubble-content",
          onLongpress: _cache[1] || (_cache[1] = ($event) => handleToggleMessageItem($event, unref(messageModel), true)),
          onContextmenu: _cache[2] || (_cache[2] = withModifiers(($event) => handleToggleMessageItem($event, unref(messageModel)), ["prevent", "right"])),
          onTouchstart: _cache[3] || (_cache[3] = ($event) => handleH5LongPress($event, unref(messageModel), "touchstart")),
          onTouchend: _cache[4] || (_cache[4] = ($event) => handleH5LongPress($event, unref(messageModel), "touchend")),
          onMouseover: _cache[5] || (_cache[5] = ($event) => handleH5LongPress($event, unref(messageModel), "touchend"))
        }, [
          createVNode(MessageBubble, {
            messageItem: unref(messageModel),
            content: unref(messageModel).getMessageContent(),
            blinkMessageIDList: props.blinkMessageIDList,
            classNameList: props.bubbleClassNameList,
            onResendMessage: _cache[0] || (_cache[0] = ($event) => resendMessage(unref(messageModel)))
          }, {
            messageElement: withCtx(() => [
              !unref(isUniFrameWork) ? renderSlot(_ctx.$slots, "messageBubble", { key: 0 }, void 0, true) : createCommentVNode("", true)
            ]),
            default: withCtx(() => [
              unref(isUniFrameWork) ? renderSlot(_ctx.$slots, "messageBubble", { key: 0 }, void 0, true) : createCommentVNode("", true)
            ]),
            _: 3
          }, 8, ["messageItem", "content", "blinkMessageIDList", "classNameList"])
        ], 32)) : createCommentVNode("", true)
      ]);
    };
  }
});
export {
  _sfc_main as default
};
