<?php
/**
 * AI Assistant Module.
 *
 * Provides the connection settings for the plugin's AI features (an
 * OpenAI-compatible API such as Groq). The features themselves live in their
 * own modules (e.g. the AI Visibility Check's refined-intro rewriter) and use
 * Core\LlmClient. Disabled by default until a key is added.
 *
 * @package Platform\Helm\Modules\Ai
 */

declare( strict_types = 1 );

namespace Platform\Helm\Modules\Ai;

use Platform\Helm\Contracts\ModuleInterface;
use Platform\Helm\Core\Assets;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

final class AiModule implements ModuleInterface {

	private AiSettingsPage $settings_page;
	private AiInsightsPage $insights_page;

	public function __construct( Assets $assets ) {
		unset( $assets ); // Settings page needs no assets bundle.
		$this->settings_page = new AiSettingsPage();
		$this->insights_page = new AiInsightsPage();
	}

	public function id(): string {
		return 'ai_assistant';
	}

	public function name(): string {
		return __( 'AI Assistant', 'platform-helm' );
	}

	public function description(): string {
		return __( 'Connects an OpenAI-compatible AI API (Groq recommended — free, fast, no training on your data) to power the AI Visibility Check rewriter, the Meta Generator, and the AI Insights analyst. Admin-triggered only; your key is encrypted at rest.', 'platform-helm' );
	}

	public function default_enabled(): bool {
		return true;
	}

	public function boot(): void {
		$this->settings_page->register_hooks();
		$this->insights_page->register_hooks();
	}
}
