"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

function _bluebird() {
  const data = require("bluebird");

  _bluebird = function () {
    return data;
  };

  return data;
}

function _capsule() {
  const data = _interopRequireDefault(require("../../components/core/capsule"));

  _capsule = function () {
    return data;
  };

  return data;
}

function _fsContainer() {
  const data = _interopRequireDefault(require("../../components/container/fs-container"));

  _fsContainer = function () {
    return data;
  };

  return data;
}

var _default =
/*#__PURE__*/
function () {
  var _createCapsule = (0, _bluebird().coroutine)(function* (type = 'fs', dir) {
    const containerFactory = getContainerFactory();
    const capsule = yield _capsule().default.create(containerFactory);
    yield capsule.start();
    return capsule;

    function getContainerFactory() {
      switch (type) {
        case 'fs':
        default:
          return (
            /*#__PURE__*/
            (0, _bluebird().coroutine)(function* () {
              return new (_fsContainer().default)(dir);
            })
          );
      }
    }
  });

  function createCapsule() {
    return _createCapsule.apply(this, arguments);
  }

  return createCapsule;
}();

exports.default = _default;