import { defineComponent, ref, onMounted, onUnmounted, computed, unref, openBlock, createElementBlock, normalizeClass, createElementVNode, toDisplayString, createVNode, createCommentVNode } from "vue";
import "../../../../adapter-vue.mjs";
import TUIChatEngine, { TUIStore, StoreName, TUITranslateService } from "@tencentcloud/chat-uikit-engine";
import Icon from "../../../common/Icon.vue.mjs";
import closeIcon from "../../../../assets/icon/icon-close.svg.mjs";
import { isUniFrameWork, isH5 } from "../../../../utils/env.mjs";
import { transformTextWithKeysToEmojiNames } from "../../emoji-config/index.mjs";
const _hoisted_1 = { class: "input-quote-content" };
const _hoisted_2 = { class: "max-one-line" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  props: {
    displayType: { default: "editor" }
  },
  setup(__props) {
    const props = __props;
    const TYPES = TUIChatEngine.TYPES;
    const quoteMessage = ref();
    onMounted(() => {
      TUIStore.watch(StoreName.CHAT, {
        quoteMessage: onQuoteMessageUpdated
      });
    });
    onUnmounted(() => {
      TUIStore.unwatch(StoreName.CHAT, {
        quoteMessage: onQuoteMessageUpdated
      });
    });
    const quoteContentText = computed(() => {
      var _a, _b;
      let _quoteContentText;
      switch ((_a = quoteMessage.value) == null ? void 0 : _a.type) {
        case TYPES.MSG_TEXT:
          _quoteContentText = transformTextWithKeysToEmojiNames((_b = quoteMessage.value.payload) == null ? void 0 : _b.text);
          break;
        case TYPES.MSG_IMAGE:
          _quoteContentText = TUITranslateService.t("TUIChat.图片");
          break;
        case TYPES.MSG_AUDIO:
          _quoteContentText = TUITranslateService.t("TUIChat.语音");
          break;
        case TYPES.MSG_VIDEO:
          _quoteContentText = TUITranslateService.t("TUIChat.视频");
          break;
        case TYPES.MSG_FILE:
          _quoteContentText = TUITranslateService.t("TUIChat.文件");
          break;
        case TYPES.MSG_CUSTOM:
          _quoteContentText = TUITranslateService.t("TUIChat.自定义");
          break;
        case TYPES.MSG_FACE:
          _quoteContentText = TUITranslateService.t("TUIChat.表情");
          break;
        case TYPES.MSG_MERGER:
          _quoteContentText = TUITranslateService.t("TUIChat.聊天记录");
          break;
        default:
          _quoteContentText = TUITranslateService.t("TUIChat.消息");
          break;
      }
      return _quoteContentText;
    });
    function cancelQuote() {
      TUIStore.update(StoreName.CHAT, "quoteMessage", { message: void 0, type: "quote" });
    }
    function onQuoteMessageUpdated(options) {
      if ((options == null ? void 0 : options.message) && (options == null ? void 0 : options.type) === "quote") {
        quoteMessage.value = options.message;
      } else {
        quoteMessage.value = void 0;
      }
    }
    return (_ctx, _cache) => {
      return Boolean(unref(quoteMessage)) && props.displayType !== "audio" ? (openBlock(), createElementBlock("div", {
        key: 0,
        class: normalizeClass({
          "input-quote-container": true,
          "input-quote-container-uni": unref(isUniFrameWork),
          "input-quote-container-h5": unref(isH5)
        })
      }, [
        createElementVNode("div", _hoisted_1, [
          createElementVNode("div", _hoisted_2, toDisplayString(unref(quoteMessage).nick || unref(quoteMessage).from) + ": " + toDisplayString(unref(quoteContentText)), 1),
          createVNode(Icon, {
            class: "input-quote-close-icon",
            file: unref(closeIcon),
            width: "11px",
            height: "11px",
            onOnClick: cancelQuote
          }, null, 8, ["file"])
        ])
      ], 2)) : createCommentVNode("", true);
    };
  }
});
export {
  _sfc_main as default
};
