<?php
   
$wp_customize->add_section(new constructionarc_Toggle_Section($wp_customize, 'constructionarc_top_header', array(
    'title' =>	esc_html__('Top Header','construction-arc'),
    'panel' => 'constructionarc_header_settings',
    'hiding_control' => 'constructionarc_top_header_enable'
)));
$wp_customize->add_setting('constructionarc_top_header_nav', array(
    'transport' => 'postMessage',
    'sanitize_callback' => 'wp_kses_post',
));
$wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_top_header_nav', array(
    'type' => 'tab',
    'section' => 'constructionarc_top_header',
    'buttons' => array(
        array(
            'name' => esc_html__('Content', 'construction-arc'),
            'fields' => array(
                'constructionarc_top_header_hide_show',
                'constructionarc_topheader_left',
                'constructionarc_topheader_right',
                'constructionarc_topheader_social_link',
                'constructionarc_top_header_quick_content',
                'constructionarc_topheader_free_hand',
            ),
            'active' => true,
        ),
        array(
            'name' => esc_html__('Style', 'construction-arc'),
            'fields' => array(
                'constructionarc_th_bg_color',
                'constructionarc_topheader_social_color_link'
            ),
        ),
        array(
            'name' => esc_html__("Advance", 'construction-arc'),
            'fields' => array(
            )
        )
    ),
)));

$wp_customize->add_setting( 'constructionarc_top_header_hide_show',
    array(
        'default' => json_encode(array(
            'desktop' => 'show',
            'tablet' => 'show',
            'mobile' => 'hide'
        )),
        'sanitize_callback' => 'constructionarc_themes_sanitize_field_responsive_buttonset',
        'transport'         => 'postMessage',
    )
);
$wp_customize->add_control(new constructionarc_Custom_Control_Responsive_Buttonset( $wp_customize, 'constructionarc_top_header_hide_show',
        array(
            'choices'  => array(
                'show' => esc_html__( 'Show', 'construction-arc' ),
                'hide' => esc_html__( 'Hide', 'construction-arc' ),
            ),
            'label'    => esc_html__( 'Top Header', 'construction-arc' ),
            'section' => 'constructionarc_top_header',
        )
    )
);
    
$wp_customize->add_setting('constructionarc_topheader_left', array(
    'default' => 'quick_contact',
    'transport' => 'postMessage',
    'sanitize_callback' => 'constructionarc_themes_sanitize_select'        
));
$wp_customize->add_control('constructionarc_topheader_left', array(
    'label' => esc_html__('Left Side Top Header', 'construction-arc'),
    'section' => 'constructionarc_top_header',
    'type' => 'select',
    'choices' => array(
        'none' => esc_html__('None', 'construction-arc'),
        'quick_contact' => esc_html__('Quick Contact Information', 'construction-arc'),
        'top_menu'  => esc_html__('Top Menu Nav', 'construction-arc'),
        'free_hand'  => esc_html__('Free Hand', 'construction-arc'),
    )
));

$wp_customize->add_setting('constructionarc_topheader_right', array(
    'default' => 'social_media',
    'transport' => 'postMessage',
    'sanitize_callback' => 'constructionarc_themes_sanitize_select'        
));
$wp_customize->add_control('constructionarc_topheader_right', array(
    'label' => esc_html__('Right Side Top Header', 'construction-arc'),
    'section' => 'constructionarc_top_header',
    'type' => 'select',
    'choices' => array(
        'none' => esc_html__('None', 'construction-arc'),
        'social_media'  => esc_html__('Social Media Links', 'construction-arc'),
        'top_menu'  => esc_html__('Top Menu Nav', 'construction-arc'),
    )
));

$wp_customize->selective_refresh->add_partial( 'constructionarc_topheader_right', array (
    'settings' => array( 
        'constructionarc_topheader_right',
        'constructionarc_topheader_left',
        'constructionarc_topheader_free_hand',
    ),
    'selector' => '#masthead',
    'fallback_refresh' => true,
    'render_callback' => function () {
        $layout = get_theme_mod('constructionarc_header_layout','layout_two');
        return get_template_part('header/header', str_replace("layout_","", $layout));
    }
));

$wp_customize->add_setting('constructionarc_topheader_social_link', array(
    'sanitize_callback' => 'sanitize_text_field'
));
$wp_customize->add_control(new constructionarc_Info_Text($wp_customize, 'constructionarc_topheader_social_link', array(
    'label' => esc_html__('Social Links', 'construction-arc'),
    'section' => 'constructionarc_top_header',
    'description' => sprintf(esc_html__('Add your %1$s here', 'construction-arc'), '<a href="#" target="_blank">Social Links</a>')
)));

