<?php
/**
 * @package ThemeREX\AutoDealer
 */

declare(strict_types=1);

namespace ThemeREX\AutoDealer\Elementor\DynamicTags;

if ( ! class_exists( '\Elementor\Core\DynamicTags\Tag' ) ) {
	return;
}

class StatusTag extends AbstractVehicleTag {

	protected string $tag_name  = 'trx-ad-status';
	protected string $tag_title = 'Vehicle Status';

	public function __construct( array $data = array() ) {
		parent::__construct( $data );
		$this->tag_title = __( 'Vehicle Status', 'trx-auto-dealer' );
	}

	protected function resolveValue( int $vehicleId ): string {
		$status = $this->specs( $vehicleId, 'status' );
		if ( '' === $status ) {
			return '';
		}
		$labels = array(
			'available'   => __( 'Available', 'trx-auto-dealer' ),
			'reserved'    => __( 'Reserved', 'trx-auto-dealer' ),
			'sold'        => __( 'Sold', 'trx-auto-dealer' ),
			'coming_soon' => __( 'Coming Soon', 'trx-auto-dealer' ),
		);
		return $labels[ $status ] ?? ucfirst( str_replace( '_', ' ', $status ) );
	}
}
