module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.l = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}


/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// identity function for calling harmory imports with the correct context
/******/ 	__webpack_require__.i = function(value) { return value; };

/******/ 	// define getter function for harmory exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		Object.defineProperty(exports, name, {
/******/ 			configurable: false,
/******/ 			enumerable: true,
/******/ 			get: getter
/******/ 		});
/******/ 	};

/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};

/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "/";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 121);
/******/ })
/************************************************************************/
/******/ ({

/***/ "./src/config/Expression.js":
/***/ function(module, exports, __webpack_require__) {

"use strict";
"use strict";

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

var _classCallCheck2 = __webpack_require__(1);

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = __webpack_require__(2);

var _createClass3 = _interopRequireDefault(_createClass2);

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

var Expression = function () {
  function Expression(expression) {
    (0, _classCallCheck3.default)(this, Expression);

    this.expression = expression;
  }

  (0, _createClass3.default)(Expression, [{
    key: "toString",
    value: function toString() {
      return this.expression.toString();
    }
  }, {
    key: "value",
    value: function value() {
      return this.expression();
    }
  }]);
  return Expression;
}();

exports.default = Expression;

/***/ },

/***/ "./src/config/features/collection.js":
/***/ function(module, exports, __webpack_require__) {

"use strict";
'use strict';

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

var _toConsumableArray2 = __webpack_require__(4);

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

exports.default = collection;

var _isEmpty = __webpack_require__(33);

var _isEmpty2 = _interopRequireDefault(_isEmpty);

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

function collection(existing) {
  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    args[_key - 1] = arguments[_key];
  }

  if (!(0, _isEmpty2.default)(args)) {
    return [].concat((0, _toConsumableArray3.default)(existing || []), [args]);
  } else {
    return existing;
  }
}

/***/ },

/***/ "./src/config/features/feature.js":
/***/ function(module, exports, __webpack_require__) {

"use strict";
"use strict";

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

var _defineProperty2 = __webpack_require__(11);

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _extends3 = __webpack_require__(0);

var _extends4 = _interopRequireDefault(_extends3);

exports.default = feature;

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

function feature(existing, id) {
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

  if (!id) {
    return existing;
  }

  var settings = (0, _extends4.default)({}, existing && existing[id] || {}, options, {
    id: id
  });

  return (0, _extends4.default)({}, existing || {}, (0, _defineProperty3.default)({}, id, settings));
}

/***/ },

/***/ "./src/config/features/scope.js":
/***/ function(module, exports, __webpack_require__) {

"use strict";
"use strict";

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

var _toConsumableArray2 = __webpack_require__(4);

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

exports.default = scope;

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

function scope(existing) {
  for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    args[_key - 1] = arguments[_key];
  }

  if (args.length > 0) {
    return [].concat((0, _toConsumableArray3.default)(existing), [args]);
  } else {
    return existing;
  }
}

/***/ },

/***/ "./src/config/features/selector.js":
/***/ function(module, exports, __webpack_require__) {

"use strict";
'use strict';

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

var _defineProperty2 = __webpack_require__(11);

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _extends3 = __webpack_require__(0);

var _extends4 = _interopRequireDefault(_extends3);

exports.default = selector;

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

function selector(existing, id, handler) {
  if (!id || typeof handler !== 'function') {
    return existing;
  }

  return (0, _extends4.default)({}, existing || {}, (0, _defineProperty3.default)({}, id, handler.bind ? handler.bind(this) : handler));
}

/***/ },

/***/ "./src/config/index.js":
/***/ function(module, exports, __webpack_require__) {

"use strict";
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.defaultReducers = exports.defaultFeatures = undefined;

var _toConsumableArray2 = __webpack_require__(4);

var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);

var _defineProperty2 = __webpack_require__(11);

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _extends8 = __webpack_require__(0);

var _extends9 = _interopRequireDefault(_extends8);

exports.api = api;

var _lodash = __webpack_require__(6);

var _stringify = __webpack_require__("./src/config/stringify.js");

var _stringify2 = _interopRequireDefault(_stringify);

var _string = __webpack_require__(34);

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

var featuresReq = __webpack_require__(97);
var reducersReq = __webpack_require__(98);
var es6 = function es6(mod) {
  return mod.default ? mod.default : mod;
};

