<div fxLayout="row">
  <div fxFlex="100">
    <mat-card-header fxLayout="row" fxLayoutAlign="space-between center" class="modal-info-header">
      <div fxFlex="95" fxLayoutAlign="start start">
        <span class="page-title">Send Payment</span>
      </div>
      <button tabindex="11" fxFlex="5" fxLayoutAlign="center center" class="btn-close-x p-0" default mat-button [mat-dialog-close]="false">X</button>
    </mat-card-header>
    <mat-card-content class="padding-gap-x-large">
      <form #sendPaymentForm="ngForm" fxLayoutAlign="space-between stretch" fxLayout="column">
        <mat-form-field fxLayout="column" fxFlex="100">
          <mat-label>Payment Request</mat-label>
          <textarea #paymentReq="ngModel" autoFocus matInput name="paymentRequest" rows="4" tabindex="1" required [ngModel]="paymentRequest" (ngModelChange)="onPaymentRequestEntry($event)" (matTextareaAutosize)="true"></textarea>
          <mat-hint *ngIf="paymentRequest && paymentDecodedHintPre !== ''" fxLayout="row wrap" fxFlex="100">
            {{paymentDecodedHintPre}}
            <span *ngIf="convertedCurrency && convertedCurrency.iconType === 'FA' && paymentDecodedHintPre !== ''" fxLayoutAlign="center center" class="mr-3px">
              <fa-icon [icon]="convertedCurrency.symbol" />
            </span>
            <span *ngIf="convertedCurrency && convertedCurrency.iconType === 'SVG' && paymentDecodedHintPre !== ''" fxLayoutAlign="center center" class="mr-3px" [innerHTML]="convertedCurrency.symbol"></span>
            {{paymentDecodedHintPost}}
          </mat-hint>
          <mat-error *ngIf="!paymentRequest">Payment request is required.</mat-error>
          <mat-error *ngIf="paymentReq.errors?.decodeError">{{paymentDecodedHint}}</mat-error>
        </mat-form-field>
        <mat-form-field *ngIf="zeroAmtInvoice" fxFlex="100">
          <mat-label>Amount (Sats)</mat-label>
          <input #paymentAmt="ngModel" matInput name="amount" tabindex="2" required [(ngModel)]="paymentAmount" (change)="onAmountChange($event)">
          <mat-hint>It is a zero amount invoice, enter amount to be paid.</mat-hint>
          <mat-error *ngIf="!paymentAmount">Payment amount is required.</mat-error>
        </mat-form-field>
        <mat-expansion-panel fxFlex="100" class="flat-expansion-panel mt-2" expanded="false" (closed)="onAdvancedPanelToggle(true, false)" (opened)="onAdvancedPanelToggle(false, false)">
          <mat-expansion-panel-header>
            <mat-panel-title>
              <span>{{advancedTitle}}</span>
            </mat-panel-title>
          </mat-expansion-panel-header>
          <div fxFlex="100" fxLayout="column" fxLayoutAlign="space-between stretch" fxLayout.gt-sm="row wrap">
            <mat-form-field fxLayout="column" fxFlex="27" fxLayoutAlign="start end">
              <mat-label>Fee Limits</mat-label>
              <mat-select tabindex="5" [(value)]="selFeeLimitType">
                <mat-option *ngFor="let feeLimitType of feeLimitTypes" [value]="feeLimitType">
                  {{feeLimitType?.name}}
                </mat-option>
              </mat-select>
            </mat-form-field>
            <mat-form-field fxLayout="column" fxFlex="33">
              <mat-label>{{selFeeLimitType?.placeholder}}</mat-label>
              <input #fLmt="ngModel" matInput type="number" name="feeLmt" required tabindex="6" [step]="1" [min]="0" [disabled]="selFeeLimitType === feeLimitTypes[0]" [(ngModel)]="feeLimit">
              <mat-error *ngIf="selFeeLimitType !== feeLimitTypes[0] && !feeLimit">{{selFeeLimitType?.placeholder}} is required.</mat-error>
            </mat-form-field>
            <mat-form-field fxLayout="column" fxFlex="37" fxLayoutAlign="start end">
              <mat-label>First Outgoing Channel</mat-label>
              <input type="text" aria-label="First Outgoing Channel" matInput tabindex="7" [formControl]="selectedChannelCtrl" [matAutocomplete]="auto">
              <mat-autocomplete #auto="matAutocomplete" [displayWith]="displayFn" (optionSelected)="onSelectedChannelChanged()">
                <mat-option *ngFor="let activeChannel of filteredMinAmtActvChannels" [value]="activeChannel">{{activeChannel?.remote_alias || activeChannel?.chan_id}}</mat-option>
              </mat-autocomplete>
              <mat-error *ngIf="selectedChannelCtrl.errors?.notfound">Channel not found in the list.</mat-error>
            </mat-form-field>
            <mat-slide-toggle fxFlex="25" tabindex="8" color="primary" name="isAmp" [(ngModel)]="isAmp">AMP Payment</mat-slide-toggle>
          </div>
        </mat-expansion-panel>
        <div *ngIf="paymentError !== ''" fxFlex="100" class="alert alert-danger mt-1">
          <fa-icon class="mr-1 alert-icon" [icon]="faExclamationTriangle" />
          <span *ngIf="paymentError !== ''">{{paymentError}}</span>
        </div>
        <div class="mt-2" fxLayout="row" fxLayoutAlign="end center">
          <button class="mr-1" mat-button color="primary" tabindex="9" type="reset" (click)="resetData()">Clear Fields</button>
          <button mat-button id="sendBtn" color="primary" tabindex="10" (click)="onSendPayment()">Send Payment</button>
        </div>
      </form>
    </mat-card-content>
  </div>
</div>
