"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 _tableRowOProject = _interopRequireDefault(require("../table-row-o-project"));

var _mileStone = _interopRequireDefault(require("./mile-stone"));

var _workTask = _interopRequireDefault(require("./work-task"));

var _work = _interopRequireDefault(require("./work"));

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; }

var prefix = 'tita-summary-work-progress';

var RenderRow = function RenderRow(_ref) {
  var item = _ref.item,
      openWorkMileSetting = _ref.openWorkMileSetting,
      openWorkTaskSetting = _ref.openWorkTaskSetting;
  var render = (0, _react.useMemo)(function () {
    if (!item.IsImport) {
      var _item$children;

      //暂时取反 应该不取反
      return (_item$children = item.children) === null || _item$children === void 0 ? void 0 : _item$children.map(function (child) {
        var result = [];
        result.push( /*#__PURE__*/_react["default"].createElement(_work["default"], {
          data: child
        }));

        if (child.Milestones) {
          var _child$Milestones;

          (_child$Milestones = child.Milestones) === null || _child$Milestones === void 0 ? void 0 : _child$Milestones.forEach(function (mileStone) {
            if (openWorkMileSetting) {
              result.push( /*#__PURE__*/_react["default"].createElement(_mileStone["default"], {
                workId: child.Id,
                data: mileStone
              }));
            }

            if (mileStone.Tasks && openWorkTaskSetting) {
              var _mileStone$Tasks;

              (_mileStone$Tasks = mileStone.Tasks) === null || _mileStone$Tasks === void 0 ? void 0 : _mileStone$Tasks.map(function (task) {
                result.push( /*#__PURE__*/_react["default"].createElement(_workTask["default"], {
                  data: task
                }));
              });
            }
          });
        }

        return result;
      });
    } else {
      return /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", {
        colSpan: 3
      }, /*#__PURE__*/_react["default"].createElement(_tableRowOProject["default"], {
        data: item,
        extraClass: "".concat(prefix, "__table-obj")
      })));
    }
  }, [item]);
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", {
    colSpan: 3
  }, /*#__PURE__*/_react["default"].createElement(_tableRowOProject["default"], {
    data: item,
    extraClass: "".concat(prefix, "__table-obj")
  }))), render);
};

var _default = RenderRow;
exports["default"] = _default;