"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.discoverInitProjectRefFromRemote = discoverInitProjectRefFromRemote;
const native_git_repository_client_1 = require("../../git/native-git-repository-client");
const registry_1 = require("../../platform/repository-host/registry");
const registry_2 = require("../../platform/ticket-tracker/registry");
async function discoverInitProjectRefFromRemote(cwd, remoteName, input) {
    const provider = input.providerType === "repositoryHost"
        ? (0, registry_1.getRepositoryHostProvider)(input.kind)
        : (0, registry_2.getTicketTrackerProvider)(input.kind);
    if (!provider?.detectProjectRefFromRemoteUrl) {
        return null;
    }
    const remoteUrl = await (0, native_git_repository_client_1.discoverGitRemoteUrl)(cwd, remoteName);
    return remoteUrl ? provider.detectProjectRefFromRemoteUrl(remoteUrl) : null;
}
