'use strict';

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

var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

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

var mounter = null;
if (typeof window !== 'undefined') {
  // now we are in the server
  mounter = require('./client').mounter;
} else {
  mounter = require('./server').mounter;
}

function mount(layoutClass, regions) {
  var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

  options.rootId = options.rootId || 'react-root';
  options.rootProps = options.rootProps || {};
  mounter(layoutClass, regions, options);
}

function withOptions(options, fn) {
  return function () {
    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    var newArgs = [].concat(args, [options]);
    return fn.apply(undefined, (0, _toConsumableArray3.default)(newArgs));
  };
}