"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.isOkr()) {
        if (this.isMyOkr()) {
          cb(_menus.PAGE_MY_OWNER_OKR);
        } else if (this.isMyPartOkr()) {
          cb(_menus.PAGE_MY_PART_OKR);
        } else if (this.isMyTargetOkr()) {
          cb(_menus.PAGE_MY_TARGET_OKR);
        } else if (this.isTargetUser()) {
          return null;
        } else {
          cb(_menus.PAGE_MY_OWNER_OKR);
        }
      } else if (this.isOkrMap()) {
        cb(_menus.PAGE_OKR_MAP);
      } else if (this.isOkrDashboard()) {
        cb(_menus.PAGE_OKR_DASHBOARD);
      } else if (this.isOkrFunction()) {
        cb(_menus.PAGE_OKR_FUNCTION);
      } else if (this.isOkrCases()) {
        cb(_menus.PAGE_OKR_CASES);
      }

      return null;
    }
  }, {
    key: "isMyOkr",
    value: function isMyOkr() {
      var search = this.history.location.search;
      return !!search.match(/relation[\s]*?=[\s]*?1/);
    }
  }, {
    key: "isMyPartOkr",
    value: function isMyPartOkr() {
      var search = this.history.location.search;
      return !!search.match(/relation[\s]*?=[\s]*?2/);
    }
  }, {
    key: "isMyTargetOkr",
    value: function isMyTargetOkr() {
      var search = this.history.location.search;
      return !!search.match(/relation[\s]*?=[\s]*?3/);
    }
  }, {
    key: "isTargetUser",
    value: function isTargetUser() {
      var search = this.history.location.search;
      return !!search.match(/toUserId[\s]*?=[\d]+/);
    }
  }, {
    key: "isOkr",
    value: function isOkr() {
      var pathname = this.history.location.pathname;
      return pathname.match(/okr\/manage/);
    }
  }, {
    key: "isOkrMap",
    value: function isOkrMap() {
      var pathname = this.history.location.pathname;
      return pathname.match(/okr\/map/);
    }
  }, {
    key: "isOkrDashboard",
    value: function isOkrDashboard() {
      var pathname = this.history.location.pathname;
      return pathname.match(/okr\/chart/);
    }
  }, {
    key: "isOkrFunction",
    value: function isOkrFunction() {
      var pathname = this.history.location.pathname;
      return pathname.match(/okr\/panel/);
    }
  }, {
    key: "isOkrCases",
    value: function isOkrCases() {
      var pathname = this.history.location.pathname;
      return pathname.match(/okr\/cases/);
    }
  }]);

  return _default;
}();

exports["default"] = _default;