<?php
/**
 * Activation hook handler.
 *
 * @package Ppok\AIToolkit
 * @license GPL-2.0-or-later
 */

namespace Ppok\AIToolkit;

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

class Activator {

	public const OPTION_KEY = 'ppok_ai_toolkit_settings';

	/**
	 * Default plugin options seeded on first activation.
	 *
	 * Tracks architecture.plugin_options.keys in .context/project.json — the v1
	 * gating model. add_option() is sticky, so these are the values existing
	 * sites will live with until an admin overrides them.
	 *
	 * @return array<string, mixed>
	 */
	public static function default_settings(): array {
		return array(
			'abilities_enabled'       => array(),
			'write_post_types'        => array( 'post' ),
			'write_post_statuses'     => array( 'draft' ),
			'block_allowlist_mode'    => 'registered',
			'block_curated_allowlist' => array(),
			'log_retention_days'      => 90,
		);
	}

	public static function activate(): void {
		if ( false === get_option( self::OPTION_KEY ) ) {
			add_option( self::OPTION_KEY, self::default_settings() );
		}

		( new Event_Logger() )->maybe_install_schema();

		flush_rewrite_rules();
	}
}
