<form fxLayout="column" fxFlex="98" fxLayout.gt-sm="row wrap" fxLayoutAlign="start stretch" fxLayoutAlign.gt-sm="space-between start" *ngIf="!sweepAll; else sweepAllBlock;" class="padding-gap overflow-x-hidden" (submit)="onSendFunds()" (reset)="resetData()" #form="ngForm">
  <mat-form-field fxFlex.gt-sm="55">
    <input matInput [(ngModel)]="transaction.address" placeholder="Bitcoin Address" tabindex="1" name="address" required #address="ngModel">
    <mat-error *ngIf="!transaction.address">Bitcoin address is required.</mat-error>
  </mat-form-field>
  <mat-form-field fxFlex.gt-sm="30">
    <input matInput [(ngModel)]="transaction.amount" placeholder="Amount" name="amount" type="number" step="100" min="0" tabindex="2" required #amount="ngModel">
    <span matSuffix> {{selAmountUnit}} </span>
    <mat-error *ngIf="!transaction.amount">Amount is required.</mat-error>
  </mat-form-field>
  <mat-form-field fxFlex.gt-sm="10" fxLayoutAlign="start end">
    <mat-select [value]="selAmountUnit" tabindex="3" required name="amountUnit" (selectionChange)="onAmountUnitChange($event)">
      <mat-option *ngFor="let amountUnit of amountUnits" [value]="amountUnit">{{amountUnit}}</mat-option>
    </mat-select>
  </mat-form-field>
  <div fxLayout="column" fxFlex="100" fxFlex.gt-sm="60" fxLayout.gt-sm="row wrap" fxLayoutAlign="start stretch" fxLayoutAlign.gt-sm="space-between start">  
    <mat-form-field fxFlex="48">
      <mat-select [(value)]="selTransType" tabindex="4">
        <mat-option *ngFor="let transType of transTypes" [value]="transType.id">
          {{transType.name}}
        </mat-option>
      </mat-select>
    </mat-form-field>
    <mat-form-field fxFlex="48" *ngIf="selTransType=='1'">
      <input matInput [(ngModel)]="transaction.blocks" placeholder="Number of Blocks" type="number" name="blocks" step="1" min="0" required tabindex="5" #blocks="ngModel">
      <mat-error *ngIf="!transaction.blocks">Number of blocks is required.</mat-error>
    </mat-form-field>
    <mat-form-field fxFlex="48" *ngIf="selTransType=='2'">
      <input matInput [(ngModel)]="transaction.fees" placeholder="Fees ({{nodeData?.smaller_currency_unit}}/Byte)" type="number" name="fees" step="1" min="0" required tabindex="6" #fees="ngModel">
      <mat-error *ngIf="!transaction.fees">Fees is required.</mat-error>
    </mat-form-field>
  </div>
  <div fxLayout="column" fxFlex="100" fxFlex.gt-sm="40" fxLayout.gt-sm="row wrap" fxLayoutAlign="start stretch" fxLayoutAlign.gt-sm="space-between start"></div>
  <div fxLayout="row" fxFlex="100" fxFlex.gt-sm="30" fxLayoutAlign="space-between stretch" class="mt-2">
    <button fxFlex="48" fxLayoutAlign="center center" mat-stroked-button color="primary" tabindex="7" type="reset">Clear Fields</button>
    <button fxFlex="48" fxLayoutAlign="center center" mat-raised-button color="primary" type="submit" tabindex="8">Send Funds</button>
  </div>
</form>
<ng-template #sweepAllBlock>
  <form fxLayout="column" fxFlex="100" class="padding-gap overflow-x-hidden">
    <div fxLayout="column" fxFlex="98" fxLayout.gt-sm="row wrap" fxLayoutAlign="start stretch" fxLayoutAlign.gt-sm="space-between start" (submit)="onSendFunds()" (reset)="resetData()" #formSweepAll>
      <mat-form-field fxFlex.gt-sm="55">
        <input matInput [(ngModel)]="transaction.address" placeholder="Bitcoin Address" tabindex="1" name="address" required #addressSweep="ngModel">
        <mat-error *ngIf="!transaction.address">Bitcoin address is required.</mat-error>
      </mat-form-field>
      <mat-form-field fxFlex.gt-sm="20">
        <mat-select [(value)]="selTransType" tabindex="4">
          <mat-option *ngFor="let transType of transTypes" [value]="transType.id">
            {{transType.name}}
          </mat-option>
        </mat-select>
      </mat-form-field>
      <mat-form-field fxFlex.gt-sm="20" fxLayoutAlign="start end" *ngIf="selTransType=='1'">
        <input matInput [(ngModel)]="transaction.blocks" placeholder="Number of Blocks" type="number" name="blocks" step="1" min="0" required tabindex="5" #blocks="ngModel">
        <mat-error *ngIf="!transaction.blocks">Number of blocks is required.</mat-error>
      </mat-form-field>
      <mat-form-field fxFlex.gt-sm="20" fxLayoutAlign="start end" *ngIf="selTransType=='2'">
        <input matInput [(ngModel)]="transaction.fees" placeholder="Fees ({{nodeData?.smaller_currency_unit}}/Byte)" type="number" name="fees" step="1" min="0" required tabindex="6" #feesSweep="ngModel">
        <mat-error *ngIf="!transaction.fees">Fees is required.</mat-error>
      </mat-form-field>
    </div>
    <div>
      <div fxFlex="100" fxFlex.gt-sm="30" fxLayout="row" fxLayoutAlign="space-between stretch" class="mt-2">  
        <button fxFlex="48" fxLayoutAlign="center center" mat-stroked-button color="primary" tabindex="7" type="reset">Clear Fields</button>
        <button fxFlex="48" fxLayoutAlign="center center" mat-raised-button color="primary" type="submit" tabindex="8">Send Funds</button>
      </div>
    </div>
  </form>
</ng-template>