"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const getRegistryName_1 = require("../resolve/npm/getRegistryName");
function shortIdToFullId(shortId, registry) {
    if (shortId[0] === '/') {
        const registryName = getRegistryName_1.default(registry);
        return `${registryName}${shortId}`;
    }
    return shortId;
}
exports.shortIdToFullId = shortIdToFullId;
function getPkgShortId(reference, pkgName) {
    if (reference.indexOf('/') === -1) {
        return `/${pkgName}/${reference}`;
    }
    return reference;
}
exports.getPkgShortId = getPkgShortId;
function getPkgId(reference, pkgName, registry) {
    if (reference.indexOf('/') === -1) {
        const registryName = getRegistryName_1.default(registry);
        return `${registryName}/${pkgName}/${reference}`;
    }
    return reference;
}
exports.getPkgId = getPkgId;
function pkgIdToRef(pkgId, pkgName, resolution, standardRegistry) {
    if (resolution.type)
        return pkgId;
    const registryName = getRegistryName_1.default(standardRegistry);
    if (pkgId.startsWith(`${registryName}/`)) {
        const ref = pkgId.replace(`${registryName}/${pkgName}/`, '');
        if (ref.indexOf('/') === -1)
            return ref;
        return pkgId.replace(`${registryName}/`, '/');
    }
    return pkgId;
}
exports.pkgIdToRef = pkgIdToRef;
function pkgShortId(pkgId, standardRegistry) {
    const registryName = getRegistryName_1.default(standardRegistry);
    if (pkgId.startsWith(`${registryName}/`)) {
        return pkgId.substr(pkgId.indexOf('/'));
    }
    return pkgId;
}
exports.pkgShortId = pkgShortId;
//# sourceMappingURL=shrinkwrap.js.map