<?php
/**
 * Class: Off_Canvas_Widget
 * Name: Barre latérale
 * Slug: eac-addon-off-canvas
 *
 * Description: Construit et affiche une barre létérale avec un contenu défini, à une position déterminée
 * ouverte par un bouton ou un texte
 *
 * @since 1.8.5
 */

namespace EACCustomWidgets\Includes\Widgets;

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

use EACCustomWidgets\Core\Utils\Eac_Tools_Util;
use EACCustomWidgets\Core\Eac_Load_Config;

use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Icons_Manager;
use Elementor\Group_Control_Background;
use Elementor\TemplateLibrary\Source_Local;

class Off_Canvas_Widget extends Widget_Base {

	/**
	 * Le nom de la clé du composant dans le fichier de configuration
	 *
	 * @var $slug
	 *
	 * @access private
	 */
	private $slug = 'off-canvas';

	/**
	 * Retrieve widget name.
	 *
	 * @access public
	 *
	 * @return string widget name.
	 */
	public function get_name(): string {
		return Eac_Load_Config::get_widget_name( $this->slug );
	}

	/**
	 * Retrieve widget title.
	 *
	 * @access public
	 *
	 * @return string widget title.
	 */
	public function get_title(): string {
		return Eac_Load_Config::get_widget_title( $this->slug );
	}

	/**
	 * Retrieve widget icon.
	 *
	 * @access public
	 *
	 * @return string widget icon.
	 */
	public function get_icon(): string {
		return Eac_Load_Config::get_widget_icon( $this->slug );
	}

	/**
	 * Affecte le composant à la catégorie définie dans plugin.php
	 *
	 * @access public
	 *
	 * @return array widget category.
	 */
	public function get_categories(): array {
		return Eac_Load_Config::get_widget_categories( $this->slug );
	}

	/**
	 * Load dependent libraries
	 *
	 * @access public
	 *
	 * @return array libraries list.
	 */
	public function get_script_depends(): array {
		return array( 'eac-off-canvas' );
	}

	/**
	 * Load dependent styles
	 *
	 * Les styles sont chargés dans le footer
	 *
	 * @return array CSS list.
	 */
	public function get_style_depends(): array {
		return array( 'eac-off-canvas' );
	}

	/**
	 * Get widget keywords.
	 *
	 * Retrieve the list of keywords the widget belongs to.
	 *
	 * @access public
	 *
	 * @return array Widget keywords.
	 */
	public function get_keywords(): array {
		return Eac_Load_Config::get_widget_keywords( $this->slug );
	}

	/**
	 * Get help widget get_custom_help_url.
	 *
	 * @access public
	 *
	 * @return string URL help center
	 */
	public function get_custom_help_url(): string {
		return Eac_Load_Config::get_widget_help_url( $this->slug );
	}

	/**
	 * has_widget_inner_wrapper
	 *
	 * @return bool
	 */
	public function has_widget_inner_wrapper(): bool {
		return false;
	}

	/**
	 * is_dynamic_content
	 *
	 * @return bool
	 */
	protected function is_dynamic_content(): bool {
		return true;
	}

