<?php

$wp_customize->add_section(new constructionarc_Toggle_Section($wp_customize, 'constructionarc_service_section', array(
    'title'		=>	esc_html__('Services Section','construction-arc'),
    'panel'		=> 'constructionarc_frontpage_settings',
    'priority'  => constructionarc_themes_get_section_position('constructionarc_service_section'),
    'hiding_control' => 'constructionarc_service_disable'
)));

    //ENABLE/DISABLE SERVICE SECTION
    $wp_customize->add_setting('constructionarc_service_disable', array(
        'default' => 'disable',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_switch',    
    ));
    $wp_customize->add_control(new constructionarc_Switch_Control($wp_customize, 'constructionarc_service_disable', array(
        'label' => esc_html__('Section', 'construction-arc'),
        'section' => 'constructionarc_service_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_service_nav', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'wp_kses_post',
    ));
    $wp_customize->add_control(new constructionarc_Custom_Control_Tab($wp_customize, 'constructionarc_service_nav', array(
        'type' => 'tab',
        'section' => 'constructionarc_service_section',
        'priority' => 1,
        'buttons' => array(
            array(
                'name' => esc_html__('Content', 'construction-arc'),
                'fields' => array(
                    'constructionarc_service_super_title',
                    'constructionarc_service_title',
                    'constructionarc_service_title_style_heading',
                    'constructionarc_service_title_style',
                    'constructionarc_service_title_align',
                    'constructionarc_service',
                    'constructionarc_service_bg_url',
                    'constructionarc_service_layout',
                    'constructionarc_service_button',
                    'constructionarc_service_type',
                    'constructionarc_service_advance_settings'
                ),
                'active' => true,
            ),
            array(
                'name' => esc_html__('Style', 'construction-arc'),
                'fields' => array(
                ),
            ),
            array(
                'name' => esc_html__('Advanced', 'construction-arc'),
                'fields' => array(
                    'constructionarc_service_bg_type',
                    'constructionarc_service_bg_color',
                    'constructionarc_service_bg_image',
                    'constructionarc_service_overlay_color',
                    'constructionarc_service_padding',
                    'constructionarc_service_cs_seperator',
                ),
            ),
        ),
    )));
    
    $wp_customize->add_setting( 'constructionarc_service_super_title', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'sanitize_text_field'			
    ) );
    $wp_customize->add_control( 'constructionarc_service_super_title', array(
        'label'    => esc_html__( 'Super Title', 'construction-arc' ),
        'section'  => 'constructionarc_service_section',
        'type'     => 'text',
    ));


    $wp_customize->add_setting( 'constructionarc_service_title', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'sanitize_text_field'			
    ) );
    $wp_customize->add_control( 'constructionarc_service_title', array(
        'label'    => esc_html__( 'Title', 'construction-arc' ),
        'section'  => 'constructionarc_service_section',
        'type'     => 'text',
    ));
   
    $wp_customize->add_setting('constructionarc_service_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_service_title_align',
            array(
                'choices'  => array(
                    'text-left' => esc_html__('Left', 'construction-arc'),
                    'text-center' => esc_html__('Center', 'construction-arc'),
                    'text-right' => esc_html__('Right', 'construction-arc'),
                ),
                'label'    => esc_html__( 'Alignment', 'construction-arc' ),
                'section'  => 'constructionarc_service_section',
                'settings' => 'constructionarc_service_title_align',
            )
        )
    );

   
    $wp_customize->add_setting('constructionarc_service_title_style_heading', array(
        'sanitize_callback' => 'sanitize_text_field',
        'transport' => 'postMessage',
    ));
    $wp_customize->add_control(new constructionarc_Customize_Heading($wp_customize, 'constructionarc_service_title_style_heading', array(
        'section' => 'constructionarc_service_section',
        'label' => esc_html__('Section Title Style', 'construction-arc')
    )));

    $wp_customize->add_setting('constructionarc_service_title_style', array(
        'default' => 'style1',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'         
    ));
    $wp_customize->add_control('constructionarc_service_title_style', array(
        'section' => 'constructionarc_service_section',
        '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_service_type', array(
        'default' => 'default',
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_select'
    ));
    $wp_customize->add_control('constructionarc_service_type', array(
        'section' => 'constructionarc_service_section',
        'type' => 'radio',
        'label' => esc_html__('Select Type', 'construction-arc'),
        'choices' => array(
            'default' => esc_html__('Default', 'construction-arc'),
            'advance' => esc_html__('Advanced', 'construction-arc')
        )
    ));

    
    $wp_customize->add_setting('constructionarc_service', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'constructionarc_themes_sanitize_repeater',		
        'default' => json_encode(array(
            array(
                'service_page' => '',
                'service_icon' =>'fa-solid fa-bezier-curve',
                'button_text' => '',
            )
        ))
    ));
    $wp_customize->add_control(new constructionarc_Themes_Repeater_Control( $wp_customize,'constructionarc_service', 
        array(
            'label' 	   => esc_html__('Default Services Settings', 'construction-arc'),
            'section' 	   => 'constructionarc_service_section',
            'settings' 	   => 'constructionarc_service',
            'box_label' => esc_html__('Service Item', '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')
            ),
            'button_text' => array(
                'type' => 'text',
                'label' => esc_html__('Button Text', 'construction-arc'),
                'default' => ''
            ),
        )
    ));

   
    $id = "service";
    $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'       => '',
            )
        ))
    ));
    $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' => esc_html__("Title", 'construction-arc'),
            ),
            'block_desc' => array(
                'type' => 'textarea',
                'label' => esc_html__("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' => ''
            ),
        )
    ));

    $wp_customize->add_setting('constructionarc_service_layout', array(
        'sanitize_callback' => 'constructionarc_themes_sanitize_options',
        'default' => 'style1',
        'transport' => 'postMessage'
    ));
    $wp_customize->add_control(new constructionarc_Selector($wp_customize, 'constructionarc_service_layout', array(
        'section' => 'constructionarc_service_section',
        'label' => esc_html__('Layout Settings', 'construction-arc'),
        'options' => array(
            'style1' => get_template_directory_uri() . '/inc/customizer/images/service1.webp',
            'style2' => get_template_directory_uri() . '/inc/customizer/images/service2.webp',
        )
    )));

   
    $wp_customize->add_setting('constructionarc_service_bg_url', array(
        'transport' => 'postMessage',
        'sanitize_callback' => 'absint'
    ));
    $wp_customize->add_control(new WP_Customize_Cropped_Image_Control($wp_customize, 'constructionarc_service_bg_url', array(
        'label'	   => esc_html__('Feature Image','construction-arc'),
        'section'  => 'constructionarc_service_section',
        'height'=>800, // cropper Height
        'width'=>420, // Cropper Width
        'flex_width'=>true, //Flexible Width
        'flex_height'=>true, // Flexible Heiht
    )));

    $wp_customize->add_setting('constructionarc_pro_service', array(
        'sanitize_callback' => 'constructionarc_sanitize_text'
    ));
    $wp_customize->add_control(new constructionarc_Themes_Upgrade_Text($wp_customize, 'constructionarc_pro_service', array(
        'section' => 'constructionarc_service_section',
        'label' => esc_html__('For More Settings,', 'construction-arc'),
        'choices' => array(
            esc_html__('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_service_settings', array(
    'settings' => array( 
        'constructionarc_service_disable', 
        'constructionarc_service',
        'constructionarc_service_type',
        'constructionarc_service_bg_url',
        'constructionarc_service_advance_settings',
        'constructionarc_service_layout',
    ),
    'selector' => '#service-section',
    'fallback_refresh' => true,
    'container_inclusive' => true,
    'render_callback' => function () {
        return get_template_part( 'section/section', 'service' );
    }
));