<?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 EcafeAddons\EcafeElementLoad;

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

class Ecafe_Post_Authorinfo extends Widget_Base {

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

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

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

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

	public function get_keywords() {
		return array( 'post', 'post info', 'post author', 'author' );
	}

	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(
			'contentSection',
			array(
				'label' => esc_html__( 'Post Author', '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' => 'horizontal',
				'options' => array(
					'horizontal' => esc_html__( 'Horizontal', 'essential-classy-addons-for-elementor' ),
					'vertical'   => esc_html__( 'Vertical', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$this->add_control(
			'layoutReverse',
			array(
				'label'     => esc_html__( 'Reverse Layout', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'no',
			)
		);
		$this->add_responsive_control(
			'maxWidth',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Max Width', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 1,
						'max'  => 800,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'selectors'   => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper' => 'max-width: {{SIZE}}{{UNIT}}',
				),
			)
		);
		$this->add_responsive_control(
			'firstBoxMargin',
			array(
				'label'      => esc_html__( 'First Box', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-first' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'SecondBoxMargin',
			array(
				'label'      => esc_html__( 'Second Box', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_control(
			'textAlign',
			array(
				'label'       => esc_html__( 'Text 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',
					),
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second' => 'align-items: {{VALUE}};',
				),
				'label_block' => false,
			)
		);
		$this->add_control(
			'avtarAlign',
			array(
				'label'       => esc_html__( 'Avatar 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',
					),
				),
				'condition'   => array(
					'layout' => 'vertical',
				),
				'selectors'   => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper.vertical' => 'align-items: {{VALUE}};',
				),
				'label_block' => false,
			)
		);
		$this->add_control(
			'aName',
			array(
				'label'     => esc_html__( 'User Name', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
				'separator' => 'before',
			)
		);
		$this->add_control(
			'aFName',
			array(
				'label'     => esc_html__( 'First Name', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->add_control(
			'aLName',
			array(
				'label'     => esc_html__( 'Last Name', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->add_control(
			'aFLNameInline',
			array(
				'label'     => esc_html__( 'First Last Name Inline', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->add_control(
			'aRole',
			array(
				'label'     => esc_html__( 'Role', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
				'separator' => 'before',
			)
		);
		$this->add_control(
			'aRolePrefix',
			array(
				'label'       => esc_html__( 'Prefix Text', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'Role : ', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Text', 'essential-classy-addons-for-elementor' ),
				'condition'   => array(
					'aRole' => 'yes',
				),
			)
		);
		$this->add_control(
			'aBio',
			array(
				'label'     => esc_html__( 'Bio', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->add_control(
			'aAvtar',
			array(
				'label'     => esc_html__( 'Avatar', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->add_control(
			'aSocial',
			array(
				'label'     => esc_html__( 'Social', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Enable', 'essential-classy-addons-for-elementor' ),
				'label_off' => esc_html__( 'Disable', 'essential-classy-addons-for-elementor' ),
				'default'   => 'yes',
			)
		);
		$this->end_controls_section();

		/*Notice panel*/
		$ecwidgetdoclink = esc_url( 'https://ecaddons.com/docs/post-author-info-blog-builder-tutorial/' );
		include ECAFE_PATH . 'element/widgets/ecafe-widgetpanel-help.php';

		/*name start*/
		$this->start_controls_section(
			'aNameStyling',
			array(
				'label'     => esc_html__( 'User Name', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'aName' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'aNamePadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-authorname' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'aNameMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-authorname' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'aNameTypo',
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-authorname',
			)
		);
		$this->start_controls_tabs( 'tabsaNamestyle' );
		$this->start_controls_tab(
			'tabaNameN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aNameColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-authorname' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabaNameH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aNameColorH',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper:hover .ec-post-aiw-second .ec-authorname' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*name end*/

		/*first name start*/
		$this->start_controls_section(
			'aFNameStyling',
			array(
				'label'     => esc_html__( 'First Name', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'aFName' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'aFNamePadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-firstname-wrapper .ec-firstname' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'aFNameMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-firstname-wrapper .ec-firstname' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'aFNameTypo',
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-firstname-wrapper .ec-firstname',
			)
		);
		$this->start_controls_tabs( 'tabsaFNamestyle' );
		$this->start_controls_tab(
			'tabaFNameN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aFNameColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-firstname-wrapper .ec-firstname' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabaFNameH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aFNameColorH',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-firstname-wrapper:hover .ec-firstname' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*first name end*/

		/*last name start*/
		$this->start_controls_section(
			'aLNameStyling',
			array(
				'label'     => esc_html__( 'Last Name', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'aLName' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'aLNamePadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-firstname-wrapper .ec-lastname' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'aLNameMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-firstname-wrapper .ec-lastname' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'aLNameTypo',
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-firstname-wrapper .ec-lastname',
			)
		);
		$this->start_controls_tabs( 'tabsaLNamestyle' );
		$this->start_controls_tab(
			'tabaLNameN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aLNameColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-firstname-wrapper .ec-lastname' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabaLNameH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aLNameColorH',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper:hover .ec-post-aiw-second .ec-firstname-wrapper .ec-lastname' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*last name end*/

		/*role start*/
		$this->start_controls_section(
			'aRoleStyling',
			array(
				'label'     => esc_html__( 'Role', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'aRole' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'aRolePadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ecc-authorrole' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'aRoleMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ecc-authorrole' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'aRoleTypo',
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ecc-authorrole',
			)
		);
		$this->start_controls_tabs( 'tabsaRolestyle' );
		$this->start_controls_tab(
			'tabaRoleN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aRoleColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ecc-authorrole' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabaRoleH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aRoleColorH',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper:hover .ec-post-aiw-second .ecc-authorrole' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*role end*/

		/*name start*/
		$this->start_controls_section(
			'aBioStyling',
			array(
				'label'     => esc_html__( 'Bio', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'aBio' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'aBioPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ecc-authorbio' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'aBioMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ecc-authorbio' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'aBioTypo',
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ecc-authorbio',
			)
		);
		$this->start_controls_tabs( 'tabsaBiostyle' );
		$this->start_controls_tab(
			'tabaBioN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aBioColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ecc-authorbio' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabaBioH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aBioColorH',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper:hover .ec-post-aiw-second .ecc-authorbio' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*bio end*/

		/*avtar start*/
		$this->start_controls_section(
			'aAvtarStyling',
			array(
				'label'     => esc_html__( 'Avatar', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'aAvtar' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'aAvtarPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-first .ec-authoravatar img' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'aAvtarMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-first .ec-authoravatar img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'aAvtarWidth',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Width', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 1,
						'max'  => 500,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'selectors'   => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-first .ec-authoravatar img' => 'width: {{SIZE}}{{UNIT}}',
				),
			)
		);

		$this->start_controls_tabs( 'tabsaAvtarstyle' );
		$this->start_controls_tab(
			'tabaAvtarN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'aAvtarBg',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-first .ec-authoravatar img',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'aAvtarBorder',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-first .ec-authoravatar img',
			)
		);
		$this->add_responsive_control(
			'aAvtarBr',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-first .ec-authoravatar img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'aAvtarShadow',
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-first .ec-authoravatar img',
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabaAvtarH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'aAvtarBgH',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper:hover .ec-post-aiw-first .ec-authoravatar img',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'aAvtarBorderH',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper:hover .ec-post-aiw-first .ec-authoravatar img',
			)
		);
		$this->add_responsive_control(
			'aAvtarBrH',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper:hover .ec-post-aiw-first .ec-authoravatar img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'aAvtarShadowH',
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper:hover .ec-post-aiw-first .ec-authoravatar img',
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*avtar end*/

		/*social start*/
		$this->start_controls_section(
			'aSocialStyling',
			array(
				'label'     => esc_html__( 'Social', 'essential-classy-addons-for-elementor' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array(
					'aSocial' => 'yes',
				),
			)
		);
		$this->add_responsive_control(
			'aSocialSize',
			array(
				'type'        => Controls_Manager::SLIDER,
				'label'       => esc_html__( 'Size', 'essential-classy-addons-for-elementor' ),
				'size_units'  => array( 'px' ),
				'range'       => array(
					'px' => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'render_type' => 'ui',
				'selectors'   => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-authorsocial li a' => 'font-size: {{SIZE}}{{UNIT}}',
				),
			)
		);
		$this->add_responsive_control(
			'aSocialGap',
			array(
				'label'      => esc_html__( 'Gap', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-authorsocial li:not(:last-child)' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->start_controls_tabs( 'tabsaSocialstyle' );
		$this->start_controls_tab(
			'tabaSocialN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aSocialColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-authorsocial li a' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabaSocialH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'aSocialColorH',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper .ec-post-aiw-second .ec-authorsocial li a:hover' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*social end*/

		/*box start*/
		$this->start_controls_section(
			'aBoxStyling',
			array(
				'label' => esc_html__( 'Box', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_control(
			'aBoxAlign',
			array(
				'label'       => esc_html__( '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',
					),
				),
				'label_block' => false,
			)
		);
		$this->add_responsive_control(
			'aBoxPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->start_controls_tabs( 'tabsaBoxstyle' );
		$this->start_controls_tab(
			'tabaBoxN',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'aBoxBg',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'aBoxBorder',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper',
			)
		);
		$this->add_responsive_control(
			'aBoxBr',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'aBoxShadow',
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper',
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabaBoxH',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'aBoxBgH',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper:hover',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'aBoxBorderH',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper:hover',
			)
		);
		$this->add_responsive_control(
			'aBoxBrH',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .ec-post-authorinfo-wrapper:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'aBoxShadowH',
				'selector' => '{{WRAPPER}} .ec-post-authorinfo-wrapper:hover',
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*box end*/
	}

	protected function render() {

		$settings      = $this->get_settings_for_display();
		$layout        = ! empty( $settings['layout'] ) ? $settings['layout'] : 'horizontal';
		$aName         = ! empty( $settings['aName'] ) ? $settings['aName'] : 'no';
		$aFame         = ! empty( $settings['aFName'] ) ? $settings['aFName'] : 'no';
		$aLame         = ! empty( $settings['aLName'] ) ? $settings['aLName'] : 'no';
		$aFLNameInline = ! empty( $settings['aFLNameInline'] ) ? $settings['aFLNameInline'] : 'no';

		$aRole   = ! empty( $settings['aRole'] ) ? $settings['aRole'] : 'no';
		$aBio    = ! empty( $settings['aBio'] ) ? $settings['aBio'] : 'no';
		$aAvtar  = ! empty( $settings['aAvtar'] ) ? $settings['aAvtar'] : 'no';
		$aSocial = ! empty( $settings['aSocial'] ) ? $settings['aSocial'] : 'no';
		$gqo     = get_queried_object();

		$authorName = $authorFLName  = $authorRole = $authorBio = $authorAvtar = $authorSocial = '';
		if ( $gqo ) {

			if ( is_singular() && isset( $gqo->post_author ) ) {
				$post_author = $gqo->post_author;
			} elseif ( is_author() ) {
				$post_author = $gqo->ID;
			} else {
				global $post;
				if ( $post ) {
					$post_author = $post->post_author;
				} else {
					return; // No author info available
				}
			}
			$authorUrl = get_author_posts_url( $gqo->post_author );

			if ( ! empty( $aName ) && $aName == 'yes' ) {
				$authorName = '<a href="' . esc_url( $authorUrl ) . '" class="ec-authorname" rel="' . esc_attr__( 'author', 'essential-classy-addons-for-elementor' ) . '" >' . get_the_author_meta( 'display_name', $gqo->post_author ) . '</a>';
			}
			$aFLNameInlineClass = '';
			if ( ( ! empty( $aFame ) && $aFame == 'yes' ) || ( ! empty( $aLame ) && $aLame == 'yes' ) ) {
				if ( ! empty( $aFLNameInline ) && $aFLNameInline == 'yes' ) {
					$aFLNameInlineClass = ' ec-firstname-wrapper-inline';
				}
				$fname = get_the_author_meta( 'first_name', $gqo->post_author );
				$lname = get_the_author_meta( 'last_name', $gqo->post_author );

				if ( ! empty( $fname ) || ! empty( $lname ) ) {
					$authorFLName .= '<div class="ec-firstname-wrapper ' . esc_attr( $aFLNameInlineClass ) . '">';
				}

				if ( ! empty( $aFame ) && $aFame == 'yes' ) {
					if ( ! empty( $fname ) ) {
						$authorFLName .= '<div class="ec-firstname">' . $fname . '</div>';
					}
				}
				if ( ! empty( $aLame ) && $aLame == 'yes' ) {
					if ( ! empty( $lname ) ) {
						$authorFLName .= '<div class="ec-lastname">' . $lname . '</div>';
					}
				}

				if ( ! empty( $fname ) || ! empty( $lname ) ) {
					$authorFLName .= '</div>';
				}
			}

			if ( ! empty( $aRole ) && $aRole == 'yes' ) {
				$aRolePrefix = ! empty( $settings['aRolePrefix'] ) ? $settings['aRolePrefix'] : '';
				$user_info   = get_userdata( $post_author );
				$roles       = ! empty( $user_info->roles ) ? $user_info->roles : array();
				$authorRole  = '<span class="ecc-authorrole">' . esc_attr( $aRolePrefix ) . array_shift( $roles ) . '</span>';
			}

			if ( ! empty( $aBio ) && $aBio == 'yes' ) {
				$authorBio = '<span class="ecc-authorbio">' . get_the_author_meta( 'user_description', $gqo->post_author ) . '</span>';
			}
			if ( ! empty( $aAvtar ) && $aAvtar == 'yes' ) {
				$authorAvtar = '<a href="' . esc_url( $authorUrl ) . '" rel="' . esc_attr__( 'author', 'essential-classy-addons-for-elementor' ) . '" class="ec-authoravatar"><img src="' . esc_url( get_avatar_url( $gqo->post_author ) ) . '" /></a>';
			}
			if ( ! empty( $aSocial ) && $aSocial == 'yes' ) {
				$userUrl   = get_the_author_meta( 'user_url', $gqo->post_author );
				$userEmail = get_the_author_meta( 'email', $gqo->post_author );

				if ( ! empty( $userUrl ) || ! empty( $userEmail ) ) {
					$authorSocial = '<ul class="ec-authorsocial">';
					if ( ! empty( $userUrl ) ) {
						$authorSocial .= '<li><a href="' . esc_url( $userUrl ) . '" rel="' . esc_attr__( 'website', 'essential-classy-addons-for-elementor' ) . '" target="_blank"><i class="fas fa-globe-europe"></i></a></li>';
					}
					if ( ! empty( $userEmail ) ) {
						$authorSocial .= '<li><a href="mailto:' . esc_attr( $userEmail ) . '" rel="' . esc_attr__( 'email', 'essential-classy-addons-for-elementor' ) . '"><i class="fas fa-envelope"></i></a></li>';
					}
					$authorSocial .= '</ul>';
				}
			}

			$layoutReverse = ! empty( $settings['layoutReverse'] ) ? $settings['layoutReverse'] : 'no';
			$reverse       = '';
			if ( ! empty( $layoutReverse ) && $layoutReverse == 'yes' ) {
				$reverse = ' ec-pai-rev';
			}
			$aBoxAlign   = ! empty( $settings['aBoxAlign'] ) ? $settings['aBoxAlign'] : 'ec-alignbox-left';
			$output      = '<div class="ec-post-authorinfo-wrapper ' . esc_attr( $layout ) . ' ' . esc_attr( $reverse ) . ' ec-alignbox-' . esc_attr( $aBoxAlign ) . '">';
				$output .= '<div class="ec-post-aiw-first">' . $authorAvtar . '</div>';
				$output .= '<div class="ec-post-aiw-second">' . $authorName . $authorFLName . $authorRole . $authorBio . $authorSocial . '</div>';
			$output     .= '</div>';
			echo wp_kses_normalize_entities( $output );
		}
	}
}
