"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 _consumer() {
  const data = require("../../../consumer");

  _consumer = function () {
    return data;
  };

  return data;
}

function _scope() {
  const data = require("../../../scope");

  _scope = function () {
    return data;
  };

  return data;
}

function _loader() {
  const data = _interopRequireDefault(require("../../../cli/loader"));

  _loader = function () {
    return data;
  };

  return data;
}

function _loaderMessages() {
  const data = require("../../../cli/loader/loader-messages");

  _loaderMessages = function () {
    return data;
  };

  return data;
}

function _remote() {
  const data = _interopRequireDefault(require("../../../remotes/remote"));

  _remote = function () {
    return data;
  };

  return data;
}

function _componentsList() {
  const data = _interopRequireDefault(require("../../../consumer/component/components-list"));

  _componentsList = function () {
    return data;
  };

  return data;
}

function _scopeRemotes() {
  const data = require("../../../scope/scope-remotes");

  _scopeRemotes = function () {
    return data;
  };

  return data;
}

var _default =
/*#__PURE__*/
function () {
  var _list = (0, _bluebird().coroutine)(function* ({
    scopeName,
    showAll,
    // include nested
    showRemoteVersion,
    namespacesUsingWildcards
  }) {
    const consumer = yield (0, _consumer().loadConsumer)();
    const scope = consumer.scope;

    if (scopeName) {
      const remotes = yield (0, _scopeRemotes().getScopeRemotes)(scope);
      const remote = yield remotes.resolve(scopeName, scope);
      return remoteList(remote);
    }

    return scopeList();

    function remoteList(remote) {
      _loader().default.start(_loaderMessages().BEFORE_REMOTE_LIST);

      return remote.list(namespacesUsingWildcards);
    }

    function scopeList() {
      return _scopeList.apply(this, arguments);
    }

    function _scopeList() {
      _scopeList = (0, _bluebird().coroutine)(function* () {
        _loader().default.start(_loaderMessages().BEFORE_LOCAL_LIST);

        const componentsList = new (_componentsList().default)(consumer);
        return componentsList.listScope(showRemoteVersion, showAll, namespacesUsingWildcards);
      });
      return _scopeList.apply(this, arguments);
    }
  });

  function list(_x) {
    return _list.apply(this, arguments);
  }

  return list;
}();

exports.default = _default;