<div class="item">
	<?php
	wp_enqueue_style( 'properties-styles' );
	$prop_price_value             = get_post_meta( $property_id, 'property_price_value', true );
	$prop_price_unit              = get_post_meta( $property_id, 'property_price_unit', true );
	$prop_price_prefix            = get_post_meta( $property_id, 'property_price_prefix', true );
	$prop_price_postfix           = get_post_meta( $property_id, 'property_price_postfix', true );
	$prop_enable_short_price_unit = tfre_get_option( 'enable_short_price_unit', 0 ) == 1 ? true : false;
	$prop_address                 = get_post_meta( $property_id, 'property_address', true );
	$prop_size                    = get_post_meta( $property_id, 'property_size', true ) ? get_post_meta( $property_id, 'property_size', true ) : 0;
	$prop_land_area               = get_post_meta( $property_id, 'property_land', true ) ? get_post_meta( $property_id, 'property_land', true ) : 0;
	$prop_rooms                   = get_post_meta( $property_id, 'property_rooms', true ) ? get_post_meta( $property_id, 'property_rooms', true ) : 0;
	$prop_bedrooms                = get_post_meta( $property_id, 'property_bedrooms', true ) ? get_post_meta( $property_id, 'property_bedrooms', true ) : 0;
	$prop_bathrooms               = get_post_meta( $property_id, 'property_bathrooms', true ) ? get_post_meta( $property_id, 'property_bathrooms', true ) : 0;
	$prop_garages                 = get_post_meta( $property_id, 'property_garage', true ) ? get_post_meta( $property_id, 'property_garage', true ) : 0;
	$prop_garages_size            = get_post_meta( $property_id, 'property_garage_size', true ) ? get_post_meta( $property_id, 'property_garage_size', true ) : 0;
	$prop_year                    = get_post_meta( $property_id, 'property_year', true ) ? get_post_meta( $property_id, 'property_year', true ) : '';
	$prop_featured                = get_post_meta( $property_id, 'property_featured', true ) ? get_post_meta( $property_id, 'property_featured', true ) : false;
	$prop_label                   = get_the_terms( $property_id, 'property-label' );
	$prop_status                  = get_the_terms( $property_id, 'property-status' );
	$prop_gallery_images          = get_post_meta( $property_id, 'gallery_images', true ) ? get_post_meta( $property_id, 'gallery_images', true ) : '';
	$width_image                  = '820';
	$height_image                 = '546';
	$property_thumb               = tfre_image_resize_id( get_post_thumbnail_id( $property_id ), $width_image, $height_image, true );
	$list_gallery_images          = get_sources_property_gallery_images( $prop_gallery_images );
	if ( is_array( $list_gallery_images ) ) {
		if ( attachment_url_to_postid( $property_thumb ) != attachment_url_to_postid( $list_gallery_images[0] ) ) {
			array_unshift( $list_gallery_images, $property_thumb );
		}
	}
	$prop_agent_info      = get_post_meta( $property_id, 'property_agent_info', true );
	$agent_post_meta_data = get_post_custom( $prop_agent_info );
	$user_name            = $prop_agent_info ? ( isset( $agent_post_meta_data['agent_full_name'] ) ? $agent_post_meta_data['agent_full_name'][0] : '' ) : get_the_author();
	$user_avatar          = $prop_agent_info ? ( isset( $agent_post_meta_data['agent_avatar'] ) ? $agent_post_meta_data['agent_avatar'][0] : '' ) : get_the_author_meta( 'profile_image_id', get_the_author_meta( 'ID' ) );
	$no_avatar            = get_avatar_url( get_the_author_meta( 'ID' ) );
	$default_image_src    = tfre_get_option( 'default_user_avatar', '' )['url'] != '' ? tfre_get_option( 'default_user_avatar', '' )['url'] : $no_avatar;

	//setting favorite
	global $current_user;
	wp_get_current_user();
	$check_is_favorite = false;
	$user_id           = $current_user->ID;
	$my_favorites      = get_user_meta( $user_id, 'favorites_property', true );
	if ( ! empty( $my_favorites ) ) {
		$check_is_favorite = array_search( $property_id, $my_favorites );
	}
	$title_not_favorite = $title_favorited = '';
	$icon_favorite     = apply_filters( 'tfre_icon_favorite', 'far fa-bookmark' );
	$icon_not_favorite = apply_filters( 'tfre_icon_not_favorite', 'far fa-bookmark' );

	if ( $check_is_favorite !== false ) {
		$css_class = $icon_favorite;
		$title     = esc_attr__( 'It is your favorite', 'tf-real-estate' );
	} else {
		$css_class = $icon_not_favorite;
		$title     = esc_attr__( 'Add to Favorite', 'tf-real-estate' );
	}
	$toggle_lazy_load  = tfre_get_option( 'toggle_lazy_load' );
	$measurement_units = tfre_get_option( 'measurement_units' );
	?>
	<div class="properties-post property-inner">
		<div class="featured-property card-image">
			<a class="view-gallery property-thumb"
				data-gallery="<?php echo esc_attr( json_encode( $list_gallery_images ) ); ?>"
				href="<?php echo esc_url( get_the_permalink() ); ?>">
				<?php
				$get_id_post_thumbnail = get_post_thumbnail_id( $property_id );
				if ( $toggle_lazy_load == 'on' ) {
					echo sprintf( '<img loading="lazy" class="lazy %2$s" src="" data-src="%1$s" data-image="%1$s" data-location="%3$s" data-bed="%9$s" data-bath="%10$s"  data-size="%11$s" data-measurement-units="%12$s" data-id="%4$s" data-price="%5$s" data-price-prefix="%6$s" data-price-postfix="%7$s" title="%8$s" alt="image">', empty( $get_id_post_thumbnail ) ? TF_PLUGIN_URL . "includes/elementor-widget/assets/images/no-image.jpg" : tfre_image_resize_id( $get_id_post_thumbnail, $width_image, $height_image, true ), esc_attr( $class_image_map ), esc_attr( ! empty( $prop_address ) ? $prop_address : '' ), esc_attr( $property_id ), esc_attr( tfre_format_price( $prop_price_value, $prop_price_unit, true, $prop_enable_short_price_unit ) ), esc_attr( $prop_price_prefix ), esc_attr( $prop_price_postfix ), esc_attr( get_the_title() ),$prop_bedrooms,$prop_bathrooms,$prop_size,$measurement_units );
				} else {
					echo sprintf( '<img loading="lazy" class="%2$s" src="%1$s" data-image="%1$s" data-location="%3$s" data-bed="%9$s" data-bath="%10$s"  data-size="%11$s" data-measurement-units="%12$s" data-id="%4$s" data-price="%5$s" data-price-prefix="%6$s" data-price-postfix="%7$s" title="%8$s" alt="image">', empty( $get_id_post_thumbnail ) ? TF_PLUGIN_URL . "includes/elementor-widget/assets/images/no-image.jpg" : tfre_image_resize_id( $get_id_post_thumbnail, $width_image, $height_image, true ), esc_attr( $class_image_map ), esc_attr( ! empty( $prop_address ) ? $prop_address : '' ), esc_attr( $property_id ), esc_attr( tfre_format_price( $prop_price_value, $prop_price_unit, true, $prop_enable_short_price_unit ) ), esc_attr( $prop_price_prefix ), esc_attr( $prop_price_postfix ), esc_attr( get_the_title() ),$prop_bedrooms,$prop_bathrooms,$prop_size,$measurement_units );
				}
				?>
			</a>
			<?php if ( ! empty( tfre_get_option( 'enable_card_label_bottom' ) ) ) : ?>
				<?php if ( is_array( $prop_label ) ) : ?>
					<span class="label-text"><?php echo esc_html( $prop_label[0]->name, 'tf-real-estate' ); ?></span>
				<?php endif; ?>
			<?php endif; ?>
			<div class="bottom-infor-features">
				<?php if ( ! empty( tfre_get_option( 'enable_card_action' ) ) ) : ?>
					<?php if ( ! empty( tfre_get_option( 'enable_card_label' ) ) ) : ?>
						<ul class="list-text">
							<?php if ( $prop_featured == true ) : ?>
								<li>
									<span class="featured-text"><?php esc_html_e( 'Featured', 'tf-real-estate' ); ?></span>
								</li>
							<?php endif; ?>
							<?php if ( is_array( $prop_status ) ) : ?>
								<li>
									<span class="status-text"><?php echo esc_html( $prop_status[0]->name, 'tf-real-estate' ); ?></span>
								</li>
							<?php endif; ?>
						</ul>
					<?php endif; ?>
					<ul class="list-controller">
						<li>
							<a class="compare tfre-compare-property hv-tool" href="javascript:void(0)"
								data-property-id="<?php the_ID() ?>" data-toggle="tooltip"
								data-tooltip="<?php echo esc_attr_e( 'Add Compare', 'tf-real-estate' ); ?>"
								title="<?php echo esc_attr_e( 'Compare', 'tf-real-estate' ); ?>">
								<i class="far fa-plus"></i>
							</a>
						</li>
						<li>
							<div class="bookmark">
								<div class="bg-bookmark">
									<a href="javascript:void(0)"
										class="tfre-property-favorite hv-tool <?php esc_attr_e( $check_is_favorite !== false ? 'active' : '' ); ?>"
										data-tfre-data-property-id="<?php echo esc_attr( intval( $property_id ) ); ?>"
										data-toggle="tooltip" data-tooltip="<?php echo esc_attr( $title ) ?>"
										data-tfre-data-title-not-favorite="<?php echo esc_attr_e( 'Add to Favorite', 'tf-real-estate' ); ?>"
										data-tfre-data-title-favorited="<?php echo esc_attr_e( 'It is your favorite', 'tf-real-estate' ); ?>"
										data-tfre-data-icon-not-favorite="<?php echo esc_attr( $icon_not_favorite ); ?>"
										data-tfre-data-icon-favorited="<?php echo esc_attr( $icon_favorite ); ?>">
										<i class="<?php echo esc_attr( $css_class ); ?>"></i>
									</a>
								</div>
							</div>
						</li>
						<li>
							<a class="property-quick-view zoomGallery hv-tool"
								data-gallery="<?php echo esc_attr( json_encode( $list_gallery_images ) ); ?>"
								href="javascript:void(0)"
								data-tooltip="<?php echo esc_attr_e( 'Quick View', 'tf-real-estate' ); ?>"
								data-toggle="modal" data-target="#property_quick_view_modal"
								data-property-id="<?php esc_attr_e( $property_id ); ?>">
								<i class="icon-homeya-eyes"></i>
							</a>
						</li>
					</ul>
				<?php endif; ?>
			</div>
		</div>
		<div class="content">
			<div class="heading">
				<h3 class="title">
					<a
						href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo esc_attr( get_the_title() ); ?></a>
				</h3>
				<?php if ( ! empty( tfre_get_option( 'enable_card_address' ) ) ) : ?>
					<div class="address">
						<i class="icon-homeya-location-3"></i>
						<span><?php echo esc_html__( $prop_address ); ?></span>
					</div>
				<?php endif; ?>
			</div>
			<div class="description">
				<?php if ( ! empty( tfre_get_option( 'enable_card_bedroom' ) ) ) : ?>
					<div class="property-information">
						<i class="icon-homeya-bed2"></i>
						<?php echo '<span class="value">' . $prop_bedrooms . '</span>'; ?>
					</div>
				<?php endif; ?>
				<?php if ( ! empty( tfre_get_option( 'enable_card_bathroom' ) ) ) : ?>
					<div class="property-information">
						<i class="icon-homeya-bath3"></i>
						<?php echo '<span class="value">' . $prop_bathrooms . '</span>'; ?>
					</div>
				<?php endif; ?>
				<?php if ( ! empty( tfre_get_option( 'enable_card_size' ) ) ) : ?>
					<div class="property-information">
						<i class="icon-homeya-ruler"></i>
						<?php echo sprintf( '<span class="value">' . tfre_get_format_number( intval( $prop_size ) ) . ' ' . esc_html( $measurement_units) . '</span>'); ?>
					</div>
				<?php endif; ?>
				<?php if ( ! empty( tfre_get_option( 'enable_card_room' ) ) ) : ?>
					<div class="property-information">
						<i class="icon-homeya-door"></i>
						<?php echo sprintf( '%s', '<span class="value">' . $prop_rooms . '</span>' ); ?>
					</div>
				<?php endif; ?>
				<?php if ( ! empty( tfre_get_option( 'enable_card_land_area' ) ) ) : ?>
					<div class="property-information">
						<i class="icon-homeya-ruler"></i>
						<?php echo sprintf( '%s', '<span class="value">' . tfre_get_format_number( intval( $prop_land_area ) ) . ' ' . $measurement_units . '</span>' ); ?>
					</div>
				<?php endif; ?>
				<?php if ( ! empty( tfre_get_option( 'enable_card_garage' ) ) ) : ?>
					<div class="property-information">
						<i class="icon-homeya-garage"></i>
						<?php echo sprintf( '%s', '<span class="value">' . $prop_garages . '</span>' ); ?>
					</div>
				<?php endif; ?>
				<?php if ( ! empty( tfre_get_option( 'enable_card_garage_size' ) ) ) : ?>
					<div class="property-information">
						<i class="icon-homeya-ruler"></i>
						<?php echo sprintf( '%s', '<span class="value">' . tfre_get_format_number( intval( $prop_garages_size ) ) . ' ' . $measurement_units . '</span>' ); ?>
					</div>
				<?php endif; ?>
			</div>
			<?php if ( ! empty( tfre_get_option( 'enable_card_agent' ) ) || ! empty( tfre_get_option( 'enable_card_price' ) ) ) : ?>
				<div class="bottom">
					<?php if ( ! empty( tfre_get_option( 'enable_card_agent' ) ) ) : ?>
						<a href="<?php echo esc_url( get_permalink( $prop_agent_info ) ); ?>" class="avatar">
							<img alt="<?php echo esc_attr( $user_name ); ?>"
							src="<?php echo esc_attr( tfre_image_resize_id( $user_avatar, '50', '50', true ) ); ?>"
							onerror="this.src = '<?php echo esc_url( $default_image_src ) ?>';"
							class="avatar avatar-96 photo" loading="lazy"><span><?php echo esc_attr( $user_name ); ?></span>
						</a>
					<?php endif; ?>
					<?php if ( ! empty( tfre_get_option( 'enable_card_price' ) ) ) : ?>
							<span class="price">
								<?php if ( $prop_price_prefix != '' ) : ?>
									<?php echo esc_html__( $prop_price_prefix ); ?>
								<?php endif; ?>
								<?php echo esc_html__( tfre_format_price( $prop_price_value, $prop_price_unit, true, $prop_enable_short_price_unit ) ); ?>
								<?php if ( $prop_price_postfix != '' ) : ?>
									<span><?php echo esc_html__( $prop_price_postfix ); ?></span>
								<?php endif; ?>
							</span>
					<?php endif; ?>
				</div>
			<?php endif; ?>
		</div>
	</div>
</div>