<?php

namespace XIMSAPLUGIN\Element;

use Elementor\Controls_Manager;
use Elementor\Controls_Stack;
use Elementor\Group_Control_Typography;
use Elementor\Scheme_Typography;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Border;
use Elementor\Repeater;
use Elementor\Widget_Base;
use Elementor\Utils;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Plugin;

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

class digm_intregration_section extends Widget_Base {

	/**
	 * Get widget name.
	 *
	 * Retrieve Elementor widget name.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget name.
	 */
	public function get_name() {
		return 'digm_intregration_section';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'Digital Marketing Intigation', 'ximsa' );
	}

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

	/**
	 * Get widget categories.
	 *
	 * Retrieve the list of categories the Elementor widget belongs to.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return array Widget categories.
	 */
	public function get_categories() {
		return [ 'ximsa' ];
	}

	/**
	 * Register Elementor 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(
            'int_info',
            [
                'label' => __( 'Section Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'shape1',
			[
				'label' => esc_html__( 'Shape', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'inside1',
			[
				'label' => esc_html__( 'Inside One', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'dartboard',
			[
				'label' => esc_html__( 'Dart Board', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'sub_title',
			[
				'label' => esc_html__( 'Sub Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);

        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'sponsor',
			[
				'label' => esc_html__( 'Sponsor', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'link',
			[
				'label' => esc_html__( 'Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'sponsors',
			[
				'label' => esc_html__( 'Sponsor Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
			]
		);

		$this->end_controls_section();

        $this->start_controls_section(
            'fanf_settings_style',
            [
                'label' => __( 'Fanfact Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
			'container_width',
			[
				'label' => esc_html__( 'Container Width', 'ximsa' ),
				'type' => \Elementor\Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 2000,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				
				'selectors' => [
					'{{WRAPPER}} .container, .container-lg, .container-md, .container-sm, .container-xl, .container-xxl' => 'max-width: {{SIZE}}{{UNIT}};',
				],
			]
		);

        $this->add_control(
            'sub_h_bg_cl',
            [
                'label'     => esc_html__( 'Sub Heading BG Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-dm-section-title span' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_control(
            'se_sub_h_color',
            [
                'label'     => esc_html__( 'Sub Heading Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-dm-section-title span' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'se_sth_typography',
                'label'          => esc_html__( 'Sub Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-dm-section-title span',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'se_title_style',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'main_title_color',
            [
                'label'     => esc_html__( 'Heading Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-dm-section-title h2' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'main_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-dm-section-title h2',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->end_controls_section();
	}
		


	protected function render() {
		
		$settings = $this->get_settings_for_display(); ?>
		<!-- Start of Intregrations section
        ============================================= -->
        <section id="xis-dm-intregration" class="xis-dm-intregration-section">
            <div class="container">
                <div class="xis-dm-intregration-content  position-relative">
                    <span class="xis-dm-int-shape1 position-absolute"><img src="<?php echo esc_url($settings['shape1']['url']);?>"></span>
                    <div class="row">
                        <div class="col-lg-5">
                            <div class="xis-dm-intregration-img-wrap position-relative wow fadeInUp" data-wow-delay="0ms" data-wow-duration="1500ms">
                                <div class="xis-dm-intregration-img1">
                                    <img src="<?php echo esc_url($settings['inside1']['url']);?>" alt="">
                                </div>
                                <div class="xis-dm-intregration-img2 position-absolute">
                                    <img src="<?php echo esc_url($settings['dartboard']['url']);?>" alt="">
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-7">
                            <div class="xis-dm-intregration-text-wrap wow fadeInUp" data-wow-delay="300ms" data-wow-duration="1500ms">
                                <div class="xis-dm-section-title xis-dm-headline pera-content">
                                    <span><?php echo esc_html($settings['sub_title']);?></span>
                                    <h2><?php echo esc_html($settings['title']);?></h2>
                                </div>
                                <div class="xis-dm-intregration-sponsor ul-li">
                                    <ul>
                                        <?php foreach($settings['sponsors'] as $item):?>
                                            <li><a href="<?php echo esc_url($item['link']['url']);?>"><img src="<?php echo esc_url($item['sponsor']['url']);?>"></a></li>
                                        <?php endforeach;?>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>  
            </div>	
        </section>
    <!-- End of Intregrations section
        ============================================= -->
		<?php 
      }
	
	

}
