<?php

namespace VertexMediaLLC\ZyreElementorAddons\Widget;

use Elementor\Controls_Manager;
use VertexMediaLLC\ZyreElementorAddons\Traits\List_Item_Advanced_Trait;

defined( 'ABSPATH' ) || die();

class Image_List extends Base {

	use List_Item_Advanced_Trait;

	public function get_title() {
		return esc_html__( 'Image List', 'zyre-elementor-addons' );
	}

	public function get_icon() {
		return 'zy-fonticon zy-Image-list';
	}

	public function get_keywords() {
		return [ 'image list', 'images lists', 'image grid', 'lists icons', 'list icon', 'icon list', 'icons lists', 'lists items', 'list item', 'text', 'feature content' ];
	}

	public function get_custom_help_url() {
		return $this->set_help_url();
	}

	protected function register_content_controls() {
		$this->start_controls_section(
			'section_content_heading',
			[
				'label' => esc_html__( 'Image List Content', 'zyre-elementor-addons' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			]
		);

		// Pre-styles
		$this->set_prestyle_controls();

		$this->register_list_item_advanced_content_controls( [ 'id_prefix' => 'image' ] );

		$this->end_controls_section();
	}

	protected function register_style_controls() {
		$this->__general_style_controls();
		$this->__item_style_controls();
		$this->__content_style_controls();
		$this->__title_style_controls();
		$this->__description_style_controls();
		$this->__media_wrapper_style_controls();
		$this->__media_style_controls();
		$this->__media_caption_style_controls();
	}

	protected function __general_style_controls() {
		$this->start_controls_section(
			'section_general_style',
			[
				'label' => esc_html__( 'General', 'zyre-elementor-addons' ),
				'tab'   => Controls_Manager::TAB_STYLE,

			]
		);

		$this->register_general_style_controls( [ 'id_prefix' => 'image' ] );

		$this->register_grid_style_controls(
			[
				'id_prefix'       => 'image',
				'selector_suffix' => 'divider',
			]
		);

		$this->end_controls_section();
	}

	protected function __item_style_controls() {

		$this->start_controls_section(
			'section_item_style',
			[
				'label' => esc_html__( 'List Item', 'zyre-elementor-addons' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->register_item_style_controls( [ 'id_prefix' => 'image' ] );

		$this->end_controls_section();
	}

	protected function __content_style_controls() {
		$this->start_controls_section(
			'section_item_content_style',
			[
				'label' => esc_html__( 'Item Content', 'zyre-elementor-addons' ),
				'tab'   => Controls_Manager::TAB_STYLE,

			]
		);

		$this->register_content_style_controls( [ 'id_prefix' => 'image' ] );

		$this->register_grid_style_controls(
			[
				'id_prefix'       => 'image',
				'selector_suffix' => 'content',
			]
		);

		$this->end_controls_section();
	}

	protected function __title_style_controls() {

		$this->start_controls_section(
			'section_title_style',
			[
				'label' => esc_html__( 'Title', 'zyre-elementor-addons' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->register_text_style_controls(
			[
				'id_prefix'   => 'item_title',
				'widget_base' => 'image',
			]
		);

		$this->end_controls_section();
	}

	protected function __description_style_controls() {

		$this->start_controls_section(
			'section_description_style',
			[
				'label' => esc_html__( 'Description', 'zyre-elementor-addons' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			]
		);

		$this->register_text_style_controls(
			[
				'id_prefix'   => 'item_text',
				'widget_base' => 'image',
			]
		);

		$this->end_controls_section();
	}

	protected function __media_wrapper_style_controls() {
		$this->start_controls_section(
			'section_media_wrapper_style',
			[
				'label'     => esc_html__( 'Media Wrapper', 'zyre-elementor-addons' ),
				'tab'       => Controls_Manager::TAB_STYLE,
			]
		);

		$this->register_media_wrapper_style_controls( [ 'id_prefix' => 'image' ] );

		$this->end_controls_section();
	}

	protected function __media_caption_style_controls() {
		$this->start_controls_section(
			'section_media_caption_style',
			[
				'label'     => esc_html__( 'Media Caption', 'zyre-elementor-addons' ),
				'tab'       => Controls_Manager::TAB_STYLE,
			]
		);

		$this->register_media_caption_style_controls( [ 'id_prefix' => 'image' ] );

		$this->end_controls_section();
	}

	protected function __media_style_controls() {
		$this->start_controls_section(
			'section_media_style',
			[
				'label'     => esc_html__( 'Image or Icon', 'zyre-elementor-addons' ),
				'tab'       => Controls_Manager::TAB_STYLE,

			]
		);

		$this->register_item_type_element_style_controls( [ 'id_prefix' => 'image' ] );

		$this->register_grid_style_controls(
			[
				'id_prefix'       => 'image',
				'selector_suffix' => 'image',
			]
		);

		$this->end_controls_section();
	}

	protected function render() {
		$this->render_items( null, [ 'id_prefix' => 'image' ] );
	}
}
