<?php

class AIOC_TeamCarouselItem extends ET_Builder_Module {

	public $slug       = 'aioc_team_carousel_item';
	public $type       = 'child';
	public $vb_support = 'on';

	protected $module_credits = array(
		'module_uri' => 'https://diviextended.com/product/all-in-one-carousel-for-divi',
		'author'     => 'Elicus',
		'author_uri' => 'http://elicus.com',
	);
	
	public function init() {
		$this->name 						= esc_html__( 'Team Member', 'all-in-one-carousel-for-divi' );
		$this->advanced_setting_title_text  = esc_html__( 'Team Member', 'all-in-one-carousel-for-divi' );
        $this->child_title_var              = 'name';
		$this->main_css_element 			= '.aioc_team_carousel %%order_class%%';
		if ( is_archive() ) {
            $this->main_css_element = '%%order_class%%';
        }
		add_filter( 'et_builder_processed_range_value', array( $this, 'aioc_builder_processed_range_value' ), 10, 3 );
	}

	public function get_settings_modal_toggles() {
		return array(
			'general'  => array(
				'toggles' => array(
					'main_content' => array(
						'title' => esc_html__( 'Content', 'all-in-one-carousel-for-divi' ),
					),
					'image' => array(
						'title' => esc_html__( 'Image', 'all-in-one-carousel-for-divi' ),
					),
					'social_icons' => array(
						'title' => esc_html__( 'Social Icons', 'all-in-one-carousel-for-divi' ),
					),
				),
			),
			'advanced' => array(
				'toggles' => array(
					'text' => array(
						'title' => esc_html__( 'Text', 'all-in-one-carousel-for-divi' ),
					),
					'text_settings' => array(
						'title' => esc_html__( 'Content', 'all-in-one-carousel-for-divi' ),
						'sub_toggles'   => array(
                            'name' => array(
                                'name' => 'Name',
                            ),
                            'designation' => array(
                                'name' => 'Designation',
                            ),
                            'content' => array(
                                'name' => 'Content',
                            ),
                        ),
                        'tabbed_subtoggles' => true,
					),
					'image' => array(
						'title' => esc_html__( 'Image', 'all-in-one-carousel-for-divi' ),
					),
					'social_icon_settings'       => array(
						'title'    => esc_html__( 'Social Icons', 'all-in-one-carousel-for-divi' ),
					),
					'content_bg_settings' => array(
						'title' => esc_html__( 'Content Background', 'all-in-one-carousel-for-divi' ),
					),
				),
			),
		);
	}

