<?php
$html_id = pxl_get_element_id($settings);
if ( ! empty( $settings['link']['url'] ) ) {
    $widget->add_render_attribute( 'link_arrow', 'href', $settings['link']['url'] );

    if ( $settings['link']['is_external'] ) {
        $widget->add_render_attribute( 'link_arrow', 'target', '_blank' );
    }

    if ( $settings['link']['nofollow'] ) {
        $widget->add_render_attribute( 'link_arrow', 'rel', 'nofollow' );
    }
}
?>
<div class="pxl-menu-click">
    <div class="pxl-button-click">
    </div>
    <div class="pxl-sub-click">
        <?php
        $p_menu = hubsteel()->get_page_opt('p_menu');
        if(!empty($p_menu)) {
            $settings['menu'] = $p_menu;
        }
        if(!empty($settings['menu'])) { ?>
            <div class="pxl-nav-menu pxl-nav-menu1 <?php echo esc_attr($settings['hover_active_style'].' '.$settings['sub_show_effect'].' '.$settings['menu_mega_type']); ?> <?php echo esc_attr($settings['hover_active_style_sub']); ?>">
                <?php wp_nav_menu(array(
                    'theme_location' => 'primary',
                    'menu_class' => 'pxl-menu-primary clearfix',
                    'walker'     => class_exists( 'PXL_Mega_Menu_Walker' ) ? new PXL_Mega_Menu_Walker : '',
                    'link_before'     => '<span>',
                    'link_after'      => '<i class="caseicon-angle-arrow-down pxl-hide"></i><i class="pxl-dot"></i></span>',
                    'menu'        => wp_get_nav_menu_object($settings['menu']))
                ); ?>
            </div>
        <?php } elseif( has_nav_menu( 'primary' ) ) { ?>
            <div class="pxl-nav-menu pxl-nav-menu1 <?php echo esc_attr($settings['hover_active_style'].' '.$settings['sub_show_effect'].' '.$settings['menu_mega_type']); ?> <?php echo esc_attr($settings['hover_active_style_sub']); ?>">
                <?php $attr_menu = array(
                    'theme_location' => 'primary',
                    'menu_class' => 'pxl-menu-primary clearfix',
                    'link_before'     => '<span>',
                    'link_after'      => '<i class="caseicon-angle-arrow-down pxl-hide"></i><i class="pxl-dot"></i></span></span>',
                    'walker'         => class_exists( 'PXL_Mega_Menu_Walker' ) ? new PXL_Mega_Menu_Walker : '',
                );
                wp_nav_menu( $attr_menu ); ?>
            </div>
        <?php } ?>
        <div class="pxl-contact-menu">
            <div class="pxl-contact-inner">
                <?php if(!empty($settings['image']['id'])) : 
                    $image_size = !empty($settings['img_size']) ? $settings['img_size'] : '1403x282'; 
                    $img = pxl_get_image_by_size( array(
                        'attach_id'  => $settings['image']['id'],
                        'thumb_size' => $image_size,
                    ));
                    $thumbnail = $img['thumbnail'];
                    ?>
                    <div class="pxl-item--img">
                        <div class="pxl-image">
                            <?php echo pxl_print_html($thumbnail); ?>
                        </div>
                        <div class="pxl-menu-meta">
                            <div class="pxl-item-title">
                                <?php echo esc_attr($settings['title']); ?>
                            </div>
                            <div class="pxl-menu-btn">
                                <a class="pxl-button-link" <?php pxl_print_html($widget->get_render_attribute_string( 'link_arrow' )); ?>>
                                    <svg xmlns="http://www.w3.org/2000/svg" fill="#000" height="512" viewBox="0 0 24 24" width="512"><path d="m16.0039 9.414-8.60699 8.607-1.414-1.414 8.60599-8.607h-7.58499v-2h10.99999v11h-2z" fill="rgb(0,0,0)"></path></svg>
                                </a>
                            </div>
                        </div>
                    </div>
                <?php endif; ?>
            </div>
            <div class="pxl-contact-bottom">
                <?php if(isset($settings['lists']) && !empty($settings['lists']) && count($settings['lists'])): ?>
                    <div class="pxl-list">
                        <?php foreach ($settings['lists'] as $key => $value): ?>
                            <div class="pxl--item">
                                <div class="pxl-item-title-list">
                                    <?php echo pxl_print_html($value['title_list'])?>
                                </div>
                                <ul>
                                    <li><?php echo pxl_print_html($value['text_list1'])?></li>
                                    <li><?php echo pxl_print_html($value['text_list2'])?></li>
                                    <li><?php echo pxl_print_html($value['text_list3'])?></li>
                                </ul>
                            </div>
                        <?php endforeach; ?>
                    </div>
                <?php endif; ?>
                <div class="pxl-social">
                    <div class="pxl-item-title-list">
                        <?php echo esc_attr($settings['title_social']); ?>
                    </div>
                    <?php 
                    $team_social = !empty($settings['social']) ? json_decode($settings['social'], true) : []; 
                    if (!empty($team_social)) : ?>
                        <div class="pxl-social--icon">
                            <?php foreach ($team_social as $social_item): ?>
                                <a href="<?php echo esc_url($social_item['url']); ?>" target="_blank">
                                    <i class="<?php echo esc_attr($social_item['icon']); ?>"></i>
                                </a>
                            <?php endforeach; ?>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>