<?php
declare(strict_types=1);
/**
 * 대메뉴 클릭 → 좌측 MY MENU에 소메뉴 표시 (gov-portal 기본)
 *
 * @var list<array> $govNavItems
 * @var int $govActiveParentIdx
 * @var string $govCurrentPath
 * @var list<string> $govDashboardAliases
 */
helper('admin');
?>
<nav class="portal-top-nav" id="portalTopNavClick" aria-label="대분류 메뉴">
  <?php foreach ($govNavItems as $pIdx => $item): ?>
  <?php
  $isActive = ($pIdx === $govActiveParentIdx);
  $hasChildren = ! empty($item['hasChildren']);
  if ($hasChildren):
  ?>
  <div class="portal-nav-item">
    <button type="button"
            class="portal-nav-trigger <?= $isActive ? 'is-active' : '' ?>"
            data-parent-idx="<?= (int) $pIdx ?>"
            aria-expanded="<?= $isActive ? 'true' : 'false' ?>">
      <?= esc($item['name']) ?>
    </button>
  </div>
  <?php elseif ($item['href'] !== ''): ?>
  <div class="portal-nav-item">
    <a href="<?= esc($item['url']) ?>"
       class="portal-nav-link <?= $isActive ? 'is-active' : '' ?>"
       data-parent-idx="<?= (int) $pIdx ?>">
      <?= esc($item['name']) ?>
    </a>
  </div>
  <?php else: ?>
  <div class="portal-nav-item">
    <span class="portal-nav-trigger" style="opacity:.5;cursor:default;"><?= esc($item['name']) ?></span>
  </div>
  <?php endif; ?>
  <?php endforeach; ?>
</nav>
