<?php

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

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template variables passed via extract().
$grid_template_rows    = isset( $grid_template_rows ) ? $grid_template_rows : [];
$grid_template_columns = isset( $grid_template_columns ) ? $grid_template_columns : [];
$available_hours       = isset( $available_hours ) ? $available_hours : [];
$visible_days          = isset( $visible_days ) ? $visible_days : [];
$hidden_columns        = isset( $hidden_columns ) ? $hidden_columns : [];
$hidden_hour_tracks    = isset( $hidden_hour_tracks ) ? $hidden_hour_tracks : [];
$marker_visible        = isset( $marker_visible ) ? $marker_visible : false;
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
<style id="sugar-calendar-bookings-calendar-styles">
    .sugar-calendar-bookings-calendar__content {
        grid-template-rows: <?php echo esc_attr( implode( ' ', $grid_template_rows ) ); ?>;
        grid-auto-rows: 0;
    }

	<?php if ( ! empty( $grid_template_columns ) ) : ?>

    .sugar-calendar-bookings-calendar__header,
    .sugar-calendar-bookings-calendar__content,
    .sugar-calendar-bookings-calendar__footer {
        grid-template-columns: <?php echo esc_attr( implode( ' ', $grid_template_columns ) ); ?>;
    }

	<?php endif; ?>

    .sugar-calendar-bookings-calendar__content {
	<?php echo esc_attr( implode( ',', $available_hours ) ); ?> {
        --enabled: 100%;
    }
    }

	<?php if ( $marker_visible ) : ?>

    .sugar-calendar-bookings-calendar__current-time-line {
        display: block !important;
        grid-column-start: <?php echo esc_attr( $visible_days[0] ); ?>;
    }

	<?php
	endif;

	// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template variable in foreach loop.
	foreach ( $hidden_columns as $column ) :
	?>

    .sugar-calendar-bookings-calendar__cell--<?php echo esc_attr( $column ); ?> {
        display: none !important;
    }

	<?php endforeach; ?>

	<?php
	// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template variable in foreach loop.
	foreach ( $hidden_hour_tracks as $track ) :
	?>

    .sugar-calendar-bookings-calendar__cell__hour[data-row="<?php echo esc_attr( $track ); ?>"] {
        display: none !important;
    }

	<?php endforeach; ?>
</style>
