<?php
/**
 * Generation step service.
 *
 * @package SmartyPress_AI_Engine
 */

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

/**
 * Narrow adapter for legacy title/sections/content/excerpt steps.
 *
 * This keeps legacy pipelines from depending on the full generator facade.
 */
class SmartyPress_AI_Content_Generator_Generation_Step_Service {

	/**
	 * Generator facade used by legacy step methods during the transition.
	 *
	 * @var object
	 */
	private $generator;

	/**
	 * Constructor.
	 *
	 * @param object $generator Generator facade with generation step methods.
	 */
	public function __construct( $generator ) {
		$this->generator = $generator;
	}

	/**
	 * Generate title.
	 *
	 * @param string $context Context.
	 * @param string $provider_name Provider.
	 * @param array  $options Options.
	 * @return array
	 */
	public function generate_title( $context, $provider_name = '', $options = array() ) {
		return $this->generator->generate_title( $context, $provider_name, $options );
	}

	/**
	 * Generate sections.
	 *
	 * @param string $topic Topic.
	 * @param string $title Title.
	 * @param string $provider_name Provider.
	 * @param array  $options Options.
	 * @return array
	 */
	public function generate_sections( $topic, $title = '', $provider_name = '', $options = array() ) {
		return $this->generator->generate_sections( $topic, $title, $provider_name, $options );
	}

	/**
	 * Generate content.
	 *
	 * @param string $title Title.
	 * @param string $context Context.
	 * @param string $provider_name Provider.
	 * @param array  $options Options.
	 * @return array
	 */
	public function generate_content( $title, $context = '', $provider_name = '', $options = array() ) {
		return $this->generator->generate_content( $title, $context, $provider_name, $options );
	}

	/**
	 * Generate excerpt.
	 *
	 * @param string $content Content.
	 * @param string $provider_name Provider.
	 * @param array  $options Options.
	 * @return array
	 */
	public function generate_excerpt( $content, $provider_name = '', $options = array() ) {
		return $this->generator->generate_excerpt( $content, $provider_name, $options );
	}

	/**
	 * Optimize generated post fields for SEO.
	 *
	 * @param array $args Optimization arguments.
	 * @return array
	 */
	public function optimize_generated_post_for_seo( array $args ) {
		return $this->generator->optimize_generated_post_for_seo( $args );
	}

	/**
	 * Get post type SEO rules.
	 *
	 * @param string $post_type Post type.
	 * @param array  $settings Generation settings.
	 * @return array
	 */
	public function get_post_type_seo_rules( $post_type, array $settings ) {
		return $this->generator->get_post_type_seo_rules( $post_type, $settings );
	}
}
