<?php
/** Read verified Ocean Extra module switches. */

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

function wpagent_ability_get_oceanwp_extra_modules(): array {
	return array(
		'label'               => __( 'Ocean-Extra-Module lesen', 'wp-agent-companion' ),
		'description'         => __( 'Liest die geprüften Ocean-Extra-Modulschalter samt Konflikthash und sicherer Schreibpolicy.', 'wp-agent-companion' ),
		'category'            => 'wp-agent',
		'input_schema'        => array( 'type' => 'object', 'properties' => array(), 'additionalProperties' => false ),
		'output_schema'       => wpagent_ocean_extra_modules_output_schema(),
		'execute_callback'    => 'wpagent_exec_get_oceanwp_extra_modules',
		'permission_callback' => 'wpagent_perm_manage_options',
		'meta'                => array( 'show_in_rest' => true, 'annotations' => array( 'readonly' => true, 'destructive' => false, 'idempotent' => true ) ),
	);
}

/** @return array<string,mixed>|WP_Error */
function wpagent_exec_get_oceanwp_extra_modules() {
	$ready = wpagent_ocean_extra_modules_require_runtime();
	if ( is_wp_error( $ready ) ) {
		return $ready;
	}
	$snapshot = wpagent_ocean_extra_modules_snapshot();
	if ( is_wp_error( $snapshot ) ) {
		return $snapshot;
	}
	return array(
		'modules'    => wpagent_ocean_extra_modules_normalize( $snapshot ),
		'state_hash' => wpagent_ocean_extra_modules_state_hash( $snapshot ),
	);
}
