/**
 * @license
 * Copyright 2025 Vybestack LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import { GeminiOAuthProvider } from '../auth/gemini-oauth-provider.js';
import { QwenOAuthProvider } from '../auth/qwen-oauth-provider.js';
import { AnthropicOAuthProvider } from '../auth/anthropic-oauth-provider.js';
/**
 * Track which OAuth providers have been registered to avoid duplicate registration
 */
let registeredProviders = new Set();
/**
 * Context-aware OAuth provider registration
 * Only registers OAuth providers when actually needed for specific providers
 */
export function ensureOAuthProviderRegistered(providerName, oauthManager, tokenStore, addItem) {
    if (registeredProviders.has(providerName) || !oauthManager) {
        return;
    }
    let oauthProvider = null;
    switch (providerName) {
        case 'gemini':
            oauthProvider = new GeminiOAuthProvider(tokenStore);
            break;
        case 'qwen':
            oauthProvider = new QwenOAuthProvider(tokenStore);
            break;
        case 'anthropic':
            oauthProvider = new AnthropicOAuthProvider(tokenStore);
            break;
        default:
            return; // No OAuth provider needed for this provider name
    }
    if (oauthProvider && addItem) {
        oauthProvider.setAddItem?.(addItem);
    }
    if (oauthProvider) {
        oauthManager.registerProvider(oauthProvider);
        registeredProviders.add(providerName);
    }
}
/**
 * Check if an OAuth provider has been registered
 */
export function isOAuthProviderRegistered(providerName) {
    return registeredProviders.has(providerName);
}
/**
 * Reset registered providers (mainly for testing)
 */
export function resetRegisteredProviders() {
    registeredProviders = new Set();
}
//# sourceMappingURL=oauth-provider-registration.js.map