<div
  class="sm:absolute sm:inset-0 flex flex-col flex-auto min-w-0 sm:overflow-hidden bg-card dark:bg-transparent"
>
  <!-- Header -->
  <div
    class="relative flex flex-col sm:flex-row flex-0 sm:items-center sm:justify-between py-8 px-6 md:px-8 border-b"
  >
    <!-- Loader -->
    <div class="absolute inset-x-0 bottom-0" *ngIf="isLoading">
      <mat-progress-bar [mode]="'indeterminate'"></mat-progress-bar>
    </div>
    <!-- Title -->
    <div class="text-4xl font-extrabold tracking-tight">전체목록</div>
    <!-- Actions -->
    <div class="flex shrink-0 items-center mt-6 sm:mt-0 sm:ml-4">
      <!-- Memo -->
      <!-- <mat-form-field>
        <ng-container *ngIf="partners$ | async as partners">
          <ng-container
            *ngFor="let partner of partners; trackBy: __trackByFn"
          >
            <div
              class="inventory-grid grid items-center gap-4 py-3 px-6 md:px-8 border-b"
            >
              <fieldset>
                총 회원수:{{ partenr.totalMemberCount }}
                총 보유머니:{{ partner.totalHoldingMoney }}
                총 콤프:{{ partner.totalComp }}
                총 합계:{{ partner.total }}
              </fieldset>
            </div>
          </ng-container>
        </ng-container>
      </mat-form-field> -->

      <!-- Search -->
      <mat-form-field
        class="fuse-mat-dense fuse-mat-no-subscript fuse-mat-rounded min-w-64"
      >
        <mat-icon
          class="icon-size-5"
          matPrefix
          [svgIcon]="'heroicons_solid:search'"
        ></mat-icon>
        <input
          matInput
          [formControl]="searchInputControl"
          [autocomplete]="'off'"
          [placeholder]="'Search user'"
        />
      </mat-form-field>
      <!-- Add user button -->
      <button
        class="ml-4"
        mat-flat-button
        [color]="'primary'"
        (click)="__createProduct()"
      >
        <mat-icon [svgIcon]="'heroicons_outline:plus'"></mat-icon>
        <span class="ml-2 mr-1">Add</span>
      </button>
    </div>
  </div>

  <!-- Main -->
  <div class="flex flex-auto overflow-hidden">
    <!-- Products list -->
    <div
      class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto"
    >
      <ng-container *ngIf="partners$ | async as partners">
        <ng-container *ngIf="partners.length > 0; else noPartner">
          <div class="grid">
            <!-- Header -->
            <div
              class="inventory-grid z-10 sticky top-0 grid gap-4 py-4 px-6 md:px-8 shadow text-md font-semibold text-secondary bg-gray-50 dark:bg-black dark:bg-opacity-5"
              matSort
              matSortDisableClear
            >
              <div></div>
              <div class="hidden sm:block">아이디</div>
              <div class="hidden sm:block">매장수</div>
              <div class="hidden sm:block">관리</div>
              <div class="hidden sm:block">요율</div>
              <div class="hidden sm:block">예금주</div>
              <div class="hidden sm:block">연락처</div>
              <div class="hidden sm:block">등급</div>
              <div class="hidden sm:block">정산</div>
              <div class="hidden sm:block">보유금</div>
              <div class="hidden sm:block">로그</div>
              <div class="hidden sm:block">콤프</div>
              <div class="hidden sm:block">쿠폰</div>
              <div class="hidden sm:block">충전금</div>
              <div class="hidden sm:block">환전금</div>
              <div class="hidden sm:block">수익금</div>
              <div class="hidden sm:block">가입날짜</div>
              <div class="hidden sm:block">상태</div>
              <div class="hidden sm:block">비고</div>
              <!-- <div class="hidden md:block" [mat-sort-header]="'sku'">SKU</div>
              <div [mat-sort-header]="'name'">Name</div>
              <div class="hidden sm:block" [mat-sort-header]="'price'">
                Price
              </div>
              <div class="hidden lg:block" [mat-sort-header]="'stock'">
                Stock
              </div>
              <div class="hidden lg:block" [mat-sort-header]="'active'">
                Active
              </div>
              <div class="hidden sm:block">Details</div> -->
            </div>
            <!-- Rows -->
            <ng-container *ngIf="partners$ | async as partners">
              <ng-container
                *ngFor="let partner of partners; trackBy: __trackByFn"
              >
                <div
                  class="inventory-grid grid items-center gap-4 py-3 px-6 md:px-8 border-b"
                >
                  <!-- id -->
                  <ng-container *ngIf="users$ | async as users">
                    <ng-container
                      *ngFor="let user of users; trackBy: __trackByFn"
                    >
                      <!-- rank -->
                      {{ partner.rank }}
                      <div
                        class="hidden sm:block truncate"
                        (click)="viewUserDetail(user.id!)"
                      >
                        {{ partner.id }}
                      </div>
                      <!-- nickname -->
                      {{ partner.nickname }}
                    </ng-container>
                  </ng-container>

                  <!-- 매장수 -->
                  <div class="hidden sm:block truncate">
                    {{ partner.branchCount }}
                    {{ partner.divisionCount }}
                    {{ partner.officeCount }}
                    {{ partner.storeCount }}
                    {{ partner.memberCount }}
                  </div>
                  <!-- management -->
                  <div class="hidden sm:block truncate">
                    <button mat-flat-button [color]="'primary'">
                      <mat-form-field>
                        <mat-select placeholder="관리">
                          <mat-option value="">보유금지급/회수</mat-option>
                          <mat-option value="">수수료설정</mat-option>
                          <mat-option value="">콤프지급/회수</mat-option>
                          <mat-option value="">쿠폰머니지급/회수</mat-option>
                          <mat-option value="">쪽지보내기</mat-option>
                          <mat-option value="">베팅리스트</mat-option>
                          <mat-option value="">강제로그아웃</mat-option>
                        </mat-select>
                      </mat-form-field>
                    </button>
                  </div>
                  <!-- rate -->
                  <div class="hidden sm:block truncate">
                    <button
                      mat-button
                      color="primary"
                      matTooltip="요율확인
                                카지노-바카라: 0%
                                카지노-룰렛: 0%
                                카지노-드레곤타이거: 0%
                                카지노-그외: 0%
                                슬롯: 0%
                                카지노루징: 0%
                                슬롯루징: 0%"
                    >
                      요율
                    </button>

                    <!-- accountHolder -->
                    <div class="hidden sm:block truncate">
                      {{ partner.accountHolder }}
                    </div>

                    <!-- contact -->
                    <div class="hidden sm:block truncate">
                      {{ partner.phoneNumber }}
                    </div>

                    <!-- level -->
                    <div class="hidden sm:block truncate">
                      LV.{{ partner.level }}
                    </div>
                  </div>

                  <!-- calculateType -->
                  <div class="hidden sm:block truncate">
                    {{ partner.calculateType }}
                  </div>

                  <!-- reserve -->
                  <div class="hidden sm:block truncate">
                    콤프{{ partner.comp }} 쿠폰{{ partner.coupon }}
                  </div>

                  <!-- holdingMoney -->
                  <div class="hidden sm:block truncate">
                    {{ partner.holdingMoney }}
                  </div>

                  <!-- comp -->
                  <div class="hidden sm:block truncate">
                    {{ partner.comp }}P
                  </div>

                  <!-- coupon -->
                  <div class="hidden sm:block truncate">
                    {{ partner.coupon }}
                  </div>

                  <!-- charge -->
                  <div class="hidden sm:block truncate">
                    본인 {{ partner.ownCharge }} 하부
                    {{ partner.bottomCharge }}
                  </div>

                  <!-- exchange -->
                  <div class="hidden sm:block truncate">
                    본인 {{ partner.ownExchange }} 하부
                    {{ partner.bottomExchange }}
                  </div>

                  <!-- revenue -->
                  <div class="hidden sm:block truncate">
                    본인 {{ partner.ownRevenue }} 하부
                    {{ partner.bottomRevenue }}
                  </div>

                  <!-- accession -->
                  <div class="hidden sm:block truncate">
                    가입날짜{{ partner.accession }}
                  </div>

                  <!-- state -->
                  <div class="hidden sm:block truncate">
                    {{ partner.state }}
                  </div>

                  <!-- note -->
                  <div class="hidden sm:block truncate">
                    <button mat-flat-button [color]="'primary'">
                      {{ partner.note }}
                    </button>
                  </div>
                  <!-- Image -->
                  <!-- <div class="flex items-center">
                    <div
                      class="relative flex flex-0 items-center justify-center w-12 h-12 mr-6 rounded overflow-hidden border"
                    >
                      <img
                        class="w-8"
                        *ngIf="user.thumbnail"
                        [alt]="'Product thumbnail image'"
                        [src]="user.thumbnail"
                      />
                      <div
                        class="flex items-center justify-center w-full h-full text-xs font-semibold leading-none text-center uppercase"
                        *ngIf="!user.thumbnail"
                      >
                        NO THUMB
                      </div>
                    </div>
                  </div> -->

                  <!-- SKU -->
                  <!-- <div class="hidden md:block truncate">
                    {{ user.sku }}
                  </div> -->

                  <!-- Name -->
                  <!-- <div class="truncate">
                    {{ user.name }}
                  </div> -->

                  <!-- Price -->
                  <!-- <div class="hidden sm:block">
                    {{ user.price | currency: "USD":"symbol":"1.2-2" }}
                  </div> -->

                  <!-- Stock -->
                  <!-- <div class="hidden lg:flex items-center">
                    <div class="min-w-4">{{ user.stock }}</div> -->
                  <!-- Low stock -->
                  <!-- <div
                      class="flex items-end ml-2 w-1 h-4 bg-red-200 rounded overflow-hidden"
                      *ngIf="user.stock < 20"
                    >
                      <div class="flex w-full h-1/3 bg-red-600"></div>
                    </div> -->
                  <!-- Medium stock -->
                  <!-- <div
                      class="flex items-end ml-2 w-1 h-4 bg-orange-200 rounded overflow-hidden"
                      *ngIf="user.stock >= 20 && user.stock < 30"
                    >
                      <div class="flex w-full h-2/4 bg-orange-400"></div>
                    </div> -->
                  <!-- High stock -->
                  <!-- <div
                      class="flex items-end ml-2 w-1 h-4 bg-green-100 rounded overflow-hidden"
                      *ngIf="user.stock >= 30"
                    >
                      <div class="flex w-full h-full bg-green-400"></div>
                    </div>
                  </div> -->

                  <!-- Active -->
                  <!-- <div class="hidden lg:block">
                    <ng-container *ngIf="user.active">
                      <mat-icon
                        class="text-green-400 icon-size-5"
                        [svgIcon]="'heroicons_solid:check'"
                      ></mat-icon>
                    </ng-container>
                    <ng-container *ngIf="!user.active">
                      <mat-icon
                        class="text-gray-400 icon-size-5"
                        [svgIcon]="'heroicons_solid:x'"
                      ></mat-icon>
                    </ng-container>
                  </div> -->

                  <!-- Details button -->
                  <!-- <div>
                    <button
                      class="min-w-10 min-h-7 h-7 px-2 leading-6"
                      mat-stroked-button
                      (click)="__toggleDetails(user.id)"
                    >
                      <mat-icon
                        class="icon-size-5"
                        [svgIcon]="
                          selectedUser?.id === user.id
                            ? 'heroicons_solid:chevron-up'
                            : 'heroicons_solid:chevron-down'
                        "
                      ></mat-icon>
                    </button>
                  </div> -->
                </div>
              </ng-container>
            </ng-container>
          </div>

          <mat-paginator
            class="sm:absolute sm:inset-x-0 sm:bottom-0 border-b sm:border-t sm:border-b-0 z-10 bg-gray-50 dark:bg-transparent"
            [ngClass]="{ 'pointer-events-none': isLoading }"
            [length]="pagination?.length"
            [pageIndex]="pagination?.page"
            [pageSize]="pagination?.size"
            [pageSizeOptions]="[5, 10, 25, 100]"
            [showFirstLastButtons]="true"
          ></mat-paginator>
        </ng-container>
      </ng-container>

      <ng-template #noPartner>
        <div
          class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center"
        >
          There are no partners!
        </div>
      </ng-template>
    </div>
  </div>
</div>
