<?php
/**
 * Promo (Feautes Services) Section
*/
$wp_customize->add_section(new constructionarc_Toggle_Section($wp_customize, 'constructionarc_promoservice_section', array(
    'title' => esc_html__('Feature Services Section', 'construction-arc'),
    'panel' => 'constructionarc_frontpage_settings',
    'priority' => constructionarc_themes_get_section_position('constructionarc_promoservice_section'),
    'hiding_control' => 'constructionarc_promoservice_disable'
)));

//ENABLE/DISABLE FEATURES SERVIVE SECTION
$wp_customize->add_setting('constructionarc_promoservice_disable', array(
	'default' => 'enable',
	'transport' => 'postMessage',
	'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
));
$wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_promoservice_disable', array(
	'label' => esc_html__('Section', 'construction-arc'),
	'section' => 'constructionarc_promoservice_section',
	'switch_label' => array(
		'enable' => esc_html__('Enable', 'construction-arc'),
		'disable' => esc_html__('Disable', 'construction-arc'),
	),
	'class' => 'switch-section',
    'priority' => -1,
)));

    $wp_customize->add_setting('constructionarc_promoservice_nav', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'wp_kses_post',
    ));
    $wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_promoservice_nav', array(
        'type' => 'tab',
        'section' => 'constructionarc_promoservice_section',
        'priority' => 1,
        'buttons' => array(
            array(
                'name' => esc_html__('Content', 'construction-arc'),
                'fields' => array(
                    'constructionarc_promoservice_super_title',
                    'constructionarc_promoservice_title',
                    'constructionarc_promoservice_title_align',
                    'constructionarc_promoservice_title_style',
                    'constructionarc_promoservice_style',
                    'constructionarc_promoservice_type_heading',
                    'constructionarc_promoservice_show_image',
                    'constructionarc_promoservice_show_icon',
                    'constructionarc_promoservice',
                    'constructionarc_promo_service_icon',
                    'constructionarc_promoservice_type',
                    'constructionarc_promoservice_advance_settings'
                ),
                'active' => true,
            ),
            array(
                'name' => esc_html__('Style', 'construction-arc'),
                'fields' => array(
                    'constructionarc_promoservice_icon_style',
                ),
            ),
            array(
                'name' => esc_html__('Advanced', 'construction-arc'),
                'fields' => array(
                    'constructionarc_promoservice_bg_type',
                    'constructionarc_promoservice_bg_color',
                    'constructionarc_promoservice_bg_image',
                    'constructionarc_promoservice_overlay_color',
                    'constructionarc_promoservice_padding',
                    'constructionarc_promoservice_cs_seperator',
                ),
            ),
        ),
    )));

    $wp_customize->add_setting('constructionarc_promoservice_super_title', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control('constructionarc_promoservice_super_title', array(
        'section' => 'constructionarc_promoservice_section',
        'type' => 'text',
        'label' => esc_html__('Super Title', 'construction-arc')
    ));

    $wp_customize->add_setting('constructionarc_promoservice_title', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control('constructionarc_promoservice_title', array(
        'section' => 'constructionarc_promoservice_section',
        'type' => 'text',
        'label' => esc_html__('Title', 'construction-arc')
    ));

    $wp_customize->add_setting('constructionarc_promoservice_title_align', array(
        'default' => 'text-center',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Custom_Control_Buttonset($wp_customize,'constructionarc_promoservice_title_align',
        array(
            'choices'  => array(
                'text-left' => esc_html__('Left', 'construction-arc'),
                'text-right' => esc_html__('Right', 'construction-arc'),
                'text-center' => esc_html__('Center', 'construction-arc'),
            ),
            'label'    => esc_html__( 'Alignment', 'construction-arc' ),
            'section'  => 'constructionarc_promoservice_section',
            'settings' => 'constructionarc_promoservice_title_align',
        ))
    );

    $wp_customize->add_setting('constructionarc_promoservice_title_style', array(
        'default' => 'style1',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'         
    ));
    $wp_customize->add_control('constructionarc_promoservice_title_style', array(
        'section' => 'constructionarc_promoservice_section',
        'label'    => esc_html__( 'Section Title Style', 'construction-arc' ),
        'type'    => 'select',
        'choices' => array(
            'style1' => esc_html__('Style 1','construction-arc'),
            'style2' => esc_html__('Style 2','construction-arc'),			
            'style3' => esc_html__('Style 3','construction-arc'),			
        )
    ));


    $wp_customize->add_setting('constructionarc_promoservice_type_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control(new constructionarc_Customize_Heading($wp_customize, 'constructionarc_promoservice_type_heading', array(
        'section' => 'constructionarc_promoservice_section',
        'label' => esc_html__('Select Feature Services Type', 'construction-arc')
    )));

    $wp_customize->add_setting('constructionarc_promoservice_type', array(
        'default' => 'default',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'
    ));
    $wp_customize->add_control('constructionarc_promoservice_type', array(
        'section' => 'constructionarc_promoservice_section',
        'type' => 'radio',
        'choices' => array(
            'default' => esc_html__('Default', 'construction-arc'),
            'advance' => esc_html__('Advanced', 'construction-arc')
        )
    ));

    $wp_customize->add_setting('constructionarc_promoservice', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',		
        'default' => json_encode(array(
            array(
                'service_page' => '',
                'service_icon' =>'fa-solid fa-bezier-curve',
                'bg_color' => '',
                'color' => '',
                'alignment' => 'center',

            )
        ))
    ));
    $wp_customize->add_control(new constructionarc_Themes_Repeater_Control( $wp_customize, 
        'constructionarc_promoservice', 
        array(
            'label' 	   => esc_html__('Default Services Settings', 'construction-arc'),
            'section' 	   => 'constructionarc_promoservice_section',
            'settings' 	   => 'constructionarc_promoservice',
            'box_label' => esc_html__('Service', 'construction-arc'),
            'add_label' => esc_html__('Add New', 'construction-arc'),
            'limit' => 6,
        ),
        array(
            'service_page' => array(
                'type' => 'select',
                'label' => esc_html__('Select Page', 'construction-arc'),
                'options' => $pages
            ),
            'service_icon' => array(
                'type' => 'icon',
                'label' => esc_html__('Choose Icon', 'construction-arc'),
                'default' => 'fa-solid fa-bezier-curve'
            ),
            'bg_color' => array(
                'type'  => 'colorpicker',
                'label' => esc_html__( 'Background Color', 'construction-arc' ),
            ),
            'color' => array(
                'type'  => 'colorpicker',
                'label' => esc_html__( 'Color', 'construction-arc' ),
            ),
            'alignment' => array(
                'type' => 'select',
                'label' => esc_html__("Alignment", 'construction-arc'),
                'default' => 'center',
                'options' => array(
                    'start' => esc_html__('Left', 'construction-arc'),
                    'center' => esc_html__('Center', 'construction-arc'),
                    'end' => esc_html__('Right', 'construction-arc')
                )
            )
            
        )
    ));


    $id = "promoservice";
    $wp_customize->add_setting("constructionarc_{$id}_advance_settings", array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',		
        'default' => json_encode(array(
            array(
                'block_image'      => '',
                'block_icon'       => 'fa-solid fa-bezier-curve',
                'block_title'      => '',
                'block_desc'       => '',
                'button_text'      => '',
                'button_url'       => '',
                'block_bg_color'   => '',
                'block_color'      => '',
                'block_alignment'  => 'center',
            )
        ))
    ));
    $wp_customize->add_control(new constructionarc_Themes_Repeater_Control( $wp_customize, "constructionarc_{$id}_advance_settings", 
        array(
            'label' 	   => esc_html__('Advance Services Settings', 'construction-arc'),
            'section' 	   => "constructionarc_{$id}_section",
            'settings' 	   => "constructionarc_{$id}_advance_settings",
            'box_label' => esc_html__('Service Item', 'construction-arc'),
            'add_label' => esc_html__('Add New', 'construction-arc'),
            'limit' => 6,
        ),
        array(
            'block_image' => array(
                'type' => 'upload',
                'label' => __("Upload Image", 'construction-arc'),
            ),
            'block_icon' => array(
                'type' => 'icon',
                'label' => esc_html__('Choose Icon', 'construction-arc'),
                'default' => 'fa-solid fa-bezier-curve'
            ),
            'block_title' => array(
                'type' => 'text',
                'label' => __("Title", 'construction-arc'),
            ),
            'block_desc' => array(
                'type' => 'textarea',
                'label' => __("Short Description", 'construction-arc'),
            ),
            'button_text' => array(
                'type' => 'text',
                'label' => esc_html__('Button Text', 'construction-arc'),
                'default' => ''
            ),
            'button_url' => array(
                'type' => 'url',
                'label' => esc_html__('Button Url', 'construction-arc'),
                'default' => ''
            ),
            'block_bg_color' => array(
                'type'  => 'colorpicker',
                'label' => esc_html__( 'Background Color', 'construction-arc' ),
            ),
            'block_color' => array(
                'type'  => 'colorpicker',
                'label' => esc_html__( 'Color', 'construction-arc' ),
            ),
            'block_alignment' => array(
                'type' => 'select',
                'label' => esc_html__("Alignment", 'construction-arc'),
                'default' => 'center',
                'options' => array(
                    'start' => esc_html__('Left', 'construction-arc'),
                    'center' => esc_html__('Center', 'construction-arc'),
                    'end' => esc_html__('Right', 'construction-arc')
                )
            ),
        )
    ));

    $wp_customize->add_setting('constructionarc_promoservice_style', array(
        'sanitize_callback' => 'constructionarc_themes_sanitize_options',
        'default' => 'style1',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Selector($wp_customize, 'constructionarc_promoservice_style', array(
        'section' => 'constructionarc_promoservice_section',
        'label' => esc_html__('Choose Layout', 'construction-arc'),
        'options' => array(
            'style1' => get_template_directory_uri() . '/inc/customizer/images/fsc1.webp',
            'style2' => get_template_directory_uri() . '/inc/customizer/images/fsc2.webp',
        )
    )));

    $wp_customize->add_setting('constructionarc_promo_service_icon', array(
        'sanitize_callback' => 'sanitize_text_field',
        'default' => 0,
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Range_Control($wp_customize, 'constructionarc_promo_service_icon', array(
        'section' => 'constructionarc_promoservice_section',
        'label' => esc_html__('Margin Top', 'construction-arc'),
        'input_attrs' => array(
            'min' => -120,
            'max' => 120,
            'step' => 1,
        ),
    )));

    $wp_customize->add_setting('constructionarc_promoservice_show_image', array(
        'default' => 'enable',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_switch',     
    ));
    $wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_promoservice_show_image', array(
        'label' => esc_html__('Display Image', 'construction-arc'),
        'section' => 'constructionarc_promoservice_section',
        'switch_label' => array(
            'enable' => esc_html__('Yes', 'construction-arc'),
            'disable' => esc_html__('No', 'construction-arc'),
        )
    )));

    $wp_customize->add_setting('constructionarc_promoservice_show_icon', array(
        'default' => 'enable',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_switch',     
    ));
    $wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_promoservice_show_icon', array(
        'label' => esc_html__('Display Icon', 'construction-arc'),
        'section' => 'constructionarc_promoservice_section',
        'switch_label' => array(
            'enable' => esc_html__('Yes', 'construction-arc'),
            'disable' => esc_html__('No', 'construction-arc'),
        )
    )));
    
    $wp_customize->add_setting('constructionarc_promoservice_icon_style',
        array(
            'sanitize_callback' => 'constructionarc_themes_sanitize_field_background',
            'transport'     => 'postMessage',
            'default'       => json_encode(array(
                'padding'   => '',
                'radius'    => '',
                'borderwidth' => '',
                'bordercolor' => '',
                'iconsize' => '',
            )),
        )
    );
    $wp_customize->add_control( new constructionarc_Themes_Custom_Control_Group( $wp_customize, 'constructionarc_promoservice_icon_style',
        array(
            'label'    => esc_html__( 'Item Icon Settings', 'construction-arc' ),
            'section'  => 'constructionarc_promoservice_section',
            'priority' => 100,
        ),
        array(
            'padding' => array(
                'type'  => 'cssbox',
                'label' => esc_html__( 'Padding', 'construction-arc' ),
            ),
            'radius' => array(
                'type'  => 'cssbox',
                'label' => esc_html__( 'Radius', 'construction-arc' ),
            ),
            'borderwidth' => array(
                'type'  => 'number',
                'label' => esc_html__( 'Border Width', 'construction-arc' ),
            ),
            'bordercolor' => array(
                'type'  => 'color',
                'label' => esc_html__( 'Border Color', 'construction-arc' ),
            ),
            'iconsize' => array(
                'type'  => 'number',
                'label' => esc_html__( 'Font Size', 'construction-arc' ),
            ),
        ))
    );

    $wp_customize->add_setting('constructionarc_pro_promoservice', array(
        'sanitize_callback' => 'constructionarc_sanitize_text'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_promoservice', array(
        'section' => 'constructionarc_promoservice_section',
        'label' => esc_html__('For More Settings,', 'construction-arc'),
        'choices' => array(
            esc_html__('(4+) Different Layout & Settings', 'construction-arc'),
            esc_html__('Add Unlimited Service Items', 'construction-arc'),
            esc_html__('(5+) Different Section Title Style', 'construction-arc'),
            esc_html__('Advanced Services Items Settings', 'construction-arc'),
            esc_html__('More Icon Settings ( Background Color/Color/Border Color/Border Width & Padding )', 'construction-arc'),
            esc_html__('Title, sub title & text color options', 'construction-arc'),
			esc_html__('4+ Different Background Options( Color/Video/Gradient/Image ) ', 'construction-arc'),
			esc_html__('More Than 35+ Top & Bottom Separator Shape Illustrator with Color & Height Option', 'construction-arc'),
        ),
        'priority' => 250,
    )));

$wp_customize->selective_refresh->add_partial( 'constructionarc_promoservice_refresh', array (
    'settings' => array( 
        'constructionarc_promoservice_disable',
        'constructionarc_promoservice',
        'constructionarc_promoservice_style',
        'constructionarc_promoservice_show_image',
        'constructionarc_promoservice_type',
        'constructionarc_promoservice_advance_settings',
     ),
    'selector' => '#promoservice-section',
    'fallback_refresh' => true,
    'container_inclusive' => true,
    'render_callback' => function () {
        return get_template_part( 'section/section', 'promoservice' );
    }
));