<?php
/**
 * SoftwareApplication 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 SoftwareApplication extends SchemaBase {

	public function schema_data() {
		return array(
			'title'   => 'SoftwareApplication',
			'type'    => 'SoftwareApplication',
			'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_software_application',
			array(
				array(
					'id'      => 'schema_name',
					'label'   => __( 'Schema Title', 'seovault-ai' ),
					'show'    => true,
					'default' => true,
					'type'    => 'Title',
					'std'     => 'SoftwareApplication',
				),
				array(
					'id'       => '@id',
					'type'     => 'Hidden',
					'std'      => '%current.url%#software',
					'required' => true,
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'       => 'name',
					'label'    => __( 'Application Name', 'seovault-ai' ),
					'desc'     => __( 'The software name as shown on this page.', 'seovault-ai' ),
					'required' => true,
					'std'      => '',
					'type'     => 'Text',
					'default'  => true,
					'show'     => true,
				),
				array(
					'id'      => 'description',
					'label'   => __( 'Description', 'seovault-ai' ),
					'desc'    => __( 'Optional summary of what the application does.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Textarea',
				),
				array(
					'id'      => 'applicationCategory',
					'label'   => __( 'Category', 'seovault-ai' ),
					'desc'    => __( 'Optional category such as BusinessApplication or GameApplication.', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Text',
				),
				array(
					'id'      => 'operatingSystem',
					'label'   => __( 'Operating System', 'seovault-ai' ),
					'desc'    => __( 'Recommended. Platforms the app runs on (for example Windows, iOS, Web).', 'seovault-ai' ),
					'default' => true,
					'show'    => true,
					'std'     => '',
					'type'    => 'Text',
				),
				array(
					'id'       => 'offers',
					'label'    => __( 'Offers', 'seovault-ai' ),
					'desc'     => __( 'Required for readiness. Enter a real price (use 0 for free). Always include an ISO 4217 currency. Do not invent prices.', 'seovault-ai' ),
					'type'     => 'Group',
					'required' => true,
					'default'  => true,
					'show'     => true,
					'fields'   => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'Offer',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'       => 'price',
							'label'    => __( 'Price', 'seovault-ai' ),
							'desc'     => __( 'Numeric price. Use 0 for free software. Do not leave blank or invent a price just to pass validation.', 'seovault-ai' ),
							'required' => true,
							'std'      => '',
							'type'     => 'Number',
							'default'  => true,
							'show'     => true,
						),
						array(
							'id'       => 'priceCurrency',
							'label'    => __( 'Currency', 'seovault-ai' ),
							'desc'     => __( 'ISO 4217 currency code (for example USD). Required whenever a price is set, including free (0).', 'seovault-ai' ),
							'required' => true,
							'std'      => '',
							'type'     => 'Text',
							'default'  => true,
							'show'     => true,
						),
					),
				),
				array(
					'id'      => 'aggregateRating',
					'label'   => __( 'Aggregate Rating', 'seovault-ai' ),
					'desc'    => __( 'Optional rating branch. Only add when you have a real aggregate rating from reviews. Fabricated ratings are not ready.', 'seovault-ai' ),
					'type'    => 'Group',
					'default' => true,
					'show'    => true,
					'fields'  => array(
						array(
							'id'      => '@type',
							'type'    => 'Hidden',
							'std'     => 'AggregateRating',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'ratingValue',
							'label'   => __( 'Rating Value', 'seovault-ai' ),
							'desc'    => __( 'Average rating within the best/worst scale. Leave blank if you have no real rating data.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Number',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'ratingCount',
							'label'   => __( 'Rating Count', 'seovault-ai' ),
							'desc'    => __( 'Number of ratings that produced the average. Required when a rating value is set.', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Number',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'bestRating',
							'label'   => __( 'Best Rating', 'seovault-ai' ),
							'desc'    => __( 'Optional upper bound of the scale (defaults to 5 when omitted).', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Number',
							'default' => true,
							'show'    => true,
						),
						array(
							'id'      => 'worstRating',
							'label'   => __( 'Worst Rating', 'seovault-ai' ),
							'desc'    => __( 'Optional lower bound of the scale (defaults to 1 when omitted).', 'seovault-ai' ),
							'std'     => '',
							'type'    => 'Number',
							'default' => true,
							'show'    => true,
						),
					),
				),
			)
		);
	}
}
