"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 _classnames = _interopRequireDefault(require("classnames"));

var _oProgress = _interopRequireDefault(require("./components/o-progress"));

var _krProgress = _interopRequireDefault(require("./components/kr-progress"));

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

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var prefix = "tita-okr-excel-progress";

var Progress = function Progress(_ref) {
  var _classNames;

  var value = _ref.value,
      status = _ref.status,
      editable = _ref.editable,
      onChange = _ref.onChange,
      _ref$type = _ref.type,
      type = _ref$type === void 0 ? "o" : _ref$type,
      _ref$autoUpdate = _ref.autoUpdate,
      autoUpdate = _ref$autoUpdate === void 0 ? false : _ref$autoUpdate,
      _ref$autoUpdateItem = _ref.autoUpdateItem,
      autoUpdateItem = _ref$autoUpdateItem === void 0 ? 1 : _ref$autoUpdateItem,
      _ref$riskLevel = _ref.riskLevel,
      riskLevel = _ref$riskLevel === void 0 ? 1 : _ref$riskLevel,
      _ref$id = _ref.id,
      id = _ref$id === void 0 ? "" : _ref$id,
      _ref$getPopupContaine = _ref.getPopupContainer,
      getPopupContainer = _ref$getPopupContaine === void 0 ? function () {} : _ref$getPopupContaine;
  var renderContent = (0, _react.useMemo)(function () {
    switch (type) {
      case "o":
        return /*#__PURE__*/_react["default"].createElement(_oProgress["default"], {
          id: id,
          value: value,
          editable: editable,
          onChange: onChange,
          autoUpdate: autoUpdate,
          autoUpdateItem: autoUpdateItem,
          riskLevel: riskLevel,
          getPopupContainer: getPopupContainer
        });

      case "kr":
        return /*#__PURE__*/_react["default"].createElement(_krProgress["default"], {
          id: id,
          value: value,
          editable: editable,
          onChange: onChange,
          autoUpdate: autoUpdate,
          autoUpdateItem: autoUpdateItem,
          riskLevel: riskLevel,
          getPopupContainer: getPopupContainer
        });

      default:
        return "";
    }
  }, [value, editable, onChange, type, status, riskLevel]);
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])(prefix)
  }, renderContent, /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(prefix, "__bg"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "__bg--normal"), status === "normal"), _defineProperty(_classNames, "".concat(prefix, "__bg--risk"), status === "risk"), _defineProperty(_classNames, "".concat(prefix, "__bg--delay"), status === "delay"), _classNames)),
    style: {
      width: "".concat(value > 100 ? 100 : value, "%")
    }
  }));
};

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