<div class="content">
  <div class="inner-content">
    <h2 class="sr-only">{{ "filters" | i18n }}</h2>
    <ul>
      <li [ngClass]="{ active: selectedAll }">
        <a href="#" appStopClick appBlurClick (click)="selectAll()">
          <i class="bwi bwi-fw bwi-filter" aria-hidden="true"></i>&nbsp;{{ "allItems" | i18n }}
        </a>
      </li>
      <li [ngClass]="{ active: selectedFavorites }">
        <a href="#" appStopClick appBlurClick (click)="selectFavorites()">
          <i class="bwi bwi-fw bwi-star" aria-hidden="true"></i>&nbsp;{{ "favorites" | i18n }}
        </a>
      </li>
      <li [ngClass]="{ active: selectedTrash }">
        <a href="#" appStopClick appBlurClick (click)="selectTrash()">
          <i class="bwi bwi-fw bwi-trash" aria-hidden="true"></i>&nbsp;{{ "trash" | i18n }}
        </a>
      </li>
    </ul>
    <h2>{{ "types" | i18n }}</h2>
    <ul>
      <li [ngClass]="{ active: selectedType === cipherType.Login }">
        <a href="#" appStopClick appBlurClick (click)="selectType(cipherType.Login)">
          <i class="bwi bwi-fw bwi-globe" aria-hidden="true"></i>&nbsp;{{ "typeLogin" | i18n }}
        </a>
      </li>
      <li [ngClass]="{ active: selectedType === cipherType.Card }">
        <a href="#" appStopClick appBlurClick (click)="selectType(cipherType.Card)">
          <i class="bwi bwi-fw bwi-credit-card" aria-hidden="true"></i>&nbsp;{{ "typeCard" | i18n }}
        </a>
      </li>
      <li [ngClass]="{ active: selectedType === cipherType.Identity }">
        <a href="#" appStopClick appBlurClick (click)="selectType(cipherType.Identity)">
          <i class="bwi bwi-fw bwi-id-card" aria-hidden="true"></i>&nbsp;{{ "typeIdentity" | i18n }}
        </a>
      </li>
      <li [ngClass]="{ active: selectedType === cipherType.SecureNote }">
        <a href="#" appStopClick appBlurClick (click)="selectType(cipherType.SecureNote)">
          <i class="bwi bwi-fw bwi-sticky-note" aria-hidden="true"></i>&nbsp;{{
            "typeSecureNote" | i18n
          }}
        </a>
      </li>
    </ul>
    <p *ngIf="!loaded" class="text-muted">{{ "loading" | i18n }}</p>
    <ng-container *ngIf="loaded">
      <div class="heading">
        <h2>{{ "folders" | i18n }}</h2>
        <button appBlurClick (click)="addFolder()" appA11yTitle="{{ 'addFolder' | i18n }}">
          <i class="bwi bwi-plus bwi-fw" aria-hidden="true"></i>
        </button>
      </div>
      <ul>
        <ng-template #recursiveFolders let-folders>
          <li
            *ngFor="let f of folders"
            [ngClass]="{ active: selectedFolder && f.node.id === selectedFolderId }"
          >
            <a href="#" appStopClick appBlurClick (click)="selectFolder(f.node)">
              <i
                *ngIf="f.children.length"
                class="bwi bwi-fw"
                title="{{ 'toggleCollapse' | i18n }}"
                aria-hidden="true"
                [ngClass]="{
                  'bwi-angle-right': isCollapsed(f.node),
                  'bwi-angle-down': !isCollapsed(f.node)
                }"
                (click)="collapse(f.node)"
                appStopProp
              ></i>
              <i
                *ngIf="f.children.length === 0"
                class="bwi bwi-fw bwi-folder"
                aria-hidden="true"
              ></i>
              &nbsp;{{ f.node.name }}
              <span
                appStopProp
                appStopClick
                (click)="editFolder(f.node)"
                role="button"
                appA11yTitle="{{ 'editFolder' | i18n }}"
                *ngIf="f.node.id"
              >
                <i class="bwi bwi-pencil bwi-fw" aria-hidden="true"></i>
              </span>
            </a>
            <ul class="bwi-ul" *ngIf="f.children.length && !isCollapsed(f.node)">
              <ng-container
                *ngTemplateOutlet="recursiveFolders; context: { $implicit: f.children }"
              >
              </ng-container>
            </ul>
          </li>
        </ng-template>
        <ng-container
          *ngTemplateOutlet="recursiveFolders; context: { $implicit: nestedFolders }"
        ></ng-container>
      </ul>
      <div *ngIf="collections && collections.length">
        <h2>{{ "collections" | i18n }}</h2>
        <ul>
          <ng-template #recursiveCollections let-collections>
            <li
              *ngFor="let c of collections"
              [ngClass]="{ active: c.node.id === selectedCollectionId }"
            >
              <a href="#" appStopClick appBlurClick (click)="selectCollection(c.node)">
                <i
                  *ngIf="c.children.length"
                  class="bwi bwi-fw"
                  title="{{ 'toggleCollapse' | i18n }}"
                  aria-hidden="true"
                  [ngClass]="{
                    'bwi-angle-right': isCollapsed(c.node),
                    'bwi-angle-down': !isCollapsed(c.node)
                  }"
                  (click)="collapse(c.node)"
                  appStopProp
                ></i>
                <i
                  *ngIf="c.children.length === 0"
                  class="bwi bwi-fw bwi-collection"
                  aria-hidden="true"
                ></i>
                &nbsp;{{ c.node.name }}
              </a>
              <ul class="bwi-ul" *ngIf="c.children.length && !isCollapsed(c.node)">
                <ng-container
                  *ngTemplateOutlet="recursiveCollections; context: { $implicit: c.children }"
                >
                </ng-container>
              </ul>
            </li>
          </ng-template>
          <ng-container
            *ngTemplateOutlet="recursiveCollections; context: { $implicit: nestedCollections }"
          >
          </ng-container>
        </ul>
      </div>
    </ng-container>
  </div>
  <div class="footer">
    <app-nav class="nav"></app-nav>
  </div>
</div>
