<div fxLayout="column" fxLayout.gt-sm="row" fxLayoutAlign="space-between stretch">
  <div fxFlex="35" class="modal-qr-code-container padding-gap-large" [fxLayoutAlign]="((invoice?.bolt11 && invoice?.bolt11 !== '') || (invoice?.bolt12 && invoice?.bolt12 !== '')) ? 'center start' : 'center center'" [ngClass]="{'display-none': screenSize === screenSizeEnum.XS || screenSize === screenSizeEnum.SM}">
    <qr-code *ngIf="((invoice?.bolt11 && invoice?.bolt11 !== '') || (invoice?.bolt12 && invoice?.bolt12 !== ''))" [value]="invoice?.bolt11 || invoice?.bolt12" [size]="qrWidth" [errorCorrectionLevel]="'L'" />
    <span *ngIf="!invoice?.bolt11 && !invoice?.bolt12" class="font-size-300">N/A</span>
  </div>
  <div fxFlex="65">
    <mat-card-header fxLayout="row" fxLayoutAlign="space-between center" class="modal-info-header">
      <div fxFlex="95" fxLayoutAlign="start start">
        <fa-icon class="page-title-img mr-1" [icon]="faReceipt" />
        <span class="page-title">
          {{screenSize === screenSizeEnum.XS ?  (newlyAdded ? 'Created' : 'Invoice') : (newlyAdded ? 'Invoice Created' : 'Invoice Information')}}
          <span *ngIf="invoice?.status === 'paid'" class="dot green ml-1" matTooltip="Paid" matTooltipPosition="right" [ngClass]="{'mr-0': screenSize === screenSizeEnum.XS}"></span>
          <span *ngIf="invoice?.status === 'unpaid'" class="dot yellow ml-1" matTooltip="Unpaid" matTooltipPosition="right" [ngClass]="{'mr-0': screenSize === screenSizeEnum.XS}"></span>
          <span *ngIf="invoice?.status === 'expired'" class="dot red ml-1" matTooltip="Expired" matTooltipPosition="right" [ngClass]="{'mr-0': screenSize === screenSizeEnum.XS}"></span>
        </span>
      </div>
      <button tabindex="3" fxFlex="5" fxLayoutAlign="center center" class="btn-close-x p-0" mat-button (click)="onClose()">X</button>
    </mat-card-header>
    <mat-card-content class="padding-gap-x-large" [ngClass]="{'xs-scroll-y': screenSize === screenSizeEnum.XS}">
      <div fxLayout="column">
        <div fxFlex="30" class="modal-qr-code-container padding-gap" [fxLayoutAlign]="((invoice?.bolt11 && invoice?.bolt11 !== '') || (invoice?.bolt12 && invoice?.bolt12 !== '')) ? 'center start' : 'center center'" [ngClass]="{'display-none': screenSize !== screenSizeEnum.XS && screenSize !== screenSizeEnum.SM}">
          <qr-code *ngIf="((invoice?.bolt11 && invoice?.bolt11 !== '') || (invoice?.bolt12 && invoice?.bolt12 !== ''))" [value]="invoice?.bolt11 || invoice?.bolt12" [size]="qrWidth" [errorCorrectionLevel]="'L'" />
          <span *ngIf="!invoice?.bolt11 && !invoice?.bolt12" class="font-size-120">QR Code Not Applicable</span>
        </div>
        <mat-divider *ngIf="screenSize === screenSizeEnum.XS || screenSize === screenSizeEnum.SM" class="my-1" />
        <div *ngIf="invoice?.warning_capacity" fxLayout="row">
          <div fxFlex="100" class="alert alert-warn">
            <fa-icon class="mr-1 alert-icon" [icon]="faExclamationTriangle" />
            <span>{{invoice?.warning_capacity}}</span>
          </div>
        </div>
        <div fxLayout="row">
          <div fxFlex="50">
            <h4 fxLayoutAlign="start" class="font-bold-500">{{screenSize === screenSizeEnum.XS ? 'Amount' : 'Amount Requested'}}</h4>
            <span class="foreground-secondary-text">
              {{(invoice?.amount_msat/1000 || 0) | number}} Sats<ng-container *ngIf="!invoice?.amount_msat || invoice?.amount_msat === '0' || invoice?.amount_msat === 'any'"> (zero amount) </ng-container>
            </span>
          </div>
          <div fxFlex="50">
            <h4 fxLayoutAlign="start" class="font-bold-500">Amount Received</h4>
            <span class="overflow-wrap foreground-secondary-text">
              <ng-container *ngIf="invoice?.status === 'paid'">
                <div *ngIf="flgInvoicePaid" class="invoice-animation-container">
                  <div class="invoice-animation-div">
                    <span class="wiggle">{{invoice?.amount_received_msat/1000 | number}} Sats</span>
                    <span *ngFor="let i of [].constructor(35)" class="particles-circle"></span>
                  </div>
                </div>
                <div *ngIf="!flgInvoicePaid">{{invoice?.amount_received_msat/1000 | number}} Sats</div>
              </ng-container>
              <ng-container *ngIf="invoice?.status !== 'paid'">
                <span *ngIf="invoice?.status !== 'unpaid'">-</span>
                <mat-spinner *ngIf="invoice?.status === 'unpaid'" [diameter]="20" />
              </ng-container>
            </span>
          </div>
        </div>
        <mat-divider class="w-100 my-1" />   
        <div fxLayout="row">
          <div fxFlex="50">
            <h4 fxLayoutAlign="start" class="font-bold-500">Date Expiry</h4>
            <span class="foreground-secondary-text">{{(invoice?.expires_at * 1000) | date:'dd/MMM/y HH:mm'}}</span>
          </div>
          <div fxFlex="50">
            <h4 fxLayoutAlign="start" class="font-bold-500">Date Settled</h4>
            <span class="foreground-secondary-text">{{((invoice?.paid_at * 1000) | date:'dd/MMM/y HH:mm') || '-'}}</span>
          </div>
        </div>
        <mat-divider class="w-100 my-1" />
      <div fxLayout="row">
          <div fxFlex="100">
            <h4 fxLayoutAlign="start" class="font-bold-500">Description</h4>
            <span class="foreground-secondary-text">{{invoice?.description || '-'}}</span>
          </div>
        </div>
        <mat-divider class="w-100 my-1" />
        <div fxLayout="row">
          <div fxFlex="100">
            <h4 fxLayoutAlign="start" class="font-bold-500">{{ invoice?.bolt12 ? 'Bolt12' : (invoice?.bolt11 && !invoice.label.includes('keysend-')) ? 'Bolt11' : 'Keysend' }} Invoice</h4>
            <span class="overflow-wrap foreground-secondary-text">{{invoice?.bolt11 || invoice?.bolt12}}</span>
          </div>
        </div>
        <div *ngIf="showAdvanced">
          <mat-divider class="w-100 my-1" />
          <div fxLayout="row">
            <div fxFlex="100">
              <h4 fxLayoutAlign="start" class="font-bold-500">Payment Hash</h4>
              <span class="overflow-wrap foreground-secondary-text">{{invoice?.payment_hash}}</span>
            </div>
          </div>
          <mat-divider class="w-100 my-1" />
          <div fxLayout="row">
            <div fxFlex="100">
              <h4 fxLayoutAlign="start" class="font-bold-500">Label</h4>
              <span class="overflow-wrap foreground-secondary-text">{{invoice?.label}}</span>
            </div>
          </div>
          <mat-divider class="w-100 my-1" />
        </div>
        <div fxLayout="row" fxLayoutAlign="end center" [ngClass]="{'mt-2': !showAdvanced, 'mt-1': showAdvanced}">
          <button class="mr-1" mat-button color="primary" type="reset" tabindex="1" (click)="onShowAdvanced()">
            <p *ngIf="!showAdvanced; else hideAdvancedText">Show Advanced</p>
            <ng-template #hideAdvancedText><p>Hide Advanced</p></ng-template>
          </button>
          <button *ngIf="((invoice?.bolt11 && invoice?.bolt11 !== '') || (invoice?.bolt12 && invoice?.bolt12 !== ''))" autoFocus mat-button color="primary" tabindex="2" type="submit" rtlClipboard [payload]="invoice?.bolt11 || invoice?.bolt12" (copied)="onCopyPayment($event)">Copy Invoice</button>
          <button *ngIf="!invoice?.bolt11 && !invoice?.bolt12" autoFocus mat-button color="primary" tabindex="2" type="button" (click)="onClose()">OK</button>
        </div>
      </div>
      </mat-card-content>
  </div>
</div>
