"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _antd = require("antd");
require("moment/locale/zh-cn");
var _zh_CN = _interopRequireDefault(require("antd/lib/calendar/locale/zh_CN.js"));
var _time = _interopRequireDefault(require("../../imgs/time.png"));
var _caution = _interopRequireDefault(require("../../imgs/caution.png"));
var _help = _interopRequireDefault(require("../../imgs/help.png"));
var _config = require("../../../vtx-facility-modal/config");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var Charts = function Charts(_ref) {
  var data = _ref.data,
    date = _ref.date,
    theme = _ref.theme;
  var getListData = function getListData(value) {
    var _a, _b, _c, _d;
    var listData;
    if ((data === null || data === void 0 ? void 0 : data.length) > 0) {
      var list = _toConsumableArray(data);
      var obj = list.find(function (ele) {
        return ele.date === value.format('YYYY-MM-DD');
      });
      var leaveDurationStr = (_b = (_a = obj === null || obj === void 0 ? void 0 : obj.leaveDurationStr) === null || _a === void 0 ? void 0 : _a.replace("小时", "h")) === null || _b === void 0 ? void 0 : _b.replace('分', 'm');
      var index = leaveDurationStr === null || leaveDurationStr === void 0 ? void 0 : leaveDurationStr.indexOf('m');
      if (index !== -1) {
        leaveDurationStr = leaveDurationStr ? "".concat(leaveDurationStr === null || leaveDurationStr === void 0 ? void 0 : leaveDurationStr.substring(0, index), "m") : '';
      }
      var overtimeDurationStr = (_d = (_c = obj === null || obj === void 0 ? void 0 : obj.overtimeDurationStr) === null || _c === void 0 ? void 0 : _c.replace("小时", "h")) === null || _d === void 0 ? void 0 : _d.replace('分', 'm');
      var index1 = overtimeDurationStr === null || overtimeDurationStr === void 0 ? void 0 : overtimeDurationStr.indexOf('m');
      if (index1 !== -1) {
        overtimeDurationStr = overtimeDurationStr ? "".concat(overtimeDurationStr === null || overtimeDurationStr === void 0 ? void 0 : overtimeDurationStr.substring(0, index), "m") : '';
      }
      listData = Object.assign(Object.assign({}, obj), {
        leaveDurationStr: leaveDurationStr,
        overtimeDurationStr: overtimeDurationStr
      });
    }
    return listData || {};
  };
  var _content = function content(listData) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover'
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-title'
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-title-date'
    }, (listData === null || listData === void 0 ? void 0 : listData.date) || ''), /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-title-time'
    }, !!(listData === null || listData === void 0 ? void 0 : listData.leaveDuration) && /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-title-time-qj'
    }, "\u8BF7\u5047", listData === null || listData === void 0 ? void 0 : listData.leaveDurationStr), !!(listData === null || listData === void 0 ? void 0 : listData.overtimeDuration) && /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-title-time-jb'
    }, "\u52A0\u73ED", listData === null || listData === void 0 ? void 0 : listData.overtimeDurationStr))), /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-content'
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-content-left'
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-content-left-title'
    }, "\u6709\u6548\u4F5C\u4E1A\u65F6\u957F"), !!(listData === null || listData === void 0 ? void 0 : listData.date) && /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-content-left-data'
    }, (_b = (_a = listData === null || listData === void 0 ? void 0 : listData.validDurationStr) === null || _a === void 0 ? void 0 : _a.split('小时')) === null || _b === void 0 ? void 0 : _b[0], /*#__PURE__*/_react["default"].createElement("span", {
      className: 'staff-popover-content-left-data-unit'
    }, "h"), (_f = (_e = (_d = (_c = listData === null || listData === void 0 ? void 0 : listData.validDurationStr) === null || _c === void 0 ? void 0 : _c.split('小时')) === null || _d === void 0 ? void 0 : _d[1]) === null || _e === void 0 ? void 0 : _e.split('分')) === null || _f === void 0 ? void 0 : _f[0], /*#__PURE__*/_react["default"].createElement("span", {
      className: 'staff-popover-content-left-data-unit'
    }, "m"), (_m = (_l = (_k = (_j = (_h = (_g = listData === null || listData === void 0 ? void 0 : listData.validDurationStr) === null || _g === void 0 ? void 0 : _g.split('小时')) === null || _h === void 0 ? void 0 : _h[1]) === null || _j === void 0 ? void 0 : _j.split('分')) === null || _k === void 0 ? void 0 : _k[1]) === null || _l === void 0 ? void 0 : _l.split('秒')) === null || _m === void 0 ? void 0 : _m[0], /*#__PURE__*/_react["default"].createElement("span", {
      className: 'staff-popover-content-left-data-unit'
    }, "s"))), /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-content-right'
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-content-right-title'
    }, "\u8FDD\u89C4\u65F6\u957F"), !!(listData === null || listData === void 0 ? void 0 : listData.date) && /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-content-right-data',
      style: {
        color: 'rgba(245, 34, 45, 1)'
      }
    }, (_p = (_o = listData === null || listData === void 0 ? void 0 : listData.alarmDurationStr) === null || _o === void 0 ? void 0 : _o.split('小时')) === null || _p === void 0 ? void 0 : _p[0], /*#__PURE__*/_react["default"].createElement("span", {
      className: 'staff-popover-content-left-data-unit'
    }, "h"), (_t = (_s = (_r = (_q = listData === null || listData === void 0 ? void 0 : listData.alarmDurationStr) === null || _q === void 0 ? void 0 : _q.split('小时')) === null || _r === void 0 ? void 0 : _r[1]) === null || _s === void 0 ? void 0 : _s.split('分')) === null || _t === void 0 ? void 0 : _t[0], /*#__PURE__*/_react["default"].createElement("span", {
      className: 'staff-popover-content-left-data-unit'
    }, "m"), (_z = (_y = (_x = (_w = (_v = (_u = listData === null || listData === void 0 ? void 0 : listData.alarmDurationStr) === null || _u === void 0 ? void 0 : _u.split('小时')) === null || _v === void 0 ? void 0 : _v[1]) === null || _w === void 0 ? void 0 : _w.split('分')) === null || _x === void 0 ? void 0 : _x[1]) === null || _y === void 0 ? void 0 : _y.split('秒')) === null || _z === void 0 ? void 0 : _z[0], /*#__PURE__*/_react["default"].createElement("span", {
      className: 'staff-popover-content-left-data-unit'
    }, "s")))), /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-bottom'
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-bottom-left'
    }, "\u5B8C\u6210\u7387 ", /*#__PURE__*/_react["default"].createElement(_antd.Tooltip, {
      title: "\u6709\u6548\u4F5C\u4E1A\u65F6\u957F/\u6392\u73ED\u65F6\u957F*100%"
    }, /*#__PURE__*/_react["default"].createElement("img", {
      src: _help["default"]
    })), " "), /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-bottom-middle'
    }, /*#__PURE__*/_react["default"].createElement(_antd.Progress, {
      size: "small",
      percent: (listData === null || listData === void 0 ? void 0 : listData.rate) || 0,
      strokeColor: (0, _config.getColorByRate)(listData === null || listData === void 0 ? void 0 : listData.rate),
      trailColor: theme === 'dark' ? '#444B59' : '#D1D5D9',
      strokeWidth: 4,
      showInfo: false
    })), /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-popover-bottom-right',
      style: {
        color: (0, _config.getSpanColorByRate)(listData === null || listData === void 0 ? void 0 : listData.rate)
      }
    }, /*#__PURE__*/_react["default"].createElement("span", null, (listData === null || listData === void 0 ? void 0 : listData.rate) || 0), "%")));
  };
  var dateCellRender = function dateCellRender(value) {
    var _a, _b, _c, _d, _e, _f;
    var listData = getListData(value);
    return /*#__PURE__*/_react["default"].createElement(_antd.Popover, {
      content: function content() {
        return _content(listData);
      },
      zIndex: 1060
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "staff-calendar"
    }, !!(listData === null || listData === void 0 ? void 0 : listData.leaveDuration) && /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-calendar-dot'
    }), !!(listData === null || listData === void 0 ? void 0 : listData.overtimeDuration) && /*#__PURE__*/_react["default"].createElement("div", {
      className: 'staff-calendar-dot1'
    }), !!(listData === null || listData === void 0 ? void 0 : listData.validDuration) && !!(listData === null || listData === void 0 ? void 0 : listData.validDurationStr) && (/*#__PURE__*/_react["default"].createElement("div", {
      className: "staff-calendar-item"
    }, /*#__PURE__*/_react["default"].createElement("img", {
      src: _time["default"]
    }), /*#__PURE__*/_react["default"].createElement("div", null, (_c = (_b = (_a = listData === null || listData === void 0 ? void 0 : listData.validDurationStr) === null || _a === void 0 ? void 0 : _a.replace("小时", "h")) === null || _b === void 0 ? void 0 : _b.replace('分', 'm')) === null || _c === void 0 ? void 0 : _c.replace("秒", "s")))), !!(listData === null || listData === void 0 ? void 0 : listData.alarmDuration) && !!(listData === null || listData === void 0 ? void 0 : listData.alarmDurationStr) && (/*#__PURE__*/_react["default"].createElement("div", {
      className: "staff-calendar-item"
    }, /*#__PURE__*/_react["default"].createElement("img", {
      src: _caution["default"]
    }), /*#__PURE__*/_react["default"].createElement("div", null, (_f = (_e = (_d = listData === null || listData === void 0 ? void 0 : listData.alarmDurationStr) === null || _d === void 0 ? void 0 : _d.replace("小时", "h")) === null || _e === void 0 ? void 0 : _e.replace('分', 'm')) === null || _f === void 0 ? void 0 : _f.replace("秒", "s")))), !!(listData === null || listData === void 0 ? void 0 : listData.validDuration) && /*#__PURE__*/_react["default"].createElement(_antd.Progress, {
      size: "small",
      percent: (listData === null || listData === void 0 ? void 0 : listData.rate) || 0,
      strokeColor: (0, _config.getColorByRate)(listData === null || listData === void 0 ? void 0 : listData.rate),
      trailColor: theme === 'dark' ? '#444B59' : '#D1D5D9',
      strokeWidth: 4,
      showInfo: false
    })));
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-static-charts"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Calendar, {
    headerRender: function headerRender() {
      return null;
    },
    dateCellRender: dateCellRender,
    locale: _zh_CN["default"],
    value: date
  }));
};
var _default = exports["default"] = Charts;
//# sourceMappingURL=Charts.js.map
