import type { IntegrationProvider } from "./types";
import { mondayProvider } from "./providers/monday";
import { webhookProvider } from "./providers/webhook";
import { planningCenterProvider } from "./providers/planning-center";
import { airtableProvider } from "./providers/airtable";
import { googleSheetsProvider } from "./providers/google-sheets";
import { csvExportProvider } from "./providers/csv-export";

const providers: Map<string, IntegrationProvider> = new Map();

function register(provider: IntegrationProvider) {
  providers.set(provider.id, provider);
}

register(planningCenterProvider);
register(mondayProvider);
register(airtableProvider);
register(googleSheetsProvider);
register(webhookProvider);
register(csvExportProvider);

export function getProvider(id: string): IntegrationProvider | undefined {
  return providers.get(id);
}

export function getAllProviders(): IntegrationProvider[] {
  return Array.from(providers.values());
}

export function getProvidersByCategory(
  category: string
): IntegrationProvider[] {
  return getAllProviders().filter((p) => p.category === category);
}
