'use strict';

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

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

var drawSecretSantas = function drawSecretSantas(users) {
  // Shuffle all the users
  var shuffled = users.sort(function () {
    return Math.floor(Math.random() * users.length);
  });

  // Create new list and just take all the shuffled users
  var gifters = [].concat(_toConsumableArray(shuffled));

  // Create a second list that takes the shuffled gifters ...
  var recipients = [].concat(_toConsumableArray(shuffled));

  // ... and move the first one to the last! We
  // don't want pairs or small groups of the raffle. This keeps it snaky 🐍!
  recipients.push(recipients.shift());

  // Boom, let's raffle! 🎫
  var raffle = users.map(function (user, raffleRound) {
    var gifter = gifters[raffleRound];
    var recipient = recipients[raffleRound];

    return {
      gifter: gifter,
      recipient: recipient
    };
  });

  return raffle;
};

exports.default = drawSecretSantas;
@@ -524,18 +524,17 @@
   var gi
-ft
+v
 ers = %5B%5D
@@ -625,18 +625,17 @@
 ffled gi
-ft
+v
 ers ...%0A
@@ -788,22 +788,20 @@
  of the 
+d
 ra
-ffle
+w
 . This k
@@ -874,22 +874,20 @@
 , let's 
+d
 ra
-ffle
+w
 ! %F0%9F%8E%AB%0A  va
@@ -888,22 +888,20 @@
 %F0%9F%8E%AB%0A  var 
+d
 ra
-ffle
+w
  = users
@@ -921,22 +921,20 @@
  (user, 
+d
 ra
-ffle
+w
 Round) %7B
@@ -948,29 +948,25 @@
 r gi
-ft
+v
 er = gi
-ft
+v
 ers%5B
+d
 ra
-ffle
+w
 Roun
@@ -1000,22 +1000,20 @@
 ipients%5B
+d
 ra
-ffle
+w
 Round%5D;%0A
@@ -1038,18 +1038,16 @@
   gi
-ft
+v
 er: gi
-ft
+v
 er,%0A
@@ -1100,14 +1100,12 @@
 urn 
+d
 ra
-ffle
+w
 ;%0A%7D;

Update terminology