	/**
	 * Register widget controls.
	 *
	 * Adds different input fields to allow the user to change and customize the widget settings.
	 *
	 * @access protected
	 */
	protected function register_controls(): void {

		$this->start_controls_section(
			'oc_settings',
			array(
				'label' => esc_html__( 'Settings', 'eac-components' ),
				'tab'   => Controls_Manager::TAB_CONTENT,
			)
		);

			$start = is_rtl() ? 'right' : 'left';
			$end   = is_rtl() ? 'left' : 'right';
			$this->add_control(
				'oc_content_position',
				array(
					'label'       => esc_html__( 'Position', 'eac-components' ),
					'description' => esc_html__( 'Position of the Off-canvas and the button (sticky)', 'eac-components' ),
					'type'        => Controls_Manager::CHOOSE,
					'default'     => 'left',
					'options'     => array(
						'stretch'   => array(
							'title' => esc_html__( 'Relative', 'eac-components' ),
							'icon'  => 'eicon-v-align-stretch',
						),
						'top'    => array(
							'title' => esc_html__( 'Top', 'eac-components' ),
							'icon'  => 'eicon-v-align-top',
						),
						'left'   => array(
							'title' => is_rtl() ? esc_html__( 'Right', 'eac-components' ) : esc_html__( 'Left', 'eac-components' ),
							'icon'  => "eicon-h-align-{$start}",
						),
						'right'  => array(
							'title' => is_rtl() ? esc_html__( 'Left', 'eac-components' ) : esc_html__( 'Right', 'eac-components' ),
							'icon'  => "eicon-h-align-{$end}",
						),
						'bottom' => array(
							'title' => esc_html__( 'Bottom', 'eac-components' ),
							'icon'  => 'eicon-v-align-bottom',
						),
					),
					'toggle'  => false,
					'render_type'  => 'template',
					'prefix_class' => 'oc-offcanvas__canvas-',
				)
			);

			$this->add_control(
				'oc_content_overlay',
				array(
					'label'        => esc_html__( 'Active overlay', 'eac-components' ),
					'type'         => Controls_Manager::SWITCHER,
					'label_on'     => esc_html__( 'Yes', 'eac-components' ),
					'label_off'    => esc_html__( 'No', 'eac-components' ),
					'return_value' => 'yes',
					'default'      => 'yes',
					'separator'    => 'after',
				)
			);

			$this->start_controls_tabs( 'oc_content_settings' );

				$this->start_controls_tab(
					'oc_content',
					array(
						'label'     => esc_html__( 'Content', 'eac-components' ),
					)
				);

					$this->add_control(
						'oc_content_title',
						array(
							'label'       => esc_html__( 'Title', 'eac-components' ),
							'type'        => Controls_Manager::TEXT,
							'dynamic'     => array( 'active' => true ),
							'ai'          => array( 'active' => false ),
							'default'     => esc_html__( 'Content header', 'eac-components' ),
							'placeholder' => esc_html__( 'Content header', 'eac-components' ),
							'render_type' => 'ui',
						)
					);

					$this->add_control(
						'oc_content_type',
						array(
							'label'       => esc_html__( 'Content type', 'eac-components' ),
							'type'        => Controls_Manager::SELECT,
							'default'     => 'texte',
							'options'     => array(
								'form'      => esc_html__( 'Shortcode', 'eac-components' ),
								'menu'      => esc_html__( 'Menu', 'eac-components' ),
								'texte'     => esc_html__( 'Custom text', 'eac-components' ),
								'tmpl_cont' => esc_html__( 'Elementor template container', 'eac-components' ),
								'tmpl_sec'  => esc_html__( 'Elementor template section', 'eac-components' ),
								'tmpl_page' => esc_html__( 'Elementor template page', 'eac-components' ),
								'widget'    => esc_html( 'Widget' ),
							),
						)
					);

					$this->add_control(
						'oc_content_shortcode',
						array(
							'label'       => esc_html__( 'Enter shortcode', 'eac-components' ),
							'type'        => Controls_Manager::TEXTAREA,
							'placeholder' => '[eac_elementor_tmpl id="xxxx"]',
							'ai'          => array( 'active' => false ),
							'condition'   => array( 'oc_content_type' => 'form' ),
						)
					);

					$this->add_control(
						'oc_content_text',
						array(
							'label'     => esc_html__( 'Description', 'eac-components' ),
							'type'      => Controls_Manager::WYSIWYG,
							'default'   => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.',
							'condition' => array( 'oc_content_type' => 'texte' ),
						)
					);

					$this->add_control(
						'oc_content_container',
						array(
							'label'       => esc_html__( 'Elementor template container', 'eac-components' ),
							'type'        => Controls_Manager::SELECT,
							'options'     => Eac_Tools_Util::get_elementor_templates( 'container' ),
							'condition'   => array( 'oc_content_type' => 'tmpl_cont' ),
							'label_block' => true,
						)
					);

					$this->add_control(
						'oc_content_section',
						array(
							'label'       => esc_html__( 'Elementor template section', 'eac-components' ),
							'type'        => Controls_Manager::SELECT,
							'options'     => Eac_Tools_Util::get_elementor_templates( 'section' ),
							'condition'   => array( 'oc_content_type' => 'tmpl_sec' ),
							'label_block' => true,
						)
					);

					$this->add_control(
						'oc_content_page',
						array(
							'label'       => esc_html__( 'Elementor template page', 'eac-components' ),
							'type'        => Controls_Manager::SELECT,
							'options'     => Eac_Tools_Util::get_elementor_templates( 'page' ),
							'condition'   => array( 'oc_content_type' => 'tmpl_page' ),
							'label_block' => true,
						)
					);

					$this->add_control(
						'oc_content_menu',
						array(
							'label'       => esc_html__( 'Menu', 'eac-components' ),
							'type'        => Controls_Manager::SELECT,
							'options'     => Eac_Tools_Util::get_menus_list(),
							'default'     => array_key_first( Eac_Tools_Util::get_menus_list() ),
							'description' => sprintf( '<a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a>', esc_url( admin_url( 'nav-menus.php' ) ), esc_html__( 'Apparence/Menus to manage your menus.', 'eac-components' ) ),
							'condition'   => array( 'oc_content_type' => 'menu' ),
						)
					);

					$this->add_control(
						'oc_content_menu_level',
						array(
							'label'       => esc_html__( 'Number of levels', 'eac-components' ),
							'description' => esc_html__( '0 = All', 'eac-components' ),
							'default'     => 0,
							'type'        => Controls_Manager::TEXT,
							'ai'          => array( 'active' => false ),
							'condition'   => array( 'oc_content_type' => 'menu' ),
						)
					);

					$this->add_control(
						'oc_content_widget',
						array(
							'label'       => esc_html( 'Widgets' ),
							'type'        => Controls_Manager::SELECT2,
							'options'     => Eac_Tools_Util::get_widget_list(),
							'multiple'    => true,
							'label_block' => true,
							'condition'   => array( 'oc_content_type' => 'widget' ),
						)
					);

				$this->end_controls_tab();

				$this->start_controls_tab(
					'oc_trigger',
					array(
						'label' => esc_html__( 'Trigger', 'eac-components' ),
					)
				);

					$this->add_control(
						'oc_trigger_type',
						array(
							'label'       => esc_html__( 'Trigger', 'eac-components' ),
							'type'        => Controls_Manager::SELECT,
							'options'     => array(
								'button' => esc_html__( 'Button', 'eac-components' ),
								'text'   => esc_html__( 'Text', 'eac-components' ),
							),
							'default'     => 'button',
						)
					);

					$this->add_control(
						'oc_display_text',
						array(
							'label'       => esc_html__( 'Text', 'eac-components' ),
							'default'     => esc_html__( 'Open Off-canvas', 'eac-components' ),
							'type'        => Controls_Manager::TEXT,
							'dynamic'     => array( 'active' => true ),
							'ai'          => array( 'active' => false ),
							'label_block' => true,
							'condition'   => array( 'oc_trigger_type' => 'text' ),
						)
					);

					$this->add_control(
						'oc_display_text_button',
						array(
							'label'       => esc_html__( 'Button label', 'eac-components' ),
							'default'     => esc_html__( 'Open Off-canvas', 'eac-components' ),
							'type'        => Controls_Manager::TEXT,
							'dynamic'     => array( 'active' => true ),
							'ai'          => array( 'active' => false ),
							'label_block' => true,
							'condition'   => array( 'oc_trigger_type' => 'button' ),
						)
					);

					$this->add_responsive_control(
						'oc_align_button',
						array(
							'label'     => esc_html__( 'Alignment', 'eac-components' ),
							'type'      => Controls_Manager::CHOOSE,
							'options'   => array(
								'left'   => array(
									'title' => is_rtl() ? esc_html__( 'Right', 'eac-components' ) : esc_html__( 'Left', 'eac-components' ),
									'icon'  => "eicon-h-align-{$start}",
								),
								'center' => array(
									'title' => esc_html__( 'Center', 'eac-components' ),
									'icon'  => 'eicon-h-align-center',
								),
								'right'  => array(
									'title' => is_rtl() ? esc_html__( 'Left', 'eac-components' ) : esc_html__( 'Right', 'eac-components' ),
									'icon'  => "eicon-h-align-{$end}",
								),
							),
							'default'   => 'center',
							'selectors_dictionary' => array(
								'left'   => '0 auto',
								'center' => 'auto',
								'right'  => 'auto 0',
							),
							'selectors' => array(
								'{{WRAPPER}} .oc-offcanvas__wrapper-btn, {{WRAPPER}} .oc-offcanvas__wrapper-text' => 'margin-inline: {{VALUE}};',
							),
							'condition' => array( 'oc_icon_sticky!' => 'yes' ),
						)
					);

					$this->add_control(
						'oc_icon_sticky',
						array(
							'label'        => esc_html__( 'Sticky button', 'eac-components' ),
							'type'         => Controls_Manager::SWITCHER,
							'label_on'     => esc_html__( 'Yes', 'eac-components' ),
							'label_off'    => esc_html__( 'No', 'eac-components' ),
							'return_value' => 'yes',
							'default'      => '',
							'condition'    => array(
								'oc_trigger_type'      => 'button',
								'oc_content_position!' => array( 'stretch', 'top', 'bottom' ),
							),
						)
					);

					$this->add_control(
						'oc_button_position',
						array(
							'label'       => esc_html__( 'Position (%)', 'eac-components' ),
							'type'        => Controls_Manager::SLIDER,
							'size_units'  => array( '%' ),
							'default'     => array(
								'size' => 50,
								'unit' => '%',
							),
							'range'       => array(
								'%' => array(
									'min'  => 5,
									'max'  => 95,
									'step' => 1,
								),
							),
							'label_block' => true,
							'selectors'   => array(
								'{{WRAPPER}} .oc-offcanvas__wrapper-btn.sticky-button-left' => 'inset-block-start: {{SIZE}}%; transform: rotate(-90deg) translateX(-{{SIZE}}%);',
								'{{WRAPPER}} .oc-offcanvas__wrapper-btn.sticky-button-right' => 'inset-block-start: {{SIZE}}%; transform: rotate(90deg) translateX({{SIZE}}%);',
							),
							'condition'   => array( 'oc_icon_sticky' => 'yes' ),
						)
					);

					$this->add_control(
						'oc_icon_activated',
						array(
							'label'        => esc_html__( 'Add pictogram', 'eac-components' ),
							'type'         => Controls_Manager::SWITCHER,
							'label_on'     => esc_html__( 'Yes', 'eac-components' ),
							'label_off'    => esc_html__( 'No', 'eac-components' ),
							'return_value' => 'yes',
							'default'      => '',
							'separator'    => 'before',
							'condition'    => array( 'oc_trigger_type' => 'button' ),
						)
					);

					$this->add_control(
						'oc_display_icon_button',
						array(
							'label'                  => esc_html__( 'Pictograms', 'eac-components' ),
							'type'                   => Controls_Manager::ICONS,
							'default'                => array(
								'value'   => 'fas fa-angle-double-right',
								'library' => 'fa-solid',
							),
							'skin'                   => 'inline',
							'condition'              => array(
								'oc_trigger_type'   => 'button',
								'oc_icon_activated' => 'yes',
							),
						)
					);

					$this->add_control(
						'oc_position_icon_button',
						array(
							'label'     => esc_html__( 'Position', 'eac-components' ),
							'type'      => Controls_Manager::SELECT,
							'default'   => 'before',
							'options'   => array(
								'before' => esc_html__( 'Before', 'eac-components' ),
								'after'  => esc_html__( 'After', 'eac-components' ),
							),
							'condition' => array(
								'oc_trigger_type'   => 'button',
								'oc_icon_activated' => 'yes',
							),
						)
					);

					$this->add_control(
						'oc_marge_icon_button',
						array(
							'label'              => esc_html__( 'Margin', 'eac-components' ),
							'type'               => Controls_Manager::DIMENSIONS,
							'allowed_dimensions' => array( 'left', 'right' ),
							'default'            => array(
								'left'     => 0,
								'right'    => 0,
								'unit'     => 'px',
								'isLinked' => false,
							),
							'range'              => array(
								'px' => array(
									'min'  => 5,
									'max'  => 50,
									'step' => 1,
								),
							),
							'selectors'          => array(
								'{{WRAPPER}} .button-icon' => 'margin-block: 0; margin-inline: {{LEFT}}px {{RIGHT}}px;',
							),
							'condition'          => array(
								'oc_trigger_type'   => 'button',
								'oc_icon_activated' => 'yes',
							),
						)
					);

				$this->end_controls_tab();

			$this->end_controls_tabs();

		$this->end_controls_section();

		/**
		 * Generale Style Section
		 */
		$this->start_controls_section(
			'oc_offcanvas_style',
			array(
				'label' => esc_html__( 'Container', 'eac-components' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

			$this->add_responsive_control(
				'oc_content_width',
				array(
					'label'       => esc_html__( 'Width', 'eac-components' ),
					'type'        => Controls_Manager::SLIDER,
					'size_units'  => array( 'px', 'vw' ),
					'default'     => array(
						'size' => 50,
						'unit' => 'vw',
					),
					'tablet_default' => array(
						'size' => 50,
						'unit' => 'vw',
					),
					'mobile_default' => array(
						'size' => 100,
						'unit' => 'vw',
					),
					'range'       => array(
						'px' => array(
							'min'  => 50,
							'max'  => 1140,
							'step' => 50,
						),
						'vw'  => array(
							'min'  => 5,
							'max'  => 100,
							'step' => 5,
						),
					),
					'label_block' => true,
					'selectors'   => array(
						'{{WRAPPER}}.oc-offcanvas__canvas-left .oc-offcanvas__wrapper-canvas,
						{{WRAPPER}}.oc-offcanvas__canvas-right .oc-offcanvas__wrapper-canvas' => 'inline-size: {{SIZE}}{{UNIT}};',
					),
					'condition'    => array( 'oc_content_position' => array( 'left', 'right' ) ),
				)
			);

			$this->add_control(
				'oc_content_height_auto',
				array(
					'label'     => esc_html__( 'Auto height', 'eac-components' ),
					'type'      => Controls_Manager::CHOOSE,
					'options'   => array(
						'yes' => array(
							'title' => esc_html__( 'Yes', 'eac-components' ),
							'icon'  => 'eicon-check',
						),
						'no'  => array(
							'title' => esc_html__( 'No', 'eac-components' ),
							'icon'  => 'eicon-ban',
						),
					),
					'default'   => 'yes',
					'toggle'    => false,
					'condition'    => array( 'oc_content_position' => array( 'stretch', 'top', 'bottom' ) ),
				)
			);

			$this->add_responsive_control(
				'oc_content_height',
				array(
					'label'       => esc_html__( 'Height', 'eac-components' ),
					'type'        => Controls_Manager::SLIDER,
					'size_units'  => array( 'px', 'vh' ),
					'default'     => array(
						'size' => 50,
						'unit' => 'vh',
					),
					'tablet_default' => array(
						'size' => 50,
						'unit' => 'vh',
					),
					'mobile_default' => array(
						'size' => 50,
						'unit' => 'vh',
					),
					'range'       => array(
						'vh'  => array(
							'min'  => 5,
							'max'  => 100,
							'step' => 5,
						),
					),
					'label_block' => true,
					'selectors'   => array(
						'{{WRAPPER}}.oc-offcanvas__canvas-stretch .oc-offcanvas__wrapper-canvas,
						{{WRAPPER}}.oc-offcanvas__canvas-bottom .oc-offcanvas__wrapper-canvas,
						{{WRAPPER}}.oc-offcanvas__canvas-top .oc-offcanvas__wrapper-canvas' => 'block-size: {{SIZE}}{{UNIT}};',
					),
					'condition'    => array(
						'oc_content_position' => array( 'stretch', 'top', 'bottom' ),
						'oc_content_height_auto' => 'no',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Background::get_type(),
				array(
					'name'           => 'oc_content_bgcolor',
					'types'          => array( 'classic', 'gradient' ),
					'fields_options' => array(
						'size'     => array( 'default' => 'cover' ),
						'position' => array( 'default' => 'center center' ),
						'repeat'   => array( 'default' => 'no-repeat' ),
					),
					'separator'      => 'before',
					'selector'       => '{{WRAPPER}} .oc-offcanvas__wrapper-canvas',
				)
			);

			$this->add_control(
				'oc_content_box_blend',
				array(
					'label'       => esc_html__( 'Blend mode', 'eac-components' ),
					'description' => esc_html__( 'You have selected a color and an image', 'eac-components' ),
					'type'        => Controls_Manager::SELECT,
					'default'     => 'normal',
					'options'     => array(
						'normal'      => 'Normal',
						'screen'      => 'Screen',
						'overlay'     => 'Overlay',
						'darken'      => 'Darken',
						'lighten'     => 'Lighten',
						'color-dodge' => 'Color-dodge',
						'color-burn'  => 'Color-burn',
						'hard-light'  => 'Hard-light',
						'soft-light'  => 'Soft-light',
						'difference'  => 'Difference',
						'exclusion'   => 'Exclusion',
						'hue'         => 'Hue',
						'saturation'  => 'Saturation',
						'color'       => 'Color',
						'luminosity'  => 'Luminosity',
					),
					'label_block' => true,
					'separator'   => 'before',
					'selectors'   => array( '{{WRAPPER}} .oc-offcanvas__wrapper-canvas' => 'background-blend-mode: {{VALUE}};' ),
					'condition'   => array( 'oc_content_bgcolor_background' => 'classic' ),
				)
			);

		$this->end_controls_section();

		$this->start_controls_section(
			'oc_header_style',
			array(
				'label' => esc_html__( 'Container header', 'eac-components' ),
				'tab'   => Controls_Manager::TAB_STYLE,
			)
		);

			$this->add_control(
				'oc_header_color',
				array(
					'label'     => esc_html__( 'Color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'default'   => '#000',
					'selectors' => array( '{{WRAPPER}} .oc-offcanvas__canvas-title, {{WRAPPER}} .oc-offcanvas__canvas-close .oc-first-element' => 'color: {{VALUE}};' ),
				)
			);

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				array(
					'name'     => 'oc_header_typography',
					'label'    => esc_html__( 'Typography', 'eac-components' ),
					'selector' => '{{WRAPPER}} .oc-offcanvas__canvas-title',
				)
			);

			$this->add_control(
				'oc_header_background',
				array(
					'label'     => esc_html__( 'Background color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array( '{{WRAPPER}} .oc-offcanvas__canvas-header' => 'background-color: {{VALUE}};' ),
				)
			);

			$this->add_group_control(
				Group_Control_Border::get_type(),
				array(
					'name'     => 'oc_header_border',
					'selector' => '{{WRAPPER}} .oc-offcanvas__canvas-header',
				)
			);

		$this->end_controls_section();

		$this->start_controls_section(
			'oc_content_menu_style',
			array(
				'label'     => esc_html__( 'Menu content', 'eac-components' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array( 'oc_content_type' => 'menu' ),
			)
		);

			$this->add_control(
				'oc_content_menu_color',
				array(
					'label'     => esc_html__( 'Text color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						'{{WRAPPER}} .oc-offcanvas__menu-wrapper ul li, {{WRAPPER}} .oc-offcanvas__menu-wrapper ul li a' => 'color: {{VALUE}};',
						'{{WRAPPER}} .oc-offcanvas__menu-wrapper ul li:before' => 'background-color: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'oc_content_menu_color_hover',
				array(
					'label'     => esc_html__( 'Hover text color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						'{{WRAPPER}} .oc-offcanvas__menu-wrapper ul li a:hover, {{WRAPPER}} .oc-offcanvas__menu-wrapper ul li a:focus' => 'color: {{VALUE}};',
						'{{WRAPPER}} .oc-offcanvas__menu-wrapper ul li:hover:before' => 'background-color: {{VALUE}};',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				array(
					'name'           => 'oc_content_menu_typography',
					'label'          => esc_html__( 'Typography', 'eac-components' ),
					'fields_options' => array(
						'font_size' => array(
							'default' => array(
								'unit' => 'em',
								'size' => 0.85,
							),
						),
					),
					'selector'       => '{{WRAPPER}} .oc-offcanvas__menu-wrapper > ul',
				)
			);

			$this->add_control(
				'oc_content_menu_bgcolor',
				array(
					'label'     => esc_html__( 'Background color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array( '{{WRAPPER}} .oc-offcanvas__menu-wrapper' => 'background-color: {{VALUE}};' ),
				)
			);

		$this->end_controls_section();

		$this->start_controls_section(
			'oc_content_text_style',
			array(
				'label'     => esc_html__( 'Text content', 'eac-components' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array( 'oc_content_type' => 'texte' ),
			)
		);

			$this->add_control(
				'oc_content_text_color',
				array(
					'label'     => esc_html__( 'Color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array( '{{WRAPPER}} .oc-offcanvas__content-text' => 'color: {{VALUE}};' ),
				)
			);

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				array(
					'name'     => 'oc_content_text_typography',
					'label'    => esc_html__( 'Typography', 'eac-components' ),
					'selector' => '{{WRAPPER}} .oc-offcanvas__content-text',
				)
			);

			$this->add_responsive_control(
				'oc_content_text_margines',
				array(
					'label'     => esc_html__( 'Margin', 'eac-components' ),
					'type'      => Controls_Manager::DIMENSIONS,
					'selectors' => array(
						'{{WRAPPER}} .oc-offcanvas__content-text' => 'margin-block: {{TOP}}{{UNIT}} {{BOTTOM}}{{UNIT}}; margin-inline: {{LEFT}}{{UNIT}} {{RIGHT}}{{UNIT}};',
					),
				)
			);

		$this->end_controls_section();

		$this->start_controls_section(
			'oc_content_widget_style',
			array(
				'label'     => esc_html__( 'Widget content', 'eac-components' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array( 'oc_content_type' => 'widget' ),
			)
		);

			$this->add_control(
				'oc_content_widget_title_color',
				array(
					'label'     => esc_html__( 'Title color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						'{{WRAPPER}} .oc-offcanvas__canvas-content .widget .widgettitle,
					{{WRAPPER}} .oc-offcanvas__canvas-content .widget .widget-title,
					{{WRAPPER}} .oc-offcanvas__canvas-content .widget.widget_calendar caption' => 'color: {{VALUE}};',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				array(
					'name'           => 'oc_content_widget_title_typography',
					'label'          => esc_html__( 'Title typography', 'eac-components' ),
					'fields_options' => array(
						'font_size' => array(
							'default' => array(
								'unit' => 'em',
								'size' => 1.1,
							),
						),
					),
					'selector'       => '{{WRAPPER}} .oc-offcanvas__canvas-content .widget .widgettitle,
					{{WRAPPER}} .oc-offcanvas__canvas-content .widget .widget-title,
					{{WRAPPER}} .oc-offcanvas__canvas-content .widget.widget_calendar caption',
				)
			);

			$this->add_control(
				'oc_content_widget_title_bgcolor',
				array(
					'label'     => esc_html__( 'Title background color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'default'   => 'antiquewhite',
					'selectors' => array(
						'{{WRAPPER}} .oc-offcanvas__canvas-content .widget .widgettitle,
						{{WRAPPER}} .oc-offcanvas__canvas-content .widget .widget-title'  => 'background-color: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'oc_content_widget_text_color',
				array(
					'label'     => esc_html__( 'Text color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'separator' => 'before',
					'selectors' => array(
						'{{WRAPPER}} .oc-offcanvas__canvas-content .widget ul li,
						{{WRAPPER}} .oc-offcanvas__canvas-content .widget ul li a,
						{{WRAPPER}} .oc-offcanvas__canvas-content aside.widget ul li,
						{{WRAPPER}} .oc-offcanvas__canvas-content aside.widget ul li a,
						{{WRAPPER}} .oc-offcanvas__canvas-content .widget.widget_calendar td,
						{{WRAPPER}} .oc-offcanvas__canvas-content .widget.widget_calendar th,
						{{WRAPPER}} .oc-offcanvas__canvas-content .widget .custom-html-widget,
						{{WRAPPER}} .oc-offcanvas__canvas-content .widget .tagcloud .tag-cloud-link' => 'color: {{VALUE}};',
						'{{WRAPPER}} .oc-offcanvas__canvas-content .widget ul li:before' => 'background-color: {{VALUE}};',
					),
				)
			);

			$this->add_control(
				'oc_content_widget_text_color_hover',
				array(
					'label'     => esc_html__( 'Hover text color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array(
						'{{WRAPPER}} .oc-offcanvas__canvas-content .widget ul li a:hover, {{WRAPPER}} .oc-offcanvas__canvas-content .widget ul li a:focus' => 'color: {{VALUE}};',
						'{{WRAPPER}} .oc-offcanvas__canvas-content .widget ul li:hover:before' => 'background-color: {{VALUE}};',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				array(
					'name'           => 'oc_content_widget_text_typography',
					'label'          => esc_html__( 'Text typography', 'eac-components' ),
					'fields_options' => array(
						'font_size' => array(
							'default' => array(
								'unit' => 'em',
								'size' => 0.85,
							),
						),
					),
					'selector'       => '{{WRAPPER}} .oc-offcanvas__canvas-content .widget > ul,
					{{WRAPPER}} .oc-offcanvas__canvas-content aside.widget ul,
					{{WRAPPER}} .oc-offcanvas__canvas-content .widget.widget_calendar td,
					{{WRAPPER}} .oc-offcanvas__canvas-content .widget.widget_calendar th,
					{{WRAPPER}} .oc-offcanvas__canvas-content .widget .custom-html-widget',
				)
			);

			$this->add_control(
				'oc_content_widget_bgcolor',
				array(
					'label'     => esc_html__( 'Background color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'separator' => 'before',
					'selectors' => array( '{{WRAPPER}} .oc-offcanvas__canvas-content .widget' => 'background-color: {{VALUE}};' ),
				)
			);

		$this->end_controls_section();

		$this->start_controls_section(
			'oc_button_style',
			array(
				'label'     => esc_html__( 'Trigger button', 'eac-components' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array( 'oc_trigger_type' => 'button' ),
			)
		);

			$this->start_controls_tabs( 'oc_controls_tabs' );

				$this->start_controls_tab(
					'oc_controls_tab_normal',
					array(
						'label' => esc_html__( 'Normal', 'eac-components' ),
					)
				);

					$this->add_control(
						'oc_button_color',
						array(
							'label'     => esc_html__( 'Color', 'eac-components' ),
							'type'      => Controls_Manager::COLOR,
							'selectors' => array(
								'{{WRAPPER}} .oc-offcanvas__wrapper-btn' => 'color: {{VALUE}};',
							),
						)
					);

					$this->add_group_control(
						Group_Control_Typography::get_type(),
						array(
							'name'     => 'oc_button_typography',
							'label'    => esc_html__( 'Typography', 'eac-components' ),
							'global'   => array( 'default' => Global_Typography::TYPOGRAPHY_TEXT ),
							'selector' => '{{WRAPPER}} .oc-offcanvas__wrapper-btn',
						)
					);

					$this->add_control(
						'oc_button_background',
						array(
							'label'     => esc_html__( 'Background color', 'eac-components' ),
							'type'      => Controls_Manager::COLOR,
							'selectors' => array( '{{WRAPPER}} .oc-offcanvas__wrapper-btn' => 'background-color: {{VALUE}};' ),
						)
					);

				$this->end_controls_tab();

				$this->start_controls_tab(
					'oc_controls_tab_hover',
					array(
						'label' => esc_html__( 'Hover', 'eac-components' ),
					)
				);

					$this->add_control(
						'oc_button_color_hover',
						array(
							'label'     => esc_html__( 'Color', 'eac-components' ),
							'type'      => Controls_Manager::COLOR,
							'selectors' => array(
								'{{WRAPPER}} .oc-offcanvas__wrapper-btn:hover, {{WRAPPER}} .oc-offcanvas__wrapper-btn:focus' => 'color: {{VALUE}};',
								'{{WRAPPER}} .oc-offcanvas__wrapper-btn:hover svg, {{WRAPPER}} .oc-offcanvas__wrapper-btn:focus svg' => 'fill: {{VALUE}};',
							),
						)
					);

					$this->add_control(
						'oc_button_background_hover',
						array(
							'label'     => esc_html__( 'Background color', 'eac-components' ),
							'type'      => Controls_Manager::COLOR,
							'selectors' => array(
								'{{WRAPPER}} .oc-offcanvas__wrapper-btn:hover, {{WRAPPER}} .oc-offcanvas__wrapper-btn:focus' => 'background-color: {{VALUE}};',
							),
						)
					);

					$this->add_control(
						'oc_button_border_color_hover',
						array(
							'label'     => esc_html__( 'Border color', 'eac-components' ),
							'type'      => Controls_Manager::COLOR,
							'condition' => array( 'oc_button_border_border!' => 'none' ),
							'selectors' => array(
								'{{WRAPPER}} .oc-offcanvas__wrapper-btn:hover, {{WRAPPER}} .oc-offcanvas__wrapper-btn:focus' => 'border-color: {{VALUE}};',
							),
						)
					);

				$this->end_controls_tab();

			$this->end_controls_tabs();

			$this->add_group_control(
				Group_Control_Border::get_type(),
				array(
					'name'      => 'oc_button_border',
					'selector'  => '{{WRAPPER}} .oc-offcanvas__wrapper-btn',
					'separator' => 'before',
				)
			);

			$this->add_control(
				'oc_button_radius',
				array(
					'label'              => esc_html__( 'Border radius', 'eac-components' ),
					'type'               => Controls_Manager::DIMENSIONS,
					'size_units'         => array( 'px', '%' ),
					'allowed_dimensions' => array( 'top', 'right', 'bottom', 'left' ),
					'default'            => array(
						'top'      => 8,
						'right'    => 8,
						'bottom'   => 8,
						'left'     => 8,
						'unit'     => 'px',
						'isLinked' => true,
					),
					'selectors'          => array(
						'{{WRAPPER}} .oc-offcanvas__wrapper-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
					),
				)
			);

			$this->add_responsive_control(
				'oc_button_padding',
				array(
					'label'     => esc_html__( 'Padding', 'eac-components' ),
					'type'      => Controls_Manager::DIMENSIONS,
					'selectors' => array(
						'{{WRAPPER}} .oc-offcanvas__wrapper-btn' => 'padding-block: {{TOP}}{{UNIT}} {{BOTTOM}}{{UNIT}}; padding-inline: {{LEFT}}{{UNIT}} {{RIGHT}}{{UNIT}};',
					),
				)
			);

			$this->add_group_control(
				Group_Control_Box_Shadow::get_type(),
				array(
					'name'     => 'oc_button_shadow',
					'label'    => esc_html__( 'Shadow', 'eac-components' ),
					'selector' => '{{WRAPPER}} .oc-offcanvas__wrapper-btn',
				)
			);

		$this->end_controls_section();

		$this->start_controls_section(
			'oc_texte_style',
			array(
				'label'     => esc_html__( 'Trigger text', 'eac-components' ),
				'tab'       => Controls_Manager::TAB_STYLE,
				'condition' => array( 'oc_trigger_type' => 'text' ),
			)
		);

			$this->add_control(
				'oc_texte_color',
				array(
					'label'     => esc_html__( 'Color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array( '{{WRAPPER}} .oc-offcanvas__wrapper-text span' => 'color: {{VALUE}} !important;' ),
				)
			);

			$this->add_group_control(
				Group_Control_Typography::get_type(),
				array(
					'name'     => 'oc_texte_typography',
					'label'    => esc_html__( 'Typography', 'eac-components' ),
					'selector' => '{{WRAPPER}} .oc-offcanvas__wrapper-text span',
				)
			);

			$this->add_control(
				'oc_texte_background',
				array(
					'label'     => esc_html__( 'Background color', 'eac-components' ),
					'type'      => Controls_Manager::COLOR,
					'selectors' => array( '{{WRAPPER}} .oc-offcanvas__wrapper-text span' => 'background-color: {{VALUE}};' ),
				)
			);

			$this->add_control(
				'fv_text_style_marges',
				array(
					'label'     => esc_html__( 'Padding', 'eac-components' ),
					'type'      => Controls_Manager::DIMENSIONS,
					'selectors' => array( '{{WRAPPER}} .oc-offcanvas__wrapper-text span' => 'padding-block: {{TOP}}{{UNIT}} {{BOTTOM}}{{UNIT}}; padding-inline: {{LEFT}}{{UNIT}} {{RIGHT}}{{UNIT}};' ),
				)
			);

		$this->end_controls_section();
	}

	/**
	 * Render widget output on the frontend.
	 *
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @access protected
	 */
	protected function render(): void {
		?>
		<div class='eac-off-canvas'>
			<?php $this->render_offcanvas(); ?>
		</div>
		<?php
	}

	/**
	 * Render widget output on the frontend.
	 *
	 * Written in PHP and used to generate the final HTML.
	 *
	 * @access protected
	 */
	protected function render_offcanvas(): void {
		$settings = $this->get_settings_for_display();

		$trigger        = $settings['oc_trigger_type'];
		$has_overlay    = $settings['oc_content_overlay'];
		$content        = $settings['oc_content_type'];
		$short_code     = $settings['oc_content_shortcode'];
		$menu           = $settings['oc_content_menu'];
		$texte          = $settings['oc_content_text'];
		$widget_classes = $settings['oc_content_widget'];
		$tmplcont       = $settings['oc_content_container'];
		$tmplsec        = $settings['oc_content_section'];
		$tmplpage       = $settings['oc_content_page'];

		// Quelques tests
		if ( ( 'widget' === $content && empty( $widget_classes ) ) || ( 'texte' === $content && empty( $texte ) ) || ( 'menu' === $content && empty( $menu ) ) || ( 'form' === $content && empty( $short_code ) ) || ( 'tmpl_cont' === $content && empty( $tmplcont ) ) || ( 'tmpl_sec' === $content && empty( $tmplsec ) ) || ( 'tmpl_page' === $content && empty( $tmplpage ) ) ) {
			return;
		}

		/**
		 * ID principal du document voir "data-elementor-id" class de la div section
		 * peut être différent de l'ID du post courant get_the_ID() de WP
		 * Si le post a été créé dans un template, il faut conserver ID du template
		 * pour que le CSS défini soit bien appliqué au widget
		 */
		$main_id = get_the_ID();
		if ( \Elementor\Plugin::$instance->documents->get_current() !== null ) {
			$main_id = \Elementor\Plugin::$instance->documents->get_current()->get_main_id();
		}

		// Unique ID du widget
		$id = $this->get_id();

		// Une icone avec le texte du bouton
		$icon_button = false;

		// Le bouton est collant
		$sticky_button = 'button' === $trigger && 'yes' === $settings['oc_icon_sticky'] ? 'sticky-button-' . $settings['oc_content_position'] : '';

		/** Le déclencheur est un bouton */
		if ( 'button' === $trigger ) {
			if ( 'yes' === $settings['oc_icon_activated'] && ! empty( $settings['oc_display_icon_button'] ) ) {
				$icon_button = true;
			}
			$this->add_render_attribute( 'trigger', 'type', 'button' );
			$this->add_render_attribute( 'trigger', 'class', array( 'oc-offcanvas__wrapper-trigger oc-offcanvas__wrapper-btn', esc_attr( $sticky_button ) ) );
			$this->add_render_attribute( 'trigger', 'aria-expanded', 'false' );
			$this->add_render_attribute( 'trigger', 'aria-controls', 'offcanvas_' . esc_attr( $id ) );
			$this->add_render_attribute( 'trigger', 'aria-haspopup', 'dialog' );
			$this->add_render_attribute( 'trigger', 'aria-label', esc_attr__( 'Open Off-canvas', 'eac-components' ) . ' ' . esc_attr( $settings['oc_display_text_button'] ) );
			$this->add_inline_editing_attributes( 'oc_display_text_button', 'none' );
			$this->add_render_attribute( 'oc_display_text_button', 'class', 'label-icon' );
		} elseif ( 'text' === $trigger ) {
			$this->add_render_attribute( 'trigger', 'class', 'oc-offcanvas__wrapper-trigger oc-offcanvas__wrapper-text' );
			$this->add_inline_editing_attributes( 'oc_display_text', 'none' );
		}

		/** Le wrapper du déclencheur bouton ou texte */
		$this->add_render_attribute( 'oc_wrapper', 'class', 'oc-offcanvas__wrapper' );
		$this->add_render_attribute( 'oc_wrapper', 'id', esc_attr( $id ) );
		$this->add_render_attribute( 'oc_wrapper', 'data-settings', $this->get_settings_json() );

		/** Le lien */
		$this->add_render_attribute( 'a_fancybox', 'href', '#' );
		$this->add_render_attribute( 'a_fancybox', 'class', 'eac-accessible-link' );
		$this->add_render_attribute( 'a_fancybox', 'role', 'button' );
		$this->add_render_attribute( 'a_fancybox', 'aria-expanded', 'false' );
		$this->add_render_attribute( 'a_fancybox', 'aria-controls', 'offcanvas_' . esc_attr( $id ) );
		$this->add_render_attribute( 'a_fancybox', 'aria-haspopup', 'dialog' );
		$label = 'button' === $trigger ? $settings['oc_display_text_button'] : $settings['oc_display_text'];
		$this->add_render_attribute( 'a_fancybox', 'aria-label', esc_attr__( 'Open Off-canvas', 'eac-components' ) . ' ' . esc_attr( $label ) );
		?>

		<div <?php $this->print_render_attribute_string( 'oc_wrapper' ); ?>>
			<?php if ( 'button' === $trigger ) { ?>
				<button <?php $this->print_render_attribute_string( 'trigger' ); ?>>
					<?php if ( $icon_button && 'before' === $settings['oc_position_icon_button'] ) { ?>
						<span class='button-icon eac-icon-svg'>
						<?php Icons_Manager::render_icon( $settings['oc_display_icon_button'], array( 'aria-hidden' => 'true' ) ); ?>
						</span>
					<?php } ?>
						<span <?php $this->print_render_attribute_string( 'oc_display_text_button' ); ?>><?php echo esc_html( $settings['oc_display_text_button'] ); ?></span>
					<?php if ( $icon_button && 'after' === $settings['oc_position_icon_button'] ) { ?>
						<span class='button-icon eac-icon-svg'>
						<?php Icons_Manager::render_icon( $settings['oc_display_icon_button'], array( 'aria-hidden' => 'true' ) ); ?>
						</span>
					<?php } ?>
				</button>
			<?php } elseif ( 'text' === $trigger ) { ?>
				<div <?php $this->print_render_attribute_string( 'trigger' ); ?>>
					<a <?php $this->print_render_attribute_string( 'a_fancybox' ); ?>>
						<span <?php $this->print_render_attribute_string( 'oc_display_text' ); ?>><?php echo esc_html( $settings['oc_display_text'] ); ?></span>
					</a>
				</div>
			<?php } ?>
		</div>

		<?php if ( $has_overlay ) { ?>
			<div class='oc-offcanvas__wrapper-overlay'></div>
		<?php }
		ob_start(); ?>
		<div id="offcanvas_<?php echo esc_attr( $id ); ?>" class="oc-offcanvas__wrapper-canvas elementor-<?php echo esc_attr( $main_id ); ?>" role='dialog' aria-labelledby="modal-<?php echo esc_attr( $id ); ?>" aria-modal='true'>
			<div class="elementor-element elementor-element-<?php echo esc_attr( $id ); ?>">
				<div class='oc-offcanvas__canvas-header'>
					<div class='oc-offcanvas__canvas-close'><a class='oc-first-element' href='#' aria-label="<?php esc_html_e( 'Close off-canvas', 'eac-components' ); ?>">X</a></div>
					<div class='oc-offcanvas__canvas-title'>
						<span id="modal-<?php echo esc_attr( $id ); ?>"><?php echo esc_html( $settings['oc_content_title'] ); ?></span>
					</div>
				</div>
				<div id='oc-offcanvas__canvas-content' class='oc-offcanvas__canvas-content'>
					<?php if ( 'texte' === $content ) { ?>
						<div class='oc-offcanvas__content-text'><?php echo wp_kses_post( $texte ); ?></div>
					<?php } elseif ( 'tmpl_cont' === $content ) {
						if ( get_the_ID() === (int) $tmplcont ) {
							esc_html_e( 'The Template ID cannot be the same as the currently edited template', 'eac-components' );
						} else {
							$tmplcont = apply_filters( 'wpml_object_id', $tmplcont, Source_Local::CPT, true );
							echo \Elementor\Plugin::$instance->frontend->get_builder_content_for_display( $tmplcont ); // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
						}
					} elseif ( 'tmpl_sec' === $content ) {
						if ( get_the_ID() === (int) $tmplsec ) {
							esc_html_e( 'The Template ID cannot be the same as the currently edited template', 'eac-components' );
						} else {
							$tmplsec = apply_filters( 'wpml_object_id', $tmplsec, Source_Local::CPT, true );
							echo \Elementor\Plugin::$instance->frontend->get_builder_content_for_display( $tmplsec ); // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
						}
					} elseif ( 'tmpl_page' === $content ) {
						if ( get_the_ID() === (int) $tmplpage ) {
							esc_html_e( 'The Template ID cannot be the same as the currently edited template', 'eac-components' );
						} else {
							$tmplpage = apply_filters( 'wpml_object_id', $tmplpage, Source_Local::CPT, true );
							echo \Elementor\Plugin::$instance->frontend->get_builder_content_for_display( $tmplpage ); // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
						}
					} elseif ( 'form' === $content ) {
						echo do_shortcode( shortcode_unautop( $short_code ) );
					} elseif ( 'menu' === $content ) {
						$args = array(
							'menu'            => $menu,
							'container_class' => 'oc-offcanvas__menu-wrapper',
							'depth'           => absint( $settings['oc_content_menu_level'] ),
						);
						// Affiche le menu
						wp_nav_menu( $args );
					} else {
						foreach ( $widget_classes as $widget_class ) {
							$args                    = array(
								'before_title' => '<h3 class="widgettitle">',
								'after_title'  => '</h3>',
							);
							$instance                = array();
							list($classname, $title) = array_pad( explode( '::', $widget_class ), 2, '' );

							// Widgets standards
							if ( empty( $title ) ) {
								if ( 'WP_Widget_Calendar' === $classname ) {
									$instance = array( 'title' => esc_html__( 'Calendar', 'eac-components' ) );
								} elseif ( 'WP_Widget_Search' === $classname ) {
									$instance = array( 'title' => esc_html__( 'Search', 'eac-components' ) );
								} elseif ( 'WP_Widget_Tag_Cloud' === $classname ) {
									$instance = array( 'title' => esc_html__( 'Tags cloud', 'eac-components' ) );
								} elseif ( 'WP_Widget_Recent_Posts' === $classname ) {
									$instance = array( 'title' => esc_html__( 'Recent posts', 'eac-components' ) );
								} elseif ( 'WP_Widget_Recent_Comments' === $classname ) {
									$instance = array( 'title' => esc_html__( 'Last comments', 'eac-components' ) );
								} elseif ( 'WP_Widget_RSS' === $classname ) {
									$instance = array(
										'title' => esc_html__( 'RSS feeds', 'eac-components' ),
										'url'   => get_bloginfo( 'rss2_url' ),
									);
								} elseif ( 'WP_Widget_Pages' === $classname ) {
									$instance = array( 'title' => esc_html__( 'Pages', 'eac-components' ) );
								} elseif ( 'WP_Widget_Archives' === $classname ) {
									$instance = array( 'title' => esc_html__( 'Archives', 'eac-components' ) );
								} elseif ( 'WP_Widget_Meta' === $classname ) {
									$instance = array( 'title' => 'Meta' );
								} elseif ( 'WP_Widget_Categories' === $classname ) {
									$instance = array( 'title' => esc_html__( 'Categories', 'eac-components' ) );
								}
								// Affiche le widget
								the_widget( $classname, $instance, $args );
							} else {
								dynamic_sidebar( $classname );
							}
						}
					} ?>
				</div>
			</div>
		</div>

		<?php
		echo ob_get_clean(); // phpcs:disable WordPress.Security.EscapeOutput
	}

	/**
	 * get_settings_json
	 *
	 * Retrieve fields values to pass at the widget container
	 * Convert on JSON format
	 * Modification de la règles 'data_filtre'
	 *
	 * @uses         wp_json_encode()
	 *
	 * @return   JSON oject
	 *
	 * @access   protected
	 */
	protected function get_settings_json(): string {
		$module_settings = $this->get_settings_for_display();

		$settings = array(
			'data_id'        => esc_attr( $this->get_id() ),
			'data_canvas_id' => 'offcanvas_' . esc_attr( $this->get_id() ),
			'data_position'  => $module_settings['oc_content_position'],
		);

		return wp_json_encode( $settings );
	}

	protected function content_template(): void {}
}
