<aside class="nav">
  <nav>
    <ul>
      <li>
        <strong>
          <%= copy_to_clipboard(Rails.application.config.git_version, label: "rev #{Rails.application.config.git_version}", tooltip_direction: "e") do %>
            Theseus<% if Rails.env.development? %> (dev)<% end %>
          <% end %>
        </strong>
      </li>
      <li>
        <% if current_user %>
          <div style="display: flex; justify-content: space-between; align-items: center;">
            <%= render "shared/user_mention", user: current_user %>
            <iframe src="<%= badge_tasks_path %>" width="50" height="40" style="border: none;"></iframe>
            <%= button_to "log out", signout_path, {method: :delete, class: "btn outlined muted btn-tiny"} %>
            <% if session[:impersonator_user_id] %>
              <%= button_to "stop impersonating", stop_impersonating_path, {method: :get, class: "btn outlined info btn-tiny"} %>
            <% end %>
          </div>
        <% end %>
        <small>
          <%= Flavor.greeting name: current_user&.username %>
        </small>
      </li>
      <li>
      </li>
    </ul>
    <hr />
    <ul>
      <%= nav_item(root_path, "Home") %>
      <li>
        <details <%= 'open' if request.path.start_with?('/back_office/warehouse') %>>
          <summary>Warehouse</summary>
          <ul>
            <%= nav_item(warehouse_batches_path, "Batches") %>
            <%= nav_item(warehouse_skus_path, "SKUs") %>
            <%= nav_item(warehouse_orders_path, "Orders") %>
            <%= nav_item(warehouse_templates_path, "Order templates") %>
          </ul>
        </details>
      </li>
      <li>
        <details <%= 'open' if request.path.start_with?('/back_office/letter') || request.path.start_with?('/back_office/return_addresses') %>>
          <summary>Mail</summary>
          <ul>
            <%= nav_item(letters_path, "Letters") %>
            <%= nav_item(letter_batches_path, "Letter batches") %>
            <%= nav_item(return_addresses_path, "Return Addresses") %>
          </ul>
        </details>
      </li>
      <li>
        <details <%= 'open' if request.path.start_with?('/back_office/tags') %>>
          <summary>Accounting</summary>
          <ul>
            <%= nav_item(tags_path, "Tags") %>
          </ul>
        </details>
      </li>
      <li>
        <details>
          <summary>API</summary>
          <ul>
            <%= nav_item api_keys_path, "API keys" %>
            <%= nav_item letter_queues_path, "letter queues" %>
          </ul>
        </details>
      </li>
      <li>
        <details <%= 'open' if [settings_qz_tray_path].include?(request.path) || request.path.start_with?('/back_office/hcb') %>>
          <summary>Settings</summary>
          <ul>
            <%= nav_item settings_qz_tray_path, "print settings" %>
            <%= nav_item hcb_payment_accounts_path, "HCB payment" %>
          </ul>
        </details>
      </li>
      <% admin_tool do %>
        <li>
          <details>
            <summary>Admin</summary>
            <ul>
              <%= nav_item(good_job_path, "good job, #{current_user.username}!") %>
              <%= nav_item(admin_root_path, "admin panel?") %>
              <%= nav_item(blazer_path, "blaze it") %>
            </ul>
          </details>
        </li>
      <% end %>
      <% dev_tool do %>
        <li>
          <details open>
            <summary>Developer Tools</summary>
            <ul>
              <%= nav_item(letter_opener_web_path, "mail (not the real kind)", target: "_blank") %>
            </ul>
          </details>
        </li>
      <% end %>
    </ul>
  </nav>
</aside>
<button class="nav-toggle" aria-label="Toggle navigation">
  <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M3 12H21M3 6H21M3 18H21" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
  </svg>
</button>
<script>
  document.addEventListener('DOMContentLoaded', function() {
    const navToggle = document.querySelector('.nav-toggle');
    const nav = document.querySelector('.nav');

    if (navToggle && nav) {
      navToggle.addEventListener('click', function() {
        nav.classList.toggle('active');
      });
    }
  });
</script> 