<?php

if ( !defined( 'ABSPATH' ) ) {
    exit;
}
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$countdown_data = Pricely_View_Data_CountDown::get_instance();

$countdown = $countdown_data->get_data( $view_data[ 'countdown_args' ], 'single' );

if ( !$countdown ) {

    return;
}

$auto_refresh = 'no';
$auto_refresh_url = '';

if ( $countdown[ 'auto_refresh' ][ 'enable' ] ) {

    $auto_refresh = 'yes';

    $auto_refresh_url = $countdown[ 'auto_refresh' ][ 'url' ];
}

$display_timer = $countdown[ 'display' ];

$allow_html = Pricely_Main::get_instance()->get_allow_html();
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<div class="pricely-timer <?php echo esc_attr( $view_data[ 'ui_css_class' ] ); ?>" data-pricely_datetime="<?php echo esc_attr( $countdown[ 'datetime' ] ); ?>" data-pricely_refresh="<?php echo esc_attr( $auto_refresh ); ?>" data-pricely_url="<?php echo esc_attr( $auto_refresh_url ); ?>">
    <?php
    if ( !empty( $view_data[ 'content' ][ 'title_text' ] ) ) {
        ?>
        <<?php echo esc_attr( $view_data[ 'content' ][ 'title_tag' ] ); ?> class="pricely-timer-title"><?php echo wp_kses( $view_data[ 'content' ][ 'title_text' ], $allow_html ); ?></<?php echo esc_attr( $view_data[ 'content' ][ 'title_tag' ] ); ?>>
        <?php
    }
    ?>
    <div class="prly-tm-inner prly-type-inline">
        <?php
        if ( isset( $display_timer[ 'days' ] ) ) {
            ?>
            <div class="prly-tm-box prly-tm-bx-days">
                <div class="prly-tm-content">
                    <span class="prly-tm-value prly-tm-days"><?php echo esc_html( $display_timer[ 'days' ] ); ?></span><span class="prly-tm-label"><?php echo esc_html( $view_data[ 'content' ][ 'days_text' ] ); ?></span>  
                </div>
            </div>
            <?php
        }
        ?>
        <div class="prly-tm-box prly-tm-bx-hours">
            <div class="prly-tm-content">
                <span class="prly-tm-value prly-tm-hours"><?php echo esc_html( $display_timer[ 'hours' ] ); ?></span><span class="prly-tm-label"><?php echo esc_html( $view_data[ 'content' ][ 'hours_text' ] ); ?></span>
            </div>
        </div>
        <div class="prly-tm-box prly-tm-bx-minutes">
            <div class="prly-tm-content">
                <span class="prly-tm-value prly-tm-minutes"><?php echo esc_html( $display_timer[ 'minutes' ] ); ?></span><span class="prly-tm-label"><?php echo esc_html( $view_data[ 'content' ][ 'minutes_text' ] ); ?></span>
            </div>
        </div>
        <div class="prly-tm-box prly-tm-bx-seconds">
            <div class="prly-tm-content prly-tm-last-content">
                <span class="prly-tm-value prly-tm-seconds"><?php echo esc_html( $display_timer[ 'seconds' ] ); ?></span><span class="prly-tm-label prly-tm-last"><?php echo esc_html( $view_data[ 'content' ][ 'seconds_text' ] ); ?></span>
            </div>
        </div>
    </div>
</div>