<h1>
  <span class="text-nowrap me-2">
    <my-global-icon iconName="channel" aria-hidden="true"></my-global-icon>
    <ng-container i18n>My channels</ng-container>
    <span *ngIf="this.pagination.totalItems" class="pt-badge badge-secondary">{{ this.pagination.totalItems }}</span>
  </span>

  <div>
    <a routerLink="/my-library/video-channel-syncs" class="button-link">
      <my-global-icon iconName="repeat" aria-hidden="true"></my-global-icon>
      <ng-container i18n>My synchronizations</ng-container>
    </a>
  </div>
</h1>

<my-channels-setup-message [hideLink]="true"></my-channels-setup-message>

<div class="video-channels-header d-flex justify-content-between gap-2">
  <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter>

  <a class="peertube-create-button" routerLink="/manage/create">
    <my-global-icon iconName="add" aria-hidden="true"></my-global-icon>
    <ng-container i18n>Create video channel</ng-container>
  </a>
</div>

<div class="no-results" i18n *ngIf="this.pagination.totalItems === 0">No channel found.</div>

<div class="video-channels" myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [dataObservable]="onChannelDataSubject.asObservable()">
  <div *ngFor="let videoChannel of videoChannels; let i = index" class="video-channel">
    <my-actor-avatar [actor]="videoChannel" actorType="channel" [internalHref]="[ '/c', videoChannel.nameWithHost ]" size="80"></my-actor-avatar>

    <div class="video-channel-info">
      <a [routerLink]="[ '/c', videoChannel.nameWithHost ]" class="video-channel-names" i18n-title title="Channel page">
        <div class="video-channel-display-name">{{ videoChannel.displayName }}</div>
        <div class="video-channel-name">{{ videoChannel.nameWithHost }}</div>
      </a>

      <a
        i18n class="video-channel-followers"
        [routerLink]="[ '/my-library', 'followers' ]" [queryParams]="{ search: 'channel:' + videoChannel.name }"
      >
        {videoChannel.followersCount, plural, =0 {No subscribers} =1 {1 subscriber} other {{{ videoChannel.followersCount }} subscribers}}
      </a>

      <div class="d-flex">
        <span i18n>{videoChannel.videosCount, plural, =0 {No videos} =1 {1 video} other {{{ videoChannel.videosCount }} videos}}</span>
        <span class="mx-1">·</span>
        <span i18n>{videoChannel.totalViews, plural, =0 {No views} =1 {1 view} other {{{ videoChannel.totalViews | myNumberFormatter }} views}}</span>
      </div>

      <div class="video-channel-buttons">
        <my-edit-button label [ptRouterLink]="[ '/manage/update', videoChannel.nameWithHost ]"></my-edit-button>
        <my-delete-button label (click)="deleteVideoChannel(videoChannel)"></my-delete-button>
      </div>

      <div *ngIf="!isInSmallView" class="w-100 d-flex justify-content-end chart-container">
        <div myDeferLoading>
          <ng-template>
            <p-chart
              *ngIf="chartOptions && videoChannelsChartData && videoChannelsChartData[i]"
              width="40vw" height="100px"
              type="line" [data]="videoChannelsChartData[i]" [options]="chartOptions"
            ></p-chart>
          </ng-template>
        </div>
      </div>
    </div>
  </div>
</div>
