"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

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

var _classnames = _interopRequireDefault(require("classnames"));

var _moment = _interopRequireDefault(require("moment"));

var _navTop = _interopRequireDefault(require("../../components/nav-top"));

var _followerVisitor = _interopRequireDefault(require("../../components/follower-visitor"));

var _invitePeople = _interopRequireDefault(require("../../components/invite-people"));

var _helpCard = _interopRequireDefault(require("../../components/help-card"));

var _orderHaveAward = _interopRequireDefault(require("../../components/order-have-award"));

var _bookDemo = _interopRequireDefault(require("../../components/book-demo"));

var _platform = require("../../utils/platform");

var _helpers = require("../../utils/helpers");

var _hrHeader = _interopRequireDefault(require("../../components/hr-header"));

var _hrMessage = _interopRequireDefault(require("../../components/nav-top/components/user-message/hrMessage"));

var _interface = require("../../components/help-card/interface");

var _errorBoundary = _interopRequireDefault(require("../../components/error-boundary"));

var _magnet = _interopRequireDefault(require("../../components/magnet"));

var _errorLevel = _interopRequireDefault(require("../../utils/error-level"));

var _hooks = _interopRequireDefault(require("../../utils/hooks"));

var _newMenuSwitcher = _interopRequireDefault(require("./new-menu-switcher"));

require("./index.css");

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var preCls = 'titaui-aha-2021';

function ContentTemplate(props) {
  var children = props.children,
      title = props.title;
  (0, _react.useEffect)(function () {
    if (title) document.title = title;
  }, []);
  if (_react.Children.count(children) === 0) return /*#__PURE__*/_react["default"].createElement("div", null);

  if (_react.Children.count(children) === 1) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])("".concat(preCls, "__body-content"))
    }, children);
  }

  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__body-menu"))
  }, children[0]), /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__body-content"))
  }, children[1]));
}

function PageLayout(props) {
  var _window$BSGlobal$tena, _window$BSGlobal$tena2, _getTenantInfo;

  var children = props.children;
  var hideNavTop = (0, _hooks["default"])('hideNavTop');

  var _useState = (0, _react.useState)(function () {
    return (0, _moment["default"])().unix() < (0, _moment["default"])('2022-08-26 08:00:00').unix();
  }),
      _useState2 = _slicedToArray(_useState, 1),
      isShowUpdateTip = _useState2[0];

  var isTrial = ((_window$BSGlobal$tena = window.BSGlobal.tenantAuthentication) === null || _window$BSGlobal$tena === void 0 ? void 0 : _window$BSGlobal$tena.Version) === 1 && (0, _platform.isOfficialSite)();
  var isTencentHr = ((_window$BSGlobal$tena2 = window.BSGlobal.tenantInfo) === null || _window$BSGlobal$tena2 === void 0 ? void 0 : _window$BSGlobal$tena2.Source) === 964;

  var getBookDemoVersion = function getBookDemoVersion() {
    var _window$BSGlobal$tena3;

    var menuVersion = (_window$BSGlobal$tena3 = window.BSGlobal.tenantAuthentication) === null || _window$BSGlobal$tena3 === void 0 ? void 0 : _window$BSGlobal$tena3.MenuVersion;

    if (menuVersion === _interface.ETrialVersion.OKR) {
      return _bookDemo["default"].DemoType.TryOKR;
    }

    if (menuVersion === _interface.ETrialVersion.Performance) {
      return _bookDemo["default"].DemoType.TryPerformance;
    }

    return _bookDemo["default"].DemoType.UniversalBookDemo;
  };

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])(preCls)
  }, hideNavTop !== 'true' && /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__header"))
  }, ((_getTenantInfo = (0, _helpers.getTenantInfo)()) === null || _getTenantInfo === void 0 ? void 0 : _getTenantInfo.Source) === 964 ? /*#__PURE__*/_react["default"].createElement(_hrHeader["default"], null) : /*#__PURE__*/_react["default"].createElement(_navTop["default"], null)), /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__message"))
  }, /*#__PURE__*/_react["default"].createElement(_followerVisitor["default"], null)), /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__body")),
    style: {
      height: "calc(100vh - ".concat(74, "px)")
    }
  }, children), !isTencentHr && isTrial && /*#__PURE__*/_react["default"].createElement(_magnet["default"], {
    cacheKey: "award",
    className: (0, _classnames["default"])("".concat(preCls, "__award"))
  }, /*#__PURE__*/_react["default"].createElement(_orderHaveAward["default"], null)), /*#__PURE__*/_react["default"].createElement(_magnet["default"], {
    cacheKey: "trial"
  }, /*#__PURE__*/_react["default"].createElement(_newMenuSwitcher["default"], {
    isTrial: isTrial
  })), isTrial && !isTencentHr && /*#__PURE__*/_react["default"].createElement(_magnet["default"], {
    cacheKey: "invite",
    className: "".concat(preCls, "__invite")
  }, /*#__PURE__*/_react["default"].createElement(_invitePeople["default"], null)), !isTencentHr && /*#__PURE__*/_react["default"].createElement(_magnet["default"], {
    cacheKey: "help",
    className: (0, _classnames["default"])("".concat(preCls, "__help"))
  }, /*#__PURE__*/_react["default"].createElement(_helpCard["default"], null)), isTencentHr && /*#__PURE__*/_react["default"].createElement(_magnet["default"], {
    cacheKey: "message"
  }, /*#__PURE__*/_react["default"].createElement(_hrMessage["default"], null)), /*#__PURE__*/_react["default"].createElement(_errorBoundary["default"], {
    errorLevel: _errorLevel["default"].P0,
    errorTag: "\u7533\u8BF7\u9884\u7EA6\u6F14\u793A\u5F02\u5E38"
  }, /*#__PURE__*/_react["default"].createElement(_bookDemo["default"].BookDemoPC, {
    visible: false,
    type: getBookDemoVersion()
  })));
}

var Aha2021Page = {
  ContentTemplate: ContentTemplate,
  PageLayout: PageLayout
};
var _default = Aha2021Page;
exports["default"] = _default;