<?php
/**
 * Review Schema Type — guided field definitions.
 *
 * Server-authoritative form metadata. Emission remains gated by readiness.
 *
 * @package SEOvaultSEO\Schema\Types
 */

namespace SEOvaultSEO\Schema\Types;

use SEOvaultSEO\Schema\SchemaBase;

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

class Review extends SchemaBase {

	public function schema_data() {
		return array(
			'title'   => 'Review',
			'type'    => 'Review',
			'show_on' => array(
				'rules'        => array( 'post|post' ),
				'specific'     => array(),
				'specificText' => array(),
			),
			'fields'  => $this->parse_fields( $this->get() ),
		);
	}

	public function get() {
		return apply_filters(
			'seovaultseo_schema_type_review',
			array(
				array(
					'id'      => 'schema_name',
					'label'   => __( 'Schema Title', 'seovault-ai' ),
					'show'    => true,
					'default' => true,
					'type'    => 'Title',
					'std'     => 'Review',
				),
				array(
					'id'       => '@id',
					'type'     => 'Hidden',
					'std'      => '%current.url%#review',
					'required' => true,
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'      => 'name',
					'label'   => __( 'Review Title', 'seovault-ai' ),
					'desc'    => __( 'Optional short title for this review. Leave blank if the page only needs the review body.', 'seovault-ai' ),
					'std'     => '',
					'type'    => 'Text',
					'default' => true,
					'show'    => true,
				),
				array(
					'id'       => 'reviewBody',
					'label'    => __( 'Review Content', 'seovault-ai' ),
					'desc'     => __( 'Required. Visible review text that appears on this page. Placeholders are not accepted.', 'seovault-ai' ),
					'required' => true,
					'default'  => true,
					'show'     => true,
					'std'      => '',
					'type'     => 'Textarea',
				),
				array(
					'id'       => 'itemReviewed',
					'label'    => __( 'Item Reviewed', 'seovault-ai' ),
					'desc'     => __( 'Required. The concrete thing being reviewed. Do not review your own business, product, or brand as a self-serving review.', 'seovault-ai' ),
					'type'     => 'Group',
					'required' => true,
					'default'  => true,
					'show'     => true,
					'fields'   => array(
						array(
							'id'      => '@type',
							'label'   => __( 'Item type', 'seovault-ai' ),
							'desc'    => __( 'Choose the Schema.org type that best matches the reviewed item.', 'seovault-ai' ),
							'type'    => 'Enum',
							'std'     => '',
							'default' => true,
							'show'    => true,
							'options' => array(
								''                     => __( '— Select —', 'seovault-ai' ),
								'Product'              => __( 'Product', 'seovault-ai' ),
								'Book'                 => __( 'Book', 'seovault-ai' ),
								'Movie'                => __( 'Movie', 'seovault-ai' ),
								'LocalBusiness'        => __( 'Local business', 'seovault-ai' ),
								'SoftwareApplication'  => __( 'Software application', 'seovault-ai' ),
								'Course'               => __( 'Course', 'seovault-ai' ),
								'Event'                => __( 'Event', 'seovault-ai' ),
								'Recipe'               => __( 'Recipe', 'seovault-ai' ),
								'Thing'                => __( 'Thing (generic)', 'seovault-ai' ),
							),
						),
						array(
							'id'       => 'name',
							'label'    => __( 'Item Name', 'seovault-ai' ),
							'desc'     => __( 'Concrete name of the reviewed item. Must not match the review author name.', 'seovault-ai' ),
							'required' => true,
							'std'      => '',
							'type'     => 'Text',
							'default'  => true,
							'show'     => true,
						),
					),
				),
				array(
					'id'       => 'author',
					'label'    => __( 'Author', 'seovault-ai' ),
					'desc'     => __( 'Required. The person who wrote the visible review. Must not be a self-review of the same item.', 'seovault-ai' ),
					'type'     => 'Group',
					'required' => true,
					'default'  => true,
					'show'     => true,
					'fields'   => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'Person',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'       => 'name',
							'label'    => __( 'Author Name', 'seovault-ai' ),
							'desc'     => __( 'Name of the reviewer as shown on the page.', 'seovault-ai' ),
							'required' => true,
							'std'      => '',
							'type'     => 'Text',
							'default'  => true,
							'show'     => true,
						),
					),
				),
				array(
					'id'       => 'reviewRating',
					'label'    => __( 'Rating', 'seovault-ai' ),
					'desc'     => __( 'Required. A real rating within the best/worst bounds. Do not fabricate scores.', 'seovault-ai' ),
					'type'     => 'Group',
					'required' => true,
					'default'  => true,
					'show'     => true,
					'fields'   => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'Rating',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'       => 'ratingValue',
							'label'    => __( 'Rating Value', 'seovault-ai' ),
							'desc'     => __( 'Score within the scale below (inclusive).', 'seovault-ai' ),
							'required' => true,
							'std'      => '',
							'type'     => 'Number',
							'default'  => true,
							'show'     => true,
						),
						array(
							'id'      => 'bestRating',
							'label'   => __( 'Best Rating', 'seovault-ai' ),
							'desc'    => __( 'Upper bound of the scale. Defaults to 5 when left blank.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Number',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'worstRating',
							'label'   => __( 'Worst Rating', 'seovault-ai' ),
							'desc'    => __( 'Lower bound of the scale. Defaults to 1 when left blank.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Number',
							'default' => true,
							'show'    => true,
						),
					),
				),
			)
		);
	}
}
