<?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 nft_banner 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 'nft-banner';
	}

	/**
	 * Get widget title.
	 *
	 * Retrieve Elementor widget title.
	 *
	 * @since 1.0.0
	 * @access public
	 *
	 * @return string Widget title.
	 */
	public function get_title() {
		return esc_html__( 'NFT Banner', '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(
            'slider_options',
            [
                'label' => __( 'NFT Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        
        $this->add_control(
			'circle_shape',
			[
				'label' => esc_html__( 'Circle Shape 1', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'circle2_shape',
			[
				'label' => esc_html__( 'Circle Shape 2', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'shape3',
			[
				'label' => esc_html__( 'Shape 3', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'shape4',
			[
				'label' => esc_html__( 'Shape 4', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'shape5',
			[
				'label' => esc_html__( 'Shape 5', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'shape6',
			[
				'label' => esc_html__( 'Shape 6', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);
        $this->add_control(
			'banner_img',
			[
				'label' => esc_html__( 'Banner Img', 'ximsa' ),
				'type' => Controls_Manager::MEDIA,
                'label_block' => true,
			]
		);

        $this->end_controls_section();
        $this->start_controls_section(
            'banner_content_options',
            [
                'label' => __( 'Banner Content Options', 'ximsa' ),
                'tab' => Controls_Manager::TAB_CONTENT,
            ]
        );
        $this->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'placeholder' => esc_html__( 'Type Banner Title Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'title-shape',
				'label' => esc_html__( 'Title Background', 'ximsa' ),
				'types' => [ 'classic' ],
				'exclude' => [ 'color' ],
				'selector' => '{{WRAPPER}} .xis-nft-banner-text h1 strong:before',
			]
		);
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'skilltitle',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'skils',
			[
				'label' => esc_html__( 'NFT Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ skilltitle }}}',
			]
		);
        
        $this->add_control(
			'description',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
				'default' => esc_html__( 'Take payments online with a scalable platform that grows with your perfect business.', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Banner Short Info Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'button_label',
			[
				'label' => esc_html__( 'Button Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Get In Touch', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Slider Button Label Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        $this->add_control(
			'button_link',
			[
				'label' => esc_html__( 'Button Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        $this->add_control(
			'button2_label',
			[
				'label' => esc_html__( 'Button Two Label', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
				'default' => esc_html__( 'Get In Touch', 'ximsa' ),
				'placeholder' => esc_html__( 'Type Slider Button Label Here', 'ximsa' ),
                'label_block' => true,
			]
		);
        $this->add_control(
			'button2_link',
			[
				'label' => esc_html__( 'Button Two Link', 'ximsa' ),
				'type' => Controls_Manager::URL,
                'label_block' => true,
			]
		);
        $repeater = new \Elementor\Repeater();
        
        $repeater->add_control(
			'icon',
			[
				'label' => esc_html__( 'ICONS', 'ximsa' ),
				'type' => Controls_Manager::ICONS,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'title',
			[
				'label' => esc_html__( 'Title', 'ximsa' ),
				'type' => Controls_Manager::TEXT,
                'label_block' => true,
			]
		);
        $repeater->add_control(
			'description',
			[
				'label' => esc_html__( 'Description', 'ximsa' ),
				'type' => Controls_Manager::TEXTAREA,
                'label_block' => true,
			]
		);
        
        $this->add_control(
			'features',
			[
				'label' => esc_html__( 'Features Item', 'ximsa' ),
				'type' => Controls_Manager::REPEATER,
				'fields' => $repeater->get_controls(),
				'title_field' => '{{{ title }}}',
			]
		);
		$this->end_controls_section();
        $this->start_controls_section(
            'slider_settings_style',
            [
                'label' => __( 'Banner Settings', 'ximsa' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        
        $this->add_control(
            'slider_title',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'title-bgbackground',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-nft-banner-text .cd-headline.rotate-1 b',
			]
		);
        $this->add_control(
            'sl_desc_color',
            [
                'label'     => esc_html__( 'Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-banner-text h1' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '{{WRAPPER}} .xis-nft-banner-text h1',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'slider_desc',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Description Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'sl_desc_color',
            [
                'label'     => esc_html__( 'Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-banner-text p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'sl_desc_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-banner-text p
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_title_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Title Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'feature_title_cs',
            [
                'label'     => esc_html__( 'Feature Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-banner-feature-item .xis-nft-banner-feature-hover .xis-nft-bn-ft-text h3, .xis-nft-banner-feature-item .xis-nft-bn-ft-item .xis-nft-bn-ft--text h3' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_title_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-banner-feature-item .xis-nft-banner-feature-hover .xis-nft-bn-ft-text h3
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_desc_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Description Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        $this->add_control(
            'feature_desc_cl',
            [
                'label'     => esc_html__( 'Feature Description Color', 'ximsa' ),
                'type'      => Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-banner-feature-item .xis-nft-banner-feature-hover .xis-nft-bn-ft-text p' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'fs_desc_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-banner-feature-item .xis-nft-banner-feature-hover .xis-nft-bn-ft-text p
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_icon',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Icon Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'fnt-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '
                {{WRAPPER}} .xis-nft-banner-feature-item .xis-nft-bn-ft-item .xis-nft-bn-ft--icon,
                {{WRAPPER}} .xis-nft-banner-feature-item .xis-nft-banner-feature-hover .xis-nft-bn-ft-icon, .xis-nft-header-search, .xis-nft-header-user button
                ',
			]
		);
        $this->add_control(
            'feature_number_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Number Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'fnt-icon-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-nft-banner-feature-item .xis-nft-banner-feature-hover .xis-nft-bn-ft-serial',
			]
		);
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'name'           => 'no_st_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-banner-feature-item .xis-nft-banner-feature-hover .xis-nft-bn-ft-serial
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
            'feature_box_st',
            [
                'type'      => Controls_Manager::HEADING,
                'label'     => esc_html__( 'Feature Box Style', 'ximsa' ),
                'separator' => 'before',
            ]
        );
        
        $this->add_group_control(
			\Elementor\Group_Control_Background::get_type(),
			[
				'name' => 'fs-box-background',
				'label' => esc_html__( 'Background', 'ximsa' ),
				'types' => [ 'gradient' ],
				'selector' => '{{WRAPPER}} .xis-nft-banner-feature-item .xis-nft-banner-feature-hover:before',
			]
		);
        
		$this->end_controls_section();
        
        $this->start_controls_section(
            'button__content',
            [
                'label' => __( 'Slider Button Style', 'ximsa' ),
                'tab'   => \Elementor\Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Typography::get_type(),
            [
                'name'           => 'btn_typography',
                'label'          => esc_html__( 'Typography', 'ximsa' ),
                'selector'       => '
                    {{WRAPPER}} .xis-nft-banner-text .xis-nft-banner-btn a
                ',
                'fields_options' => [
                    'typography' => [
                        'default' => 'custom',
                    ],
                ],
            ]
        );
        $this->add_control(
			'btnwidth',
			[
				'label' => esc_html__( 'Width', 'ximsa' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 1000,
						'step' => 5,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .xis-nft-banner-text .xis-nft-banner-btn a' => 'width: {{SIZE}}{{UNIT}};',
				],
			]
		);
        $this->add_control(
			'btnheight',
			[
				'label' => esc_html__( 'Height', 'ximsa' ),
				'type' => Controls_Manager::SLIDER,
				'size_units' => [ 'px', '%' ],
				'range' => [
					'px' => [
						'min' => 0,
						'max' => 1000,
						'step' => 5,
					],
					'%' => [
						'min' => 0,
						'max' => 100,
					],
				],
				'selectors' => [
					'{{WRAPPER}} .xis-nft-banner-text .xis-nft-banner-btn a' => 'height: {{SIZE}}{{UNIT}};',
				],
			]
		);
        $this->start_controls_tabs( '_banner_button_1' );
        $this->start_controls_tab(
            '_glow-extension_btn__banner_normal',
            [
                'label' => esc_html__( 'Normal', 'ximsa' ),
            ]
        );
        $this->add_control(
            'btn__color',
            [
                'label'     => esc_html__( 'Color', 'ximsa' ),
                'type'      => \Elementor\Controls_Manager::COLOR,
                'selectors' => [
                    '{{WRAPPER}} .xis-nft-banner-text .xis-nft-banner-btn a' => 'color: {{VALUE}}',
                ],
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .xis-nft-banner-text .xis-nft-banner-btn a
                ',
            ]
        );
        $this->add_responsive_control(
            'btn_border_radious',
            [
                'label'      => esc_html__( 'Border Radius', 'ximsa' ),
                'type'       => \Elementor\Controls_Manager::DIMENSIONS,
                'size_units' => ['px', '%'],
                'selectors'  => [
                    '{{WRAPPER}} .xis-nft-banner-text .xis-nft-banner-btn a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
            ]
        );
        $this->add_group_control(
			\Elementor\Group_Control_Border::get_type(),
			[
				'name' => 'btn_border',
				'label' => esc_html__( 'Border', 'plugin-name' ),
				'selector' => '{{WRAPPER}} .xis-nft-banner-text .xis-nft-banner-btn a',
			]
		);
        
        $this->end_controls_tab();
        $this->start_controls_tab(
            '_glow-extension_btn_hover',
            [
                'label' => esc_html__( 'Hover', 'ximsa' ),
            ]
        );
        $this->add_group_control(
            \Elementor\Group_Control_Background::get_type(),
            [
                'name'     => 'btn_hover_bg_color',
                'label'    => __( 'Background', 'ximsa' ),
                'types'    => ['classic', 'gradient'],
                'exclude'  => ['image'],
                'selector' => '
                    {{WRAPPER}} .xis-nft-banner-text .xis-nft-banner-btn a:before, .xis-nft-btn-2 a:before
                ',
            ]
        );
        
        $this->end_controls_tab();
        $this->end_controls_tabs();
        $this->end_controls_section();
	}
		


	protected function render() {	
	$settings = $this->get_settings_for_display();?>        
        <!-- Start of Banner section
        ============================================= -->
        <section id="xis-nft-banner" class="xis-nft-banner-section position-relative">

            <span class="xis-nft-side-shape1 position-absolute"><img src="<?php echo esc_url($settings['circle_shape']['url']);?>" alt=""></span>

            <span class="xis-nft-side-shape2 position-absolute"><img src="<?php echo esc_url($settings['circle2_shape']['url']);?>" alt=""></span>

            <div class="xis-nft-banner-img-wrapper">

                <span class="banner-shape1 position-absolute wow fadeInUp"  data-wow-delay="200ms" data-wow-duration="500ms"><img src="<?php echo esc_url($settings['shape3']['url']);?>" alt=""></span>

                <span class="banner-shape2 position-absolute wow fadeInUp" data-parallax='{"y" : -100, "rotateY":200}' data-wow-delay="400ms" data-wow-duration="500ms"><img src="<?php echo esc_url($settings['shape4']['url']);?>" alt=""></span>

                <span class="banner-shape3 position-absolute wow fadeInUp" data-wow-delay="600ms" data-wow-duration="500ms"><img src="<?php echo esc_url($settings['shape5']['url']);?>" alt=""></span>

                <span class="banner-shape4 position-absolute wow fadeInUp" data-parallax='{"y" : 100, "rotateY":200}' data-wow-delay="800ms" data-wow-duration="500ms"><img src="<?php echo esc_url($settings['shape6']['url']);?>" alt=""></span>

                <div class="xis-nft-banner-img">
                    <img src="<?php echo esc_url($settings['banner_img']['url']);?>" alt="">
                </div>

            </div>
            <div class="container">
                <div class="xis-nft-banner-content position-relative">
                    <div class="xis-nft-banner-text xis-nft-headline pera-content">
                        <h1 class="cd-headline rotate-1"><?php echo wp_kses( $settings['title'], true )?>
                            <span class="cd-words-wrapper">
                                <?php $i = 0; foreach($settings['skils'] as $item): $i++?>
                                <?php if($i == 1):?>
                                    <b class="is-visible"><?php echo esc_html($item['skilltitle']);?></b>
                                <?php else:?>
                                    <b><?php echo esc_html($item['skilltitle']);?></b>
                                <?php endif; endforeach;?>
                            </span>
                        </h1>
                        <p><?php echo wp_kses( $settings['description'], true )?></p>
                        <div class="xis-nft-banner-btn d-flex">
                            <?php if(!empty($settings['button_label'])):?>
                                <a class="d-flex justify-content-center align-items-center" href="<?php echo esc_url($settings['button_link']['url']);?>"><?php echo esc_html($settings['button_label']);?></a>
                            <?php endif;?>

                            <?php if(!empty($settings['button2_label'])):?>
                                <a class="d-flex justify-content-center align-items-center" href="<?php echo esc_url($settings['button2_link']['url']);?>"><?php echo esc_html($settings['button2_label']);?></a>
                            <?php endif;?>

                        </div>
                    </div>
                    <div class="xis-nft-banner-feature position-relative">
                        <div class="row">
                        <?php $i = 0; foreach($settings['features'] as $fet): $i++?>
                            <div class="col-md-4 wow fadeInUp"  data-wow-delay="200ms" data-wow-duration="1000ms">
                                <div class="xis-nft-banner-feature-item position-relative">
                                    <div class="xis-nft-bn-ft-item d-flex align-items-center">
                                        <div class="xis-nft-bn-ft--icon d-flex align-items-center justify-content-center">
                                            <?php \Elementor\Icons_Manager::render_icon( $fet['icon'], [ 'aria-hidden' => 'true' ] ); ?>
                                        </div>
                                        <div class="xis-nft-bn-ft--text xis-nft-headline pera-content">
                                            <h3><?php echo wp_kses( $fet['title'], true )?></h3>
                                        </div>
                                    </div>
                                    <div class="xis-nft-banner-feature-hover position-absolute">
                                        <div class="xis-nft-bn-ft-icon-serial d-flex justify-content-between align-items-center">
                                            <div class="xis-nft-bn-ft-icon d-flex align-items-center justify-content-center">
                                                <?php \Elementor\Icons_Manager::render_icon( $fet['icon'], [ 'aria-hidden' => 'true' ] ); ?>
                                            </div>
                                            <div class="xis-nft-bn-ft-serial">
                                                <?php echo esc_attr($i);?>
                                            </div>
                                        </div>
                                        <div class="xis-nft-bn-ft-text xis-nft-headline pera-content">
                                            <h3><?php echo wp_kses( $fet['title'], true )?></h3>
                                            <p><?php echo wp_kses( $fet['description'], true )?></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <?php endforeach;?>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    <!-- End of Banner section
        ============================================= -->
    <?php  
    }
	
}

