<?php

namespace DropshippingExportFreeVendor;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Service\Menu\SettingsMenu;
/**
 * @var array $menu
 * @var string $menu_tab
 * @var string $menu_type
 */
?>
<nav class="nav-tab-wrapper">
	<?php 
$rendered_items = [];
$active = '';
$sub_menu = [];
foreach ($menu as $item) {
    if ($item[SettingsMenu::MENU_FIELD_TAB] === $menu_tab || empty($menu_tab)) {
        $menu_tab = $item[SettingsMenu::MENU_FIELD_TAB];
        $active = 'nav-tab-active';
        $sub_menu = $item[SettingsMenu::MENU_FIELD_SUBMENU];
    }
    $rendered_items[] = '<a class="nav-tab ' . $active . '" href="' . $item[SettingsMenu::MENU_FIELD_URL] . '">' . $item[SettingsMenu::MENU_FIELD_NAME] . '</a>';
    $active = '';
}
echo \wp_kses_post(\implode('', $rendered_items));
?>
</nav>
<ul class="subsubsub">
<?php 
$rendered_items = [];
$active = '';
$i = 0;
foreach ($sub_menu as $sub_item) {
    ++$i;
    if ($sub_item[SettingsMenu::MENU_FIELD_TYPE] === $menu_type || empty($menu_type)) {
        $menu_type = $sub_item[SettingsMenu::MENU_FIELD_TYPE];
        $active = 'current';
    }
    $separator = \count($sub_menu) > $i ? ' | ' : '';
    $rendered_items[] = '<li><a class="' . $active . '" href="' . $sub_item[SettingsMenu::MENU_FIELD_URL] . '">' . $sub_item[SettingsMenu::MENU_FIELD_NAME] . '</a>' . $separator . '</li>';
    $active = '';
}
echo \wp_kses_post(\implode('', $rendered_items));
?>
</ul>
<?php 
