<div class="content">
  <div class="inner-content" *ngIf="cipher">
    <div class="box">
      <h2 class="box-header">
        {{ "itemInformation" | i18n }}
      </h2>
      <div class="box-content">
        <div class="box-content-row">
          <span
            class="row-label draggable"
            draggable="true"
            (dragstart)="setTextDataOnDrag($event, cipher.name)"
            >{{ "name" | i18n }}</span
          >
          {{ cipher.name }}
        </div>
        <!-- Login -->
        <div *ngIf="cipher.login">
          <div class="box-content-row box-content-row-flex" *ngIf="cipher.login.username">
            <div class="row-main">
              <span
                class="row-label draggable"
                draggable="true"
                (dragstart)="setTextDataOnDrag($event, cipher.login.username)"
                >{{ "username" | i18n }}</span
              >
              {{ cipher.login.username }}
            </div>
            <div class="action-buttons">
              <button
                type="button"
                class="row-btn"
                appStopClick
                appA11yTitle="{{ 'copyUsername' | i18n }}"
                (click)="copy(cipher.login.username, 'username', 'Username')"
              >
                <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
              </button>
            </div>
          </div>
          <div class="box-content-row box-content-row-flex" *ngIf="cipher.login.password">
            <div class="row-main">
              <span
                class="row-label draggable"
                draggable="true"
                (dragstart)="setTextDataOnDrag($event, cipher.login.password)"
                >{{ "password" | i18n }}</span
              >
              <div *ngIf="!showPassword" class="monospaced">
                {{ cipher.login.maskedPassword }}
              </div>
              <div
                *ngIf="showPassword && !showPasswordCount"
                class="monospaced password-wrapper"
                [appCopyText]="cipher.login.password"
                [innerHTML]="cipher.login.password | colorPassword"
              ></div>
              <div
                *ngIf="showPassword && showPasswordCount"
                [innerHTML]="cipher.login.password | colorPasswordCount"
              ></div>
            </div>
            <div class="action-buttons" *ngIf="cipher.viewPassword">
              <button
                type="button"
                #checkPasswordBtn
                class="row-btn btn"
                appA11yTitle="{{ 'checkPassword' | i18n }}"
                (click)="checkPassword()"
                [appApiAction]="checkPasswordPromise"
                [disabled]="$any(checkPasswordBtn).loading"
              >
                <i
                  class="bwi bwi-lg bwi-check-circle"
                  [hidden]="$any(checkPasswordBtn).loading"
                  aria-hidden="true"
                ></i>
                <i
                  class="bwi bwi-lg bwi-spinner bwi-spin"
                  [hidden]="!$any(checkPasswordBtn).loading"
                  aria-hidden="true"
                ></i>
              </button>
              <button
                type="button"
                class="row-btn"
                appStopClick
                attr.aria-label="{{ 'toggleCharacterCount' | i18n }} {{ 'password' | i18n }}"
                appA11yTitle="{{ 'toggleCharacterCount' | i18n }}"
                (click)="togglePasswordCount()"
                *ngIf="showPassword"
                [attr.aria-pressed]="showPasswordCount"
              >
                <i class="bwi bwi-lg bwi-numbered-list" aria-hidden="true"></i>
              </button>
              <button
                type="button"
                class="row-btn"
                appStopClick
                appA11yTitle="{{ 'toggleVisibility' | i18n }}"
                [attr.aria-pressed]="showPassword"
                (click)="togglePassword()"
              >
                <i
                  class="bwi bwi-lg"
                  aria-hidden="true"
                  [ngClass]="{ 'bwi-eye': !showPassword, 'bwi-eye-slash': showPassword }"
                ></i>
              </button>
              <button
                type="button"
                class="row-btn"
                appStopClick
                appA11yTitle="{{ 'copyPassword' | i18n }}"
                (click)="copy(cipher.login.password, 'password', 'Password')"
              >
                <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
              </button>
            </div>
          </div>
          <!--Passkey-->
          <div
            class="box-content-row text-muted"
            *ngIf="cipher.login.hasFido2Credentials"
            tabindex="0"
            attr.aria-label="{{ 'typePasskey' | i18n }} {{ fido2CredentialCreationDateValue }}"
          >
            <span class="row-label">{{ "typePasskey" | i18n }}</span>
            {{ fido2CredentialCreationDateValue }}
          </div>
          <div
            class="box-content-row box-content-row-flex totp"
            [ngClass]="{ low: totpLow }"
            *ngIf="cipher.login.totp && totpCode"
          >
            <div class="row-main">
              <span
                class="row-label draggable"
                draggable="true"
                (dragstart)="setTextDataOnDrag($event, totpCode)"
                >{{ "verificationCodeTotp" | i18n }}</span
              >
              <span class="totp-code">{{ totpCodeFormatted }}</span>
            </div>
            <span class="totp-countdown" aria-hidden="true">
              <span class="totp-sec">{{ totpSec }}</span>
              <svg>
                <g>
                  <circle
                    class="totp-circle inner"
                    r="12.6"
                    cy="16"
                    cx="16"
                    [ngStyle]="{ 'stroke-dashoffset.px': totpDash }"
                  ></circle>
                  <circle class="totp-circle outer" r="14" cy="16" cx="16"></circle>
                </g>
              </svg>
            </span>
            <div class="action-buttons">
              <button
                type="button"
                class="row-btn"
                appStopClick
                title="{{ 'copyValue' | i18n }}"
                (click)="copy(totpCode, 'verificationCodeTotp', 'TOTP')"
              >
                <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
                <span class="sr-only">{{ "copyValue" | i18n }}</span>
                <span
                  class="sr-only exists-only-on-parent-focus"
                  aria-live="polite"
                  aria-atomic="true"
                  >{{ totpSec }}</span
                >
              </button>
            </div>
          </div>
          <div class="box-content-row box-content-row-flex totp" *ngIf="showPremiumRequiredTotp">
            <div class="row-main">
              <span class="row-label">{{ "verificationCodeTotp" | i18n }}</span>
              <span class="row-label">
                <a [routerLink]="" (click)="showGetPremium()"
                  >{{ "premiumSubcriptionRequired" | i18n }}
                </a>
              </span>
            </div>
          </div>
        </div>
        <!-- Card -->
        <div *ngIf="cipher.card">
          <div class="box-content-row" *ngIf="cipher.card.cardholderName">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.card.cardholderName)"
              >{{ "cardholderName" | i18n }}</span
            >
            {{ cipher.card.cardholderName }}
          </div>
          <div class="box-content-row box-content-row-flex" *ngIf="cipher.card.number">
            <div class="row-main">
              <span
                class="row-label draggable"
                draggable="true"
                (dragstart)="setTextDataOnDrag($event, cipher.card.number)"
                >{{ "number" | i18n }}</span
              >
              <span *ngIf="!showCardNumber" class="monospaced">{{
                cipher.card.maskedNumber | creditCardNumber: cipher.card.brand
              }}</span>
              <span *ngIf="showCardNumber" class="monospaced">{{
                cipher.card.number | creditCardNumber: cipher.card.brand
              }}</span>
            </div>
            <div class="action-buttons">
              <button
                type="button"
                class="row-btn"
                appStopClick
                appA11yTitle="{{ 'toggleVisibility' | i18n }}"
                [attr.aria-pressed]="showCardNumber"
                (click)="toggleCardNumber()"
              >
                <i
                  class="bwi bwi-lg"
                  aria-hidden="true"
                  [ngClass]="{ 'bwi-eye': !showCardNumber, 'bwi-eye-slash': showCardNumber }"
                ></i>
              </button>
              <button
                type="button"
                class="row-btn"
                appStopClick
                appA11yTitle="{{ 'copyNumber' | i18n }}"
                (click)="copy(cipher.card.number, 'number', 'Card Number')"
              >
                <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
              </button>
            </div>
          </div>
          <div class="box-content-row" *ngIf="cipher.card.brand">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.card.brand)"
              >{{ "brand" | i18n }}</span
            >
            {{ cipher.card.brand }}
          </div>
          <div class="box-content-row" *ngIf="cipher.card.expiration">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.card.expiration)"
              >{{ "expiration" | i18n }}</span
            >
            {{ cipher.card.expiration }}
          </div>
          <div class="box-content-row box-content-row-flex" *ngIf="cipher.card.code">
            <div class="row-main">
              <span
                class="row-label draggable"
                draggable="true"
                (dragstart)="setTextDataOnDrag($event, cipher.card.code)"
                >{{ "securityCode" | i18n }}</span
              >
              <span *ngIf="!showCardCode" class="monospaced">{{ cipher.card.maskedCode }}</span>
              <span *ngIf="showCardCode" class="monospaced">{{ cipher.card.code }}</span>
            </div>
            <div class="action-buttons">
              <button
                type="button"
                class="row-btn"
                appStopClick
                appA11yTitle="{{ 'toggleVisibility' | i18n }}"
                [attr.aria-pressed]="showCardCode"
                (click)="toggleCardCode()"
              >
                <i
                  class="bwi bwi-lg"
                  aria-hidden="true"
                  [ngClass]="{ 'bwi-eye': !showCardCode, 'bwi-eye-slash': showCardCode }"
                ></i>
              </button>
              <button
                type="button"
                class="row-btn"
                appStopClick
                appA11yTitle="{{ 'copySecurityCode' | i18n }}"
                (click)="copy(cipher.card.code, 'securityCode', 'Security Code')"
              >
                <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
              </button>
            </div>
          </div>
        </div>
        <!-- Identity -->
        <div *ngIf="cipher.identity">
          <div class="box-content-row" *ngIf="cipher.identity.fullName">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.identity.fullName)"
              >{{ "identityName" | i18n }}</span
            >
            {{ cipher.identity.fullName }}
          </div>
          <div class="box-content-row" *ngIf="cipher.identity.username">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.identity.username)"
              >{{ "username" | i18n }}</span
            >
            {{ cipher.identity.username }}
          </div>
          <div class="box-content-row" *ngIf="cipher.identity.company">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.identity.company)"
              >{{ "company" | i18n }}</span
            >
            {{ cipher.identity.company }}
          </div>
          <div class="box-content-row" *ngIf="cipher.identity.ssn">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.identity.ssn)"
              >{{ "ssn" | i18n }}</span
            >
            {{ cipher.identity.ssn }}
          </div>
          <div class="box-content-row" *ngIf="cipher.identity.passportNumber">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.identity.passportNumber)"
              >{{ "passportNumber" | i18n }}</span
            >
            {{ cipher.identity.passportNumber }}
          </div>
          <div class="box-content-row" *ngIf="cipher.identity.licenseNumber">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.identity.licenseNumber)"
              >{{ "licenseNumber" | i18n }}</span
            >
            {{ cipher.identity.licenseNumber }}
          </div>
          <div class="box-content-row" *ngIf="cipher.identity.email">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.identity.email)"
              >{{ "email" | i18n }}</span
            >
            {{ cipher.identity.email }}
          </div>
          <div class="box-content-row" *ngIf="cipher.identity.phone">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, cipher.identity.phone)"
              >{{ "phone" | i18n }}</span
            >
            {{ cipher.identity.phone }}
          </div>
          <div
            class="box-content-row"
            *ngIf="cipher.identity.address1 || cipher.identity.city || cipher.identity.country"
          >
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="
                setTextDataOnDrag(
                  $event,
                  (cipher.identity.address1 ? cipher.identity.address1 + '\n' : '') +
                    (cipher.identity.address2 ? cipher.identity.address2 + '\n' : '') +
                    (cipher.identity.address3 ? cipher.identity.address3 + '\n' : '') +
                    (cipher.identity.fullAddressPart2
                      ? cipher.identity.fullAddressPart2 + '\n'
                      : '') +
                    (cipher.identity.country ? cipher.identity.country : '')
                )
              "
              >{{ "address" | i18n }}</span
            >
            <div *ngIf="cipher.identity.address1">{{ cipher.identity.address1 }}</div>
            <div *ngIf="cipher.identity.address2">{{ cipher.identity.address2 }}</div>
            <div *ngIf="cipher.identity.address3">{{ cipher.identity.address3 }}</div>
            <div *ngIf="cipher.identity.fullAddressPart2">
              {{ cipher.identity.fullAddressPart2 }}
            </div>
            <div *ngIf="cipher.identity.country">{{ cipher.identity.country }}</div>
          </div>
        </div>
        <!-- Ssh Key -->
        <div *ngIf="cipher.sshKey">
          <div class="box-content-row box-content-row-flex" *ngIf="cipher.sshKey.privateKey">
            <div class="row-main">
              <span class="row-label">{{ "sshPrivateKey" | i18n }}</span>
              <div
                *ngIf="!showPrivateKey"
                class="monospaced"
                style="white-space: pre-line"
                [innerText]="cipher.sshKey.maskedPrivateKey"
              ></div>
              <div
                *ngIf="showPrivateKey"
                class="monospaced"
                style="white-space: pre-line"
                [innerText]="cipher.sshKey.privateKey"
              ></div>
            </div>
            <div class="action-buttons" *ngIf="cipher.viewPassword">
              <button
                type="button"
                class="row-btn"
                appStopClick
                appA11yTitle="{{ 'toggleVisibility' | i18n }}"
                [attr.aria-pressed]="showPrivateKey"
                (click)="togglePrivateKey()"
              >
                <i
                  class="bwi bwi-lg"
                  aria-hidden="true"
                  [ngClass]="{ 'bwi-eye': !showPrivateKey, 'bwi-eye-slash': showPrivateKey }"
                ></i>
              </button>
              <button
                type="button"
                class="row-btn"
                appStopClick
                appA11yTitle="{{ 'copySSHPrivateKey' | i18n }}"
                (click)="copy(cipher.sshKey.privateKey, 'sshPrivateKey', 'SshPrivateKey')"
              >
                <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
              </button>
            </div>
          </div>
          <div
            class="box-content-row box-content-row-flex"
            *ngIf="cipher.sshKey.publicKey"
            appBoxRow
          >
            <div class="row-main">
              <label for="sshPublicKey">{{ "sshPublicKey" | i18n }}</label>
              <input
                id="sshPublicKey"
                type="text"
                name="SshKey.SshPublicKey"
                [ngModel]="cipher.sshKey.publicKey"
                readonly
              />
            </div>
            <div class="action-buttons">
              <button
                type="button"
                class="row-btn"
                appStopClick
                (click)="copy(cipher.sshKey.publicKey, 'sshPublicKey', 'SshPublicKey')"
                appA11yTitle="{{ 'generateSshKey' | i18n }}"
              >
                <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
              </button>
            </div>
          </div>
          <div
            class="box-content-row box-content-row-flex"
            *ngIf="cipher.sshKey.keyFingerprint"
            appBoxRow
          >
            <div class="row-main">
              <label for="sshKeyFingerprint">{{ "sshFingerprint" | i18n }}</label>
              <input
                id="sshKeyFingerprint"
                type="text"
                name="SshKey.SshKeyFingerprint"
                [ngModel]="cipher.sshKey.keyFingerprint"
                readonly
              />
            </div>
            <div class="action-buttons">
              <button
                type="button"
                class="row-btn"
                appStopClick
                (click)="copy(cipher.sshKey.keyFingerprint, 'sshFingerprint', 'SshFingerprint')"
                appA11yTitle="{{ 'generateSshKey' | i18n }}"
              >
                <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="box" *ngIf="cipher.login && cipher.login.hasUris">
      <div class="box-content">
        <div
          class="box-content-row box-content-row-flex"
          *ngFor="let u of cipher.login.uris; let i = index"
        >
          <div class="row-main">
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, u.uri)"
              *ngIf="!u.isWebsite"
              >{{ "uri" | i18n }}</span
            >
            <span
              class="row-label draggable"
              draggable="true"
              (dragstart)="setTextDataOnDrag($event, u.uri)"
              *ngIf="u.isWebsite"
              >{{ "website" | i18n }}</span
            >
            <span title="{{ u.uri }}">{{ u.hostOrUri }}</span>
          </div>
          <div class="action-buttons">
            <button
              type="button"
              class="row-btn"
              appStopClick
              appA11yTitle="{{ 'launch' | i18n }}"
              *ngIf="u.canLaunch"
              (click)="launch(u)"
            >
              <i class="bwi bwi-lg bwi-share-square" aria-hidden="true"></i>
            </button>
            <button
              type="button"
              class="row-btn"
              appStopClick
              appA11yTitle="{{ 'copyUri' | i18n }}"
              (click)="copy(u.uri, u.isWebsite ? 'website' : 'uri', 'URI')"
            >
              <i class="bwi bwi-lg bwi-clone" aria-hidden="true"></i>
            </button>
          </div>
        </div>
      </div>
    </div>
    <div class="box" *ngIf="cipher.folderId && folder">
      <div class="box-content">
        <div class="box-content-row">
          <label
            for="folderName"
            class="draggable"
            draggable="true"
            (dragstart)="setTextDataOnDrag($event, folder.name)"
            >{{ "folder" | i18n }}</label
          >
          <input id="folderName" type="text" name="folderName" [value]="folder.name" readonly />
        </div>
      </div>
    </div>
    <div class="box" *ngIf="cipher.notes">
      <h2 class="box-header">
        <span
          class="draggable"
          draggable="true"
          (dragstart)="setTextDataOnDrag($event, cipher.notes)"
          >{{ "notes" | i18n }}</span
        >
      </h2>
      <div class="box-content">
        <div class="box-content-row pre-wrap">{{ cipher.notes }}</div>
      </div>
    </div>
    <app-vault-view-custom-fields
      *ngIf="cipher.hasFields"
      [cipher]="cipher"
      [promptPassword]="promptPassword.bind(this)"
      [copy]="copy.bind(this)"
    >
    </app-vault-view-custom-fields>
    <div class="box" *ngIf="cipher.hasAttachments && (canAccessPremium || cipher.organizationId)">
      <h2 class="box-header">
        {{ "attachments" | i18n }}
      </h2>
      <div class="box-content">
        <button
          type="button"
          class="box-content-row box-content-row-flex text-default"
          *ngFor="let attachment of cipher.attachments"
          appStopClick
          (click)="downloadAttachment(attachment)"
        >
          <span class="row-main">{{ attachment.fileName }}</span>
          <small class="row-sub-label">{{ attachment.sizeName }}</small>
          <i
            class="bwi bwi-download bwi-fw row-sub-icon"
            *ngIf="!$any(attachment).downloading"
            aria-hidden="true"
          ></i>
          <i
            class="bwi bwi-spinner bwi-fw bwi-spin row-sub-icon"
            *ngIf="$any(attachment).downloading"
            aria-hidden="true"
          ></i>
        </button>
      </div>
    </div>
    <div class="box">
      <div class="box-footer">
        <div>
          <b class="font-weight-semibold">{{ "dateUpdated" | i18n }}:</b>
          {{ cipher.revisionDate | date: "medium" }}
        </div>
        <div *ngIf="cipher.creationDate">
          <b class="font-weight-semibold">{{ "dateCreated" | i18n }}:</b>
          {{ cipher.creationDate | date: "medium" }}
        </div>
        <div *ngIf="cipher.passwordRevisionDisplayDate">
          <b class="font-weight-semibold">{{ "datePasswordUpdated" | i18n }}:</b>
          {{ cipher.passwordRevisionDisplayDate | date: "medium" }}
        </div>
        <div *ngIf="cipher.hasPasswordHistory">
          <b class="font-weight-semibold">{{ "passwordHistory" | i18n }}:</b>
          <button
            type="button"
            (click)="viewHistory()"
            appStopClick
            appA11yTitle="{{ 'passwordHistory' | i18n }}, {{ cipher.passwordHistory.length }}"
          >
            <span aria-hidden="true">{{ cipher.passwordHistory.length }}</span>
          </button>
        </div>
      </div>
    </div>
  </div>
