import { defineComponent, ref, openBlock, createBlock, unref, withCtx, createElementVNode, normalizeClass, toDisplayString, createElementBlock, createCommentVNode, Fragment, renderList } from "vue";
import { TUIStore, StoreName, TUITranslateService, TUIChatService } from "@tencentcloud/chat-uikit-engine";
import "../../../../adapter-vue.mjs";
import ToolbarItemContainer from "../toolbar-item-container/index.vue.mjs";
import wordsIconLight from "../../../../assets/icon/words-light.svg.mjs";
import wordsIconDark from "../../../../assets/icon/words-dark.svg.mjs";
import { wordsList } from "../../utils/wordsList.mjs";
import { isEnabledMessageReadReceiptGlobal } from "../../utils/utils.mjs";
import { isUniFrameWork, isPC } from "../../../../utils/env.mjs";
import ChatConfig from "../../config.mjs";
const _hoisted_1 = ["onClick"];
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  emits: ["onDialogPopupShowOrHide"],
  setup(__props, { emit: __emit }) {
    const wordsIcon = ChatConfig.getTheme() === "dark" ? wordsIconDark : wordsIconLight;
    const emits = __emit;
    const currentConversation = ref();
    const container = ref();
    TUIStore.watch(StoreName.CONV, {
      currentConversation: (conversation) => {
        currentConversation.value = conversation;
      }
    });
    const selectWord = (item) => {
      var _a, _b, _c, _d, _e, _f;
      const options = {
        to: ((_b = (_a = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _a.groupProfile) == null ? void 0 : _b.groupID) || ((_d = (_c = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _c.userProfile) == null ? void 0 : _d.userID),
        conversationType: (_e = currentConversation == null ? void 0 : currentConversation.value) == null ? void 0 : _e.type,
        payload: {
          text: TUITranslateService.t(`Words.${item.value}`)
        },
        needReadReceipt: isEnabledMessageReadReceiptGlobal()
      };
      TUIChatService.sendTextMessage(options);
      (_f = container == null ? void 0 : container.value) == null ? void 0 : _f.toggleDialogDisplay(false);
    };
    const closeDialog = () => {
      var _a;
      (_a = container == null ? void 0 : container.value) == null ? void 0 : _a.toggleDialogDisplay(false);
    };
    const onDialogShow = () => {
      emits("onDialogPopupShowOrHide", true);
    };
    const onDialogClose = () => {
      emits("onDialogPopupShowOrHide", false);
    };
    return (_ctx, _cache) => {
      return openBlock(), createBlock(ToolbarItemContainer, {
        ref_key: "container",
        ref: container,
        iconFile: unref(wordsIcon),
        title: "常用语",
        needBottomPopup: true,
        iconWidth: unref(isUniFrameWork) ? "26px" : "20px",
        iconHeight: unref(isUniFrameWork) ? "26px" : "20px",
        onOnDialogShow: onDialogShow,
        onOnDialogClose: onDialogClose
      }, {
        default: withCtx(() => [
          createElementVNode("div", {
            class: normalizeClass(["words", !unref(isPC) && "words-h5"])
          }, [
            createElementVNode("div", {
              class: normalizeClass(["words-header", !unref(isPC) && "words-h5-header"])
            }, [
              createElementVNode("span", {
                class: normalizeClass(["words-header-title", !unref(isPC) && "words-h5-header-title"])
              }, toDisplayString(unref(TUITranslateService).t("Words.常用语-快捷回复工具")), 3),
              !unref(isPC) ? (openBlock(), createElementBlock("span", {
                key: 0,
                class: normalizeClass(["words-header-close", !unref(isPC) && "words-h5-header-close"]),
                onClick: closeDialog
              }, " 关闭 ", 2)) : createCommentVNode("", true)
            ], 2),
            createElementVNode("ul", {
              class: normalizeClass(["words-list", !unref(isPC) && "words-h5-list"])
            }, [
              (openBlock(true), createElementBlock(Fragment, null, renderList(unref(wordsList), (item, index) => {
                return openBlock(), createElementBlock("li", {
                  key: index,
                  class: normalizeClass(["words-list-item", !unref(isPC) && "words-h5-list-item"]),
                  onClick: ($event) => selectWord(item)
                }, toDisplayString(unref(TUITranslateService).t(`Words.${item.value}`)), 11, _hoisted_1);
              }), 128))
            ], 2)
          ], 2)
        ]),
        _: 1
      }, 8, ["iconFile", "iconWidth", "iconHeight"]);
    };
  }
});
export {
  _sfc_main as default
};
