"use strict";

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

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

function _objectSpread2() {
  const data = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));

  _objectSpread2 = function () {
    return data;
  };

  return data;
}

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

  _bluebird = function () {
    return data;
  };

  return data;
}

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

  _loader = function () {
    return data;
  };

  return data;
}

function _() {
  const data = require("..");

  _ = function () {
    return data;
  };

  return data;
}

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

  _loaderMessages = function () {
    return data;
  };

  return data;
}

var _default =
/*#__PURE__*/
function () {
  var _show = (0, _bluebird().coroutine)(function* ({
    id,
    json,
    versions,
    remote,
    outdated,
    compare,
    detailed,
    dependents,
    dependencies
  }) {
    if (versions) {
      return getComponent(versions).then(components => ({
        components,
        versions
      }));
    }

    return getComponent().then(({
      component,
      componentModel,
      dependentsInfo,
      dependenciesInfo
    }) => ({
      component,
      componentModel,
      dependentsInfo,
      dependenciesInfo,
      json,
      outdated,
      detailed
    }));

    function getComponent(allVersions) {
      const params = {
        id,
        allVersions,
        showRemoteVersions: outdated,
        showDependents: dependents,
        showDependencies: dependencies
      };

      if (remote) {
        _loader().default.start(_loaderMessages().BEFORE_SHOW_REMOTE);

        return (0, _().getScopeComponent)(params);
      }

      return (0, _().getConsumerComponent)((0, _objectSpread2().default)({}, params, {
        compare
      }));
    }
  });

  function show(_x) {
    return _show.apply(this, arguments);
  }

  return show;
}();

exports.default = _default;