"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.catComponent = catComponent;
function _constants() {
  const data = require("@teambit/legacy/dist/constants");
  _constants = function () {
    return data;
  };
  return data;
}
function _scope() {
  const data = require("@teambit/legacy/dist/scope");
  _scope = function () {
    return data;
  };
  return data;
}
async function catComponent(id) {
  // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
  const scope = await (0, _scope().loadScope)();
  const bitId = await scope.getParsedId(id);
  // $FlowFixMe unclear what's the issue here
  const component = await scope.getModelComponent(bitId);
  if (bitId.hasVersion()) {
    // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
    const version = await component.loadVersion(bitId.version, scope.objects);
    return version.toObject();
  }
  if (bitId.version === _constants().LATEST_BIT_VERSION && id.includes(_constants().VERSION_DELIMITER)) {
    const version = await component.loadVersion(component.getHeadRegardlessOfLaneAsTagOrHash(), scope.objects);
    return version.toObject();
  }
  return component.toObject();
}

//# sourceMappingURL=cat-component.js.map