import { defineComponent, ref, openBlock, createBlock, unref, withCtx, createVNode } from "vue";
import { TUIStore, StoreName } from "@tencentcloud/chat-uikit-engine";
import "../../../../adapter-vue.mjs";
import faceIconLight from "../../../../assets/icon/face-light.svg.mjs";
import faceIconDark from "../../../../assets/icon/face-dark.svg.mjs";
import EmojiPickerDialog from "./emoji-picker-dialog.vue.mjs";
import ToolbarItemContainer from "../toolbar-item-container/index.vue.mjs";
import { isH5 } from "../../../../utils/env.mjs";
import ChatConfig from "../../config.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "index",
  emits: ["sendMessage", "toggleComponent", "insertEmoji", "dialogShowInH5", "dialogCloseInH5", "changeToolbarDisplayType"],
  setup(__props, { expose: __expose, emit: __emit }) {
    const faceIcon = ChatConfig.getTheme() === "dark" ? faceIconDark : faceIconLight;
    const emits = __emit;
    const currentConversation = ref();
    const container = ref();
    TUIStore.watch(StoreName.CONV, {
      currentConversation: (conversation) => {
        currentConversation.value = conversation;
      }
    });
    const onDialogShow = (dialogRef) => {
      if (!isH5) {
        return;
      }
      emits("changeToolbarDisplayType", "emojiPicker");
      emits("dialogShowInH5", dialogRef.value);
    };
    const onDialogClose = (dialogRef) => {
      if (!isH5) {
        return;
      }
      emits("changeToolbarDisplayType", "none");
      emits("dialogCloseInH5", dialogRef.value);
    };
    const insertEmoji = (emojiObj) => {
      emits("insertEmoji", emojiObj);
    };
    const sendMessage = () => {
      emits("sendMessage");
    };
    const onClose = () => {
      var _a;
      (_a = container.value) == null ? void 0 : _a.toggleDialogDisplay(false);
    };
    __expose({
      closeEmojiPicker: onClose
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(ToolbarItemContainer, {
        ref_key: "container",
        ref: container,
        iconFile: unref(faceIcon),
        title: "表情",
        onOnDialogShow: onDialogShow,
        onOnDialogClose: onDialogClose
      }, {
        default: withCtx(() => [
          createVNode(EmojiPickerDialog, {
            onInsertEmoji: insertEmoji,
            onSendMessage: sendMessage,
            onOnClose: onClose
          })
        ]),
        _: 1
      }, 8, ["iconFile"]);
    };
  }
});
export {
  _sfc_main as default
};
