<?php 
    $is_items = (isset($settings['items']) && !empty($settings['items']) && count($settings['items'])) || false;
    $animate_delay = !empty($settings['pxl_animate_delay']) ? (int)$settings['pxl_animate_delay'] : 100;

    $pxl_devider = (!empty($settings['pxl_divider'])) ? 'pxl-is-devider' : '';
    $direction = ($settings['direction'] === 'row') ? 'pxl-layout-horizontal' : 'pxl-layout-vertical';
    $show_heading = !empty($settings['show_heading']) || false;

    $heading_text = !empty($settings['heading']) ? $settings['heading'] : 'Add heading here.';
    $style = ($direction === 'pxl-layout-vertical') ? $settings['style_v'] : $settings['style_h'];

    $classes = $direction.' '.$style.' '.$pxl_devider;  
    
?>
<!-- Template -->

<div class="pxl-links <?php echo esc_attr($classes); ?>" > 
    <div class="pxl-item--container">
        <div class="pxl-item--inner">
            <?php if($show_heading): ?>
                <h6 class="pxl-item--heading"><?php echo esc_html($heading_text); ?></h6>
            <?php endif; ?>
            <?php if($is_items) : ?>
                <ul class="pxl-item--list">
                    <?php foreach($settings['items'] as $key=>$item) : ?>
                        <?php
                            $link_key = $widget->get_repeater_setting_key( 'link', 'value', $key );
                            if ( ! empty( $item['link']['url'] ) ) {
                                $widget->add_render_attribute( $link_key, 'href', $item['link']['url'] );
                                if ( $item['link']['is_external'] ) {
                                    $widget->add_render_attribute( $link_key, 'target', '_blank' );
                                }
                                if ( $item['link']['nofollow'] ) {
                                    $widget->add_render_attribute( $link_key, 'rel', 'nofollow' );
                                }
                            }
                            $link_attributes = $widget->get_render_attribute_string( $link_key );
                            $active = $key === 0 ? 'active' : '';
                            $wow_delay = $key * $animate_delay;
                        ?>
                        <li class="pxl-item--single <?php echo esc_attr('elementor-repeater-item-'.$item['_id']. ' ' .$settings['pxl_animate']); ?>" data-wow-delay="<?php echo esc_attr($wow_delay.'ms'); ?>">
                            <a class="pxl-item--link <?php echo esc_attr($active); ?>" <?php echo implode(' ', [ $link_attributes ] ); ?>>
                                <?php if(!empty($item['pxl_icon']['value'])) : ?>
                                    <span class="pxl-item--icon">
                                        <?php \Elementor\Icons_Manager::render_icon( $item['pxl_icon'], [ 'aria-hidden' => 'true', 'class' => '' ], 'i' ); ?>
                                    </span>
                                <?php endif; ?>
                                <?php if($settings['style_v'] === 'pxl-layout-vertical2') : ?>
                                    <span class="pxl-item--text" >
                                        <span class="pxl-text--main"><?php echo esc_html($item['text']); ?></span>
                                        <span class="pxl-text--copy"><?php echo esc_html($item['text']); ?></span>
                                    </span>
                                <?php else: ?>
                                    <span class="pxl-item--text" >
                                        <?php echo esc_attr($item['text']); ?>
                                    </span>
                                <?php endif; ?>

                                <?php if($settings['style_v'] === 'pxl-layout-vertical3') : ?>
                                    <span class="pxl-item--btn">
                                        <span>                                            
                                            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="15" viewBox="0 0 16 15" fill="none">
                                                <path d="M15 7.30933L9 13.3093M15 7.30933L9 1.30933M15 7.30933L1 7.30933" stroke="#4AAB3D" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
                                            </svg>
                                        </span>
                                    </span>
                                <?php endif; ?>
                            </a>
                        </li>
                    <?php endforeach; ?>
                </ul>
            <?php endif; ?>
        </div>
    </div>
</div>
