<?php
namespace EcafeAddons\Widgets;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Utils;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Background;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;

use EcafeAddons\EcafeElementLoad;

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

class Ecafe_Business_Hours extends Widget_Base {

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

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

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

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

	public function get_keywords() {
		return array( 'business hours', 'hours', 'opening', 'time table', 'schedule', 'opening hours', 'store hours', 'service timings', 'open close schedule' );
	}

	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__( 'Business Hours', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$repeater = new \Elementor\Repeater();
		$repeater->add_control(
			'firstIcon',
			array(
				'label'   => esc_html__( 'Icon', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::ICONS,
				'default' => array(
					'value'   => 'fab fa-microblog',
					'library' => 'brands',
				),
			)
		);
		$repeater->add_control(
			'firstText',
			array(
				'label'       => esc_html__( 'First Text', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'Label', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Label', 'essential-classy-addons-for-elementor' ),
			)
		);
		$repeater->add_control(
			'secondText',
			array(
				'label'       => esc_html__( 'Second Text', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'Description', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Description', 'essential-classy-addons-for-elementor' ),
			)
		);
		$repeater->add_control(
			'firstIconColor',
			array(
				'label'     => esc_html__( 'Icon Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list {{CURRENT_ITEM}} .eca-bh-list-left .eca-bh-icon' => 'color: {{VALUE}};',
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list {{CURRENT_ITEM}} .eca-bh-list-left .eca-bh-icon svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$repeater->add_control(
			'firstTextColor',
			array(
				'label'     => esc_html__( 'First Text Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list {{CURRENT_ITEM}} .eca-bh-list-left' => 'color: {{VALUE}};',
				),
			)
		);
		$repeater->add_control(
			'secondTextColor',
			array(
				'label'     => esc_html__( 'Second Text Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list {{CURRENT_ITEM}} .eca-bh-list-right' => 'color: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'bhList',
			array(
				'label'       => esc_html__( 'Content', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::REPEATER,
				'fields'      => $repeater->get_controls(),
				'separator'   => 'before',
				'default'     => array(
					array(
						'firstText'  => 'Sunday',
						'secondText' => 'Closed',
					),
					array(
						'firstText'  => 'Monday - Friday',
						'secondText' => '9:00 AM - 6:00 PM',
					),
					array(
						'firstText'  => 'Saturday',
						'secondText' => '9:00 AM - 6:00 PM',
					),
				),
				'title_field' => '{{{ firstText }}}',
			)
		);
		$this->end_controls_section();

		$this->start_controls_section(
			'contentHeader',
			array(
				'label' => esc_html__( 'Header', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'iconLibrary',
			array(
				'label'   => esc_html__( 'Icon', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::ICONS,
				'default' => array(
					'value'   => 'fab fa-microblog',
					'library' => 'brands',
				),
			)
		);
		$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__( 'OPENING HOURS', '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(),
			)
		);
		$this->end_controls_section();

		$this->start_controls_section(
			'contentFooter',
			array(
				'label' => esc_html__( 'Footer', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);
		$this->add_control(
			'buttonPosition',
			array(
				'label'   => esc_html__( 'Position', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'default',
				'options' => array(
					'default'      => esc_html__( 'Default', 'essential-classy-addons-for-elementor' ),
					'beforeHeader' => esc_html__( 'Before Header', 'essential-classy-addons-for-elementor' ),
					'afterHeader'  => esc_html__( 'After Header', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$this->add_control(
			'buttonType',
			array(
				'label'   => esc_html__( 'Type', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'link',
				'options' => array(
					'link'  => esc_html__( 'Link', 'essential-classy-addons-for-elementor' ),
					'tel'   => esc_html__( 'Tel', 'essential-classy-addons-for-elementor' ),
					'email' => esc_html__( 'E Mail', 'essential-classy-addons-for-elementor' ),
				),
			)
		);
		$this->add_control(
			'buttonIcon',
			array(
				'label'   => esc_html__( 'Icon', 'essential-classy-addons-for-elementor' ),
				'type'    => Controls_Manager::ICONS,
				'default' => array(
					'value'   => 'fab fa-microblog',
					'library' => 'brands',
				),
			)
		);
		$this->add_control(
			'buttonText',
			array(
				'label'       => esc_html__( 'Text', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'default'     => esc_html__( 'Contact Us', 'essential-classy-addons-for-elementor' ),
				'placeholder' => esc_html__( 'Enter Text', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'buttonLink',
			array(
				'label'         => esc_html__( 'Link', 'essential-classy-addons-for-elementor' ),
				'type'          => Controls_Manager::URL,
				'placeholder'   => esc_html__( 'https://your-link.com', 'essential-classy-addons-for-elementor' ),
				'show_external' => true,
				'default'       => array( 'url' => '#' ),
				'dynamic'       => array( 'active' => true ),
				'condition'     => array(
					'buttonType' => 'link',
				),
			)
		);
		$this->add_control(
			'buttonTel',
			array(
				'label'     => __( 'Tel', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::TEXT,
				'condition' => array(
					'buttonType' => 'tel',
				),
			)
		);
		$this->add_control(
			'buttonEmail',
			array(
				'label'       => esc_html__( 'Email', 'essential-classy-addons-for-elementor' ),
				'type'        => Controls_Manager::TEXT,
				'dynamic'     => array( 'active' => true ),
				'placeholder' => esc_html__( 'Enter Email', 'essential-classy-addons-for-elementor' ),
				'condition'   => array(
					'buttonType' => 'email',
				),
			)
		);
		$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/business-hours/' );
		$ecwidgetdoclink  = esc_url( 'https://ecaddons.com/docs/business-hours-widget-tutorial/' );
		include ECAFE_PATH . 'element/widgets/ecafe-widgetpanel-help.php';

		/*
		style start*/
		/*heading icon start*/
		$this->start_controls_section(
			'hiStyling',
			array(
				'label' => esc_html__( 'Heading Icon', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_responsive_control(
			'hiPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'hiMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'hiSize',
			array(
				'label'      => esc_html__( 'Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 200,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon' => 'font-size:{{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon svg' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->add_control(
			'hiColorNorm',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon' => 'color: {{VALUE}};',
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'hiBgNorm',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'hiBorderNorm',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon',
			)
		);
		$this->add_responsive_control(
			'hiBrNorm',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'hiShadowNorm',
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-icon',
			)
		);
		$this->end_controls_section();
		/*heading icon end*/

		/*heading text start*/
		$this->start_controls_section(
			'htStyling',
			array(
				'label' => esc_html__( 'Heading Text', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_responsive_control(
			'hAlign',
			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',
					),
				),
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-header-area' => 'justify-content:{{VALUE}};',
				),
			)
		);
		$this->add_responsive_control(
			'htPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-header-area' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'htMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-header-area' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'htTypo',
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-header-area',
			)
		);
		$this->add_control(
			'htColorNorm',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-header-area' => 'color: {{VALUE}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'htBgNorm',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-header-area',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'htBorderNorm',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-header-area',
			)
		);
		$this->add_responsive_control(
			'htBrNorm',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-header-area' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'htShadowNorm',
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-header .eca-bh-header-area',
			)
		);
		$this->end_controls_section();
		/*heading text end*/

		/*button start*/
		$this->start_controls_section(
			'bStyling',
			array(
				'label' => esc_html__( 'Button', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_responsive_control(
			'bPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'bMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_control(
			'bIconStyling',
			array(
				'label' => esc_html__( 'Icon', 'essential-classy-addons-for-elementor' ),
				'type'  => Controls_Manager::HEADING,
			)
		);
		$this->add_responsive_control(
			'biSize',
			array(
				'label'      => esc_html__( 'Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 200,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button .eca-bh-icon' => 'font-size:{{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button .eca-bh-icon svg' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
				),
			)
		);
		$this->start_controls_tabs( 'tabsBiStyle' );
		$this->start_controls_tab(
			'tabBiNormal',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'biNColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button .eca-bh-icon' => 'color: {{VALUE}};',
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button .eca-bh-icon svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabBiHover',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'biHColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button:hover .eca-bh-icon' => 'color: {{VALUE}};',
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button:hover .eca-bh-icon svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->add_control(
			'bTextStyling',
			array(
				'label'     => esc_html__( 'Text', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'btTypo',
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button',
			)
		);
		$this->start_controls_tabs( 'tabsBtStyle' );
		$this->start_controls_tab(
			'tabBtNormal',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'btNColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabBtHover',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'btHColor',
			array(
				'label'     => esc_html__( 'Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button:hover' => 'color: {{VALUE}};',
				),
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->add_control(
			'bBoxStyling',
			array(
				'label'     => esc_html__( 'Button Box', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);
		$this->start_controls_tabs( 'tabsBStyle' );
		$this->start_controls_tab(
			'tabBNormal',
			array(
				'label' => esc_html__( 'Normal', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'      => 'bBgNorm',
				'types'     => array( 'classic', 'gradient' ),
				'selector'  => '{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button',
				'condition' => array(
					'buttonHoverEffectH!' => 'yes',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'bBorderNorm',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button',
			)
		);
		$this->add_responsive_control(
			'bBrNorm',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'bShadowNorm',
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button',
			)
		);
		$this->end_controls_tab();
		$this->start_controls_tab(
			'tabBHover',
			array(
				'label' => esc_html__( 'Hover', 'essential-classy-addons-for-elementor' ),
			)
		);
		$this->add_control(
			'buttonHoverEffectH',
			array(
				'label'     => esc_html__( 'Hover Effect', '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_control(
			'buttonEffectPosH',
			array(
				'label'     => esc_html__( 'Position', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::SELECT,
				'default'   => '',
				'options'   => array(
					''                              => esc_html__( 'Bottom', 'essential-classy-addons-for-elementor' ),
					'eca-button-hover-effect-top'   => esc_html__( 'Top', 'essential-classy-addons-for-elementor' ),
					'eca-button-hover-effect-left'  => esc_html__( 'Left', 'essential-classy-addons-for-elementor' ),
					'eca-button-hover-effect-right' => esc_html__( 'Right', 'essential-classy-addons-for-elementor' ),
				),
				'condition' => array(
					'buttonHoverEffectH' => 'yes',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'      => 'bBgHover',
				'types'     => array( 'classic', 'gradient' ),
				'selector'  => '{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button:hover',
				'condition' => array(
					'buttonHoverEffectH!' => 'yes',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'      => 'bBgEffectHover',
				'types'     => array( 'classic', 'gradient' ),
				'selector'  => '{{WRAPPER}} .eca-button-hover-effect:hover:after',
				'condition' => array(
					'buttonHoverEffectH' => 'yes',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'bBorderHover',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button:hover',
			)
		);
		$this->add_responsive_control(
			'bBrHover',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'bShadowHover',
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-footer .eca-bh-footer-button:hover',
			)
		);
		$this->end_controls_tab();
		$this->end_controls_tabs();
		$this->end_controls_section();
		/*button end*/

		/*list common start*/
		$this->start_controls_section(
			'lctyling',
			array(
				'label' => esc_html__( 'List Common', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_control(
			'leftListStyling',
			array(
				'label' => esc_html__( 'Left Side', 'essential-classy-addons-for-elementor' ),
				'type'  => Controls_Manager::HEADING,
			)
		);
		$this->add_responsive_control(
			'lLISize',
			array(
				'label'      => esc_html__( 'Icon Size', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::SLIDER,
				'size_units' => array( 'px', '%' ),
				'range'      => array(
					'px' => array(
						'min' => 1,
						'max' => 200,
					),
					'%'  => array(
						'min'  => 1,
						'max'  => 100,
						'step' => 1,
					),
				),
				'default'    => array(
					'unit' => 'px',
					'size' => 20,
				),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-left .eca-bh-icon' => 'font-size:{{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-left .eca-bh-icon svg' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
				),
			)
		);
			$this->add_responsive_control(
				'lLIBox',
				array(
					'label'      => esc_html__( 'Icon Box', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px', '%' ),
					'range'      => array(
						'px' => array(
							'min' => 1,
							'max' => 200,
						),
						'%'  => array(
							'min'  => 1,
							'max'  => 100,
							'step' => 1,
						),
					),
					'default'    => array(
						'unit' => 'px',
						'size' => 25,
					),
					'selectors'  => array(
						'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-left .eca-bh-icon' => 'width:{{SIZE}}{{UNIT}};height:{{SIZE}}{{UNIT}};',
					),
				)
			);
			$this->add_responsive_control(
				'lLIGap',
				array(
					'label'      => esc_html__( 'Icon Gap', 'essential-classy-addons-for-elementor' ),
					'type'       => Controls_Manager::SLIDER,
					'size_units' => array( 'px', '%' ),
					'range'      => array(
						'px' => array(
							'min' => 1,
							'max' => 300,
						),
						'%'  => array(
							'min'  => 1,
							'max'  => 100,
							'step' => 1,
						),
					),
					'selectors'  => array(
						'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-left .eca-bh-icon' => 'margin-right:{{SIZE}}{{UNIT}};',
					),
				)
			);
		$this->add_control(
			'lLIColor',
			array(
				'label'     => esc_html__( 'Icon Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-left .eca-bh-icon' => 'color: {{VALUE}};',
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-left .eca-bh-icon svg' => 'fill: {{VALUE}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'lLTTypo',
				'label'    => esc_html__( 'Text Typography', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-left',
			)
		);
		$this->add_control(
			'lLTColor',
			array(
				'label'     => esc_html__( 'Text Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-left' => 'color: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'rightListStyling',
			array(
				'label'     => esc_html__( 'Right Side', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);
		$this->add_group_control(
			Group_Control_Typography::get_type(),
			array(
				'name'     => 'rLTTypo',
				'label'    => esc_html__( 'Text Typography', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-right',
			)
		);
		$this->add_control(
			'rLTColor',
			array(
				'label'     => esc_html__( 'Text Color', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::COLOR,
				'selectors' => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list-right' => 'color: {{VALUE}};',
				),
			)
		);
		$this->add_control(
			'bListStyling',
			array(
				'label'     => esc_html__( 'List', 'essential-classy-addons-for-elementor' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);
		$this->add_responsive_control(
			'lcPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'lcMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'lcBg',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'lcBorder',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list',
			)
		);
		$this->add_responsive_control(
			'lcBr',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'lcShadow',
				'selector' => '{{WRAPPER}} .eca-business-hours .eca-bh-lists .eca-bh-list',
			)
		);
		$this->end_controls_section();
		/*list common end*/

		/*box start*/
		$this->start_controls_section(
			'bhBoxStyling',
			array(
				'label' => esc_html__( 'Box', 'essential-classy-addons-for-elementor' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);
		$this->add_responsive_control(
			'bhPadding',
			array(
				'label'      => esc_html__( 'Padding', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_responsive_control(
			'bhMargin',
			array(
				'label'      => esc_html__( 'Margin', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%', 'em' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Background::get_type(),
			array(
				'name'     => 'bhBg',
				'types'    => array( 'classic', 'gradient' ),
				'selector' => '{{WRAPPER}} .eca-business-hours',
			)
		);
		$this->add_group_control(
			Group_Control_Border::get_type(),
			array(
				'name'     => 'bhBorder',
				'label'    => esc_html__( 'Border', 'essential-classy-addons-for-elementor' ),
				'selector' => '{{WRAPPER}} .eca-business-hours',
			)
		);
		$this->add_responsive_control(
			'bhBr',
			array(
				'label'      => esc_html__( 'Border Radius', 'essential-classy-addons-for-elementor' ),
				'type'       => Controls_Manager::DIMENSIONS,
				'size_units' => array( 'px', '%' ),
				'selectors'  => array(
					'{{WRAPPER}} .eca-business-hours' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
				),
			)
		);
		$this->add_group_control(
			Group_Control_Box_Shadow::get_type(),
			array(
				'name'     => 'bhShadow',
				'selector' => '{{WRAPPER}} .eca-business-hours',
			)
		);
		$this->end_controls_section();
		/*box end*/
	}

	protected function render() {

		$settings    = $this->get_settings_for_display();
		$iconLibrary = ! empty( $settings['iconLibrary'] ) ? $settings['iconLibrary'] : '';
		$titleText   = ! empty( $settings['title'] ) ? $settings['title'] : '';
		$titleTag    = ! empty( $settings['titleTag'] ) ? $settings['titleTag'] : 'h1';

		$buttonPosition = ! empty( $settings['buttonPosition'] ) ? $settings['buttonPosition'] : 'default';
		$buttonType     = ! empty( $settings['buttonType'] ) ? $settings['buttonType'] : 'link';
		$buttonIcon     = ! empty( $settings['buttonIcon'] ) ? $settings['buttonIcon'] : '';
		$buttonText     = ! empty( $settings['buttonText'] ) ? $settings['buttonText'] : '';

		$buttonLink  = ! empty( $settings['buttonLink']['url'] ) ? $settings['buttonLink']['url'] : '';
		$buttonTel   = ! empty( $settings['buttonTel'] ) ? $settings['buttonTel'] : '';
		$buttonEmail = ! empty( $settings['buttonEmail'] ) ? $settings['buttonEmail'] : '';

		$title = $titleIconCol = $titleTextCol = '';
		if ( ! empty( $iconLibrary ) || ! empty( $titleText ) ) {
			if ( ! empty( $iconLibrary ) ) {
				ob_start();
				\Elementor\Icons_Manager::render_icon( $iconLibrary, array( 'aria-hidden' => 'true' ) );
				$titleIconCol = '<span class="eca-bh-icon">' . ob_get_contents() . '</span>';
				ob_end_clean();
			}
			if ( ! empty( $titleText ) ) {
				$titleTextCol = esc_html( $titleText );
			}

			$title = '<div class="eca-bh-header"><' . \EcafeHelper::check_and_validate_html_tag( $titleTag ) . ' class="eca-bh-header-area">' . $titleIconCol . $titleTextCol . '</' . \EcafeHelper::check_and_validate_html_tag( $titleTag ) . '></div>';
		}

		$button = $buttonSrc = $buttonTextCol = $buttonIconCol = '';
		if ( ! empty( $buttonIcon ) || ! empty( $buttonText ) ) {
			if ( $buttonType == 'link' && ! empty( $buttonLink ) ) {
				$buttonSrc = $buttonLink;
			} elseif ( $buttonType == 'tel' && ! empty( $buttonTel ) ) {
				$buttonSrc = 'tel:' . $buttonTel;
			} elseif ( $buttonType == 'email' && ! empty( $buttonEmail ) ) {
				$buttonSrc = 'mailto:' . $buttonEmail;
			}

			if ( ! empty( $buttonIcon ) ) {
				ob_start();
				\Elementor\Icons_Manager::render_icon( $buttonIcon, array( 'aria-hidden' => 'true' ) );
				$buttonIconCol = '<span class="eca-bh-icon">' . ob_get_contents() . '</span>';
				ob_end_clean();
			}
			if ( ! empty( $buttonText ) ) {
				$buttonTextCol = esc_html( $buttonText );
			}

			$buttonHoverEffectH = ( isset( $settings['buttonHoverEffectH'] ) && $settings['buttonHoverEffectH'] == 'yes' ) ? 'eca-button-hover-effect ' . esc_attr( $settings['buttonEffectPosH'] ) : '';
			$button             = '<div class="eca-bh-footer"><a class="eca-bh-footer-button ' . esc_attr( $buttonHoverEffectH ) . '" href="' . esc_url( $buttonSrc ) . '">' . $buttonIconCol . $buttonTextCol . '</a></div>';
		}

		$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';
		}
		$output = '<div class="eca-business-hours ' . esc_attr( $tiltclass ) . ' ' . esc_attr( $tippyclass ) . '" ' . $tiltrender . ' ' . $tippyrender . '>';

		if ( $buttonPosition == 'beforeHeader' ) {
			$output .= $button;
		}

			$output .= $title;

		if ( $buttonPosition == 'afterHeader' ) {
			$output .= $button;
		}

			$output .= '<ul class="eca-bh-lists">';
		foreach ( $settings['bhList'] as $item ) {
			$firstIcon  = ! empty( $item['firstIcon'] ) ? $item['firstIcon'] : '';
			$firstText  = ! empty( $item['firstText'] ) ? $item['firstText'] : '';
			$secondText = ! empty( $item['secondText'] ) ? $item['secondText'] : '';

			$output              .= '<li class="eca-bh-list">';
			$output              .= '<span class="elementor-repeater-item-' . esc_attr( $item['_id'] ) . ' eca-bh-list-in">';
					$firstIconCol = $firstTextCol = '';
			if ( ! empty( $firstIcon ) || ! empty( $firstText ) ) {
				if ( ! empty( $firstIcon ) ) {
									ob_start();
									\Elementor\Icons_Manager::render_icon( $firstIcon, array( 'aria-hidden' => 'true' ) );
									$firstIconCol = '<span class="eca-bh-icon">' . ob_get_contents() . '</span>';
									ob_end_clean();
				}
				if ( ! empty( $firstText ) ) {
								$firstTextCol .= esc_html( $firstText );
				}

							$output .= '<span class="eca-bh-list-left">' . $firstIconCol . $firstTextCol . '</span>';
			}
			if ( ! empty( $secondText ) ) {
					$output .= '<span class="eca-bh-list-right">' . esc_html( $secondText ) . '</span>';
			}
							$output .= '</li>';
		}
			$output .= '</ul>';

		if ( $buttonPosition == 'default' ) {
			$output .= $button;
		}
			$output .= '</div>';

			echo wp_kses_normalize_entities( $output );
	}
}