</div>
<div class="footer" *ngIf="cipher">
  <button
    type="button"
    class="primary"
    (click)="edit()"
    appA11yTitle="{{ 'edit' | i18n }}"
    *ngIf="!cipher.isDeleted"
  >
    <i class="bwi bwi-pencil bwi-fw bwi-lg" aria-hidden="true"></i>
  </button>
  <button
    type="button"
    class="primary"
    (click)="restore()"
    appA11yTitle="{{ 'restore' | i18n }}"
    *ngIf="cipher.isDeleted"
  >
    <i class="bwi bwi-undo bwi-fw bwi-lg" aria-hidden="true"></i>
  </button>
  <button
    type="button"
    class="primary"
    *ngIf="!cipher?.organizationId && !cipher.isDeleted"
    (click)="clone()"
    appA11yTitle="{{ 'clone' | i18n }}"
  >
    <i class="bwi bwi-files bwi-fw bwi-lg" aria-hidden="true"></i>
  </button>
  <div class="right" *ngIf="canDeleteCipher$ | async">
    <button
      type="button"
      (click)="delete()"
      class="danger"
      appA11yTitle="{{ (cipher.isDeleted ? 'permanentlyDelete' : 'delete') | i18n }}"
    >
      <i class="bwi bwi-trash bwi-lg bwi-fw" aria-hidden="true"></i>
    </button>
  </div>
</div>
