<?php

use Elementor\Controls_Manager;

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

/**
 * Elementor icon box widget.
 *
 * Elementor widget that displays an icon, a headline and a text.
 *
 */
class Opalestate_Split_maps_search_Elementor_Widget extends Opalestate_Elementor_Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Retrieve icon box widget name.
	 *
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'opalestate-split-maps-search';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve icon box widget title.
	 *
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Block: Split Maps Property Search', 'opalestate-pro' );
	}

	/**
	 * Get widget icon.
	 *
	 * Retrieve icon box widget icon.
	 *
	 * @access public
	 *
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return apply_filters( 'opalestate_' . $this->get_name(), 'eicon-search' );
	}

	/**
	 * Get widget keywords.
	 *
	 * Retrieve the list of keywords the widget belongs to.
	 *
	 * @access public
	 *
	 * @return array Widget keywords.
	 */
	public function get_keywords() {
		return [ 'opalestate-pro', 'search' ];
	}

	/**
	 * Register icon box widget controls.
	 *
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @access protected
	 */
	protected function _register_controls() {
		$this->start_controls_section(
			'agents_search_form',
			[
				'label' => esc_html__( 'Search Form', 'opalestate-pro' ),
			]
		);

		$this->add_control(
			'search_form',
			[
				'label'   => esc_html__( 'Search Form', 'opalestate-pro' ),
				'type'    => \Elementor\Controls_Manager::SELECT,
				'default' => 'advanced-v2',
				'options' => opalestate_search_properties_form_styles(),
			]
		);

		$this->add_responsive_control(
			'column',
			[
				'label'        => esc_html__( 'Columns', 'opalestate-pro' ),
				'type'         => \Elementor\Controls_Manager::SELECT,
				'default'      => 3,
				'options'      => [ 1 => 1, 2 => 2, 3 => 3, 4 => 4, 6 => 6 ],
				'prefix_class' => 'elementor-grid%s-',
				'condition'    => [
					'item_layout' => 'grid',
				],

			]
		);

		$this->add_control(
			'column_gap',
			[
				'label'     => esc_html__( 'Columns Gap', 'opalestate-pro' ),
				'type'      => Controls_Manager::SLIDER,
				'range'     => [
					'px' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .elementor-items-container' => 'grid-column-gap: {{SIZE}}{{UNIT}}',

				],
				'condition' => [
					'item_layout' => 'grid',
				],
			]
		);
		$this->end_controls_section();
	}
}
