"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRepositoryUrl = exports.getGitProviderBaseUrl = exports.VcsProvider = exports.RepositoryEntityType = void 0;
var RepositoryEntityType;
(function (RepositoryEntityType) {
    RepositoryEntityType["APPLICATION"] = "application";
    RepositoryEntityType["WORKFLOW"] = "workflow";
    RepositoryEntityType["SCHEDULED_JOB"] = "scheduled_job";
})(RepositoryEntityType || (exports.RepositoryEntityType = RepositoryEntityType = {}));
var VcsProvider;
(function (VcsProvider) {
    VcsProvider["GITHUB"] = "github";
    VcsProvider["GITLAB"] = "gitlab";
    VcsProvider["AZURE_DEVOPS"] = "azure_devops";
    VcsProvider["BITBUCKET"] = "bitbucket";
})(VcsProvider || (exports.VcsProvider = VcsProvider = {}));
const getGitProviderBaseUrl = (provider, token) => {
    switch (provider) {
        case VcsProvider.GITLAB: {
            if (token?.instanceUrl)
                return token.instanceUrl;
            return 'https://gitlab.com';
        }
        case VcsProvider.AZURE_DEVOPS: {
            return 'https://dev.azure.com';
        }
        case VcsProvider.BITBUCKET: {
            return 'https://bitbucket.org';
        }
        case VcsProvider.GITHUB:
        default: {
            return 'https://github.com';
        }
    }
};
exports.getGitProviderBaseUrl = getGitProviderBaseUrl;
const getRepositoryUrl = (repository, token) => {
    const baseUrl = (0, exports.getGitProviderBaseUrl)(repository.provider, token);
    if (repository.provider === VcsProvider.AZURE_DEVOPS) {
        // Azure DevOps URL format: https://dev.azure.com/{organization}/{project}/_git/{repo}
        return `${baseUrl}/${repository.owner}/_git/${repository.name}`;
    }
    return `${baseUrl}/${repository.owner}/${repository.name}`;
};
exports.getRepositoryUrl = getRepositoryUrl;
//# sourceMappingURL=index.js.map