<?php
/**
 * AI provider factory.
 *
 * @package Ugcify\AI
 */

namespace Ugcify\AI;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class AIProviderFactory {
	/**
	 * Create active provider.
	 *
	 * @param array<string,mixed>|null $settings Settings.
	 * @return AIProviderInterface
	 */
	public function make( ?array $settings = null ): AIProviderInterface {
		$settings = is_array( $settings ) ? $settings : AISettings::get_settings();
		$provider = isset( $settings['provider'] ) ? (string) $settings['provider'] : AISettings::DEFAULT_PROVIDER;

		switch ( $provider ) {
			case 'wordpress':
				return new WordPressAIProvider( $settings );
			case 'openai':
				return new OpenAIProvider( $settings );
			case 'gemini':
				return new GeminiProvider( $settings );
			case 'anthropic':
			default:
				return new AnthropicProvider( $settings );
		}
	}
}
