"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getConsumerComponent = getConsumerComponent;
function _consumer() {
  const data = require("@teambit/legacy/dist/consumer");
  _consumer = function () {
    return data;
  };
  return data;
}
function _nothingToCompareTo() {
  const data = require("./nothing-to-compare-to");
  _nothingToCompareTo = function () {
    return data;
  };
  return data;
}
async function getConsumerComponent({
  id,
  compare,
  allVersions
}) {
  const consumer = await (0, _consumer().loadConsumer)();
  const bitId = consumer.getParsedId(id);
  if (allVersions) {
    return consumer.loadAllVersionsOfComponentFromModel(bitId);
  }
  const component = await consumer.loadComponent(bitId); // loads recent component
  if (compare) {
    if (!component.componentFromModel) throw new (_nothingToCompareTo().NothingToCompareTo)(id);
    return {
      component,
      componentModel: component.componentFromModel
    };
  }
  await consumer.onDestroy('get-component');
  return {
    component
  };
}

//# sourceMappingURL=get-consumer-component.js.map