<div fxLayout="column" fxFlex="100" class="padding-gap">
  <form #queryRoutesForm="ngForm" fxLayout="column" fxLayoutAlign="space-between stretch" fxLayout.gt-sm="row wrap" (ngSubmit)="queryRoutesForm.form.valid && onQueryRoutes()">
    <div fxFlex="100" class="alert alert-warn">
      <fa-icon class="mr-1 alert-icon" [icon]="faExclamationTriangle" />
      <span>The actual routing fee on a payment can be different from the fee shown on query routes.</span>
    </div>
    <mat-form-field fxLayout="column" fxFlex="69" fxLayoutAlign="start end">
      <mat-label>Destination Pubkey</mat-label>
      <input #destPubkey="ngModel" matInput name="destinationPubkey" tabindex="1" required [(ngModel)]="destinationPubkey">
      <mat-error *ngIf="!destinationPubkey">Destination pubkey is required.</mat-error>
    </mat-form-field>
    <mat-form-field fxLayout="column" fxFlex="29" fxLayoutAlign="start end">
      <mat-label>Amount (Sats)</mat-label>
      <input matInput name="amount" tabindex="2" type="number" required [step]="1000" [min]="0" [(ngModel)]="amount">
      <mat-error *ngIf="!amount">Amount is required.</mat-error>
    </mat-form-field>
    <div fxLayout="row" class="mt-1">
      <button class="mr-1" mat-stroked-button color="primary" tabindex="3" type="reset" (click)="resetData()">Clear</button>
      <button mat-flat-button color="primary" type="submit" tabindex="4">Query Route</button>
    </div>
  </form>
  <div fxLayout="row" fxLayoutAlign="start center" class="page-sub-title-container mt-2 mb-1">
    <div fxFlex="70">
      <fa-icon class="page-title-img mr-1" [icon]="faRoute" />
      <span class="page-title">Transaction Route</span>
    </div>
  </div>
  <div class="table-container mb-6" [perfectScrollbar]>
    <mat-progress-bar *ngIf="flgLoading[0]===true" mode="indeterminate" />
    <table #table mat-table matSort [matSortActive]="tableSetting.sortBy" [matSortDirection]="tableSetting.sortOrder" [dataSource]="qrHops" [ngClass]="{'overflow-auto error-border': flgLoading[0]==='error','overflow-auto': true}">
      <ng-container matColumnDef="id">
        <th *matHeaderCellDef mat-header-cell mat-sort-header>ID</th>
        <td *matCellDef="let hop" mat-cell>
          <div class="ellipsis-parent" [ngStyle]="{'width': (screenSize === screenSizeEnum.XS) ? '6rem' : colWidth}">
            <span class="ellipsis-child">{{hop?.id}}</span>
          </div>
        </td>
      </ng-container>
      <ng-container matColumnDef="alias">
        <th *matHeaderCellDef mat-header-cell mat-sort-header>Alias</th>
        <td *matCellDef="let hop" mat-cell> 
          <div class="ellipsis-parent" [ngStyle]="{'width': (screenSize === screenSizeEnum.XS) ? '6rem' : colWidth}">
            <span class="ellipsis-child">{{hop?.alias}}</span>
          </div>
        </td>
      </ng-container>
      <ng-container matColumnDef="channel">
        <th *matHeaderCellDef mat-header-cell mat-sort-header>Channel</th>
        <td *matCellDef="let hop" mat-cell>{{hop?.channel}}</td>
      </ng-container>
      <ng-container matColumnDef="direction">
        <th *matHeaderCellDef mat-header-cell mat-sort-header>Direction</th>
        <td *matCellDef="let hop" mat-cell>{{hop?.direction}}</td>
      </ng-container>
      <ng-container matColumnDef="delay">
        <th *matHeaderCellDef mat-header-cell mat-sort-header arrowPosition="before">Delay</th>
        <td *matCellDef="let hop" mat-cell><span fxLayoutAlign="end center">{{hop?.delay | number}} </span></td>
      </ng-container>
      <ng-container matColumnDef="msatoshi">
        <th *matHeaderCellDef mat-header-cell mat-sort-header arrowPosition="before">Amount (Sats)</th>
        <td *matCellDef="let hop" mat-cell><span fxLayoutAlign="end center">{{hop?.amount_msat/1000 | number}}</span></td>
      </ng-container>
      <ng-container matColumnDef="actions">
        <th *matHeaderCellDef mat-header-cell>
          <div class="bordered-box table-actions-select" fxLayoutAlign="center center">Actions</div>
       </th>
        <td *matCellDef="let hop" mat-cell fxLayoutAlign="end center">
          <button mat-stroked-button color="primary" type="button" tabindex="4" class="table-actions-button" (click)="onHopClick(hop, $event)">View Info</button>          
        </td>
      </ng-container>
      <tr *matHeaderRowDef="displayedColumns" mat-header-row></tr>
      <tr *matRowDef="let row; columns: displayedColumns;" mat-row></tr>
    </table>
  </div>
</div>
