<?php
namespace Elementor;

/**
 * Elementor Widget
 * @package Feron
 * @since 1.0.0
 */ 
 
class Md_Sidebar extends Widget_Base {

	/**
	 * Get widget name.
	 * Retrieve button widget name.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'feron-md-sidebar-widget';
	}

	/**
	 * Get widget title.
	 * Retrieve button widget title.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Match Details Sidebar', 'feron-core' );
	}

	/**
	 * Get widget icon.
	 * Retrieve button widget icon.
	 *
	 * @since  1.0.0
	 * @access public
	 * @return string Widget icon.
	 */
	public function get_icon() {
		return 'eicon-flash';
	}

	/**
	 * Get widget categories.
	 * Retrieve the list of categories the button widget belongs to.
	 * Used to determine where to display the widget in the editor.
	 *
	 * @since  2.0.0
	 * @access public
	 * @return array Widget categories.
	 */
	public function get_categories()
    {
        return ['feron_widgets'];
    }
	
	/**
	 * Register button widget controls.
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @since  1.0.0
	 * @access protected
	 */
	protected function register_controls() {

		$this->start_controls_section(
			'feature_card_content',
			[
				'label' => __( 'Feature Content', 'feron-core' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);

		$this->add_control(
			'show_area',
			[
				'label' => __( 'Show Top Area', 'feron-core' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'Show', 'feron-core' ),
				'label_off' => __( 'Hide', 'feron-core' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);	

		$this->add_control(
			'show_area_2',
			[
				'label' => __( 'Show Bottom Area', 'feron-core' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'Show', 'feron-core' ),
				'label_off' => __( 'Hide', 'feron-core' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);	

		$this->add_control(
			'bg_image',
			[
				'label' => esc_html__('Background image', 'feron-core'),
				'type' => Controls_Manager::MEDIA,
				'default' => ['url' => Utils::get_placeholder_image_src(),],
			]
		);


		$this->end_controls_section();	


		$this->start_controls_section(
			'content_section',
			[
				'label' => __( 'Block', 'feron-core' ),
				'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
			]
		);
		$this->add_control(
		  'repeat', 
			[
				'type' => Controls_Manager::REPEATER,
				'separator' => 'before',
				'default' => 
					[
						['section_title' => esc_html__('Projects Completed', 'feron-core')],
					],
				'fields' => 
					[		
						
						[
							'name' => 'section_image',
							'label' => __( 'Image', 'feron-core' ),
							'type' => Controls_Manager::MEDIA,
							'default' => [
								'url' => Utils::get_placeholder_image_src(),
							],
						],

						[
							'name' => 'section_subtitle',
							'label' => esc_html__('Subtitle', 'feron-core'),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__('', 'feron-core')
						],	

						[
							'name' => 'section_title',
							'label' => esc_html__('Title', 'feron-core'),
							'type' => Controls_Manager::TEXTAREA,
							'default' => esc_html__('', 'feron-core')
						],
						
					],
				'title_field' => '{{section_title}}',
			 ]
	);
		
		
	$this->end_controls_section();	

	
		}

	/**
	 * Render button widget output on the frontend.
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @since  1.0.0
	 * @access protected
	 */
	protected function render() {
		$settings = $this->get_settings_for_display();
		$allowed_tags = wp_kses_allowed_html('post');
		?> 

		<div class="gt-match-details-wrapper m-0 p-0">
			<div class="gt-main-sideber">

				<?php  if ( 'yes' === $settings['show_area'] ) : ?>
				<div class="gt-single-sideber-widgett">
					<h4>upcoming matches</h4>
					<div class="gt-sideber-box">
						<div class="gt-box-item">
							<ul class="gt-list">
								<li>Venom Squad</li>
								<li>vs</li>
								<li>Fatal Force</li>
								<li class="text">
									<i class="fa-solid fa-angles-right"></i>
								</li>
							</ul>
							<ul class="gt-date-list">
								<li>
									<i class="fa-regular fa-calendar"></i>
									30 May, 2024
								</li>
								<li>
									<i class="fa-regular fa-clock"></i>
									10:00 am - 12:30 pm
								</li>
							</ul>
						</div>
					</div>
					<div class="gt-sideber-box">
						<div class="gt-box-item">
							<ul class="gt-list">
								<li>Asgard</li>
								<li>vs</li>
								<li>war zone</li>
								<li class="text">
									<i class="fa-solid fa-angles-right"></i>
								</li>
							</ul>
							<ul class="gt-date-list">
								<li>
									<i class="fa-regular fa-calendar"></i>
									30 May, 2024
								</li>
								<li>
									<i class="fa-regular fa-clock"></i>
									10:00 am - 12:30 pm
								</li>
							</ul>
						</div>
					</div>
					<div class="gt-sideber-box">
						<div class="gt-box-item">
							<ul class="gt-list">
								<li>Doom Legion</li>
								<li>vs</li>
								<li>Neon King</li>
								<li class="text">
									<i class="fa-solid fa-angles-right"></i>
								</li>
							</ul>
							<ul class="gt-date-list">
								<li>
									<i class="fa-regular fa-calendar"></i>
									30 May, 2024
								</li>
								<li>
									<i class="fa-regular fa-clock"></i>
									10:00 am - 12:30 pm
								</li>
							</ul>
						</div>
					</div>
					<div class="gt-sideber-box">
						<div class="gt-box-item">
							<ul class="gt-list">
								<li>Lagging Legends</li>
								<li>vs</li>
								<li>GG EZ</li>
								<li class="text">
									<i class="fa-solid fa-angles-right"></i>
								</li>
							</ul>
							<ul class="gt-date-list">
								<li>
									<i class="fa-regular fa-calendar"></i>
									30 May, 2024
								</li>
								<li>
									<i class="fa-regular fa-clock"></i>
									10:00 am - 12:30 pm
								</li>
							</ul>
						</div>
					</div>
				</div>
				<?php endif ;?>	

				<?php  if ( 'yes' === $settings['show_area_2'] ) : ?>
				<div class="gt-contact-bg bg-cover" style="background-image: url(<?php echo wp_get_attachment_url($settings['bg_image']['id']);?>);">
					<div class="gt-contact-content">
						<h3>Need Any Help</h3>
						<p>Nees Any Help, Call Us  24/7 Full Support</p>
						<div class="gt-contact-item">
							<div class="gt-icon">
								<i class="fa-solid fa-phone"></i>
							</div>
							<ul class="gt-list">
								<li><span>Call Us:</span></li>
								<li><a href="tel:+0094382229540">+009 438 222 9540</a></li>
							</ul>
						</div>
						<div class="gt-contact-item">
							<div class="gt-icon">
								<i class="fa-regular fa-envelope"></i>
							</div>
							<ul class="gt-list">
								<li><span>Mail Us</span></li>
								<li><a href="infor@idergamil.com">
									infor@dergamil.com
								</a></li>
							</ul>
						</div>
						<div class="gt-contact-item mb-0">
							<div class="gt-icon">
								<i class="fa-solid fa-location-dot"></i>
							</div>
							<ul class="gt-list">
								<li><span>Location:</span></li>
								<li>Toronto, Montreal, City</li>
							</ul>
						</div>
					</div>
				</div>
				<?php endif ;?>	
			</div>
		</div>

             
		<?php 
	}


}

Plugin::instance()->widgets_manager->register_widget_type(new Md_Sidebar());