$wp_customize->add_setting('constructionarc_top_header_quick_content', array(
    'transport' => 'postMessage',
    'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',
    'default' => json_encode(array(
        array(
            'icon' => 'fa-solid fa-headset',
            'label' => '',
            'val' => '+01-555-555-5555',
            'enable' => 'enable'
        ),
        array(
            'icon' => 'fa-regular fa-envelope-open',
            'label' => '',
            'val' => 'example@example.com',
            'enable' => 'enable'
        ),
        array(
            'icon' => 'fas fa-map-marker-alt',
            'label' => '',
            'val' => '123 Main Street, Springfield, USA',
            'enable' => 'enable'
        )
    ))
));
$wp_customize->add_control(new constructionarc_Themes_Repeater_Control($wp_customize, 'constructionarc_top_header_quick_content', array(
        'label' => esc_html__('Information', 'construction-arc'),
        'section' => 'constructionarc_top_header',
        'box_label' => esc_html__('Information Item', 'construction-arc'),
        'add_label' => esc_html__('Add New', 'construction-arc'),
        'sortable'	=> 'enable',
        'limit' => 3,
    ), 
    array(
        'icon' => array(
            'type' => 'icon',
            'label' => esc_html__('Icon', 'construction-arc'),
            'default' => ''
        ),
        'label' => array(
            'type' => 'text',
            'label' => esc_html__('Label', 'construction-arc'),
            'default' => ''
        ),
        'val' => array(
            'type' => 'text',
            'label' => esc_html__('Value', 'construction-arc'),
            'default' => ''
        ),			
        'enable' => array(
            'type' => 'switch',
            'label' => esc_html__('Enable', 'construction-arc'),
            'switch' => array(
                'enable' => esc_html__('Yes', 'construction-arc'),
                'disable' => esc_html__('No', 'construction-arc')
            ),
            'default' => 'enable'
        )
    )
));

$wp_customize->selective_refresh->add_partial( 'constructionarc_top_header_quick_content', array (
    'settings' => array( 
        'constructionarc_top_header_quick_content' 
    ),
    'selector' => '.constructionarc-quick-info',
    'container_inclusive' => true,
    'fallback_refresh' => false,
    'render_callback' => function () {
        return constructionarc_themes_quick_contact();
    }
));

$wp_customize->add_setting('constructionarc_topheader_free_hand', array(
    'sanitize_callback' => 'constructionarc_themes_sanitize_text',
    'default' => esc_html__('Need Any Help: +1-555-555-5555 or example@example.com', 'construction-arc'),
    'transport' => 'postMessage'
));
$wp_customize->add_control('constructionarc_topheader_free_hand', array(
    'label' => esc_html__('Free hand', 'construction-arc'),
    'section' => 'constructionarc_top_header',
    'type' => 'textarea'
));

$wp_customize->add_setting('constructionarc_th_bg_color', array(
    'default' => '',
    'transport' => 'postMessage',
    'sanitize_callback' => 'constructionarc_themes_sanitize_color_alpha',
));
$wp_customize->add_control(new constructionarc_Alpha_Color_Control($wp_customize, 'constructionarc_th_bg_color', array(
    'label' => esc_html__('Background', 'construction-arc'),
    'section' => 'constructionarc_top_header',
)));

$wp_customize->add_setting('constructionarc_topheader_social_color_link', array(
    'sanitize_callback' => 'sanitize_text_field'
));
$wp_customize->add_control(new constructionarc_Info_Text($wp_customize, 'constructionarc_topheader_social_color_link', array(
    'label' => esc_html__('Social Colors', 'construction-arc'),
    'section' => 'constructionarc_top_header',
    'description' => sprintf(esc_html__('Customize your %s here', 'construction-arc'), '<a href="#" target="_blank">Social Colors</a>')
)));


$wp_customize->add_setting('constructionarc_pro_top_header', array(
    'sanitize_callback' => 'constructionarc_sanitize_text'
));
$wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_top_header', array(
    'section' => 'constructionarc_top_header',
    'label' => esc_html__('For More Settings,', 'construction-arc'),
    'choices' => array(
        esc_html__('Advanced user friendly customizer', 'construction-arc'),
        esc_html__('Toggle visibility in variant device', 'construction-arc'),
        esc_html__('Background & gradient color', 'construction-arc'),
        esc_html__('Change text and link color', 'construction-arc'),
        esc_html__('Customize margin & padding', 'construction-arc'),
    ),
    'priority' => 250,
)));