text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  
  var _moveToEdge = require('../../move-to-edge');
  
  var _moveToEdge2 = _interopRequireDefault(_moveToEdge);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  exports.default = function (_ref) {
    var amount = _ref.amount,
        originalIndex = _ref.originalIndex,
        target = _ref.target,
        insideDroppable = _ref.insideDroppable,
        draggable = _ref.draggable,
        droppable = _ref.droppable;
  
    if (!target) {
      console.error('there will always be a target in the original list');
      return null;
    }
  
    var axis = droppable.axis;
    var targetIndex = insideDroppable.indexOf(target);
  
    if (targetIndex === -1) {
      console.error('unable to find target in destination droppable');
      return null;
    }
  
    if (targetIndex === originalIndex) {
      var _newCenter = draggable.page.withoutMargin.center;
      var _newImpact = {
        movement: {
          draggables: [],
          amount: amount,
          isBeyondStartPosition: false
        },
        direction: droppable.axis.direction,
        destination: {
          droppableId: droppable.id,
          index: originalIndex
        }
      };
  
      return {
        pageCenter: _newCenter,
        impact: _newImpact
      };
    }
  
    var isMovingPastOriginalIndex = targetIndex > originalIndex;
    var edge = isMovingPastOriginalIndex ? 'end' : 'start';
  
    var newCenter = (0, _moveToEdge2.default)({
      source: draggable.page.withoutMargin,
      sourceEdge: edge,
      destination: isMovingPastOriginalIndex ? target.page.withoutMargin : target.page.withMargin,
      destinationEdge: edge,
      destinationAxis: axis
    });
  
    var needsToMove = function () {
      if (!isMovingPastOriginalIndex) {
        return insideDroppable.slice(targetIndex, originalIndex);
      }
  
      var from = originalIndex + 1;
  
      var to = targetIndex + 1;
  
      return insideDroppable.slice(from, to).reverse();
    }().map(function (d) {
      return d.id;
    });
  
    var newImpact = {
      movement: {
        draggables: needsToMove,
        amount: amount,
        isBeyondStartPosition: isMovingPastOriginalIndex
      },
      direction: axis.direction,
      destination: {
        droppableId: droppable.id,
        index: targetIndex
      }
    };
  
    return {
      pageCenter: newCenter,
      impact: newImpact
    };
  };