"use strict";

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

var _getLocale = require("../../utils/getLocale");

var _constant = require("./constant");

var getProgressState = function getProgressState(oStatus, riskLevel) {
  // 2代表已结束
  if (oStatus === 2) {
    return "end";
  }

  return _constant.OkrRiskMapping[riskLevel] ? _constant.OkrRiskMapping[riskLevel] : "normal";
};

exports.getProgressState = getProgressState;

var formatCycleData = function formatCycleData(periodParams, isGetCycleRange) {
  if (!periodParams) return "";
  var quarter = ["", (0, _getLocale.getLocale)("OKR_MyO_Pop_1stQuarter"), (0, _getLocale.getLocale)("OKR_MyO_Pop_2ndQuarter"), (0, _getLocale.getLocale)("OKR_MyO_Pop_3rdQuarter"), (0, _getLocale.getLocale)("OKR_MyO_Pop_4thQuarter")];
  var cycleDate = "";
  var startDate = periodParams.startDate;
  var endDate = periodParams.endDate;
  var annualNum = Number("".concat(periodParams.annualNum)) === -1 ? (0, _getLocale.getLocale)("OKR_MyO_Butt_Allyears") : periodParams.annualNum;

  switch (periodParams.cycleType.toString()) {
    case "-1":
      cycleDate = (0, _getLocale.getLocale)("OKR_MyO_Butt_AllStates");
      break;

    case "1":
      cycleDate = (0, _getLocale.getLocale)("OKR_MyO_Pop_Year");
      break;

    case "2":
      // 季度
      cycleDate = quarter[Number(periodParams.yqmNum)];
      break;

    case "3":
      cycleDate = "".concat(periodParams.yqmNum, "\u6708");
      break;

    default:
      cycleDate = (0, _getLocale.getLocale)("Mod_Customization");
  }

  if (new Date(periodParams.startDate).getFullYear() === new Date().getFullYear()) {
    startDate = periodParams.startDate.slice(5);
    endDate = periodParams.endDate.slice(5);
  }

  return "".concat(annualNum, "\u5E74  ").concat(cycleDate).concat(isGetCycleRange ? ",".concat(startDate, "~").concat(endDate) : "");
};

exports.formatCycleData = formatCycleData;

var formatMenu = function formatMenu(data) {
  data.sort(function (a, b) {
    return a.Order - b.Order;
  });
  data.forEach(function (item) {
    item.ChildMenus.sort(function (a, b) {
      return a.Order - b.Order;
    });
  });
  return data;
};

exports.formatMenu = formatMenu;

var getProcessColor = function getProcessColor(status, level, type) {
  var processColor = {
    1: {
      riskLevel: 1,
      linearStartColor: "#4E90FF",
      linearEndColor: "#2879ff",
      backgroundColor: "rgba(40,121,255,0.11)"
    },
    3: {
      riskLevel: 3,
      linearStartColor: "#FFA5A5",
      linearEndColor: "#F05E5E",
      backgroundColor: "rgba(222,89,89,0.1)"
    },
    2: {
      riskLevel: 2,
      linearStartColor: "#FDCD41",
      linearEndColor: "#FFE18B",
      backgroundColor: "#FEF5DC"
    }
  };

  if (status === 2) {
    var tempColor = processColor[2];
    return tempColor[type];
  }

  var color = processColor["".concat(level)];
  if (level === 0) color = processColor["1"];
  if (!color) return {};
  return color[type];
};

exports.getProcessColor = getProcessColor;
var _default = {};
exports["default"] = _default;