text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  
  var _regenerator = require('babel-runtime/regenerator');
  
  var _regenerator2 = _interopRequireDefault(_regenerator);
  
  var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
  
  var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
  
  var sendFilesToCSB = function () {
    var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(parameters, config) {
      var fileName, type, formData;
      return _regenerator2.default.wrap(function _callee$(_context) {
        while (1) {
          switch (_context.prev = _context.next) {
            case 0:
              if (!config) config = {};
              fileName = config.fileName ? config.fileName : 'example';
              type = config.type ? config.type : 's';
              formData = new _formData2.default();
  
              formData.append('parameters', parameters);
  
              return _context.abrupt('return', fetch('https://codesandbox.io/api/v1/sandboxes/define?json=1', {
                method: 'post',
                body: formData,
                mode: 'cors'
              }).then(function (response) {
                return response.json();
              }).then(function (_ref2) {
                var errors = _ref2.errors,
                    sandbox_id = _ref2.sandbox_id;
  
                if (errors) throw errors;
                return {
                  sandboxId: sandbox_id,
                  sandboxUrl: (0, _constants.getSandboxUrl)(sandbox_id, type, fileName)
                };
              }));
  
            case 6:
            case 'end':
              return _context.stop();
          }
        }
      }, _callee, this);
    }));
  
    return function sendFilesToCSB(_x, _x2) {
      return _ref.apply(this, arguments);
    };
  }();
  
  var _constants = require('../constants');
  
  require('isomorphic-unfetch');
  
  var _formData = require('form-data');
  
  var _formData2 = _interopRequireDefault(_formData);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  exports.default = sendFilesToCSB;