<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

?>

<div class="brands-container-js prodigy-custom-template"
	data-brands='<?php use Prodigy\includes\helpers\Prodigy_Elementor;

	echo esc_attr( wp_json_encode( array_values( $data ?? array() ), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE ) ); ?>'>
	<div class="prodigy-select__brands-widget prodigy-select__product-brands-widget">
		<div class="prodigy-select__product-brands">
			<div class="prodigy-product__product-brand-text-label">
				<span class="prodigy-product__product-brand-text-label--inner">
					<?php esc_html_e( 'Brands list', 'prodigy-commerce' ); ?>
				</span>
			</div>
			<label for="brand-select" class="prodigy-visually-hidden">
				<?php esc_html_e( 'Select a brand', 'prodigy-commerce' ); ?>
			</label>
			<select class="prodigy-main-select brands-js" id="brand-select" aria-label="<?php esc_attr_e( 'Select a brand', 'prodigy-commerce' ); ?>">
				<?php if ( isset( $data ) && Prodigy_Elementor::is_editor_mode() ) : ?>
					<?php foreach ( $data as $brand ) : ?>
						<option value="<?php echo esc_attr( $brand['brand_slug'] ); ?>">
							<?php echo esc_html( $brand['brand_name'] ); ?>
						</option>
					<?php endforeach; ?>
				<?php endif; ?>
			</select>
		</div>
	</div>
