'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _regenerator;

function _load_regenerator() {
  return _regenerator = _interopRequireDefault(require('babel-runtime/regenerator'));
}

var _bluebird;

function _load_bluebird() {
  return _bluebird = require('bluebird');
}

var _consumer;

function _load_consumer() {
  return _consumer = require('../../../consumer');
}

var _moveComponents;

function _load_moveComponents() {
  return _moveComponents = require('../../../consumer/component-ops/move-components');
}

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

exports.default = function () {
  var _ref = (0, (_bluebird || _load_bluebird()).coroutine)( /*#__PURE__*/(_regenerator || _load_regenerator()).default.mark(function _callee(_ref2) {
    var from = _ref2.from,
        to = _ref2.to;
    var consumer, moveResults;
    return (_regenerator || _load_regenerator()).default.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return (0, (_consumer || _load_consumer()).loadConsumer)();

          case 2:
            consumer = _context.sent;
            _context.next = 5;
            return (0, (_moveComponents || _load_moveComponents()).movePaths)(consumer, { from, to });

          case 5:
            moveResults = _context.sent;
            _context.next = 8;
            return consumer.onDestroy();

          case 8:
            return _context.abrupt('return', moveResults);

          case 9:
          case 'end':
            return _context.stop();
        }
      }
    }, _callee, this);
  }));

  function move(_x) {
    return _ref.apply(this, arguments);
  }

  return move;
}();