<?php
namespace EcafeAddons\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Text_Stroke;

use EcafeAddons\EcafeElementLoad;

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

class Ecafe_Title extends Widget_Base {

	public function get_name() {
		return 'ecafe-title';
	}

	public function get_title() {
		return esc_html__( 'Title', 'essential-classy-addons-for-elementor' );
	}

	public function get_icon() {
		return 'ecafe-ele-back-icon ecafe-title-icon';
	}

	public function get_categories() {
		return array( 'essential' );
	}

	public function get_keywords() {
		return array( 'title', 'advanced title', 'info title', 'heading' );
	}

	public function get_custom_help_url() {
		return 'https://store.kapasias.com/helpdesk/';
	}

	public function has_widget_inner_wrapper(): bool {
		return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
	}

	protected function register_controls() {

		$this->start_controls_section(
			'content_section',
			array(
				'label' => esc_html__( 'Title', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'Layout',
			array(
				'label'   => esc_html__( 'Layout', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'default',
				'options' => array(
					'default'  => esc_html__( 'Simple', 'essential-classy-addons-for-elementor' ),
					'advanced' => esc_html__( 'Advanced', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$this->add_control(
			'DStyle',
			array(
				'label'     => esc_html__( 'Style', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'ds1',
				'options'   => array(
					'ds1' => esc_html__( 'Style 1', 'essential-classy-addons-for-elementor' ),
					'ds2' => esc_html__( 'Style 2', 'essential-classy-addons-for-elementor' ),
					'ds3' => esc_html__( 'Style 3', 'essential-classy-addons-for-elementor' ),
					'ds4' => esc_html__( 'Style 4', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'Layout' => 'default',
				),
			)
		);
		$this->add_control(
			'AStyle',
			array(
				'label'     => esc_html__( 'Style', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'as1',
				'options'   => array(
					'as1'  => esc_html__( 'Style 1', 'essential-classy-addons-for-elementor' ),
					'as2'  => esc_html__( 'Style 2', 'essential-classy-addons-for-elementor' ),
					'as3'  => esc_html__( 'Style 3', 'essential-classy-addons-for-elementor' ),
					'as4'  => esc_html__( 'Style 4', 'essential-classy-addons-for-elementor' ),
					'as5'  => esc_html__( 'Style 5', 'essential-classy-addons-for-elementor' ),
					'as6'  => esc_html__( 'Style 6', 'essential-classy-addons-for-elementor' ),
					'as7'  => esc_html__( 'Style 7', 'essential-classy-addons-for-elementor' ),
					'as8'  => esc_html__( 'Style 8', 'essential-classy-addons-for-elementor' ),
					'as9'  => esc_html__( 'Style 9', 'essential-classy-addons-for-elementor' ),
					'as10' => esc_html__( 'Style 10', 'essential-classy-addons-for-elementor' ),
					'as11' => esc_html__( 'Style 11', 'essential-classy-addons-for-elementor' ),
					'as12' => esc_html__( 'Style 12', 'essential-classy-addons-for-elementor' ),
					'as13' => esc_html__( 'Style 13', 'essential-classy-addons-for-elementor' ),
					'as14' => esc_html__( 'Style 14', 'essential-classy-addons-for-elementor' ),
					'as15' => esc_html__( 'Style 15', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'Layout' => 'advanced',
				),
			)
		);
		$this->add_control(
			'Title',
			array(
				'label'       => esc_html__( 'Title', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'Title', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Title', 'essential-classy-addons-for-elementor' ),
				'separator'   => 'before',
			)
		);
		$this->add_control(
			'TitleTag',
			array(
				'label'   => esc_html__( 'Tag', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'h1',
				'options' => \EcafeHelper::getHtmlTag( 'a' ),
			)
		);
		$this->add_control(
			'TitleLink',
			array(
				'label'       => esc_html__( 'Link', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::URL,
				'dynamic'     => array( 'active' => true ),
				'placeholder' => esc_html__( '#', 'essential-classy-addons-for-elementor' ),
				'default'     => array(
					'url' => '#',
				),
				'condition'   => array(
					'TitleTag' => 'a',
				),
			)
		);
		$this->add_control(
			'SubTitle',
			array(
				'label'       => esc_html__( 'Sub Title', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'Sub Title', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Sub Title', 'essential-classy-addons-for-elementor' ),
				'separator'   => 'before',
				'condition'   => array(
					'AStyle!' => 'as15',
				),
			)
		);
		$this->add_control(
			'SubTitleTag',
			array(
				'label'     => esc_html__( 'Tag', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => 'h3',
				'options'   => \EcafeHelper::getHtmlTag(),
				'condition' => array(
					'AStyle!' => 'as15',
				),
			)
		);
		$this->add_responsive_control(
			'contentAlign',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => array(
						'title' => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center'     => array(
						'title' => esc_html__( 'Center', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-center',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'separator' => 'before',
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-wrapper-inner' => 'align-items:{{VALUE}};',
				),
				'condition' => array(
					'AStyle!' => 'as15',
				),
			)
		);
		$this->add_responsive_control(
			'contentAlign15',
			array(
				'label'     => esc_html__( 'Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'flex-start' => array(
						'title' => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center'     => array(
						'title' => esc_html__( 'Center', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-center',
					),
					'flex-end'   => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
				),
				'separator' => 'before',
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper' => 'align-items:{{VALUE}};',
				),
				'condition' => array(
					'AStyle' => 'as15',
				),
			)
		);
		$this->add_responsive_control(
			'contentTextAlign',
			array(
				'label'     => esc_html__( 'Long Text Alignment', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::CHOOSE,
				'options'   => array(
					'left'    => array(
						'title' => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-left',
					),
					'center'  => array(
						'title' => esc_html__( 'Center', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-center',
					),
					'right'   => array(
						'title' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-text-align-right',
					),
					'justify' => array(
						'title' => esc_html__( 'Justify', 'essential-classy-addons-for-elementor' ),
						'icon'  => 'eicon-h-align-stretch',
					),
				),
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-wrapper-inner' => 'text-align:{{VALUE}};',
				),
				'condition' => array(
					'AStyle!' => 'as15',
				),
			)
		);
		$this->add_responsive_control(
			'contentWidth',
			array(
				'label'      => esc_html__( 'Content Width', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 500,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-wrapper-inner' => 'width:{{SIZE}}{{UNIT}};',
				),
				'condition'  => array(
					'AStyle!' => 'as15',
				),
			)
		);
		$this->end_controls_section();

		$this->start_controls_section(
			'extras_section',
			array(
				'label' => esc_html__( 'Extras', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'Overlay',
			array(
				'label'   => esc_html__( 'Overlay Color Effect', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SWITCHER,
				'default' => 'no',
			)
		);
		$this->add_control(
			'OverlayColor1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.overlay:before' => 'background: {{VALUE}};',
				),
				'default'   => '#8D0801',
				'condition' => array(
					'Overlay' => 'yes',
				),
			)
		);
		$this->add_control(
			'OverlayColor2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.overlay:after' => 'background: {{VALUE}};',
				),
				'default'   => '#bf0603',
				'condition' => array(
					'Overlay' => 'yes',
				),
			)
		);
		$this->end_controls_section();

		/*Tilt Effect Options*/
		include ECAFE_PATH . 'element/widgets/ecafe-tilt-options.php';

		/*Tippy Tooltip Options*/
		include ECAFE_PATH . 'element/widgets/ecafe-tippy-options.php';

		/*Notice panel*/
		$ecwidgetdemolink = esc_url( 'https://ecaddons.com/elements/title/' );
		$ecwidgetdoclink  = esc_url( 'https://ecaddons.com/docs/title-widget-tutorial/' );
		include ECAFE_PATH . 'element/widgets/ecafe-widgetpanel-help.php';

		/*
		style start*/
		/*title start*/
		$this->start_controls_section(
			'titleStyling',
			array(
				'label' => esc_html__( 'Title', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_responsive_control(
			'titlePadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'titleMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'titleTypography',
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-title',
			)
		);
		$this->add_control(
			'titleColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-title' => 'color: {{VALUE}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'titleBackground',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-title',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'titleBorder',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-title',
			)
		);
		$this->add_responsive_control(
			'titleBr',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-title' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Text_Shadow::get_type(),
			array(
				'name'     => 'titleTextShadow',
				'label'    => __( 'Text Shadow', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-title',
			)
		);
		$this->add_group_control(
			Group_Control_Text_Stroke::get_type(),
			array(
				'name'     => 'titleTextStroke',
                'label'    => esc_html__( 'Text Stroke', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-title',
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'titleShadow',
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-title',
			)
		);
		$this->end_controls_section();
		/*title end*/

		/*shape start*/
		$this->start_controls_section(
			'shapeStyling',
			array(
				'label'     => esc_html__( 'Shape', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'AStyle' => 'as15',
				),
			)
		);
		$this->add_responsive_control(
			'shapeWidthSize',
			array(
				'label'      => esc_html__( 'Width', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 200,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper.as15 .eca-heading-wrapper-inner svg' => 'width:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'shapeHeightSize',
			array(
				'label'      => esc_html__( 'Height', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 200,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper.as15 .eca-heading-wrapper-inner svg' => 'height:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_control(
			'shapeColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.as15 .eca-heading-wrapper-inner svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->end_controls_section();
		/*shape end*/

		/*sub title start*/
		$this->start_controls_section(
			'subtitleStyling',
			array(
				'label'     => esc_html__( 'Sub Title', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'AStyle!' => 'as15',
				),
			)
		);
		$this->add_responsive_control(
			'subtitlePadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'subtitleMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'subtitleTypography',
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title',
			)
		);
		$this->add_control(
			'subtitleColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title' => 'color: {{VALUE}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'subtitleBackground',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'subtitleBorder',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title',
			)
		);
		$this->add_responsive_control(
			'subtitleBr',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Text_Shadow::get_type(),
			array(
				'name'     => 'subtitleTextShadow',
				'label'    => __( 'Text Shadow', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title',
			)
		);
		$this->add_group_control(
			Group_Control_Text_Stroke::get_type(),
			array(
				'name'     => 'subtitleTextStroke',
                'label'    => esc_html__( 'Text Stroke', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title',
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'subtitleShadow',
				'selector' => '{{WRAPPER}} .eca-heading-wrapper .eca-heading-sub-title',
			)
		);
		$this->end_controls_section();
		/*sub title end*/

		/*extras start*/
		$this->start_controls_section(
			'extrasStyling',
			array(
				'label'     => esc_html__( 'Extras', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'Layout'  => 'advanced',
					'AStyle!' => 'as15',
				),
			)
		);
		$this->add_control(
			'as12Color',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.advanced.as1 .eca-heading-title:before, {{WRAPPER}} .eca-heading-wrapper.advanced.as2 .eca-heading-sub-title:before,
					{{WRAPPER}} .eca-heading-wrapper.advanced.as1 .eca-heading-title:after,
					{{WRAPPER}} .eca-heading-wrapper.advanced.as2 .eca-heading-sub-title:after' => 'background: {{VALUE}};',
				),
				'condition' => array(
					'AStyle' => array( 'as1', 'as2' ),
				),
			)
		);
		$this->add_control(
			'as34Color',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.advanced.as3 .eca-heading-title:before, {{WRAPPER}} .eca-heading-wrapper.advanced.as4 .eca-heading-sub-title:before' => 'background: {{VALUE}};',
				),
				'condition' => array(
					'AStyle' => array( 'as3', 'as4' ),
				),
			)
		);
		$this->add_control(
			'as56Color',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.advanced.as5 .eca-heading-title:before, {{WRAPPER}} .eca-heading-wrapper.advanced.as6 .eca-heading-sub-title:before' => 'background: {{VALUE}};',
				),
				'condition' => array(
					'AStyle' => array( 'as5', 'as6' ),
				),
			)
		);
		$this->add_control(
			'as78Color1',
			array(
				'label'     => esc_html__( 'Color 1', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.advanced.as7 .eca-heading-title:after, {{WRAPPER}} .eca-heading-wrapper.advanced.as7 .eca-heading-title:before, {{WRAPPER}} .eca-heading-wrapper.advanced.as8 .eca-heading-sub-title:after, {{WRAPPER}} .eca-heading-wrapper.advanced.as8 .eca-heading-sub-title:before' => 'background: {{VALUE}};',
				),
				'condition' => array(
					'AStyle' => array( 'as7', 'as8' ),
				),
			)
		);
		$this->add_control(
			'as78Color2',
			array(
				'label'     => esc_html__( 'Color 2', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.advanced.as7 .eca-heading-title:after, {{WRAPPER}} .eca-heading-wrapper.advanced.as8 .eca-heading-sub-title:after' => 'background: {{VALUE}};',
				),
				'condition' => array(
					'AStyle' => array( 'as7', 'as8' ),
				),
			)
		);
		$this->add_control(
			'as910Color',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.advanced.as9 .eca-heading-title:after, {{WRAPPER}} .eca-heading-wrapper.advanced.as9 .eca-heading-title:before, {{WRAPPER}} .eca-heading-wrapper.advanced.as10 .eca-heading-sub-title:after, {{WRAPPER}} .eca-heading-wrapper.advanced.as10 .eca-heading-sub-title:before' => 'border-bottom: 1px solid {{VALUE}};border-top: 1px solid {{VALUE}};',
				),
				'condition' => array(
					'AStyle' => array( 'as9', 'as10' ),
				),
			)
		);
		$this->add_control(
			'as1112Color',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.advanced.as11 .eca-heading-title:after, {{WRAPPER}} .eca-heading-wrapper.advanced.as11 .eca-heading-title:before, {{WRAPPER}} .eca-heading-wrapper.advanced.as12 .eca-heading-sub-title:after, {{WRAPPER}} .eca-heading-wrapper.advanced.as12 .eca-heading-sub-title:before' => 'border-bottom: 2px solid {{VALUE}};',
				),
				'condition' => array(
					'AStyle' => array( 'as11', 'as12' ),
				),
			)
		);
		$this->add_control(
			'as1314Color',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.advanced.as13 .eca-heading-title:before, {{WRAPPER}} .eca-heading-wrapper.advanced.as14 .eca-heading-sub-title:before' => 'background: {{VALUE}};',
				),
				'condition' => array(
					'AStyle' => array( 'as13', 'as14' ),
				),
			)
		);
		$this->add_control(
			'as1314IconColor',
			array(
				'label'     => esc_html__( 'Icon Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-heading-wrapper.advanced.as13 .eca-heading-title:after, {{WRAPPER}} .eca-heading-wrapper.advanced.as14 .eca-heading-sub-title:after' => 'color:{{VALUE}};',
				),
				'condition' => array(
					'AStyle' => array( 'as13', 'as14' ),
				),
			)
		);
		$this->end_controls_section();
		/*extras end*/

		/*box start*/
		$this->start_controls_section(
			'boxStyling',
			array(
				'label' => esc_html__( 'Box', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_responsive_control(
			'boxPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'boxMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'boxBackground',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'boxBorder',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-heading-wrapper',
			)
		);
		$this->add_responsive_control(
			'boxBr',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-heading-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'boxShadow',
				'selector' => '{{WRAPPER}} .eca-heading-wrapper',
			)
		);
		$this->end_controls_section();
		/*
		box end*/
		/*style end*/
	}

	protected function render() {

		$settings    = $this->get_settings_for_display();
		$Layout      = ! empty( $settings['Layout'] ) ? $settings['Layout'] : 'default';
		$DStyle      = ! empty( $settings['DStyle'] ) ? $settings['DStyle'] : 'ds1';
		$AStyle      = ! empty( $settings['AStyle'] ) ? $settings['AStyle'] : 'as1';
		$Title       = ! empty( $settings['Title'] ) ? $settings['Title'] : '';
		$TitleTag    = ! empty( $settings['TitleTag'] ) ? $settings['TitleTag'] : 'h1';
		$SubTitle    = ! empty( $settings['SubTitle'] ) ? $settings['SubTitle'] : '';
		$SubTitleTag = ! empty( $settings['SubTitleTag'] ) ? $settings['SubTitleTag'] : 'h3';

		$op = $OPTitle = $OPSubTitle = $Style = $Overlay = '';
		if ( ! empty( $Title ) ) {
			if ( $TitleTag == 'a' && ! empty( $settings['TitleLink']['url'] ) ) {
				$this->add_link_attributes( 'titlelink', $settings['TitleLink'] );
				$this->add_render_attribute( 'titlelink', 'class', 'eca-heading-title' );

				$OPTitle = '<' . \EcafeHelper::check_and_validate_html_tag( $TitleTag ) . ' ' . $this->get_render_attribute_string( 'titlelink' ) . '>' . esc_html( $Title ) . '</' . \EcafeHelper::check_and_validate_html_tag( $TitleTag ) . '>';
			} else {
				$OPTitle = '<' . \EcafeHelper::check_and_validate_html_tag( $TitleTag ) . ' class="eca-heading-title">' . esc_html( $Title ) . '</' . \EcafeHelper::check_and_validate_html_tag( $TitleTag ) . '>';
			}
		}
		if ( ! empty( $SubTitle ) ) {
			$OPSubTitle = '<' . \EcafeHelper::check_and_validate_html_tag( $SubTitleTag ) . ' class="eca-heading-sub-title">' . esc_html( $SubTitle ) . '</' . \EcafeHelper::check_and_validate_html_tag( $SubTitleTag ) . '>';
		}

		if ( ! empty( $settings['Overlay'] ) && $settings['Overlay'] == 'yes' ) {
			$Overlay = 'overlay';
		}
		if ( ! empty( $Layout ) ) {
			if ( $Layout == 'default' ) {
				$Style = $DStyle;
			} elseif ( $Layout == 'advanced' ) {
				$Style = $AStyle;
			}
		}

		$tiltclass  = '';
		$tiltrender = '';
		if ( isset( $settings['tiltEffect'] ) && $settings['tiltEffect'] === 'yes' ) {
			/*Tilt Effect Render*/
			include ECAFE_PATH . 'element/widgets/ecafe-tilt-render.php';
		}
		$tippyclass  = '';
		$tippyrender = '';
		if ( isset( $settings['tippyTooltip'] ) && $settings['tippyTooltip'] === 'yes' ) {
			/*Tippy Tooltip Render*/
			include ECAFE_PATH . 'element/widgets/ecafe-tippy-render.php';
		}

		$op     .= '<div class="eca-heading-wrapper ' . esc_attr( $Layout ) . ' ' . esc_attr( $Style ) . ' ' . esc_attr( $Overlay ) . ' ' . esc_attr( $tiltclass ) . ' ' . esc_attr( $tippyclass ) . '" ' . $tiltrender . ' ' . $tippyrender . '>';
			$op .= '<div class="eca-heading-wrapper-inner">';
		if ( $Layout ) {
			if ( $Layout == 'default' ) {
				if ( ! empty( $DStyle ) ) {
					if ( $DStyle == 'ds1' || $DStyle == 'ds3' ) {
								$op .= $OPTitle;
								$op .= $OPSubTitle;
					} elseif ( $DStyle == 'ds2' || $DStyle == 'ds4' ) {
						$op .= $OPSubTitle;
						$op .= $OPTitle;
					}
				}
			} elseif ( $Layout == 'advanced' ) {
				if ( ! empty( $AStyle ) ) {
					if ( $AStyle == 'as15' ) {
						$svg = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" overflow="visible" height="100%" viewBox="0 0 24 24"><polygon points="9.4,2 24,2 14.6,21.6 0,21.6"/></svg>';
						$op .= $svg . $svg . $svg;
						$op .= $OPTitle;
						$op .= $svg . $svg . $svg;
					} else {
						$op .= $OPTitle;
						$op .= $OPSubTitle;
					}
				}
			}
		}
			$op .= '</div>';
		$op     .= '</div>';
		echo wp_kses_normalize_entities( $op );
	}
}
