<!--

    Copyright © 2016-2026 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<mat-sidenav-container>
  <mat-sidenav #sidenav class="tb-site-sidenav mat-elevation-z2"
               [disableClose]="sidenavOpened"
               (click)="sidenavClicked()"
               [mode]="sidenavMode"
               [opened]="sidenavOpened && !forceFullscreen">
    <header class="tb-nav-header">
      <mat-toolbar color="primary" class="tb-nav-header-toolbar">
        <div class="flex flex-auto">
          <tb-logo [src]="logo" class="tb-logo-title"></tb-logo>
        </div>
      </mat-toolbar>
    </header>
    <mat-toolbar color="primary" class="tb-side-menu-toolbar flex flex-1 flex-col" role="navigation">
      <tb-side-menu></tb-side-menu>
    </mat-toolbar>
  </mat-sidenav>
  <mat-sidenav-content>
    <div class="flex flex-col" role="main" style="height: 100%;">
      <mat-toolbar color="primary" class="tb-primary-toolbar flex flex-row">
        <button mat-icon-button id="main"
                [class.!hidden]="forceFullscreen || displaySearchMode()"
                class="gt-sm:!hidden" (click)="sidenav.toggle()">
          <mat-icon class="material-icons">menu</mat-icon>
        </button>
        <button mat-icon-button
                [class.!hidden]="!forceFullscreen || displaySearchMode"
                (click)="goBack()">
          <mat-icon class="material-icons">arrow_back</mat-icon>
        </button>
        <button mat-icon-button
                [class.!hidden]="!displaySearchMode()"
                (click)="closeSearch()">
          <mat-icon class="material-icons">arrow_back</mat-icon>
        </button>
        <tb-breadcrumb
          [class.!hidden]="displaySearchMode()"
          class="mat-toolbar-tools flex-1">
        </tb-breadcrumb>
        <div [class.!hidden]="!displaySearchMode()" class="tb-dark flex flex-1 flex-row">
          <mat-form-field class="tb-appearance-transparent flex-1">
            <input #searchInput matInput
                   [formControl]="textSearch"
                   placeholder="{{ 'common.enter-search' | translate }}"/>
          </mat-form-field>
        </div>
        <tb-github-badge class="lt-md:!hidden"></tb-github-badge>
        <button [class.!hidden]="!searchEnabled"
                mat-icon-button (click)="openSearch()">
          <mat-icon class="material-icons">search</mat-icon>
        </button>
        @if (fullscreenEnabled) {
          <button
            [class.!hidden]="displaySearchMode()"
            class="lt-md:!hidden"
            mat-icon-button (click)="toggleFullscreen()">
            <mat-icon class="material-icons">{{ isFullscreen() ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>
          </button>
        }
        <tb-notification-bell></tb-notification-bell>
        <tb-user-menu [displayUserInfo]="!displaySearchMode()"></tb-user-menu>
      </mat-toolbar>
      @if (!hideLoadingBar && (isLoading$ | async)) {
        <mat-progress-bar color="warn" style="z-index: 10; margin-bottom: -4px; width: 100%;" mode="indeterminate"
                          >
        </mat-progress-bar>
      }
      <div tb-toast class="tb-main-content flex flex-1 flex-col">
        <router-outlet (activate)="activeComponentChanged($event)"></router-outlet>
      </div>
    </div>
  </mat-sidenav-content>
</mat-sidenav-container>
