"use strict";

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

var _menus = require("./menus");

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }

var _default = /*#__PURE__*/function () {
  function _default(history) {
    _classCallCheck(this, _default);

    this.history = null;
    this.history = history;
  }

  _createClass(_default, [{
    key: "highlight",
    value: function highlight(cb) {
      if (this.isMy()) cb(_menus.PAGE_MY_APPRAISAL);else if (this.isEvaluate()) cb(_menus.PAGE_EVALUATE_APPRAISAL);else if (this.isSubordinate()) cb(_menus.PAGE_SUBORDINATE_APPRAISAL);else if (this.isDepart()) cb(_menus.PAGE_DEPART_APPRAISAL);else if (this.isManage()) cb(_menus.PAGE_MANAGE_APPRAISAL);else if (this.isLibrary()) cb(_menus.PAGE_LIBRARY_APPRAISAL); // template library 正则匹配优先级
      else if (this.isTemplate()) cb(_menus.PAGE_TEMPLATE_APPRAISAL);else if (this.isDashboard()) cb(_menus.PAGE_DASHBOARD_APPRAISAL);else if (this.isReport()) cb(_menus.PAGE_STATISTICS_APPRAISAL);else if (this.isScore()) cb(_menus.PAGE_SCORE_APPRAISAL);else if (this.isHelp()) cb(_menus.PAGE_HELP_APPRAISAL);
    }
  }, {
    key: "isMy",
    value: function isMy() {
      var _this$history$locatio = this.history.location,
          pathname = _this$history$locatio.pathname,
          search = _this$history$locatio.search;
      return pathname.match(/performance/) && (!search || search.match(/reactRouterName[\s]*?=[\s]*?self/));
    }
  }, {
    key: "isEvaluate",
    value: function isEvaluate() {
      var _this$history$locatio2 = this.history.location,
          pathname = _this$history$locatio2.pathname,
          search = _this$history$locatio2.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?evaluated/);
    }
  }, {
    key: "isSubordinate",
    value: function isSubordinate() {
      var _this$history$locatio3 = this.history.location,
          pathname = _this$history$locatio3.pathname,
          search = _this$history$locatio3.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?subordinate/);
    }
  }, {
    key: "isDepart",
    value: function isDepart() {
      var _this$history$locatio4 = this.history.location,
          pathname = _this$history$locatio4.pathname,
          search = _this$history$locatio4.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?department/);
    }
  }, {
    key: "isManage",
    value: function isManage() {
      var _this$history$locatio5 = this.history.location,
          pathname = _this$history$locatio5.pathname,
          search = _this$history$locatio5.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?manage/);
    }
  }, {
    key: "isTemplate",
    value: function isTemplate() {
      var _this$history$locatio6 = this.history.location,
          pathname = _this$history$locatio6.pathname,
          search = _this$history$locatio6.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?template/);
    }
  }, {
    key: "isLibrary",
    value: function isLibrary() {
      var _this$history$locatio7 = this.history.location,
          pathname = _this$history$locatio7.pathname,
          search = _this$history$locatio7.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?templateLibrary/);
    }
  }, {
    key: "isDashboard",
    value: function isDashboard() {
      var _this$history$locatio8 = this.history.location,
          pathname = _this$history$locatio8.pathname,
          search = _this$history$locatio8.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?dashboard/);
    }
  }, {
    key: "isReport",
    value: function isReport() {
      var _this$history$locatio9 = this.history.location,
          pathname = _this$history$locatio9.pathname,
          search = _this$history$locatio9.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?report/);
    }
  }, {
    key: "isScore",
    value: function isScore() {
      var _this$history$locatio10 = this.history.location,
          pathname = _this$history$locatio10.pathname,
          search = _this$history$locatio10.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?setting/);
    }
  }, {
    key: "isHelp",
    value: function isHelp() {
      var _this$history$locatio11 = this.history.location,
          pathname = _this$history$locatio11.pathname,
          search = _this$history$locatio11.search;
      return pathname.match(/performance/) && search.match(/reactRouterName[\s]*?=[\s]*?help/);
    }
  }]);

  return _default;
}();

exports["default"] = _default;