"use strict";
const common_vendor = require("../../../common/vendor.js");
const common_assets = require("../../../common/assets.js");
const TUIKit_utils_env = require("../../utils/env.js");
class TUIGroupServer {
  constructor() {
    common_vendor.R.registerService(common_vendor.E.TUIGroup.SERVICE.NAME, this);
    common_vendor.R.registerExtension(common_vendor.E.TUIChat.EXTENSION.CHAT_HEADER.EXT_ID, this);
    this.onCallParamsMap = /* @__PURE__ */ new Map();
    this.onCallCallbackMap = /* @__PURE__ */ new Map();
    this.constants = common_vendor.E;
  }
  static getInstance() {
    if (!TUIGroupServer.instance) {
      TUIGroupServer.instance = new TUIGroupServer();
    }
    return TUIGroupServer.instance;
  }
  getOnCallParams(method) {
    return this.onCallParamsMap.get(method);
  }
  getOnCallCallback(method) {
    return this.onCallCallbackMap.get(method);
  }
  async onCall(method, params, callback) {
    var _a, _b, _c;
    this.onCallParamsMap.set(method, params);
    this.onCallCallbackMap.set(method, callback);
    switch (method) {
      case common_vendor.E.TUIGroup.SERVICE.METHOD.CREATE_GROUP:
        common_vendor.Jt.update(common_vendor.o.GRP, "isShowCreateComponent", true);
        TUIKit_utils_env.isUniFrameWork && ((_a = common_vendor.i) == null ? void 0 : _a.reLaunch({
          url: "/TUIKit/components/TUIGroup/index"
        }));
        break;
      case common_vendor.E.TUIGroup.SERVICE.METHOD.OPEN_GROUP_MANAGEMENT:
        common_vendor.es.switchGroup(params.groupID);
        common_vendor.Jt.update(common_vendor.o.GRP, "isShowManageComponent", true);
        TUIKit_utils_env.isUniFrameWork && ((_b = common_vendor.i) == null ? void 0 : _b.navigateTo({
          url: "/TUIKit/components/TUIGroup/index"
        }));
        break;
      case common_vendor.E.TUIGroup.SERVICE.METHOD.SELECT_GROUP_MEMBER:
        common_vendor.es.switchGroup(params.groupID);
        common_vendor.Jt.update(common_vendor.o.GRP, "isShowSelectComponent", true);
        TUIKit_utils_env.isUniFrameWork && ((_c = common_vendor.i) == null ? void 0 : _c.navigateTo({
          url: "/TUIKit/components/TUIGroup/index"
        }));
        break;
    }
  }
  onGetExtension(extensionID) {
    const list = [];
    switch (extensionID) {
      case common_vendor.E.TUIChat.EXTENSION.CHAT_HEADER.EXT_ID:
        list.push({
          weight: 100,
          icon: common_assets.settingSVG,
          text: "更多",
          data: {},
          listener: {
            onClicked: this.groupManage.bind(this)
          }
        });
        break;
    }
    return list;
  }
  groupManage(params) {
    common_vendor.R.callService({
      serviceName: common_vendor.E.TUIGroup.SERVICE.NAME,
      method: common_vendor.E.TUIGroup.SERVICE.METHOD.OPEN_GROUP_MANAGEMENT,
      params,
      callback: () => {
        var _a;
        TUIKit_utils_env.isUniFrameWork && ((_a = common_vendor.i) == null ? void 0 : _a.navigateBack());
      }
    });
  }
}
exports.TUIGroupServer = TUIGroupServer;
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/TUIKit/components/TUIGroup/server.js.map
