<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

use Gigneo\Modules;

$p_id         = $args['p_id'] ?? 0;
$current_step = $args['current_step'] ?? 'basic';

$steps = array(
	'basic'        => esc_html__( 'Basic', 'gigneo' ),
	'pricing'      => esc_html__( 'Pricing', 'gigneo' ),
	'details'      => esc_html__( 'Details', 'gigneo' ),
	'media'        => esc_html__( 'Media', 'gigneo' ),
	'requirements' => esc_html__( 'Requirements', 'gigneo' ),
);

$intake_form_for = gigneo_option( '_gigneo_ts_intake_form_for', 'both' );

if ( ! in_array( 'intake_form', gigneo_active_modules(), true ) || 'job' === $intake_form_for ) {
	unset( $steps['requirements'] );
}
?>
<div class="gn-edit-steps-wrapper gn-service-edit-steps">
	<div class="gn-head">
		<div class="gn-heading-area">
			<h2 class="gn-heading"><?php echo esc_html__( 'Progress', 'gigneo' ); ?></h2>
			<p class="gn-description">
			<?php
			printf(
			// translators: %1$s: current step number, %2$s: total number of steps.
				esc_html__( 'Step %1$s of %2$s steps', 'gigneo' ),
				'<span data-gn-steps="' . esc_attr( wp_json_encode( $steps ) ) . '" class="gn-current-step">' . esc_html( array_search( $current_step, array_keys( $steps ), true ) + 1 ) . '</span>',
				'<span class="gn-total-step">' . esc_html( count( $steps ) ) . '</span>'
			);
			?>
				</p>
		</div>
		<div class="gn-actions">
			<a href="<?php echo esc_url( get_permalink( $p_id ) ); ?>" <?php echo esc_attr( empty( $p_id ) ? ' disabled' : '' ); ?> target="_blank" class="gn-btn gn-btn-outline-grey gn-btn-md">
				<i class="hi hi-eye" aria-hidden="true"></i>
				<span><?php esc_html_e( 'Preview', 'gigneo' ); ?></span>
			</a>
		</div>
	</div>
	<ul class="gn-edit-steps">
		<?php
		foreach ( $steps as $slug => $label ) {
			?>
			<li class="gn-edit-step<?php echo esc_attr( $slug === $current_step ? ' gn-active' : '' ); ?>" data-gn-step="<?php echo esc_attr( $slug ); ?>">
				<div class="gn-edit-step-info">
					<span class="gn-index"><?php echo esc_html( array_search( $slug, array_keys( $steps ), true ) + 1 ); ?></span>
					<span class="gn-title"><?php echo esc_html( $label ); ?></span>
				</div>
			</li>
		<?php } ?>
	</ul>
</div>