"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var React = _interopRequireWildcard(require("react"));

var _withStyles = _interopRequireDefault(require("../../hoc/withStyles"));

var _styles = _interopRequireDefault(require("./styles"));

var _WizardSteps = _interopRequireDefault(require("../../bosons/WizardSteps"));

var _uploadFile = _interopRequireDefault(require("./uploadFile"));

var _mapData = _interopRequireDefault(require("./mapData"));

var _detailData = _interopRequireDefault(require("./detailData"));

var _findIndex = _interopRequireDefault(require("lodash/findIndex"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }

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); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

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 DataImports =
/*#__PURE__*/
function (_React$Component) {
  _inherits(DataImports, _React$Component);

  function DataImports(props) {
    var _this;

    _classCallCheck(this, DataImports);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(DataImports).call(this, props));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_makeStepActive", function (index) {
      var wizardStep = _this.state.wizardStep;
      var pos = (0, _findIndex.default)(wizardStep, {
        active: true
      });

      if (pos > -1) {
        wizardStep[pos] = _objectSpread({}, wizardStep[pos], {
          active: false
        });
        wizardStep[index] = _objectSpread({}, wizardStep[index], {
          active: true
        });

        _this.setState({
          wizardStep: wizardStep
        });
      }
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_markedVisited", function (index) {
      var wizardStep = _this.state.wizardStep;
      wizardStep[index] = _objectSpread({}, wizardStep[index], {
        visited: true
      });

      _this.setState({
        wizardStep: wizardStep
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_unmarkedVisited", function (index) {
      var wizardStep = _this.state.wizardStep;
      wizardStep[index] = _objectSpread({}, wizardStep[index], {
        visited: false
      });

      _this.setState({
        wizardStep: wizardStep
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "_onStepClick", function (step, index) {
      _this._makeStepActive(index);
    });

    _this.state = {
      wizardStep: [{
        label: 'Upload',
        active: true,
        component: React.createElement(_uploadFile.default, {
          classes: props.classes,
          makeStepActive: _this._makeStepActive,
          markedVisited: _this._markedVisited
        })
      }, {
        label: 'Map',
        component: React.createElement(_mapData.default, {
          classes: props.classes,
          makeStepActive: _this._makeStepActive,
          markedVisited: _this._markedVisited,
          unmarkedVisited: _this._unmarkedVisited
        })
      }, {
        label: 'Details',
        component: React.createElement(_detailData.default, {
          classes: props.classes,
          makeStepActive: _this._makeStepActive,
          markedVisited: _this._markedVisited,
          unmarkedVisited: _this._unmarkedVisited
        })
      }]
    };
    return _this;
  }

  _createClass(DataImports, [{
    key: "render",
    value: function render() {
      return React.createElement(React.Fragment, null, React.createElement("div", null, React.createElement(_WizardSteps.default, {
        steps: this.state.wizardStep,
        onStepClick: this._onStepClick
      })));
    }
  }]);

  return DataImports;
}(React.Component);

var _default = (0, _withStyles.default)(_styles.default)(DataImports);

exports.default = _default;