<?php
if ( ! class_exists( 'Draly_Dropshipping_Starter_Elementor_Producttabs' ) ) {
	class Draly_Dropshipping_Starter_Elementor_Producttabs extends Draly_Dropshipping_Starter_Elementor {
		public $name = 'producttabs';
		public $title = 'Product Tabs';
		public $icon = 'eicon-product-tabs';

		/**
		 * Register the widget controls.
		 *
		 * Adds different input fields to allow the user to change and customize the widget settings.
		 *
		 * @since 1.0.0
		 *
		 * @access protected
		 */
		protected function register_controls() {
			//General Section
			$this->start_controls_section(
				'general_section',
				[
					'label' => esc_html__( 'General', 'draly-dropshipping-starter' ),
				]
			);
			$this->add_control(
				'maintitle', [
					'label'       => esc_html__( 'Main Title', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::TEXT,
					'placeholder' => esc_html__( 'Enter your main title', 'draly-dropshipping-starter' ),
					'label_block' => true
				]
			);
			$this->add_control(
				'link_text', [
					'label'       => esc_html__( 'Link Text', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::TEXT,
					'placeholder' => esc_html__( 'Enter your link text', 'draly-dropshipping-starter' ),
					'label_block' => true
				]
			);
			$this->add_control(
				'link_url', [
					'label'         => esc_html__( 'Link URL', 'draly-dropshipping-starter' ),
					'type'          => \Elementor\Controls_Manager::URL,
					'placeholder'   => esc_html__( 'https://your-link.com', 'draly-dropshipping-starter' ),
					'show_external' => true,
					'default'       => [
						'url'         => '',
						'is_external' => true,
						'nofollow'    => false,
					],
					'label_block'   => true
				]
			);
			$this->add_control(
				'enable_ajax',
				[
					'label'        => esc_html__( 'Enable Ajax', 'draly-dropshipping-starter' ),
					'type'         => \Elementor\Controls_Manager::SWITCHER,
					'label_on'     => __( 'Yes', 'draly-dropshipping-starter' ),
					'label_off'    => __( 'No', 'draly-dropshipping-starter' ),
					'return_value' => 'yes',
					'default'      => '',
				]
			);
			$this->add_control(
				'css_animation',
				[
					'label'       => esc_html__( 'Css Animation', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::ANIMATION,
					'label_block' => true
				]
			);
			$this->end_controls_section();
			//Product Section
			$this->start_controls_section(
				'product_section',
				[
					'label' => esc_html__( 'Product', 'draly-dropshipping-starter' ),
				]
			);
			$layoutDir = get_template_directory() . '/woocommerce/product-styles/';
			$options   = array();
			if ( is_dir( $layoutDir ) ) {
				$files = scandir( $layoutDir );
				if ( $files && is_array( $files ) ) {
					foreach ( $files as $file ) {
						if ( $file != '.' && $file != '..' ) {
							$fileInfo = pathinfo( $file );
							if ( $fileInfo['extension'] == 'php' && $fileInfo['basename'] != 'index.php' ) {
								$file_data             = get_file_data( $layoutDir . $file, array( 'Name' => 'Name' ) );
								$file_name             = str_replace( 'content-product-', '', $fileInfo['filename'] );
								$options[ $file_name ] = $file_data['Name'];
							}
						}
					}
				}
			}
			$this->add_control(
				'style',
				[
					'label'       => esc_html__( 'Style', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => $options,
					'default'     => 'style-01',
					'label_block' => true
				]
			);
			$this->add_control(
				'product_image_size',
				[
					'label'       => esc_html__( 'Image size', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => Draly_Dropshipping_Starter_Elementor::draly_dropshipping_starter_elementor_size(),
					'description' => esc_html__( 'Select a size for product', 'draly-dropshipping-starter' ),
					'label_block' => true

				]
			);
			$this->add_control(
				'product_custom_thumb_width',
				[
					'label'       => esc_html__( 'Width', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1,
					'default'     => 300,
					'description' => esc_html__( 'Unit px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'product_image_size' => 'custom'
					),
				]
			);
			$this->add_control(
				'product_custom_thumb_height',
				[
					'label'       => esc_html__( 'Height', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1,
					'default'     => 300,
					'description' => esc_html__( 'Unit px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'product_image_size' => 'custom'
					),
				]
			);
			$repeater = new \Elementor\Repeater();
			$repeater->add_control(
				'title', [
					'label'       => esc_html__( 'Tab Title', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::TEXT,
					'placeholder' => esc_html__( 'Enter your tab title', 'draly-dropshipping-starter' ),
					'default'     => esc_html__( 'Tab', 'draly-dropshipping-starter' ),
					'label_block' => true
				]
			);
			$repeater->add_control(
				'taxonomy', [
					'label'       => esc_html__( 'Product Category', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT2,
					'multiple'    => true,
					'options'     => Draly_Dropshipping_Starter_Elementor::draly_dropshipping_starter_elementor_taxonomy(),
					'description' => esc_html__( 'Note: If you want to narrow output, select category(s) above. Only selected categories will be displayed.', 'draly-dropshipping-starter' ),
					'label_block' => true
				]
			);
			$repeater->add_control(
				'target',
				[
					'label'       => esc_html__( 'Target', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'recent-product'    => esc_html__( 'Recent Products', 'draly-dropshipping-starter' ),
						'best-selling'      => esc_html__( 'Best Selling Products', 'draly-dropshipping-starter' ),
						'top-rated'         => esc_html__( 'Top Rated Products', 'draly-dropshipping-starter' ),
						'product-category'  => esc_html__( 'Product Category', 'draly-dropshipping-starter' ),
						'featured_products' => esc_html__( 'Featured Products', 'draly-dropshipping-starter' ),
						'on_sale'           => esc_html__( 'On Sale', 'draly-dropshipping-starter' ),
						'on_new'            => esc_html__( 'On New', 'draly-dropshipping-starter' ),
						'products'          => esc_html__( 'Products', 'draly-dropshipping-starter' ),
					],
					'default'     => 'recent-product',
					'description' => esc_html__( 'Choose the target to filter products', 'draly-dropshipping-starter' ),
					'label_block' => true

				]
			);
			$repeater->add_control(
				'orderby',
				[
					'label'       => esc_html__( 'Order by', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'date'          => esc_html__( 'Date', 'draly-dropshipping-starter' ),
						'ID'            => esc_html__( 'ID', 'draly-dropshipping-starter' ),
						'author'        => esc_html__( 'Author', 'draly-dropshipping-starter' ),
						'title'         => esc_html__( 'Title', 'draly-dropshipping-starter' ),
						'modified'      => esc_html__( 'Modified', 'draly-dropshipping-starter' ),
						'rand'          => esc_html__( 'Random', 'draly-dropshipping-starter' ),
						'comment_count' => esc_html__( 'Comment count', 'draly-dropshipping-starter' ),
						'menu_order'    => esc_html__( 'Menu order', 'draly-dropshipping-starter' ),
						'_sale_price'   => esc_html__( 'Sale price', 'draly-dropshipping-starter' ),
					],
					'default'     => 'date',
					'description' => esc_html__( 'Select how to sort', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'target' => array(
							'top-rated',
							'recent-product',
							'product-category',
							'featured_products',
							'on_sale',
							'on_new',
							'product_attribute'
						)
					),
					'label_block' => true

				]
			);
			$repeater->add_control(
				'order',
				[
					'label'       => esc_html__( 'Order', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'ASC'  => esc_html__( 'Ascending', 'draly-dropshipping-starter' ),
						'DESC' => esc_html__( 'Descending', 'draly-dropshipping-starter' ),
					],
					'default'     => 'DESC',
					'condition'   => array(
						'target' => array(
							'top-rated',
							'recent-product',
							'product-category',
							'featured_products',
							'on_sale',
							'on_new',
							'product_attribute'
						)
					),
					'label_block' => true
				]
			);
			$repeater->add_control(
				'per_page',
				[
					'label'       => esc_html__( 'Product per page', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1,
					'step'        => 1,
					'default'     => 5,
					'condition'   => array(
						'target' => array(
							'top-rated',
							'recent-product',
							'product-category',
							'featured_products',
							'on_sale',
							'on_new',
							'product_attribute'
						)
					),
					'label_block' => true
				]
			);
			$repeater->add_control(
				'ids',
				[
					'label'       => esc_html__( 'Product IDs', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::TEXT,
					'placeholder' => esc_html__( 'Enter IDs', 'draly-dropshipping-starter' ),
					'description' => esc_html__( 'Ex: 1,2,3,...', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'target' => 'products'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'list',
				[
					'label'       => __( 'Tab List', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::REPEATER,
					'fields'      => $repeater->get_controls(),
					'title_field' => '{{{ title }}}',
				]
			);
			$this->end_controls_section();
			//Layout Section
			$this->start_controls_section(
				'layout_section',
				[
					'label' => esc_html__( 'Layout', 'draly-dropshipping-starter' ),
				]
			);
			$this->add_control(
				'layout',
				[
					'label'       => esc_html__( 'Layout', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'carousel' => esc_html__( 'Carousel', 'draly-dropshipping-starter' ),
						'grid'     => esc_html__( 'Grid', 'draly-dropshipping-starter' ),
					],
					'default'     => 'carousel',
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_number_row',
				[
					'label'       => esc_html__( 'The Number Of Rows', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'1' => esc_html__( '1 Row', 'draly-dropshipping-starter' ),
						'2' => esc_html__( '2 Rows', 'draly-dropshipping-starter' ),
						'3' => esc_html__( '3 Rows', 'draly-dropshipping-starter' ),
						'4' => esc_html__( '4 Rows', 'draly-dropshipping-starter' ),
						'5' => esc_html__( '5 Rows', 'draly-dropshipping-starter' ),
						'6' => esc_html__( '6 Rows', 'draly-dropshipping-starter' ),
					],
					'default'     => '1',
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_rows_space',
				[
					'label'       => esc_html__( 'Rows Space', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'rows-space-0'   => esc_html__( 'Default', 'draly-dropshipping-starter' ),
						'rows-space-10'  => esc_html__( '10px', 'draly-dropshipping-starter' ),
						'rows-space-20'  => esc_html__( '20px', 'draly-dropshipping-starter' ),
						'rows-space-30'  => esc_html__( '30px', 'draly-dropshipping-starter' ),
						'rows-space-40'  => esc_html__( '40px', 'draly-dropshipping-starter' ),
						'rows-space-50'  => esc_html__( '50px', 'draly-dropshipping-starter' ),
						'rows-space-60'  => esc_html__( '60px', 'draly-dropshipping-starter' ),
						'rows-space-70'  => esc_html__( '70px', 'draly-dropshipping-starter' ),
						'rows-space-80'  => esc_html__( '80px', 'draly-dropshipping-starter' ),
						'rows-space-90'  => esc_html__( '90px', 'draly-dropshipping-starter' ),
						'rows-space-100' => esc_html__( '100px', 'draly-dropshipping-starter' ),
					],
					'default'     => 'rows-space-0',
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_vertical',
				[
					'label'       => esc_html__( 'Vertical Slide Mode', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'true'  => esc_html__( 'Yes', 'draly-dropshipping-starter' ),
						'false' => esc_html__( 'No', 'draly-dropshipping-starter' ),
					],
					'default'     => 'false',
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_verticalswiping',
				[
					'label'       => esc_html__( 'Vertical Swipe Mode', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'true'  => esc_html__( 'Yes', 'draly-dropshipping-starter' ),
						'false' => esc_html__( 'No', 'draly-dropshipping-starter' ),
					],
					'default'     => 'false',
					'condition'   => array(
						'layout'       => 'carousel',
						'owl_vertical' => 'true'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_autoplay',
				[
					'label'       => esc_html__( 'AutoPlay', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'true'  => esc_html__( 'Yes', 'draly-dropshipping-starter' ),
						'false' => esc_html__( 'No', 'draly-dropshipping-starter' ),
					],
					'default'     => 'false',
					'description' => esc_html__( 'Enables Autoplay', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_autoplayspeed',
				[
					'label'       => esc_html__( 'Autoplay Speed', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1000,
					'default'     => 3000,
					'description' => esc_html__( 'Autoplay Speed in milliseconds', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout'       => 'carousel',
						'owl_autoplay' => 'true'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_navigation',
				[
					'label'       => esc_html__( 'Navigation', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'true'  => esc_html__( 'Yes', 'draly-dropshipping-starter' ),
						'false' => esc_html__( 'No', 'draly-dropshipping-starter' ),
					],
					'default'     => 'true',
					'description' => esc_html__( 'Prev/Next Arrows', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_dots',
				[
					'label'       => esc_html__( 'Dots', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'true'  => esc_html__( 'Yes', 'draly-dropshipping-starter' ),
						'false' => esc_html__( 'No', 'draly-dropshipping-starter' ),
					],
					'default'     => 'false',
					'description' => esc_html__( 'Show dot indicators', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_loop',
				[
					'label'       => esc_html__( 'Loop', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'true'  => esc_html__( 'Yes', 'draly-dropshipping-starter' ),
						'false' => esc_html__( 'No', 'draly-dropshipping-starter' ),
					],
					'default'     => 'false',
					'description' => esc_html__( 'Infinite loop sliding', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_slidespeed',
				[
					'label'       => esc_html__( 'Slide Speed', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 300,
					'default'     => 300,
					'description' => esc_html__( 'Slide Speed in milliseconds', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_ls_items',
				[
					'label'       => esc_html__( 'Items per row on Wide Screens', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1,
					'step'        => 1,
					'default'     => 4,
					'description' => esc_html__( 'Items per row on screen resolution of device >= 1400px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_slide_margin',
				[
					'label'       => esc_html__( 'Margin on Wide Screens', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 0,
					'default'     => 30,
					'description' => esc_html__( 'Distance( or space) between 2 items on screen resolution of device >= 1400px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout'       => 'carousel',
						'owl_vertical' => 'false'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_lg_items',
				[
					'label'       => esc_html__( 'Items per row on Desktop', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1,
					'step'        => 1,
					'default'     => 4,
					'description' => esc_html__( 'Items per row on screen resolution of device >= 1200px and < 1400px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_lg_slide_margin',
				[
					'label'       => esc_html__( 'Margin on Desktop', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 0,
					'default'     => 30,
					'description' => esc_html__( 'Distance( or space) between 2 items on screen resolution of device >= 1200px and < 1400px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout'       => 'carousel',
						'owl_vertical' => 'false'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_md_items',
				[
					'label'       => esc_html__( 'Items per row on Landscape Tablet', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1,
					'step'        => 1,
					'default'     => 3,
					'description' => esc_html__( 'Items per row on screen resolution of device >=992px and < 1200px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_md_slide_margin',
				[
					'label'       => esc_html__( 'Margin on Landscape Tablet', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 0,
					'default'     => 20,
					'description' => esc_html__( 'Distance( or space) between 2 items on screen resolution of device >=992px and < 1200px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout'       => 'carousel',
						'owl_vertical' => 'false'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_sm_items',
				[
					'label'       => esc_html__( 'Items per row on Tablet', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1,
					'step'        => 1,
					'default'     => 2,
					'description' => esc_html__( 'Items per row on screen resolution of device >=768px and < 992px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_sm_slide_margin',
				[
					'label'       => esc_html__( 'Margin on Tablet', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 0,
					'default'     => 20,
					'description' => esc_html__( 'Distance( or space) between 2 items on screen resolution of device >=768px and < 992px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout'       => 'carousel',
						'owl_vertical' => 'false'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_xs_items',
				[
					'label'       => esc_html__( 'Items per row on Mobile Landscape', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1,
					'step'        => 1,
					'default'     => 2,
					'description' => esc_html__( 'Items per row on screen resolution of device >=576px and < 768px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_xs_slide_margin',
				[
					'label'       => esc_html__( 'Margin on Mobile Landscape', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 0,
					'default'     => 20,
					'description' => esc_html__( 'Distance( or space) between 2 items on screen resolution of device >=576px and < 768px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout'       => 'carousel',
						'owl_vertical' => 'false'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_ts_items',
				[
					'label'       => esc_html__( 'Items per row on Mobile', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 1,
					'step'        => 1,
					'default'     => 1,
					'description' => esc_html__( 'Items per row on screen resolution of device < 576px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'carousel'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'owl_ts_slide_margin',
				[
					'label'       => esc_html__( 'Margin on Mobile', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::NUMBER,
					'min'         => 0,
					'default'     => 10,
					'description' => esc_html__( 'Distance( or space) between 2 items on screen resolution of device < 576px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout'       => 'carousel',
						'owl_vertical' => 'false'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'boostrap_rows_space',
				[
					'label'       => esc_html__( 'Rows space', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'rows-space-0'   => esc_html__( 'Default', 'draly-dropshipping-starter' ),
						'rows-space-10'  => esc_html__( '10px', 'draly-dropshipping-starter' ),
						'rows-space-20'  => esc_html__( '20px', 'draly-dropshipping-starter' ),
						'rows-space-30'  => esc_html__( '30px', 'draly-dropshipping-starter' ),
						'rows-space-40'  => esc_html__( '40px', 'draly-dropshipping-starter' ),
						'rows-space-50'  => esc_html__( '50px', 'draly-dropshipping-starter' ),
						'rows-space-60'  => esc_html__( '60px', 'draly-dropshipping-starter' ),
						'rows-space-70'  => esc_html__( '70px', 'draly-dropshipping-starter' ),
						'rows-space-80'  => esc_html__( '80px', 'draly-dropshipping-starter' ),
						'rows-space-90'  => esc_html__( '90px', 'draly-dropshipping-starter' ),
						'rows-space-100' => esc_html__( '100px', 'draly-dropshipping-starter' ),
					],
					'default'     => 'rows-space-0',
					'condition'   => array(
						'layout' => 'grid'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'boostrap_items',
				[
					'label'       => esc_html__( 'Items per row on Extra small devices (e.g., phones) - default for anything smaller', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'12' => esc_html__( '1 item', 'draly-dropshipping-starter' ),
						'6'  => esc_html__( '2 items', 'draly-dropshipping-starter' ),
						'4'  => esc_html__( '3 items', 'draly-dropshipping-starter' ),
						'3'  => esc_html__( '4 items', 'draly-dropshipping-starter' ),
						'15' => esc_html__( '5 items', 'draly-dropshipping-starter' ),
						'2'  => esc_html__( '6 items', 'draly-dropshipping-starter' ),
					],
					'default'     => '12',
					'description' => esc_html__( 'Screen resolution of device >= 0px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'grid'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'boostrap_sm_items',
				[
					'label'       => esc_html__( 'Items per row on Small devices (e.g., phones in landscape mode)', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'12' => esc_html__( '1 item', 'draly-dropshipping-starter' ),
						'6'  => esc_html__( '2 items', 'draly-dropshipping-starter' ),
						'4'  => esc_html__( '3 items', 'draly-dropshipping-starter' ),
						'3'  => esc_html__( '4 items', 'draly-dropshipping-starter' ),
						'15' => esc_html__( '5 items', 'draly-dropshipping-starter' ),
						'2'  => esc_html__( '6 items', 'draly-dropshipping-starter' ),
					],
					'default'     => '6',
					'description' => esc_html__( 'Screen resolution of device >= 576px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'grid'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'boostrap_md_items',
				[
					'label'       => esc_html__( 'Items per row on Medium devices (e.g., tablets)', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'12' => esc_html__( '1 item', 'draly-dropshipping-starter' ),
						'6'  => esc_html__( '2 items', 'draly-dropshipping-starter' ),
						'4'  => esc_html__( '3 items', 'draly-dropshipping-starter' ),
						'3'  => esc_html__( '4 items', 'draly-dropshipping-starter' ),
						'15' => esc_html__( '5 items', 'draly-dropshipping-starter' ),
						'2'  => esc_html__( '6 items', 'draly-dropshipping-starter' ),
					],
					'default'     => '6',
					'description' => esc_html__( 'Screen resolution of device >= 768px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'grid'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'boostrap_lg_items',
				[
					'label'       => esc_html__( 'Items per row on Large devices (e.g., small laptops)', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'12' => esc_html__( '1 item', 'draly-dropshipping-starter' ),
						'6'  => esc_html__( '2 items', 'draly-dropshipping-starter' ),
						'4'  => esc_html__( '3 items', 'draly-dropshipping-starter' ),
						'3'  => esc_html__( '4 items', 'draly-dropshipping-starter' ),
						'15' => esc_html__( '5 items', 'draly-dropshipping-starter' ),
						'2'  => esc_html__( '6 items', 'draly-dropshipping-starter' ),
					],
					'default'     => '4',
					'description' => esc_html__( 'Screen resolution of device >= 992px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'grid'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'boostrap_xl_items',
				[
					'label'       => esc_html__( 'Items per row on Extra large devices (e.g., desktops)', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'12' => esc_html__( '1 item', 'draly-dropshipping-starter' ),
						'6'  => esc_html__( '2 items', 'draly-dropshipping-starter' ),
						'4'  => esc_html__( '3 items', 'draly-dropshipping-starter' ),
						'3'  => esc_html__( '4 items', 'draly-dropshipping-starter' ),
						'15' => esc_html__( '5 items', 'draly-dropshipping-starter' ),
						'2'  => esc_html__( '6 items', 'draly-dropshipping-starter' ),
					],
					'default'     => '4',
					'description' => esc_html__( 'Screen resolution of device >= 1200px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'grid'
					),
					'label_block' => true
				]
			);
			$this->add_control(
				'boostrap_xxl_items',
				[
					'label'       => esc_html__( 'Items per row on Extra extra large devices (e.g., large desktops or high-res displays)', 'draly-dropshipping-starter' ),
					'type'        => \Elementor\Controls_Manager::SELECT,
					'options'     => [
						'12' => esc_html__( '1 item', 'draly-dropshipping-starter' ),
						'6'  => esc_html__( '2 items', 'draly-dropshipping-starter' ),
						'4'  => esc_html__( '3 items', 'draly-dropshipping-starter' ),
						'3'  => esc_html__( '4 items', 'draly-dropshipping-starter' ),
						'15' => esc_html__( '5 items', 'draly-dropshipping-starter' ),
						'2'  => esc_html__( '6 items', 'draly-dropshipping-starter' ),
					],
					'default'     => '4',
					'description' => esc_html__( 'Screen resolution of device >= 1400px', 'draly-dropshipping-starter' ),
					'condition'   => array(
						'layout' => 'grid'
					),
					'label_block' => true
				]
			);
			$this->end_controls_section();

		}

		/**
		 * Render the widget output on the frontend.
		 *
		 * Written in PHP and used to generate the final HTML.
		 *
		 * @since 1.0.0
		 *
		 * @access protected
		 */
		protected function render() {
			$atts      = $this->get_settings_for_display();
			$css_class = array( 'draly-tabs' );
			if ( $atts['product_image_size'] ) {
				if ( $atts['product_image_size'] == 'custom' ) {
					$thumb_width  = $atts['product_custom_thumb_width'];
					$thumb_height = $atts['product_custom_thumb_height'];
				} else {
					$product_image_size = explode( "x", $atts['product_image_size'] );
					$thumb_width        = $product_image_size[0];
					$thumb_height       = $product_image_size[1];
				}
				if ( $thumb_width > 0 ) {
					add_filter( 'draly_shop_product_thumb_width', function () use ( $thumb_width ) {
						return $thumb_width;
					} );
				}
				if ( $thumb_height > 0 ) {
					add_filter( 'draly_shop_product_thumb_height', function () use ( $thumb_height ) {
						return $thumb_height;
					} );
				}
			}
			$item_class   = array( 'product-item' );
			$item_class[] = $atts['style'];
			$list_class   = array();
			$owl_settings = 'data-slick data-responsive';
			if ( $atts['layout'] == 'grid' ) {
				$list_class[] = 'product-list-grid row';
				$item_class[] = $atts['boostrap_rows_space'];
				$item_class[] = 'col-' . $atts['boostrap_items'];
				$item_class[] = 'col-sm-' . $atts['boostrap_sm_items'];
				$item_class[] = 'col-md-' . $atts['boostrap_md_items'];
				$item_class[] = 'col-lg-' . $atts['boostrap_lg_items'];
				$item_class[] = 'col-xl-' . $atts['boostrap_xl_items'];
				$item_class[] = 'col-xxl-' . $atts['boostrap_xxl_items'];
			}
			if ( $atts['layout'] == 'carousel' ) {
				$list_class[]     = 'product-list-owl owl-slick';
				$item_class[]     = $atts['owl_rows_space'];
				$atts['owl_loop'] = 'false';
				$owl_settings     = Draly_Dropshipping_Starter_Helper::carousel_data_attributes( 'owl_', $atts );
			}
			$rand = uniqid();

			$data_general                                = array();
			$data_general['style']                       = $atts['style'];
			$data_general['product_image_size']          = $atts['product_image_size'];
			$data_general['product_custom_thumb_width']  = $atts['product_custom_thumb_width'];
			$data_general['product_custom_thumb_height'] = $atts['product_custom_thumb_height'];
			$data_general['layout']                      = $atts['layout'];
			$data_general['boostrap_rows_space']         = $atts['boostrap_rows_space'];
			$data_general['boostrap_items']              = $atts['boostrap_items'];
			$data_general['boostrap_sm_items']           = $atts['boostrap_sm_items'];
			$data_general['boostrap_md_items']           = $atts['boostrap_md_items'];
			$data_general['boostrap_lg_items']           = $atts['boostrap_lg_items'];
			$data_general['boostrap_xl_items']           = $atts['boostrap_xl_items'];
			$data_general['boostrap_xxl_items']          = $atts['boostrap_xxl_items'];
			$data_general['boostrap_xxl_items']          = $atts['boostrap_xxl_items'];
			?>
            <div class="<?php echo esc_attr( implode( ' ', $css_class ) ); ?>">
				<?php if ( $atts['list'] ) : ?>
                    <div class="tab-head">
						<?php if ( $atts['maintitle'] ): ?>
                            <h3 class="main-title"><?php echo esc_html( $atts['maintitle'] ); ?></h3>
						<?php endif; ?>
                        <div class="tab-right">
                            <ul class="tab-link"
                                data-general='<?php echo( json_encode( $data_general ) ); ?>'
                                data-ajax="<?php echo esc_attr( $atts['enable_ajax'] ); ?>"
                                data-animate="<?php echo esc_attr( $atts['css_animation'] ); ?>" <?php echo esc_attr( $owl_settings ); ?>>
								<?php
								foreach ( $atts['list'] as $key => $value ) :
									$class_active = '';
									$class_loaded = '';
									if ( $key == 0 ) {
										$class_active = 'active';
										$class_loaded = 'loaded';
									}
									$data_section = $value;
									?>
                                    <li class="<?php echo esc_attr( $class_active ); ?>">
                                        <a class="<?php echo esc_attr( $class_loaded ); ?>"
                                           data-section='<?php echo( json_encode( $data_section ) ); ?>'
                                           data-id="<?php echo esc_attr( get_the_ID() ); ?>"
                                           href="#<?php echo esc_attr( $key ); ?>-<?php echo esc_attr( $rand ); ?>">
											<?php if ( isset( $value['title'] ) ): ?>
                                                <span><?php echo esc_html( $value['title'] ); ?></span>
											<?php endif; ?>
                                        </a>
                                    </li>
								<?php endforeach; ?>
                            </ul>
							<?php
							if ( $atts['link_text'] && $atts['link_url']['url'] ):
								$target = $atts['link_url']['is_external'] ? '_blank' : '_self';
								?>
                                <a class="linkmore" href="<?php echo esc_url( $atts['link_url']['url'] ); ?>"
                                   target="<?php echo esc_attr( $target ); ?>"><?php echo esc_html( $atts['link_text'] ); ?>
                                    <svg width="7" height="12" viewBox="0 0 7 12" fill="none"
                                         xmlns="http://www.w3.org/2000/svg">
                                        <path d="M1.05594 11L6 5.97155L1 1" stroke="currentColor" stroke-linecap="round"
                                              stroke-linejoin="round"/>
                                    </svg>
                                </a>
							<?php endif; ?>
                        </div>
                    </div>
                    <div class="tab-container">
						<?php foreach ( $atts['list'] as $key => $value ):
							$products = Draly_Dropshipping_Starter_Pluggable_WooCommerce::draly_dropshipping_starter_get_products( $value );
							$id_loop = array();
							?>
                            <div class="tab-panel <?php if ( $key == 0 ): ?>active<?php endif; ?>"
                                 id="<?php echo esc_attr( $key ); ?>-<?php echo esc_attr( $rand ); ?>">
								<?php if ( ! empty( $atts['enable_ajax'] ) ) {
									if ( $key == 0 ) { ?>
										<?php if ( $products->have_posts() ): ?>
                                            <div class="<?php echo esc_attr( implode( ' ', $list_class ) ); ?>" <?php echo esc_attr( $owl_settings ); ?>>
												<?php while ( $products->have_posts() ) : $products->the_post(); ?>
													<?php $id_loop[] = get_the_ID(); ?>
                                                    <div <?php post_class( array_merge( $item_class, array( $value['target'] ) ) ); ?>>
														<?php wc_get_template_part( 'product-styles/content-product', $atts['style'] ); ?>
                                                    </div>
												<?php endwhile; ?>
                                            </div>
										<?php else: ?>
                                            <p>
                                                <strong><?php esc_html_e( 'No Product', 'draly-dropshipping-starter' ); ?></strong>
                                            </p>
										<?php endif; ?>
									<?php }
								} else { ?>
									<?php if ( $products->have_posts() ): ?>
                                        <div class="<?php echo esc_attr( implode( ' ', $list_class ) ); ?>" <?php echo esc_attr( $owl_settings ); ?>>
											<?php while ( $products->have_posts() ) : $products->the_post(); ?>
												<?php $id_loop[] = get_the_ID(); ?>
                                                <div <?php post_class( array_merge( $item_class, array( $value['target'] ) ) ); ?>>
													<?php wc_get_template_part( 'product-styles/content-product', $atts['style'] ); ?>
                                                </div>
											<?php endwhile; ?>
                                        </div>
									<?php else: ?>
                                        <p>
                                            <strong><?php esc_html_e( 'No Product', 'draly-dropshipping-starter' ); ?></strong>
                                        </p>
									<?php endif; ?>
								<?php } ?>
                            </div>
						<?php endforeach; ?>
                    </div>
				<?php endif; ?>
            </div>
			<?php wp_reset_postdata();
		}
	}
}