'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.composeComponentPath = composeComponentPath;
exports.composeDependencyPath = composeDependencyPath;
exports.composeDependencyPathForIsolated = composeDependencyPathForIsolated;

var _path;

function _load_path() {
  return _path = _interopRequireDefault(require('path'));
}

var _stringFormat;

function _load_stringFormat() {
  return _stringFormat = _interopRequireDefault(require('string-format'));
}

var _constants;

function _load_constants() {
  return _constants = require('../../constants');
}

var _bitId;

function _load_bitId() {
  return _bitId = _interopRequireDefault(require('../../bit-id/bit-id'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function composeComponentPath(bitId) {
  var componentsDefaultDirectory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_constants || _load_constants()).DEFAULT_COMPONENTS_DIR_PATH;

  return (0, (_stringFormat || _load_stringFormat()).default)(componentsDefaultDirectory, { name: bitId.name, scope: bitId.scope });
}

function composeDependencyPath(bitId) {
  var dependenciesDir = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_constants || _load_constants()).DEFAULT_DEPENDENCIES_DIR_PATH;

  return (_path || _load_path()).default.join(dependenciesDir, bitId.toFullPath());
}

function composeDependencyPathForIsolated(bitId) {
  var dependenciesDir = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (_constants || _load_constants()).DEFAULT_DEPENDENCIES_DIR_PATH;

  var getIdPath = function getIdPath() {
    try {
      return bitId.toFullPath();
    } catch (err) {
      return bitId.name;
    }
  };
  return (_path || _load_path()).default.join(dependenciesDir, getIdPath());
}