<?php
/**
 * This file is used to markup the filter type search.
 *
 * @since      1.0
 *
 * @package    SiteEase_Smart_Product_Filtering_Engine
 * @subpackage SiteEase_Smart_Product_Filtering_Engine/public/partials/filter-types
 */

// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>

<?php
$display_search_heading = ifqpf_get_option('display_search_heading');
if( $display_search_heading === 'yes' ){
	$heading = trim(ifqpf_get_option('search_heading'));
}
$placeholder = ifqpf_get_option('search_placeholder');

$feld_args = array(
	'type' => 'text',
	'value' => '',
	'name' => 'ifqpf_search',
	'placeholder' => $placeholder,
);

$toggle_btn = ifqpf_get_option('toggle_btn_search');
$field_toggle = ( $toggle_btn === 'yes' ) ? true : false;
$default_toggle_search = ifqpf_get_option('default_toggle_search');

$toggled_btn_class = ( $default_toggle_search === 'show' ) ? 'ifqpf-type-btn-toggled' : '';
$toggled_type_class = ( $display_search_heading === 'yes' && $toggle_btn === 'yes' ) ? 'ifqpf-toggle-enabeled' : '';
$toggled_type_class = ( $default_toggle_search === 'show' ) ? $toggled_type_class . ' ifqpf-type-toggled' : $toggled_type_class;
?>
<div class="ifqpf-type ifqpf-type-search <?php echo esc_attr( $toggled_type_class ); ?>">
	<?php if( $display_search_heading === 'yes' ) { ?>
		<div class="ifqpf-type-heading">
			<label><?php echo ( !empty( $heading ) ) ? esc_html($heading) : esc_html__('Search', 'siteease-smart-product-filtering-engine'); ?></label>
			<?php if(!empty($field_toggle)) { ?>
					<i class="ifqpf-toggle-field-btn fa-solid fa-circle-plus <?php echo esc_attr( $toggled_btn_class ); ?>"></i>
				<?php } ?> 
		</div>
	<?php } ?>
	<div class="ifqpf-field-wrap">
		<?php ifqpf_get_front_field_markup($feld_args); ?>
	</div>
</div>