<?php
    /**
     * Dark Mode Section
     * 
     * @package Blog Bee
     * @since 1.0.0
     */
    namespace BBE\Customizer\Section;

    use BBE\Customizer\Section\Section as Section;
    use BBE\Customizer\Section\Main_Banner_Left as Main_Banner_Left;
    use BBE\Customizer\Section\Main_Banner_Right as Main_Banner_Right;
    use BBE\Customizer\Theme_Defaults as Theme_Defaults;
    use BBE\Helpers;
    use WP_Query;
    use BBE\Query_Manager as Query_Manager;

    use function esc_html__;
    use function get_template_directory_uri;
    use function esc_attr;
    use function wp_reset_postdata;

    if( ! class_exists( __NAMESPACE__ . '\\Main_Banner' ) ) {
        /**
         * Dark Mode class
         */
        class Main_Banner extends Section {
            /**
             * Section Id
             * 
             * @since 1.0.0
             * @var string
             */
            public static $id = 'bbe-main-banner';

            /**
             * Register controls
             * 
             * @since 1.0.0
             */
            public function register_controls() {
                $this->tab = 'general';
                $this->add_section( 'main_banner_section' );
                $this->add_control( 'main_banner_section_tab' );
                $this->add_control( 'main_banner_reorder' );
                $this->add_control( 'main_banner_left_redirect' );
                $this->add_control( 'main_banner_right_redirect' );
                $this->add_control( 'main_banner_layouts' );
                $this->add_control( 'main_banner_position' );
                $this->add_control( 'main_banner_content_alignment' );
                $this->add_control( 'main_banner_container' );
                $this->add_control( 'main_banner_post_query_settings' );
                $this->add_control( 'main_banner_post_source' );
                $this->add_control( 'main_banner_categories' );
                $this->add_control( 'main_banner_posts_to_include' );
                $this->add_control( 'main_banner_number_of_posts' );
                $this->add_control( 'main_banner_orderby' );
                $this->add_control( 'main_banner_hide_no_featured' );
                $this->add_control( 'main_banner_post_elements_settings' );
                $this->add_control( 'main_banner_element_reorder' );
                $this->add_control( 'main_banner_meta_reorder' );
                $this->add_control( 'main_banner_image_settings' );
                $this->add_control( 'main_banner_image_sizes' );
                $this->tab = 'design';
                $this->add_control( 'main_banner_post_title_typography' );
                $this->add_control( 'main_banner_section_background' );
            }

            /**
             * Settings
             * 
             * @since 1.0.0
             */
            public function get_settings( $id = '' ) {
                $settings = [
                    'main_banner_section_tab' =>  [
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_layouts' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_radio_image' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_reorder' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_reorder' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_left_redirect' =>  [
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_right_redirect' =>  [
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_position' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_select' ],
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_content_alignment' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_radio_tab' ],
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_container' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_select' ],
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_post_query_settings' =>  [
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_post_source' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_select' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_categories' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_async_multiselect' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_tags' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_async_multiselect' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_authors' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_async_multiselect' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_posts_to_include' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_async_multiselect' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_number_of_posts' =>  [
                        'sanitize_callback' =>  'absint',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_posts_offset' =>  [
                        'sanitize_callback' =>  'absint',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_orderby' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_select' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_hide_no_featured' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_toggle' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_post_elements_settings' =>  [
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_element_reorder' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_reorder' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_meta_reorder' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_reorder' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_image_settings' =>  [
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_image_sizes' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_select' ],
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_post_title_typography' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_typography' ],
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                    'main_banner_section_background' =>  [
                        'sanitize_callback' =>  [ $this, 'sanitize_color' ],
                        'transport' =>  'postMessage',
                        'default'   =>  Theme_Defaults::get_defaults( $id )
                    ],
                ];
                return $id ? $settings[ $id ] : $settings;
            }

            /**
             * Controls
             * 
             * @since 1.0.0
             */
            public function get_controls( $id = '' ) {
                $controls = [
                    'main_banner_section' =>  [
                        'title' =>  esc_html__( 'Main Banner', 'blog-bee' ),
                        'active_callback'   =>  function() {
                            return Helpers::get_reorder_value( 'section_reorder_fields', 'main-banner' );
                        },
                        'section_to_open' =>  'section_reorder_section'
                    ],
                    'main_banner_section_tab' =>  [
                        'type'  =>  'section-tab',
                        'fields'    =>  Helpers::get_customizer_section_tabs()
                    ],
                    'main_banner_reorder' =>  [
                        'label' =>  esc_html__( 'Reorder', 'blog-bee' ),
                        'type'  =>  'reorder',
                        'direction' =>  'horizontal',
                        'fields'    =>  [
                            [
                                'label' =>  esc_html__( 'Left', 'blog-bee' ),
                                'value' =>  'left',
                                'allow_visibility'  =>  true
                            ],
                            [
                                'label' =>  esc_html__( 'Main', 'blog-bee' ),
                                'value' =>  'main',
                                'allow_visibility'  =>  false
                            ],
                            [
                                'label' =>  esc_html__( 'Right', 'blog-bee' ),
                                'value' =>  'right',
                                'allow_visibility'  =>  true
                            ],
                        ]
                    ],
                    'main_banner_left_redirect' =>  [
                        'label' =>  esc_html__( 'Edit Left Sidebar', 'blog-bee' ),
                        'type'  =>  'redirect',
                        'section_to_expand' =>  'main_banner_left_section',
                        'active_callback'   =>  function(){
                            return Helpers::get_reorder_value( 'main_banner_reorder', 'left' );
                        }
                    ],
                    'main_banner_right_redirect' =>  [
                        'label' =>  esc_html__( 'Edit Right Sidebar', 'blog-bee' ),
                        'type'  =>  'redirect',
                        'section_to_expand' =>  'main_banner_right_section',
                        'active_callback'   =>  function(){
                            return Helpers::get_reorder_value( 'main_banner_reorder', 'right' );
                        }
                    ],
                    'main_banner_layouts' =>  [
                        'label' =>  esc_html__( 'Main Layouts', 'blog-bee' ),
                        'type'  =>  'radio-image',
                        'fields'    =>  [
                            [
                                'label' =>  esc_html__( 'Layout 1', 'blog-bee' ),
                                'value' =>  'one',
                                'url'   =>  get_template_directory_uri() . '/inc/customizer/assets/images/main_banner_one.webp'
                            ],
                            [
                                'label' =>  esc_html__( 'Layout 2', 'blog-bee' ),
                                'value' =>  'two',
                                'url'   =>  get_template_directory_uri() . '/inc/customizer/assets/images/main_banner_two.webp'
                            ],
                        ]
                    ],
                    'main_banner_position' =>  [
                        'label' =>  esc_html__( 'Content Position', 'blog-bee' ),
                        'type'  =>  'bbe-select',
                        'choices'    =>  [
                            'top-left'  =>  esc_html__( 'Top Left', 'blog-bee' ),
                            'top-center'    =>  esc_html__( 'Top Center', 'blog-bee' ),
                            'top-right' =>  esc_html__( 'Top Right', 'blog-bee' ),
                            'center-left'   =>  esc_html__( 'Center Left', 'blog-bee' ),
                            'center-center' =>  esc_html__( 'Center Center', 'blog-bee' ),
                            'center-right'  =>  esc_html__( 'Center Right', 'blog-bee' ),
                            'bottom-left'   =>  esc_html__( 'Bottom Left', 'blog-bee' ),
                            'bottom-center' =>  esc_html__( 'Bottom Center', 'blog-bee' ),
                            'bottom-right'  =>  esc_html__( 'Bottom Right', 'blog-bee' ),
                        ],
                        'conditions'    =>  [
                            'relation'  =>  'AND',
                            'rules' =>  [
                                [
                                    'setting'   =>  'main_banner_layouts',
                                    'operator'  =>  'in',
                                    'value' =>  [ 'one', 'four' ]
                                ]
                            ]
                        ]
                    ],
                    'main_banner_content_alignment' =>  [
                        'label' =>  esc_html__( 'Content Alignment', 'blog-bee' ),
                        'type'  =>  'radio-tab',
                        'fields'    =>  Helpers::get_customizer_alignments(),
                        'conditions'    =>  [
                            'relation'  =>  'AND',
                            'rules' =>  [
                                [
                                    'setting'   =>  'main_banner_layouts',
                                    'operator'  =>  'in',
                                    'value' =>  [ 'two', 'three' ]
                                ]
                            ]
                        ]
                    ],
                    'main_banner_container' =>  [
                        'label' =>  esc_html__( 'Container', 'blog-bee' ),
                        'type'  =>  'bbe-select',
                        'choices'    =>  Helpers::get_card_options()
                    ],
                    'main_banner_post_query_settings' =>  [
                        'label' =>  esc_html__( 'Post Query Settings', 'blog-bee' ),
                        'type'  =>  'heading-toggle'
                    ],
                    'main_banner_post_source' =>  [
                        'label' =>  esc_html__( 'Post Source', 'blog-bee' ),
                        'type'  =>  'bbe-select',
                        'choices'   =>  [
                            'latest'    =>  esc_html__( 'Latest', 'blog-bee' ),
                            'categories'    =>  esc_html__( 'Category', 'blog-bee' ),
                            'manual'    =>  esc_html__( 'Manual', 'blog-bee' ),
                        ]
                    ],
                    'main_banner_categories' =>  [
                        'label' =>  esc_html__( 'Post Categories', 'blog-bee' ),
                        'type'  =>  'async-multiselect',
                        'endpoint'  =>  'get_taxonomy',
                        'purpose'   =>  'category',
                        'conditions'    =>  [
                            'relation'  =>  'AND',
                            'rules' =>  [
                                [
                                    'setting'   =>  'main_banner_post_source',
                                    'operator'  =>  '==',
                                    'value' =>  'categories'
                                ]
                            ]
                        ]
                    ],
                    'main_banner_posts_to_include' =>  [
                        'label' =>  esc_html__( 'Post to Include', 'blog-bee' ),
                        'type'  =>  'async-multiselect',
                        'endpoint'  =>  'get_posts',
                        'purpose'   =>  'post',
                        'conditions'    =>  [
                            'relation'  =>  'AND',
                            'rules' =>  [
                                [
                                    'setting'   =>  'main_banner_post_source',
                                    'operator'  =>  '==',
                                    'value' =>  'manual'
                                ]
                            ]
                        ]
                    ],
                    'main_banner_number_of_posts' =>  [
                        'label' =>  esc_html__( 'Number of posts', 'blog-bee' ),
                        'type'  =>  'bbe-number',
                        'show_unit' =>  false,
                        'input_attrs'   =>  [
                            'min'   =>  1,
                            'max'   =>  15,
                            'step'  =>  1
                        ]
                    ],
                    'main_banner_orderby' =>  [
                        'label' =>  esc_html__( 'Order By', 'blog-bee' ),
                        'type'  =>  'bbe-select',
                        'choices'   =>  Helpers::get_order_by()
                    ],
                    'main_banner_hide_no_featured' =>  [
                        'label' =>  esc_html__( 'Hide Posts With No Featured Image', 'blog-bee' ),
                        'type'  =>  'toggle-button'
                    ],
                    'main_banner_post_elements_settings' =>  [
                        'label' =>  esc_html__( 'Post Elements Settings', 'blog-bee' ),
                        'type'  =>  'heading-toggle'
                    ],
                    'main_banner_element_reorder' =>  [
                        'label' =>  esc_html__( 'Element Reorder', 'blog-bee' ),
                        'type'  =>  'reorder',
                        'fields'    =>  [
                            [
                                'label' =>  esc_html__( 'Title', 'blog-bee' ),
                                'value' =>  'title',
                                'allow_visibility'  =>  true
                            ],
                            [
                                'label' =>  esc_html__( 'Excerpt', 'blog-bee' ),
                                'value' =>  'excerpt',
                                'allow_visibility'  =>  true
                            ],
                            [
                                'label' =>  esc_html__( 'Meta', 'blog-bee' ),
                                'value' =>  'meta',
                                'allow_visibility'  =>  true
                            ],
                            [
                                'label' =>  esc_html__( 'Read More', 'blog-bee' ),
                                'value' =>  'read-more',
                                'allow_visibility'  =>  true
                            ],
                            [
                                'label' =>  esc_html__( 'Categories', 'blog-bee' ),
                                'value' =>  'categories',
                                'allow_visibility'  =>  true
                            ],
                        ]
                    ],
                    'main_banner_meta_reorder' =>  [
                        'label' =>  esc_html__( 'Meta Reorder', 'blog-bee' ),
                        'type'  =>  'reorder',
                        'fields'    =>  [
                            [
                                'label' =>  esc_html__( 'Author', 'blog-bee' ),
                                'value' =>  'author',
                                'allow_visibility'  =>  true
                            ],
                            [
                                'label' =>  esc_html__( 'Comments', 'blog-bee' ),
                                'value' =>  'comments',
                                'allow_visibility'  =>  true
                            ],
                            [
                                'label' =>  esc_html__( 'Read Time', 'blog-bee' ),
                                'value' =>  'read-time',
                                'allow_visibility'  =>  true
                            ],
                            [
                                'label' =>  esc_html__( 'Date', 'blog-bee' ),
                                'value' =>  'date',
                                'allow_visibility'  =>  true
                            ],
                        ]
                    ],
                    'main_banner_image_settings' =>  [
                        'label' =>  esc_html__( 'Image Settings', 'blog-bee' ),
                        'type'  =>  'heading-toggle'
                    ],
                    'main_banner_image_sizes' =>  [
                        'label' =>  esc_html__( 'Image Sizes', 'blog-bee' ),
                        'type'  =>  'bbe-select',
                        'choices'   =>  Helpers::get_customizer_image_sizes()
                    ],
                    'main_banner_post_title_typography' =>  [
                        'label' =>  esc_html__( 'Post Title Typo', 'blog-bee' ),
                        'type'  =>  'typography'
                    ],
                    'main_banner_section_background'    =>  [
                        'label' =>  esc_html__( 'Section Background', 'blog-bee' ),
                        'type'  =>  'bbe-color',
                        'color_types'   =>  [ 'solid', 'gradient', 'image' ]
                    ],
                ];
                return $id ? $controls[ $id ] : $controls;
            }

            /**
             * Defaults
             * 
             * @since 1.0.0
             */
            public function set_defaults() {
                Theme_Defaults::update_theme_defaults( [
                    'main_banner_section_tab' =>  'general',
                    'main_banner_reorder' =>  [
                        [
                            'id'  =>  'left',
                            'value' =>  true
                        ],
                        [
                            'id'  =>  'main',
                            'value' =>  true
                        ],
                        [
                            'id'  =>  'right',
                            'value' =>  true
                        ]
                    ],
                    'main_banner_left_redirect' =>  '',
                    'main_banner_right_redirect' =>  '',
                    'main_banner_layouts' =>  'two',
                    'main_banner_position' =>  'bottom-left',
                    'main_banner_content_alignment' =>  'center',
                    'main_banner_container' =>  'default',
                    'main_banner_post_query_settings' =>  false,
                    'main_banner_post_source' =>  'latest',
                    'main_banner_categories' =>  [],
                    'main_banner_posts_to_include' =>  [],
                    'main_banner_number_of_posts' =>  5,
                    'main_banner_orderby' =>  'date-desc',
                    'main_banner_hide_no_featured' =>  false,
                    'main_banner_post_elements_settings' =>  false,
                    'main_banner_element_reorder' =>  [
                        [
                            'id'  =>  'categories',
                            'value' =>  true
                        ],
                        [
                            'id'  =>  'title',
                            'value' =>  true
                        ],
                        [
                            'id'  =>  'excerpt',
                            'value' =>  true
                        ],
                        [
                            'id'  =>  'meta',
                            'value' =>  true
                        ],
                        [
                            'id'  =>  'read-more',
                            'value' =>  true
                        ]
                    ],
                    'main_banner_meta_reorder' =>  [
                        [
                            'id'    =>  'author',
                            'value' =>  true
                        ],
                        [
                            'id'    =>  'comments',
                            'value' =>  true
                        ],
                        [
                            'id'    =>  'read-time',
                            'value' =>  true
                        ],
                        [
                            'id'    =>  'date',
                            'value' =>  true
                        ]
                    ],
                    'main_banner_excerpt_length' =>  25,
                    'main_banner_slider_settings' =>  false,
                    'main_banner_slider_toggles'  =>  [
                        'arrows' =>  true,
                        'fade'  =>  true,
                        'autoplay'  =>  true,
                        'dots'  =>  false,
                    ],
                    'main_banner_slide_direction' =>  'horizontal',
                    'main_banner_speed' =>  300,
                    'main_banner_image_settings' =>  false,
                    'main_banner_image_sizes' =>  'bbe_featured_large',
                    'main_banner_image_ratio' =>  'initial',
                    'main_banner_width_layout' =>  'boxed',
                    'main_banner_post_title_typography' =>  $this->get_typography([
                        'font_weight'   =>  '600',
                        'font_size' =>  $this->get_responsive( '32px', '32px', '32px' ),
                        'line_height' =>  $this->get_responsive( 1.3, 1.3, 1.3 ),
                        'letter_spacing'    =>  $this->get_responsive( '-0.32', '-0.32', '-0.32' )
                    ]),
                    'main_banner_' =>  '0px',
                    'main_banner_border_radius' =>  '0px',
                    'main_banner_section_background'    =>  $this->get_color( [ 'value' => '' ] ),
                    'main_banner_gap'    =>  '30px',
                ] );
            }

            /**
             * Get dynamic css args
             * 
             * @since 1.0.0
             */
            public function get_dynamic_css_args(): array {
                if( ! Helpers::get_reorder_value( 'section_reorder_fields', 'main-banner' ) ) return [];
                $dynamic_args = [
                    'main_banner_position' =>  [
                        'selector'  =>  '.bbe-main-banner',
                        'prefix'    =>  'position--'
                    ],
                    'main_banner_content_alignment' =>  [
                        'selector'  =>  '.bbe-main-banner .bbe-main-banner-main',
                        'prefix'    =>  'align--'
                    ],
                    'main_banner_container' =>  [
                        'selector'  =>  '.bbe-main-banner',
                        'prefix'    =>  'card--'
                    ],
                    'main_banner_post_title_typography' =>  [
                        'value' =>  Theme_Defaults::get_theme_option( 'main_banner_post_title_typography' ),
                        'default' =>  Theme_Defaults::get_defaults( 'main_banner_post_title_typography' ),
                        'selector'  =>  'body .site .bbe-main-banner .bbe-main-banner-main .bbe-article .entry-title, body .site .bbe-main-banner .bbe-main-banner-main .bbe-article .entry-title a'
                    ],
                    'main_banner_section_background'    =>  [
                        'value' =>  Theme_Defaults::get_theme_option( 'main_banner_section_background' ),
                        'default' =>  Theme_Defaults::get_defaults( 'main_banner_section_background' ),
                        'selector'  =>  '.bbe-light .bbe-main-banner',
                        'property'  =>  '--bbe-site-bg-color'
                    ],
                ];
                return $dynamic_args;
            }

            /**
             * Query instance
             * 
             * @since 1.0.0
             */
            private function get_query_instance() {
                $query_attrs = [
                    'posts_per_page'    =>  'main_banner_number_of_posts',
                    'orderby'   =>  'main_banner_orderby',
                    'hide_featured' =>  'main_banner_hide_no_featured',
                    'cat'   =>  'main_banner_categories',
                    'post__in'  =>  'main_banner_posts_to_include',
                    'post_source'  =>  'main_banner_post_source',
                ];
                $query_instance = Query_Manager::fine_tune_query_attrs( $query_attrs );
                return $query_instance;
            }

            /**
             * Render HTML
             * 
             * @since 1.0.0
             */
            public function render_html() {
                if( ! $this->get_query_instance()->have_posts() ) return;
                
                $block_class[] = self::$id;
                $layouts = Theme_Defaults::get_theme_option( 'main_banner_layouts' );
                $block_class[] = 'layout--' . $layouts;
                $block_class[] = 'card--' . Theme_Defaults::get_theme_option( 'main_banner_container' );
                if( in_array( $layouts, [ 'one', 'four' ] ) ) $block_class[] = 'position--' . Theme_Defaults::get_theme_option( 'main_banner_position' );
                $block_class[] = 'width--' . Theme_Defaults::get_theme_option( 'main_banner_width_layout' );

                $main_banner_reorder = Theme_Defaults::get_theme_option( 'main_banner_reorder' );
                $is_layout_three = ( $layouts === 'three' );
                ?>
                    <section id="<?php echo esc_attr( self::$id ); ?>" class="<?php echo esc_attr( implode( ' ', $block_class ) ); ?>" <?php Helpers::the_aos_data_attr(); ?>>
                        
                        <div class="bbe-container">

                            <div class="row">

                                <div class="block-wrap">

                                    <?php

                                        if( ! empty( $main_banner_reorder ) && is_array( $main_banner_reorder ) ) :

                                            foreach( $main_banner_reorder as $block ) :

                                                if( ! $block[ 'value' ] ) continue;

                                                switch( $block[ 'id' ] ) :

                                                    case 'left':
                                                            Main_Banner_Left::get_instance()->render_html();
                                                        break;
                                                        
                                                    case 'right':
                                                            Main_Banner_Right::get_instance()->render_html();
                                                        break;

                                                    default: 
                                                            if( $is_layout_three ) echo '<div class="slider-content-wrap"><div class="slider-content-inner-wrap">';

                                                            $this->main_content();

                                                            if( $is_layout_three ) :

                                                                $this->slider_sidebar();
                                                                
                                                                echo '</div><!-- .slider-content-inner-wrap -->';
                                                                echo '<a href="#" rel="bookmark" class="banner-overlay" aria-label="' . __( 'Overlay', 'blog-bee' ) . '"></a>';
                                                                echo '</div><!-- .slider-content-wrap -->';

                                                            endif;
                                                        break;

                                                endswitch;

                                            endforeach;

                                        endif;

                                    ?>

                                </div>

                            </div>

                        </div>

                    </section><!-- .bbe-main-banner -->

                <?php
            }

            /**
             * Main content
             * 
             * @since 1.0.0
             */
            private function main_content() {
                $query_instance = $this->get_query_instance();
                $main_banner_element_reorder = Theme_Defaults::get_theme_option( 'main_banner_element_reorder' );
                $layouts = Theme_Defaults::get_theme_option( 'main_banner_layouts' );
                $is_layout_two = ( $layouts === 'two' );
                $block_class[] = 'bbe-main-banner-main';
                $block_class[] = 'middle-block';
                $block_class[] = 'ratio--' . Theme_Defaults::get_theme_option( 'main_banner_image_ratio' );
                if( in_array( $layouts, [ 'two', 'three' ] ) ) $block_class[] = 'align--' . Theme_Defaults::get_theme_option( 'main_banner_content_alignment' );

                $content_toggles = Theme_Defaults::get_theme_option( 'main_banner_slider_toggles' );
                $default_content_toggles = Theme_Defaults::get_defaults( 'main_banner_slider_toggles' );
                $arrows = isset( $content_toggles[ 'arrows' ] ) ? $content_toggles[ 'arrows' ] : $default_content_toggles[ 'arrows' ];
                ?>
                    <div class="<?php echo esc_attr( implode( ' ', $block_class ) ); ?>">

                        <div class="block-inner">
                            
                            <div class="entry-content slider-content">
    
                                <?php
        
                                    while( $query_instance->have_posts() ) : $query_instance->the_post();
        
                                        Query_Manager::get_opening_article_tag();
        
                                            Query_Manager::get_opening_figure_tag();
        
                                                Query_Manager::get_featured_image( Theme_Defaults::get_theme_option( 'main_banner_image_sizes' ), [ 'post_format' => false ] );
                                            
                                            if( $is_layout_two ) Query_Manager::get_closing_figure_tag();
        
                                                echo '<div class="entry-inner">';
        
                                                    if( ! empty( $main_banner_element_reorder ) && is_array( $main_banner_element_reorder ) ) {
        
                                                        foreach( $main_banner_element_reorder as $content ) {
                                                            
                                                            if( ! $content[ 'value' ] ) continue;
        
                                                            switch( $content[ 'id' ] ) {
                                                                case 'title':
                                                                        Query_Manager::get_title();
                                                                    break;
                                                                case 'excerpt':
                                                                        Query_Manager::get_excerpt( Theme_Defaults::get_theme_option( 'main_banner_excerpt_length' ) );
                                                                    break;
                                                                case 'meta':
                                                                        $this->get_meta_reorder();
                                                                    break;
                                                                case 'read-more':
                                                                        Query_Manager::get_read_more_button();
                                                                    break;
                                                                case 'categories':
                                                                        Query_Manager::get_categories();
                                                                    break;
                                                            }
        
                                                        }
        
                                                    }
                                                
                                                echo '</div>';
        
                                            if( ! $is_layout_two ) Query_Manager::get_closing_figure_tag();
        
                                        Query_Manager::get_closing_article_tag();
                                        
                                    endwhile;
        
                                    wp_reset_postdata();
        
                                ?>
        
                            </div><!-- .slider-content -->
        
                            <?php Helpers::get_slick_arrows( $arrows, true ); ?>

                        </div>

                    </div><!-- .bbe-main-banner-main -->
                <?php
            }

            /**
             * Layout four main slider sidebar
             * 
             * @since 1.0.0
             */
            private function slider_sidebar() {
                $query_instance = $this->get_query_instance();
                ?>
                    <div class="sidebar-content">

                        <?php

                            while( $query_instance->have_posts() ) : $query_instance->the_post();

                                Query_Manager::get_opening_article_tag();

                                    Query_Manager::get_opening_figure_tag();

                                        Query_Manager::get_featured_image( 'thumbnail', [ 'enable_link' => false ] );
                                    
                                    Query_Manager::get_closing_figure_tag();

                                    Query_Manager::get_title();

                                Query_Manager::get_closing_article_tag();
                                
                            endwhile;

                            wp_reset_postdata();

                        ?>

                    </div><!-- .sidebar-content -->
                <?php
            }

            /**
             * Get meta reorder
             * 
             * @since 1.0.0
             */
            private function get_meta_reorder() {
                $main_banner_meta_reorder = Theme_Defaults::get_theme_option( 'main_banner_meta_reorder' );

                if( ! empty( $main_banner_meta_reorder ) && is_array( $main_banner_meta_reorder ) ) {

                    echo '<div class="entry-meta">';

                        foreach( $main_banner_meta_reorder as $meta ) {
                            
                            if( ! $meta[ 'value' ] ) continue;

                            switch( $meta[ 'id' ] ) {
                                case 'author':
                                        Query_Manager::get_author();
                                    break;
                                case 'comments':
                                        Query_Manager::get_comments();
                                break;
                                case 'read-time':
                                        Query_Manager::get_read_time();
                                    break;
                                case 'date':
                                        Query_Manager::get_date();
                                    break;
                            }

                        }

                    echo '</div><!-- .entry-meta -->';

                }
            }
        }
        Main_Banner::get_instance();
    }