var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
import TUIChatEngine, { TUITranslateService, TUIStore, StoreName } from "@tencentcloud/chat-uikit-engine";
import { transformTextWithKeysToEmojiNames } from "../emoji-config/index.mjs";
import { chatOfflinePushInfo, callOfflinePushInfo } from "./info.mjs";
import { PUSH_SCENE, DEFAULT_DESC } from "./const.mjs";
const _OfflinePushInfoManager = class _OfflinePushInfoManager {
  constructor() {
    __publicField(this, "name", "OfflinePushInfoManager");
    __publicField(this, "offlinePushInfo", {});
    this.offlinePushInfo = {
      [PUSH_SCENE.CHAT]: chatOfflinePushInfo,
      [PUSH_SCENE.CALL]: callOfflinePushInfo
    };
  }
  static getInstance() {
    if (!_OfflinePushInfoManager.instance) {
      _OfflinePushInfoManager.instance = new _OfflinePushInfoManager();
    }
    return _OfflinePushInfoManager.instance;
  }
  getOfflinePushInfo(scene) {
    if (!Object.values(PUSH_SCENE).includes(scene)) {
      console.error(`${this.name} getOfflinePushInfo scene: ${scene} is invalid`);
      return null;
    }
    return this.offlinePushInfo[scene];
  }
  genTitle(conversation, userInfo) {
    let title = conversation == null ? void 0 : conversation.getShowName();
    if (conversation.type === TUIChatEngine.TYPES.CONV_C2C) {
      title = (userInfo == null ? void 0 : userInfo.nick) || (userInfo == null ? void 0 : userInfo.userID);
    }
    return title;
  }
  genDesc(messageType, payload) {
    let desc = "";
    if (messageType === TUIChatEngine.TYPES.MSG_TEXT) {
      desc = transformTextWithKeysToEmojiNames(payload.text);
    }
    if (messageType === TUIChatEngine.TYPES.MSG_CUSTOM) {
      desc = payload.description;
    }
    return desc || TUITranslateService.t(`TUIChat.${DEFAULT_DESC[messageType]}`);
  }
  create(options) {
    var _a;
    const { conversation, messageType = "", payload = {} } = options || {};
    const userInfo = TUIStore.getData(StoreName.USER, "userProfile");
    const entity = {
      sender: conversation.type === TUIChatEngine.TYPES.CONV_GROUP ? (_a = conversation.groupProfile) == null ? void 0 : _a.groupID : userInfo == null ? void 0 : userInfo.userID,
      nickName: userInfo == null ? void 0 : userInfo.nick,
      chatType: conversation.type === TUIChatEngine.TYPES.CONV_GROUP ? 2 : 1,
      version: 1,
      action: 1
    };
    return {
      title: this.genTitle(conversation, userInfo),
      description: this.genDesc(messageType, payload),
      extension: JSON.stringify({ entity }),
      ...this.offlinePushInfo[PUSH_SCENE.CHAT]
    };
  }
};
__publicField(_OfflinePushInfoManager, "instance", null);
let OfflinePushInfoManager = _OfflinePushInfoManager;
export {
  OfflinePushInfoManager as default
};
