"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PlatformItem = PlatformItem;
exports.isPlatform = exports.isOfficialSite = exports.isFeishu = exports.isDD = exports.getPlatformConfig = void 0;

var _react = _interopRequireDefault(require("react"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var isPlatform = function isPlatform(name) {
  var _window$BSGlobal$tena;

  // @ts-ignore
  var source = (_window$BSGlobal$tena = window.BSGlobal.tenantInfo) === null || _window$BSGlobal$tena === void 0 ? void 0 : _window$BSGlobal$tena.Source;
  var ua = navigator.userAgent.toLowerCase();

  switch (name) {
    case "wx":
      return source == 860 || ua.indexOf("micromessenger") != -1;

    case "dd":
      return source == 861;

    default:
      return false;
  }
};

exports.isPlatform = isPlatform;

var getPlatformConfig = function getPlatformConfig() {
  return {
    nameTipsEnable: !isPlatform("wx"),
    profilePageEnable: !isPlatform("wx")
  };
};

exports.getPlatformConfig = getPlatformConfig;

var isDD = function isDD(res) {
  var _window$BSGlobal$tena2;

  // @ts-ignore
  var source = (_window$BSGlobal$tena2 = window.BSGlobal.tenantInfo) === null || _window$BSGlobal$tena2 === void 0 ? void 0 : _window$BSGlobal$tena2.Source;
  if (source == 861) return res;
  return undefined;
};

exports.isDD = isDD;

var isFeishu = function isFeishu(res) {
  var _window$BSGlobal$tena3;

  // @ts-ignore
  var source = (_window$BSGlobal$tena3 = window.BSGlobal.tenantInfo) === null || _window$BSGlobal$tena3 === void 0 ? void 0 : _window$BSGlobal$tena3.Source;
  if (source == 862) return res;
  return undefined;
};

exports.isFeishu = isFeishu;

function PlatformItem(props) {
  var _window$BSGlobal$tena4;

  var children = props.children,
      _props$hidden = props.hidden,
      hidden = _props$hidden === void 0 ? [] : _props$hidden;
  var sourceMap = {
    dingding: 861,
    lark: 862
  }; // @ts-ignore

  var sourceId = (_window$BSGlobal$tena4 = window.BSGlobal.tenantInfo) === null || _window$BSGlobal$tena4 === void 0 ? void 0 : _window$BSGlobal$tena4.Source;
  var isShowSource = true;
  hidden.forEach(function (item) {
    if (sourceMap[item] == sourceId) {
      isShowSource = false;
    }
  });

  if (isShowSource) {
    return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children);
  }

  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
}

var isOfficialSite = function isOfficialSite() {
  var _window$BSGlobal$tena5;

  var source = (_window$BSGlobal$tena5 = window.BSGlobal.tenantInfo) === null || _window$BSGlobal$tena5 === void 0 ? void 0 : _window$BSGlobal$tena5.Source;
  return source !== 860 && source !== 861 && source !== 862;
};

exports.isOfficialSite = isOfficialSite;