<div fxLayout="row wrap" fxLayoutAlign="start start" fxLayout.gt-sm="column" fxFlex="100" fxLayoutAlign.gt-sm="start stretch" class="padding-gap-x-large">
  <div fxLayout="column" fxLayout.gt-xs="row wrap" fxLayoutAlign.gt-xs="start center" fxLayoutAlign="start stretch" class="page-sub-title-container">
    <div fxFlex="70"></div>
    <mat-form-field fxFlex="30">
      <input matInput (keyup)="applyFilter()" [(ngModel)]="selFilter" placeholder="Filter">
    </mat-form-field>
  </div>
  <div fxLayout="row" fxLayoutAlign="start start">
    <div [perfectScrollbar] class="table-container" fxFlex="100">
      <mat-progress-bar *ngIf="apiCallStatus?.status === apiCallStatusEnum.INITIATED" mode="indeterminate"></mat-progress-bar>
      <table mat-table #table [dataSource]="listUTXOs" matSort [ngClass]="{'overflow-auto error-border': errorMessage !== '','overflow-auto': true}">
        <ng-container matColumnDef="txid">
          <th mat-header-cell *matHeaderCellDef mat-sort-header> Transaction ID </th>
          <td mat-cell *matCellDef="let utxo">
            <span fxLayout="row" class="ellipsis-parent" [ngStyle]="{'max-width': (screenSize === screenSizeEnum.XS) ? '10rem' : '50rem'}">
              <span *ngIf="numDustUTXOs > 0 && !isDustUTXO">
                <span *ngIf="utxo.value < 1000; else emptySpace" matTooltip="Risk of dust attack" matTooltipPosition="right">
                  <mat-icon fxLayoutAlign="start center" color="warn" class="mr-1">warning</mat-icon>
                </span>
              </span>
              <span *ngIf="utxo.status === 'confirmed'" class="dot green" matTooltip="Confirmed" matTooltipPosition="right"></span>
              <span *ngIf="utxo.status !== 'confirmed'" class="dot yellow" matTooltip="{{utxo.status | titlecase}}" matTooltipPosition="right"></span>
              <span class="ellipsis-child">{{utxo.txid}}</span>
            </span>
          </td>
        </ng-container>
        <ng-container matColumnDef="output">
          <th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Output </th>
          <td mat-cell *matCellDef="let utxo"><span fxLayoutAlign="end center">
              {{utxo?.output | number}} </span></td>
        </ng-container>
        <ng-container matColumnDef="value">
          <th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Value (Sats) </th>
          <td mat-cell *matCellDef="let utxo">
            <span fxLayoutAlign="end center" *ngIf="utxo.value > 0 || utxo.value === 0">{{utxo.value | number}}</span>
            <span fxLayoutAlign="end center" class="red" *ngIf="utxo.value < 0">({{utxo.value * -1 | number}})</span>
          </td>
        </ng-container>
        <ng-container matColumnDef="blockheight">
          <th mat-header-cell *matHeaderCellDef mat-sort-header arrowPosition="before"> Blockheight </th>
          <td mat-cell *matCellDef="let utxo"><span fxLayoutAlign="end center">
              {{utxo?.blockheight | number}} </span></td>
        </ng-container>
        <ng-container matColumnDef="actions">
          <th mat-header-cell *matHeaderCellDef class="px-3">
            <div class="bordered-box table-actions-select">
              <mat-select placeholder="Actions" tabindex="1" class="mr-0">
                <mat-select-trigger></mat-select-trigger>
                <mat-option (click)="onDownloadCSV()">Download CSV</mat-option>
              </mat-select>
            </div>
          </th>
          <td mat-cell *matCellDef="let utxo" class="pl-3" fxLayoutAlign="end center">
            <button mat-stroked-button color="primary" type="button" tabindex="4" (click)="onUTXOClick(utxo, $event)">View Info</button>
          </td>
        </ng-container>
        <ng-container matColumnDef="no_utxo">
          <td mat-footer-cell *matFooterCellDef colspan="4">
            <p *ngIf="(!listUTXOs?.data || listUTXOs?.data?.length<1) && apiCallStatus?.status === apiCallStatusEnum.COMPLETED">No utxos available.</p>
            <p *ngIf="(!listUTXOs?.data || listUTXOs?.data?.length<1) && apiCallStatus?.status === apiCallStatusEnum.INITIATED">Getting utxos...</p>
            <p *ngIf="(!listUTXOs?.data || listUTXOs?.data?.length<1) && apiCallStatus?.status === apiCallStatusEnum.ERROR">{{errorMessage}}</p>
          </td>
        </ng-container>
        <tr mat-footer-row *matFooterRowDef="['no_utxo']" [ngClass]="{'display-none': listUTXOs?.data && listUTXOs?.data?.length>0}"></tr>
        <tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: flgSticky;"></tr>
        <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
      </table>
      <mat-paginator [pageSize]="pageSize" [pageSizeOptions]="pageSizeOptions" [showFirstLastButtons]="screenSize === screenSizeEnum.XS ? false : true" class="mb-1"></mat-paginator>
    </div>
  </div>
</div>
<ng-template #emptySpace>
  <mat-icon fxLayoutAlign="start center" color="warn" class="mr-1"></mat-icon>
</ng-template>