var defaultFeatures = exports.defaultFeatures = featuresReq.keys().reduce(function (memo, key) {
  return (0, _extends9.default)({}, memo, (0, _defineProperty3.default)({}, key.replace(/\.\//, '').replace(/\.js$/, ''), es6(featuresReq(key))));
}, {});

var defaultReducers = exports.defaultReducers = reducersReq.keys().reduce(function (memo, key) {
  return (0, _extends9.default)({}, memo, (0, _defineProperty3.default)({}, key.replace(/\.\//, '').replace(/\.js$/, ''), es6(reducersReq(key))));
}, {});

function api() {
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  var _options$history = options.history;
  var history = _options$history === undefined ? [] : _options$history;
  var _options$scope = options.scope;
  var scope = _options$scope === undefined ? this : _options$scope;
  var _options$features = options.features;
  var features = _options$features === undefined ? {} : _options$features;
  var _options$reducers = options.reducers;
  var reducers = _options$reducers === undefined ? {} : _options$reducers;
  var _options$keyFn = options.keyFn;
  var keyFn = _options$keyFn === undefined ? _string.pluralize : _options$keyFn;


  features = (0, _lodash.mapValues)((0, _extends9.default)({}, defaultFeatures, features), function (fn) {
    return fn.bind ? fn.bind(scope) : fn;
  });
  reducers = (0, _lodash.mapValues)((0, _extends9.default)({}, defaultReducers, reducers), function (fn) {
    return fn.bind ? fn.bind(scope) : fn;
  });

  var getState = function getState() {
    var initialState = (0, _lodash.reduce)(features, function (acc, feature, name) {
      var defaultValue = feature();

      if ((0, _lodash.isUndefined)(defaultValue)) {
        return acc;
      }

      return (0, _extends9.default)({}, acc, (0, _defineProperty3.default)({}, name, defaultValue));
    }, {});

    var state = history.reduce(function (acc, _ref) {
      var name = _ref.name;
      var args = _ref.args;

      var featureState = acc[name];
      var feature = features[name];

      return (0, _extends9.default)({}, acc, (0, _defineProperty3.default)({}, name, feature.apply(undefined, [featureState].concat((0, _toConsumableArray3.default)(args)))));
    }, initialState);

    Object.defineProperty(state, "toString", {
      value: function value() {
        return (0, _stringify2.default)(state);
      }
    });

    return state;
  };

  var _getConfig = function _getConfig() {
    var tap = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : options.tap;

    var state = getState();
    var config = (0, _lodash.reduce)(reducers, function (config, reducer, name) {
      var reduced = reducer(state);

      if ((0, _lodash.isUndefined)(reduced)) {
        return config;
      }

      return (0, _extends9.default)({}, config, (0, _defineProperty3.default)({}, name, reducer(state)));
    }, {});

    if (typeof tap === 'function') {
      config = tap.call(scope, config, options);
    }

    Object.defineProperty(config, "toString", {
      value: function value() {
        return (0, _stringify2.default)(config);
      }
    });

    return config;
  };

  var when = function when(env, configure) {
    var envs = Array.isArray(env) ? env : [env];
    var _process$env$NODE_ENV = process.env.NODE_ENV;
    var NODE_ENV = _process$env$NODE_ENV === undefined ? "development" : _process$env$NODE_ENV;


    if (env === true || envs.indexOf(NODE_ENV) !== -1) {
      return configure(api({ features: features, reducers: reducers, history: history }));
    } else if (typeof env === 'function' && env(getState(), _getConfig)) {
      return configure({ features: features, reducers: reducers, history: history });
    }

    return api({ features: features, reducers: reducers, history: history });
  };

  return (0, _lodash.reduce)(features, function (acc, feature, name) {
    return (0, _extends9.default)({}, acc, (0, _defineProperty3.default)({}, name, function () {
      for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }

      return api({
        features: features,
        reducers: reducers,
        history: history.concat({ args: args, name: name })
      });
    }));
  }, {
    getConfig: function getConfig() {
      return (0, _lodash.mapKeys)(_getConfig.apply(undefined, arguments), function (v, k) {
        return keyFn(k);
      });
    },
    getState: getState,
    history: history,
    when: when
  });
}

exports.default = api;

/***/ },

/***/ "./src/config/reducers/collection.js":
/***/ function(module, exports, __webpack_require__) {

"use strict";
'use strict';

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

var _extends2 = __webpack_require__(0);

var _extends3 = _interopRequireDefault(_extends2);

exports.default = collection;

var _path = __webpack_require__(8);

var _lang = __webpack_require__(58);

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

function collection(state) {
  var collection = state.collection;


  if (!collection) {
    return undefined;
  }

  var args = collection.map(function (val) {
    if (val.length === 1 && (0, _lang.isString)(val[0])) {
      return {
        name: (0, _path.basename)(val[0]),
        cwd: val[0]
      };
    }

    if (val.length === 1 && (0, _lang.isObject)(val[0])) {
      return val[0];
    }

    if (val.length === 1 && (0, _lang.isString)(val[0]) && (0, _lang.isString)(val[1])) {
      return {
        name: val[0],
        cwd: (0, _path.resolve)(val[1], state.context || process.cwd())
      };
    }

    if (val.length === 1 && (0, _lang.isString)(val[0]) && (0, _lang.isObject)(val[1])) {
      return (0, _extends3.default)({
        name: val[0]
      }, val[1]);
    }

    return val;
  });

  return args.filter(function (i) {
    return i.length > 0;
  });
}

/***/ },

/***/ "./src/config/reducers/feature.js":
/***/ function(module, exports) {

"use strict";
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = feature;
function feature(state) {
  return state.feature;
}

/***/ },

/***/ "./src/config/reducers/scope.js":
/***/ function(module, exports) {

"use strict";
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = scope;
function scope(state) {
  var scope = state.scope;


  return scope;
}

/***/ },

/***/ "./src/config/reducers/selector.js":
/***/ function(module, exports) {

"use strict";
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = selector;
function selector(state) {
  return state.selector;
}

/***/ },

/***/ "./src/config/stringify.js":
/***/ function(module, exports, __webpack_require__) {

"use strict";
"use strict";

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

var _stringify = __webpack_require__(54);

var _stringify2 = _interopRequireDefault(_stringify);

var _keys = __webpack_require__(9);

var _keys2 = _interopRequireDefault(_keys);

exports.default = stringify;

var _lodash = __webpack_require__(6);

var _Expression = __webpack_require__("./src/config/Expression.js");

var _Expression2 = _interopRequireDefault(_Expression);

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

function stringify(value) {
  var replacements = [];

  var replace = function replace(replacement) {
    return "__REPLACEMENT_" + (replacements.push(replacement) - 1) + "__";
  };

  var sort = function sort(object) {
    return (0, _keys2.default)(object).sort().reduce(function (sorted, key) {
      sorted[key] = object[key];

      return sorted;
    }, {});
  };

  var replacer = function replacer(key, value) {
    if (value instanceof _Expression2.default) {
      return replace(value.toString());
    }

    if (value instanceof RegExp) {
      return replace(value.toString());
    }

    return value;
  };

  var string = (0, _stringify2.default)(_lodash.isPlainObject ? sort(value) : value, replacer, 2);

  return string.replace(/(^[\s]+)?"__REPLACEMENT_([\d]+)__"/gm, function (match) {
    var indent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
    var index = arguments[2];
    return ("" + indent + replacements[index]).split("\n").join("\n" + indent);
  });
}

/***/ },

/***/ 0:
/***/ function(module, exports) {

module.exports = require("babel-runtime/helpers/extends");

/***/ },

/***/ 1:
/***/ function(module, exports) {

module.exports = require("babel-runtime/helpers/classCallCheck");

/***/ },

/***/ 11:
/***/ function(module, exports) {

module.exports = require("babel-runtime/helpers/defineProperty");

/***/ },

/***/ 121:
/***/ function(module, exports, __webpack_require__) {

module.exports = __webpack_require__("./src/config/index.js");


/***/ },

/***/ 2:
/***/ function(module, exports) {

module.exports = require("babel-runtime/helpers/createClass");

/***/ },

/***/ 33:
/***/ function(module, exports) {

module.exports = require("lodash/isEmpty");

/***/ },

/***/ 34:
/***/ function(module, exports) {

module.exports = require("skypager-util/lib/string");

/***/ },

/***/ 4:
/***/ function(module, exports) {

module.exports = require("babel-runtime/helpers/toConsumableArray");

/***/ },

/***/ 54:
/***/ function(module, exports) {

module.exports = require("babel-runtime/core-js/json/stringify");

/***/ },

/***/ 58:
/***/ function(module, exports) {

module.exports = require("lodash/lang");

/***/ },

/***/ 6:
/***/ function(module, exports) {

module.exports = require("lodash");

/***/ },

/***/ 8:
/***/ function(module, exports) {

module.exports = require("path");

/***/ },

/***/ 9:
/***/ function(module, exports) {

module.exports = require("babel-runtime/core-js/object/keys");

/***/ },

/***/ 97:
/***/ function(module, exports, __webpack_require__) {

var map = {
	"./collection.js": "./src/config/features/collection.js",
	"./feature.js": "./src/config/features/feature.js",
	"./scope.js": "./src/config/features/scope.js",
	"./selector.js": "./src/config/features/selector.js"
};
function webpackContext(req) {
	return __webpack_require__(webpackContextResolve(req));
};
function webpackContextResolve(req) {
	var id = map[req];
	if(!(id + 1)) // check for number
		throw new Error("Cannot find module '" + req + "'.");
	return id;
};
webpackContext.keys = function webpackContextKeys() {
	return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = 97;


/***/ },

/***/ 98:
/***/ function(module, exports, __webpack_require__) {

var map = {
	"./collection.js": "./src/config/reducers/collection.js",
	"./feature.js": "./src/config/reducers/feature.js",
	"./scope.js": "./src/config/reducers/scope.js",
	"./selector.js": "./src/config/reducers/selector.js"
};
function webpackContext(req) {
	return __webpack_require__(webpackContextResolve(req));
};
function webpackContextResolve(req) {
	var id = map[req];
	if(!(id + 1)) // check for number
		throw new Error("Cannot find module '" + req + "'.");
	return id;
};
webpackContext.keys = function webpackContextKeys() {
	return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = 98;


/***/ }

/******/ });