<?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;

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

$this->start_controls_section(
	'ecTippysection',
	array(
		'label' => esc_html__( 'Tippy Tooltip', 'essential-classy-addons-for-elementor' ),
		'tab'   => Controls_Manager::TAB_CONTENT,
	)
);
$this->add_control(
	'tippyTooltip',
	array(
		'label'     => esc_html__( 'Tippy Tooltip', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::SWITCHER,
		'default'   => 'no',
		'label_on'  => esc_html__( 'Show', 'essential-classy-addons-for-elementor' ),
		'label_off' => esc_html__( 'Hide', 'essential-classy-addons-for-elementor' ),
		'separator' => 'before',
	)
);
$this->add_control(
	'tippyTooltipContent',
	array(
		'label'       => esc_html__( 'Content', 'essential-classy-addons-for-elementor' ),
		'type'        => Controls_Manager::TEXTAREA,
		'default'     => esc_html__( 'I am a Tippy tooltip!', 'essential-classy-addons-for-elementor' ),
		'placeholder' => esc_html__( 'Enter Content', 'essential-classy-addons-for-elementor' ),
		'condition'   => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipTheme',
	array(
		'label'     => esc_html__( 'Theme', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::SELECT,
		'default'   => 'light',
		'options'   => array(
			'light'       => esc_html__( 'Light', 'essential-classy-addons-for-elementor' ),
			'material'    => esc_html__( 'Material', 'essential-classy-addons-for-elementor' ),
			'translucent' => esc_html__( 'Translucent', 'essential-classy-addons-for-elementor' ),
		),
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipcontentAlign',
	array(
		'label'       => esc_html__( 'Content 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',
			),
		),
		'selectors'   => array(
			'{{WRAPPER}} .tippy-box .tippy-content' => 'text-align: {{VALUE}};',
		),
		'label_block' => false,
		'condition'   => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_responsive_control(
	'tippyTooltipWidth',
	array(
		'label'      => esc_html__( 'Size', 'essential-classy-addons-for-elementor' ),
		'type'       => Controls_Manager::SLIDER,
		'size_units' => array( 'px', '%', 'em' ),
		'range'      => array(
			'px' => array(
				'min' => 1,
				'max' => 800,
			),
			'%'  => array(
				'min'  => 1,
				'max'  => 100,
				'step' => 1,
			),
			'em' => array(
				'min'  => 1,
				'max'  => 100,
				'step' => 1,
			),
		),
		'selectors'  => array(
			'{{WRAPPER}} .tippy-box' => 'width:{{SIZE}}{{UNIT}};max-width:{{SIZE}}{{UNIT}};',
		),
		'condition'  => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipPlacements',
	array(
		'label'     => esc_html__( 'Placements', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::SELECT,
		'default'   => 'top',
		'options'   => array(
			'top'          => esc_html__( 'Top', 'essential-classy-addons-for-elementor' ),
			'top-start'    => esc_html__( 'Top Start', 'essential-classy-addons-for-elementor' ),
			'top-end'      => esc_html__( 'Top End', 'essential-classy-addons-for-elementor' ),
			'right'        => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
			'right-start'  => esc_html__( 'Right Start', 'essential-classy-addons-for-elementor' ),
			'right-end'    => esc_html__( 'Right End', 'essential-classy-addons-for-elementor' ),
			'bottom'       => esc_html__( 'Bottom', 'essential-classy-addons-for-elementor' ),
			'bottom-start' => esc_html__( 'Bottom Start', 'essential-classy-addons-for-elementor' ),
			'bottom-end'   => esc_html__( 'Bottom End', 'essential-classy-addons-for-elementor' ),
			'left'         => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
			'left-start'   => esc_html__( 'Left Start', 'essential-classy-addons-for-elementor' ),
			'left-end'     => esc_html__( 'Left End', 'essential-classy-addons-for-elementor' ),
		),
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipArrows',
	array(
		'label'        => esc_html__( 'Arrows', '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' ),
		'return_value' => 'yes',
		'default'      => 'yes',
		'condition'    => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipArrowsColor',
	array(
		'label'     => esc_html__( 'Arrows Color', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .tippy-box[data-placement^=left] .tippy-arrow:before' => 'border-left-color: {{VALUE}};',
			'{{WRAPPER}} .tippy-box[data-placement^=right] .tippy-arrow:before' => 'border-right-color: {{VALUE}};',
			'{{WRAPPER}} .tippy-box[data-placement^=top] .tippy-arrow:before' => 'border-top-color: {{VALUE}};',
			'{{WRAPPER}} .tippy-box[data-placement^=bottom] .tippy-arrow:before' => 'border-bottom-color: {{VALUE}};',
		),
		'condition' => array(
			'tippyTooltip'       => 'yes',
			'tippyTooltipArrows' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipAnimations',
	array(
		'label'     => esc_html__( 'Animations', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::SELECT,
		'default'   => 'fade',
		'options'   => array(
			'fade'                 => esc_html__( 'Fade', 'essential-classy-addons-for-elementor' ),
			'shift-away'           => esc_html__( 'Shift Away', 'essential-classy-addons-for-elementor' ),
			'shift-away-subtle'    => esc_html__( 'Shift Away Subtle', 'essential-classy-addons-for-elementor' ),
			'shift-away-extreme'   => esc_html__( 'Shift Away Extreme', 'essential-classy-addons-for-elementor' ),
			'shift-toward'         => esc_html__( 'Shift Toward', 'essential-classy-addons-for-elementor' ),
			'shift-toward-subtle'  => esc_html__( 'Shift Toward Subtle', 'essential-classy-addons-for-elementor' ),
			'shift-toward-extreme' => esc_html__( 'Shift Toward Extreme', 'essential-classy-addons-for-elementor' ),
			'scale'                => esc_html__( 'Scale', 'essential-classy-addons-for-elementor' ),
			'scale-subtle'         => esc_html__( 'Scale Subtle', 'essential-classy-addons-for-elementor' ),
			'scale-extreme'        => esc_html__( 'Scale Extreme', 'essential-classy-addons-for-elementor' ),
			'perspective'          => esc_html__( 'Perspective', 'essential-classy-addons-for-elementor' ),
			'perspective-subtle'   => esc_html__( 'Perspective Subtle', 'essential-classy-addons-for-elementor' ),
			'perspective-extreme'  => esc_html__( 'Perspective Extreme', 'essential-classy-addons-for-elementor' ),
		),
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipInDuration',
	array(
		'label'     => __( 'In Duration', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::NUMBER,
		'min'       => 0,
		'max'       => 50000,
		'step'      => 100,
		'default'   => 0,
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipOutDuration',
	array(
		'label'     => __( 'Out Duration', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::NUMBER,
		'min'       => 0,
		'max'       => 50000,
		'step'      => 100,
		'default'   => 0,
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipSkid',
	array(
		'label'     => __( 'Skid (Shifts the tooltip)', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::NUMBER,
		'min'       => 0,
		'max'       => 500,
		'step'      => 1,
		'default'   => 0,
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipDistance',
	array(
		'label'     => __( 'Distance (Moves the tooltip)', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::NUMBER,
		'min'       => -200,
		'max'       => 200,
		'step'      => 1,
		'default'   => 0,
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipTriggers',
	array(
		'label'     => esc_html__( 'Triggers', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::SELECT,
		'default'   => 'mouseenter',
		'options'   => array(
			'mouseenter' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			'click'      => esc_html__( 'Click', 'essential-classy-addons-for-elementor' ),
		),
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipInteractivity',
	array(
		'label'        => esc_html__( 'Interactivity', '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' ),
		'return_value' => 'yes',
		'default'      => 'no',
		'condition'    => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipFollowCursor',
	array(
		'label'        => esc_html__( 'Follow Cursor', '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' ),
		'return_value' => 'yes',
		'default'      => 'yes',
		'condition'    => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipStyling',
	array(
		'label'     => esc_html__( 'Styling', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::HEADING,
		'separator' => 'before',
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_responsive_control(
	'tippyTooltipPadding',
	array(
		'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
		'type'       => Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', '%', 'em' ),
		'selectors'  => array(
			'{{WRAPPER}} .tippy-box' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
		'condition'  => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_group_control(
	Group_Control_Typography::get_type(),
	array(
		'name'      => 'tippyTooltipTypo',
		'selector'  => '{{WRAPPER}} .tippy-box',
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_control(
	'tippyTooltipColor',
	array(
		'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
		'type'      => Controls_Manager::COLOR,
		'selectors' => array(
			'{{WRAPPER}} .tippy-box' => 'color: {{VALUE}};',
		),
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_group_control(
	Group_Control_Background::get_type(),
	array(
		'name'      => 'tippyTooltipBg',
		'types'     => array( 'classic', 'gradient' ),
		'selector'  => '{{WRAPPER}} .tippy-box',
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_group_control(
	Group_Control_Border::get_type(),
	array(
		'name'      => 'tippyTooltipBorder',
		'label'     => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
		'selector'  => '{{WRAPPER}} .tippy-box',
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_responsive_control(
	'tippyTooltipBr',
	array(
		'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
		'type'       => Controls_Manager::DIMENSIONS,
		'size_units' => array( 'px', '%' ),
		'selectors'  => array(
			'{{WRAPPER}} .tippy-box' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
		),
		'condition'  => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_group_control(
	Group_Control_Box_Shadow::get_type(),
	array(
		'name'      => 'tippyTooltipShadow',
		'selector'  => '{{WRAPPER}} .tippy-box',
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->add_group_control(
	Group_Control_Text_Shadow::get_type(),
	array(
		'name'      => 'tippyTooltipTextShadow',
		'label'     => esc_html__( 'Text Shadow', 'essential-classy-addons-for-elementor' ),
		'selector'  => '{{WRAPPER}} .tippy-box',
		'condition' => array(
			'tippyTooltip' => 'yes',
		),
	)
);
$this->end_controls_section();