	public function get_advanced_fields_config() {
		return array(
			'fonts' => array(
				'name' => array(
					'label'          => esc_html__( 'Name', 'all-in-one-carousel-for-divi' ),
					'font_size'      => array(
						'default' => '16px',
						'range_settings'   => array(
							'min'  => '1',
							'max'  => '100',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'line_height'    => array(
						'default_on_front' => '1.2em',
						'range_settings'   => array(
							'min'  => '0.1',
							'max'  => '10',
							'step' => '0.1',
						),
					),
					'letter_spacing' => array(
						'default_on_front' => '',
						'range_settings'   => array(
							'min'  => '0',
							'max'  => '10',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'header_level'  => array(
						'default'   => 'h4',
					),
					'css'            => array(
						'main' => "{$this->main_css_element} .aioc_slide_name",
						'important' => 'all',
					),
					'hide_text_align' => true,
					'tab_slug' => 'advanced',
					'toggle_slug' => 'text_settings',
					'sub_toggle' => 'name',
				),
				'designation' => array(
					'label'          => esc_html__( 'Designation', 'all-in-one-carousel-for-divi' ),
					'font_size'      => array(
						'default' => '16px',
						'range_settings'   => array(
							'min'  => '1',
							'max'  => '100',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'line_height'    => array(
						'default_on_front' => '1.2em',
						'range_settings'   => array(
							'min'  => '0.1',
							'max'  => '10',
							'step' => '0.1',
						),
					),
					'letter_spacing' => array(
						'default_on_front' => '',
						'range_settings'   => array(
							'min'  => '0',
							'max'  => '10',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'header_level'  => array(
						'default'   => 'h5',
					),
					'css'            => array(
						'main' => "{$this->main_css_element} .aioc_slide_designation",
						'important' => 'all',
					),
					'tab_slug' => 'advanced',
					'toggle_slug' => 'text_settings',
					'sub_toggle' => 'designation',
				),
				'content' => array(
					'label'          => esc_html__( 'Content', 'all-in-one-carousel-for-divi' ),
					'font_size'      => array(
						'default' => '14px',
						'range_settings'   => array(
							'min'  => '1',
							'max'  => '100',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'line_height'    => array(
						'default' => '1.5em',
						'range_settings'   => array(
							'min'  => '0.1',
							'max'  => '10',
							'step' => '0.1',
						),
					),
					'letter_spacing' => array(
						'default' => '',
						'range_settings'   => array(
							'min'  => '0',
							'max'  => '10',
							'step' => '1',
						),
						'validate_unit'    => true,
					),
					'css'            => array(
						'main' => "{$this->main_css_element} .aioc_slide_content",
						'important' => 'all',
					),
					'hide_text_align' => true,
					'tab_slug' => 'advanced',
					'toggle_slug' => 'text_settings',
					'sub_toggle' => 'content',
				),
			),
			'margin_padding' => array(
				'css' => array(
					'main'      => '%%order_class%%',
					'important' => 'all',
				),
			),
			'slide_margin_padding' => array(
                'image' => array(
                    'margin_padding' => array(
                        'css' => array(
                        	'margin' 	=> '%%order_class%% .aioc_slide_image_wrapper',
                            'padding'    => '%%order_class%% .aioc_slide_image_wrapper',
                            'important'  => 'all',
                        ),
                    ),
                ),
                'social_icon' => array(
                    'margin_padding' => array(
                        'css' => array(
                        	'margin' 	=> '%%order_class%% .aioc_team_member_social_icon',
                            'padding'    => '%%order_class%% .aioc_team_member_social_icon',
                            'important'  => 'all',
                        ),
                    ),
                ),
                'content' => array(
                    'margin_padding' => array(
                        'css' => array(
                        	'margin' 	=> '%%order_class%% .aioc_slide_content_wrapper',
                            'padding'    => '%%order_class%% .aioc_slide_inner_content_wrapper',
                            'important'  => 'all',
                        ),
                    ),
                ),
            ),
			'max_width'            => array(
				'extra' => array(
					'team_image' => array(
						'options'              => array(
							'width' => array(
								'label'          => esc_html__( 'Image Width', 'all-in-one-carousel-for-divi' ),
								'range_settings' => array(
									'min'  => 1,
									'max'  => 100,
									'step' => 1,
								),
								'hover'          => false,
								'default_unit'   => '%',
								'default_tablet' => '',
								'default_phone'  => '',
								'tab_slug'       => 'advanced',
								'toggle_slug'    => 'image',
							),
						),
						'use_max_width'        => false,
						'use_module_alignment' => false,
						'css'                  => array(
							'main' => "{$this->main_css_element} .aioc_slide_image_wrapper img",
							'important' => 'all',
						),
					),
				),
				'default' => array(
					'css' => array(
						'main'             => '%%order_class%%',
						'module_alignment' => '%%order_class%%',
					),
				),
			),
			'borders' => array(
				'team_image'  => array(
					'css'          => array(
						'main' => array(
							'border_radii'  => '.aioc_team_carousel %%order_class%% .aioc_slide_image',
							'border_styles' => '.aioc_team_carousel %%order_class%% .aioc_slide_image',
							'important'     => 'all',
						),
					),
					'label_prefix' => esc_html__( 'Image', 'all-in-one-carousel-for-divi' ),
					'tab_slug'     => 'advanced',
					'toggle_slug'  => 'image',
				),
				'default' => array(
					'css' => array(
						'main' => array(
							'border_styles' => '%%order_class%% .aioc_slide_wrapper',
							'border_radii'  => '%%order_class%% .aioc_slide_wrapper',
						),
						'important' => 'all',
					),
				),
			),
			'box_shadow' => array(
				'default' => array(
					'css' => array(
						'main' => '%%order_class%% .aioc_slide_wrapper',
					),
				),
			),
			'background' => array(
				'css' => array(
					'main' => '%%order_class%% .aioc_slide_wrapper',
				),
			),
			'text'    => false,
			'filters' => false,
			'text_shadow' => false,
		);
	}

	public function get_fields() {
		return array_merge(
			array(
				'name' => array(
					'label'           		=> esc_html__( 'Name', 'all-in-one-carousel-for-divi' ),
					'type'           		=> 'text',
					'option_category' 		=> 'basic_option',
					'tab_slug'        		=> 'general',
					'toggle_slug'     		=> 'main_content',
					'description'     		=> esc_html__( 'Here you can input the text to be used for the title.', 'all-in-one-carousel-for-divi' ),
				),
				'designation' => array(
					'label'           		=> esc_html__( 'Designation', 'all-in-one-carousel-for-divi' ),
					'type'           		=> 'text',
					'option_category' 		=> 'basic_option',
					'tab_slug'        		=> 'general',
					'toggle_slug'     		=> 'main_content',
					'description'     		=> esc_html__( 'Here you can input the text to be used for the designation.', 'all-in-one-carousel-for-divi' ),
				),
				'content' => array(
					'label'                 => esc_html__( 'Content', 'all-in-one-carousel-for-divi' ),
					'type'                  => 'tiny_mce',
					'option_category'       => 'basic_option',
					'toggle_slug'           => 'main_content',
					'description'           => esc_html__( 'Here you can input the text to be used for the content.', 'all-in-one-carousel-for-divi' ),
				),
				'content_length'       => array(
					'label'            => esc_html__( 'Content Length', 'all-in-one-carousel-for-divi' ),
					'type'             => 'text',
					'option_category'  => 'configuration',
					'default'		  => '250',
					'tab_slug'         => 'general',
					'toggle_slug'      => 'main_content',
					'description'      => esc_html__( 'Here you can define content length in characters, if 0 no content will be shown.', 'all-in-one-carousel-for-divi' ),
				),
				'image' => array(
					'label'                 => esc_html__( 'Image', 'all-in-one-carousel-for-divi' ),
					'type'                  => 'upload',
					'option_category'       => 'basic_option',
					'upload_button_text'    => esc_attr__( 'Upload an image', 'all-in-one-carousel-for-divi' ),
					'choose_text'           => esc_attr__( 'Choose an Image', 'all-in-one-carousel-for-divi' ),
					'update_text'           => esc_attr__( 'Set As Image', 'all-in-one-carousel-for-divi' ),
					'dynamic_content'  		=> 'image',
					'tab_slug'              => 'general',
					'toggle_slug'           => 'image',
					'description'           => esc_html__( 'Upload an image to display.', 'all-in-one-carousel-for-divi' ),
				),
				'image_alt' => array(
					'label'                 => esc_html__( 'Image Alt Text', 'all-in-one-carousel-for-divi' ),
					'type'                  => 'text',
					'option_category'       => 'basic_option',
					'tab_slug'              => 'general',
					'toggle_slug'           => 'image',
					'description'           => esc_html__( 'Here you can input the text to be used for the image as HTML ALT text.', 'all-in-one-carousel-for-divi' ),
				),
				'show_social_icons' => array(
					'label'            => esc_html__( 'Show Social Icons', 'all-in-one-carousel-for-divi' ),
					'type'             => 'yes_no_button',
					'option_category'  => 'configuration',
					'options'          => array(
						'on'  => esc_html__( 'Yes', 'all-in-one-carousel-for-divi' ),
						'off' => esc_html__( 'No', 'all-in-one-carousel-for-divi' ),
					),
					'default'          => 'on',
					'default_on_front' => 'on',
					'tab_slug'         => 'general',
					'toggle_slug'      => 'social_icons',
					'description'      => esc_html__( 'Choose whether or not the social icons should be visible.', 'all-in-one-carousel-for-divi' ),
				),
				'website_url' => array(
					'label'           	=> esc_html__( 'Website URL', 'all-in-one-carousel-for-divi' ),
					'type'            	=> 'text',
					'option_category' 	=> 'basic_option',
					'dynamic_content' 	=> 'url',
					'show_if'          => array(
						'show_social_icons' => 'on',
					),
					'tab_slug'          => 'general',
					'toggle_slug'     	=> 'social_icons',
					'description'     	=> esc_html__( 'Here you can input website URL.', 'all-in-one-carousel-for-divi' ),
				),
				'facebook_url' => array(
					'label'           	=> esc_html__( 'Facebook URL', 'all-in-one-carousel-for-divi' ),
					'type'            	=> 'text',
					'option_category' 	=> 'basic_option',
					'dynamic_content' 	=> 'url',
					'show_if'          => array(
						'show_social_icons' => 'on',
					),
					'tab_slug'          => 'general',
					'toggle_slug'     	=> 'social_icons',
					'description'     	=> esc_html__( 'Here you can input facebook URL.', 'all-in-one-carousel-for-divi' ),
				),
				'twitter_url' => array(
					'label'           	=> esc_html__( 'Twitter URL', 'all-in-one-carousel-for-divi' ),
					'type'            	=> 'text',
					'option_category' 	=> 'basic_option',
					'dynamic_content' 	=> 'url',
					'show_if'          => array(
						'show_social_icons' => 'on',
					),
					'tab_slug'          => 'general',
					'toggle_slug'     	=> 'social_icons',
					'description'     	=> esc_html__( 'Here you can input twitter URL.', 'all-in-one-carousel-for-divi' ),
				),
				'linkedin_url' => array(
					'label'           	=> esc_html__( 'LinkedIn URL', 'all-in-one-carousel-for-divi' ),
					'type'            	=> 'text',
					'option_category' 	=> 'basic_option',
					'dynamic_content' 	=> 'url',
					'show_if'          => array(
						'show_social_icons' => 'on',
					),
					'tab_slug'          => 'general',
					'toggle_slug'     	=> 'social_icons',
					'description'     	=> esc_html__( 'Here you can input linkedin URL.', 'all-in-one-carousel-for-divi' ),
				),
				'instagram_url' => array(
					'label'           	=> esc_html__( 'Instagram URL', 'all-in-one-carousel-for-divi' ),
					'type'            	=> 'text',
					'option_category' 	=> 'basic_option',
					'dynamic_content' 	=> 'url',
					'show_if'          => array(
						'show_social_icons' => 'on',
					),
					'tab_slug'          => 'general',
					'toggle_slug'     	=> 'social_icons',
					'description'     	=> esc_html__( 'Here you can input instagram URL.', 'all-in-one-carousel-for-divi' ),
				),
				'youtube_url' => array(
					'label'           	=> esc_html__( 'Youtube URL', 'all-in-one-carousel-for-divi' ),
					'type'            	=> 'text',
					'option_category' 	=> 'basic_option',
					'dynamic_content' 	=> 'url',
					'show_if'          => array(
						'show_social_icons' => 'on',
					),
					'tab_slug'          => 'general',
					'toggle_slug'     	=> 'social_icons',
					'description'     	=> esc_html__( 'Here you can input youtube URL.', 'all-in-one-carousel-for-divi' ),
				),
				'email' => array(
					'label'           	=> esc_html__( 'Email', 'all-in-one-carousel-for-divi' ),
					'type'            	=> 'text',
					'option_category' 	=> 'basic_option',
					'dynamic_content' 	=> 'url',
					'show_if'          => array(
						'show_social_icons' => 'on',
					),
					'tab_slug'          => 'general',
					'toggle_slug'     	=> 'social_icons',
					'description'     	=> esc_html__( 'Here you can input email.', 'all-in-one-carousel-for-divi' ),
				),
				'phone_number' => array(
					'label'           	=> esc_html__( 'Phone', 'all-in-one-carousel-for-divi' ),
					'type'            	=> 'text',
					'option_category' 	=> 'basic_option',
					'dynamic_content' 	=> 'url',
					'show_if'          => array(
						'show_social_icons' => 'on',
					),
					'tab_slug'          => 'general',
					'toggle_slug'     	=> 'social_icons',
					'description'     	=> esc_html__( 'Here you can input phone number.', 'all-in-one-carousel-for-divi' ),
				),
				'link' => array(
					'label'           	=> esc_html__( 'Team Link URL', 'all-in-one-carousel-for-divi' ),
					'type'            	=> 'text',
					'option_category' 	=> 'basic_option',
					'tab_slug'          => 'general',
					'toggle_slug'     	=> 'link_options',
					'description'     	=> esc_html__( 'Here you can input team member external URL.', 'all-in-one-carousel-for-divi' ),
				),
				'link_target' => array(
	                'label'             => esc_html__( 'Team Link Target', 'all-in-one-carousel-for-divi' ),
	                'type'              => 'select',
	                'option_category'   => 'configuration',
	                'options'           => array(
	                    'off' => esc_html__( 'In The Same Window', 'all-in-one-carousel-for-divi' ),
	                    'on'  => esc_html__( 'In The New Tab', 'all-in-one-carousel-for-divi' ),
	                ),
	                'default'           => 'off',
	                'tab_slug'          => 'general',
	                'toggle_slug'       => 'link_options',
	                'description'       => esc_html__( 'Here you can choose whether or not the member opens the link in a new window.', 'all-in-one-carousel-for-divi' ),
	            ),
				'image_custom_padding' => array(
	                'label'                 => esc_html__( 'Image Padding', 'all-in-one-carousel-for-divi' ),
	                'type'                  => 'custom_padding',
	                'option_category'       => 'layout',
	                'mobile_options'        => true,
	                'hover'                 => false,
	                'default'          		=> '||||true|true',
					'default_on_front' 		=> '||||true|true',
	                'tab_slug'              => 'advanced',
	                'toggle_slug'           => 'image',
	                'description'           => esc_html__( 'Padding adds extra space to the inside of the element, increasing the distance between the edge of the element and its inner contents.', 'all-in-one-carousel-for-divi' ),
	            ),
				'content_custom_padding' => array(
	                'label'                 => esc_html__( 'Content Padding', 'all-in-one-carousel-for-divi' ),
	                'type'                  => 'custom_padding',
	                'option_category'       => 'layout',
	                'mobile_options'        => true,
	                'hover'                 => false,
	                'default'          		=> '20px|20px|20px|20px|true|true',
					'default_on_front' 		=> '20px|20px|20px|20px|true|true',
	                'tab_slug'              => 'advanced',
	                'toggle_slug'           => 'margin_padding',
	                'description'           => esc_html__( 'Padding adds extra space to the inside of the element, increasing the distance between the edge of the element and its inner contents.', 'all-in-one-carousel-for-divi' ),
	            ),
				'content_custom_margin' => array(
	                'label'                 => esc_html__( 'Content Margin', 'all-in-one-carousel-for-divi' ),
	                'type'                  => 'custom_padding',
	                'option_category'       => 'layout',
	                'mobile_options'        => true,
	                'hover'                 => false,
	                'default'          		=> '||||true|true',
					'default_on_front' 		=> '||||true|true',
	                'tab_slug'              => 'advanced',
	                'toggle_slug'           => 'margin_padding',
	                'description'           => esc_html__( 'Margin adds extra space to the outside of the element, increasing the distance between the edge of the element and its inner contents.', 'all-in-one-carousel-for-divi' ),
	            ),
	            'content_bg_color' => array(
	                'label'                 => esc_html__( 'Content Background', 'all-in-one-carousel-for-divi' ),
	                'type'                  => 'background-field',
	                'base_name'             => 'content_bg',
	                'context'               => 'content_bg_color',
	                'option_category'       => 'button',
	                'custom_color'          => true,
	                'background_fields'     => $this->generate_background_options( 'content_bg', 'button', 'advanced', 'content_bg_settings', 'content_bg_color' ),
	                'hover'                 => 'tabs',
	                'tab_slug'              => 'advanced',
	                'toggle_slug'           => 'content_bg_settings',
	                'description'           => esc_html__( 'Customize the background style of the content box by adjusting the background color, gradient, and image.', 'all-in-one-carousel-for-divi' ),
	            ),
	        ),
			$this->generate_background_options( 'content_bg', 'skip', 'advanced', 'content_bg_settings', 'content_bg_color' )
		);

	}

	public function render( $attrs, $content, $render_slug ) {
		global $slide_effect, $aioc_tc_disable_lazyload;

		$multi_view            		 = et_pb_multi_view_options( $this );
		$show_social_icons			 = $this->props['show_social_icons'];
		$website_url				 = $this->props['website_url'];
		$facebook_url   			 = $this->props['facebook_url'];
		$twitter_url    			 = $this->props['twitter_url'];
		$linkedin_url   			 = $this->props['linkedin_url'];
		$instagram_url  			 = $this->props['instagram_url'];
		$youtube_url    			 = $this->props['youtube_url'];
		$email          			 = $this->props['email'];
		$phone_number   			 = $this->props['phone_number'];
		$link   					 = $this->props['link'];
		$link_target   				 = $this->props['link_target'];
		$image_alt 					 = sprintf( esc_html__( '%s', 'all-in-one-carousel-for-divi' ), $this->props['image_alt'] );
		$name_level				     = $this->props['name_level'];
		$processed_name_level 	 	 = et_pb_process_header_level( $name_level, 'h4' );
		$processed_name_level 		 = esc_html( $processed_name_level );
		$designation_level			 = $this->props['designation_level'];
		$processed_designation_level = et_pb_process_header_level( $designation_level, 'h5' );
		$processed_designation_level = esc_html( $processed_designation_level );
		$content_length				 = '' !== intval( $this->props['content_length'] ) ? intval( $this->props['content_length'] ) : 250;
		$slide_border_radius  		 = '' !== $this->props['border_radii'] ? explode( '|', $this->props['border_radii'] ) : '';

		$website_html = $twitter_html = $linkedin_html = $instagram_html = $youtube_html = $email_html = $phone_number_html = $social_icons = '';

		$image_classes = 'aioc_slide_image';
		if ( 'on' === $aioc_tc_disable_lazyload ) {
			$image_classes .= ' no-lazyload skip-lazy';
		}

		$image = $multi_view->render_element( array(
			'tag'      => 'img',
			'attrs'    => array(
				'src'          => '{{image}}',
				'data-mfp-src' => '{{image}}',
				'class'        => $image_classes,
				'alt'          => $image_alt,
			),
			'required' => 'image',
		) );

		$name = $multi_view->render_element( array(
			'tag'      => $processed_name_level,
			'content'  => '{{name}}',
			'attrs'    => array(
				'class' => 'aioc_slide_name',
			),
			'required' => 'name',
		) );
		$designation = $multi_view->render_element( array(
			'tag'      => $processed_designation_level,
			'content'  => '{{designation}}',
			'attrs'    => array(
				'class' => 'aioc_slide_designation',
			),
			'required' => 'designation',
		) );
		
		if ( 'on' === $show_social_icons ) {
			$website_html = '';
			if ( '' !== $website_url ) {
				$website_html = sprintf(
					'<a href="%1$s" target="_blank"><span class="aioc_team_member_social_icon et-pb-icon">&#xe0e3;</span></a>',
					$website_url
				);
			}
			$facebook_html = '';
			if ( '' !== $facebook_url ) {
				$facebook_html = sprintf(
					'<a href="%1$s" target="_blank"><span class="aioc_team_member_social_icon et-pb-icon">&#xe093;</span></a>',
					$facebook_url
				);
			}
			$twitter_html = '';
			if ( '' !== $twitter_url ) {
				$twitter_html = sprintf(
					'<a href="%1$s" target="_blank"><span class="aioc_team_member_social_icon et-pb-icon">&#xe094;</span></a>',
					$twitter_url
				);
			}
			$linkedin_html = '';
			if ( '' !== $linkedin_url ) {
				$linkedin_html = sprintf(
					'<a href="%1$s" target="_blank"><span class="aioc_team_member_social_icon et-pb-icon">&#xe09d;</span></a>',
					$linkedin_url
				);
			}
			$instagram_html = '';
			if ( '' !== $instagram_url ) {
				$instagram_html = sprintf(
					'<a href="%1$s" target="_blank"><span class="aioc_team_member_social_icon et-pb-icon">&#xe09a;</span></a>',
					$instagram_url
				);
			}
			$youtube_html = '';
			if ( '' !== $youtube_url ) {
				$youtube_html = sprintf(
					'<a href="%1$s" target="_blank"><span class="aioc_team_member_social_icon et-pb-icon">&#xe0a3;</span></a>',
					$youtube_url
				);
			}
			$email_html = '';
			if ( '' !== $email ) {
				$email_html = sprintf(
					'<a href="mailto:%1$s" target="_blank"><span class="aioc_team_member_social_icon et-pb-icon">&#xe076;</span></a>',
					$email
				);
			}
			$phone_number_html = '';
			if ( '' !== $phone_number ) {
				$phone_number_html = sprintf(
					'<a href="tel:%1$s" target="_blank"><span class="aioc_team_member_social_icon et-pb-icon">&#xe090;</span></a>',
					$phone_number
				);
			}

			if (
				'' !== $website_html ||
				'' !== $facebook_html ||
				'' !== $twitter_html ||
				'' !== $linkedin_html ||
				'' !== $instagram_html ||
				'' !== $youtube_html ||
				'' !== $email_html ||
				'' !== $phone_number_html
			) {
				$social_icons = sprintf(
					'<div class="aioc_team_social_wrapper">%1$s%2$s%3$s%4$s%5$s%6$s%7$s%8$s</div>',
					$website_html,
					$facebook_html,
					$twitter_html,
					$linkedin_html,
					$instagram_html,
					$youtube_html,
					$email_html,
					$phone_number_html
				);
			}
		}

		if ( 'on' !== $show_social_icons ) {
			self::set_style(
				$render_slug,
				array(
					'selector'    => '.aioc_team_carousel .layout4 %%order_class%% .aioc_slide_content_wrapper',
					'declaration' => 'bottom: 0px !important;',
					'media_query' => self::get_media_query( 'min_width_981' ),
				)
			);
		} else if ( 'on' === $show_social_icons && ( '' === $website_url && '' === $facebook_url && '' === $twitter_url && '' === $linkedin_url && '' === $instagram_url && '' === $youtube_url && '' === $email && '' === $phone_number ) ) {
			self::set_style(
				$render_slug,
				array(
					'selector'    => '.aioc_team_carousel .layout4 %%order_class%% .aioc_slide_content_wrapper',
					'declaration' => 'bottom: 0px !important;',
					'media_query' => self::get_media_query( 'min_width_981' ),
				)
			);
		}

		$contentLength = substr($content, 0, $content_length);
		$content = $multi_view->render_element( array(
			'tag'      => 'div',
			'content'  => $contentLength,
			'attrs'    => array(
				'class' => 'aioc_slide_content',
			),
			'required' => 'content',
		) );

		if ( '' !== $image ) {
			$image_wrapper = sprintf(
				'<div class="aioc_slide_image_wrapper">%1$s</div>',
				et_core_intentionally_unescaped( $image, 'html' )
			);
		}

		if ( '' !== $name || '' !== $designation || '' !== $content || '' !== $social_icons ) {
			$content_wrapper = sprintf(
				'<div class="aioc_slide_content_wrapper">
					<div class="aioc_slide_inner_content_wrapper">%1$s%2$s%3$s%4$s</div>
				</div>',
				et_core_intentionally_unescaped( $name, 'html' ),
				et_core_intentionally_unescaped( $designation, 'html' ),
				et_core_intentionally_unescaped( $content, 'html' ),
				et_core_intentionally_unescaped( $social_icons, 'html' )
			);
		}
		
		if ( isset( $image_wrapper ) || isset( $content_wrapper ) ) {
			$slide_wrapper = sprintf(
				'<div class="aioc_slide_wrapper">%1$s%2$s</div>',
				isset( $image_wrapper ) ? et_core_intentionally_unescaped( $image_wrapper, 'html' ) : '',
				isset( $content_wrapper ) ? et_core_intentionally_unescaped( $content_wrapper, 'html' ) : ''
			);
		} else {
			$slide_wrapper = '';
		}

		if ( !isset( $content_wrapper ) ){
			self::set_style(
				$render_slug,
				array(
					'selector'    => '%%order_class%% .aioc_slide_image_wrapper',
					'declaration' => 'height: 100%;',
					)
			);
		}
		
		if ( 'coverflow' === $slide_effect && '' !== $slide_border_radius ){	
			self::set_style(
				$render_slug,
				array(
					'selector'    => '%%order_class%% .aioc_slide_inner_content_wrapper',
					'declaration' => sprintf( 'border-radius: %1$s %2$s %3$s %4$s;', 
						$slide_border_radius[1],
						$slide_border_radius[2],
						$slide_border_radius[3],
						$slide_border_radius[4]
					),
				)
			);
		}

		$args = array(
			'render_slug'	=> $render_slug,
			'props'			=> $this->props,
			'fields'		=> $this->fields_unprocessed,
			'module'		=> $this,
			'backgrounds' 	=> array(
				'content_bg' => array(
					'normal' => "{$this->main_css_element} .aioc_slide_inner_content_wrapper",
					'hover' => "{$this->main_css_element} .aioc_slide_inner_content_wrapper:hover",
	 			),
			),
		);
		AIOC_Helper::process_background( $args );

		$fields = array( 'slide_margin_padding' );
		AIOC_Helper::process_advanced_margin_padding_css( $this, $render_slug, $this->margin_padding, $fields );

		$background_layout_class_names = et_pb_background_layout_options()->get_background_layout_class( $this->props );
        $this->add_classname( array(
			$this->get_text_orientation_classname(),
			$background_layout_class_names[0],
			'aioc_slide_carousel_slide',
			'swiper-slide'
		) );

        $file = et_is_builder_plugin_active() ? 'style-dbp' : 'style';
		wp_enqueue_style( 'aioc-team-carousel-item-style', ALL_IN_ONE_CAROUSEL_FOR_DIVI_PATH . 'includes/modules/TeamCarouselItem/' . $file . '.min.css', array(), '1.0.0' );

		return $slide_wrapper;
	}

    /**
	 * Filter multi view value.
	 *
	 * @since 3.27.1
	 *
	 * @see ET_Builder_Module_Helper_MultiViewOptions::filter_value
	 *
	 * @param mixed $raw_value Props raw value.
	 * @param array $args {
	 *     Context data.
	 *
	 *     @type string $context      Context param: content, attrs, visibility, classes.
	 *     @type string $name         Module options props name.
	 *     @type string $mode         Current data mode: desktop, hover, tablet, phone.
	 *     @type string $attr_key     Attribute key for attrs context data. Example: src, class, etc.
	 *     @type string $attr_sub_key Attribute sub key that availabe when passing attrs value as array such as styes. Example: padding-top, margin-botton, etc.
	 * }
	 * @param ET_Builder_Module_Helper_MultiViewOptions $multi_view Multiview object instance.
	 *
	 * @return mixed
	 */
	public function multi_view_filter_value( $raw_value, $args, $multi_view ) {
		$name = isset( $args['name'] ) ? $args['name'] : '';
		$mode = isset( $args['mode'] ) ? $args['mode'] : '';

		if ( $raw_value && 'icon' === $name ) {
			$processed_value = html_entity_decode( et_pb_process_font_icon( $raw_value ) );
			if ( '%%1%%' === $raw_value ) {
				$processed_value = '"';
			}

			return $processed_value;
		}

		return $raw_value;
	}

	public function aioc_builder_processed_range_value( $result, $range, $range_string ) {
		if ( false !== strpos( $result, '0calc' ) ) {
			return $range;
		}
		return $result;
	}	

}

new AIOC_TeamCarouselItem;
