"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.listTicketTrackerProviderKinds = listTicketTrackerProviderKinds;
exports.getTicketTrackerProvider = getTicketTrackerProvider;
exports.requireTicketTrackerProvider = requireTicketTrackerProvider;
exports.resolveTicketTrackerWorkflowStatePresentationFlavor = resolveTicketTrackerWorkflowStatePresentationFlavor;
const catalog_1 = require("../../i18n/catalog");
const ticket_tracker_provider_1 = require("../gitea/ticket-tracker-provider");
const ticket_tracker_provider_2 = require("../gitlab/ticket-tracker-provider");
const ticket_tracker_provider_3 = require("../github/ticket-tracker-provider");
const provider_errors_1 = require("../provider-errors");
const TICKET_TRACKER_PROVIDERS = [
    ticket_tracker_provider_3.githubTicketTrackerProvider,
    ticket_tracker_provider_1.giteaTicketTrackerProvider,
    ticket_tracker_provider_2.gitlabTicketTrackerProvider,
];
const TICKET_TRACKER_PROVIDER_BY_KIND = new Map(TICKET_TRACKER_PROVIDERS.map((provider) => [provider.kind, provider]));
function listTicketTrackerProviderKinds() {
    return [...TICKET_TRACKER_PROVIDER_BY_KIND.keys()];
}
function getTicketTrackerProvider(kind) {
    return TICKET_TRACKER_PROVIDER_BY_KIND.get(kind);
}
function requireTicketTrackerProvider(kind, locale = catalog_1.DEFAULT_APP_LOCALE) {
    const provider = getTicketTrackerProvider(kind);
    if (!provider) {
        throw new provider_errors_1.UnsupportedProviderError("ticketTracker", kind, locale);
    }
    return provider;
}
function resolveTicketTrackerWorkflowStatePresentationFlavor(kind) {
    return requireTicketTrackerProvider(kind).workflowStatePresentationFlavor;
}
