<?xml version='1.0' standalone='yes'?>
<container
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:var="http://www.skyrix.com/od/binding"
    xmlns:const="http://www.skyrix.com/od/constant"
    xmlns:label="OGo:label"
    xmlns:rsrc="OGo:url">

  <div class="sg-reversible" ng-class="{ 'sg-flip': editor.showRawSource }">
    <div class="sg-face" layout="column" layout-fill="layout-fill">
      <md-card>
        <md-card-actions class="md-toolbar-tools" flex-none="flex-none" layout="row" layout-align="end center">
          <md-button ng-click="toggleCenter()"
                     class="sg-icon-button md-primary md-hue-1 hide show-gt-xs"
                     aria-hidden="true">
            <md-tooltip ng-if="centerIsClose" md-direction="bottom">{{ ::'Reduce' | loc }}</md-tooltip>
            <md-tooltip ng-else="centerIsClose" md-direction="bottom">{{ ::'Expand' | loc }}</md-tooltip>
            <md-icon>{{ centerIsClose ? 'fullscreen_exit' : 'fullscreen' }}</md-icon>
          </md-button>
          <md-button class="sg-icon-button hide-gt-xs"
                     label:aria-label="Close"
                     ng-click="editor.close()">
            <md-icon>close</md-icon>
          </md-button>
          <div class="md-flex"><!-- spacer --></div>
          <md-button type="button" class="sg-icon-button"
                     label:aria-label="Edit"
                     ng-show="editor.currentFolder.acls.objectEditor"
                     ui-sref="app.addressbook.card.editor({addressbookId: editor.currentFolder.id, cardId: editor.card.id})">
            <md-tooltip><var:string label:value="Edit"/></md-tooltip>
            <md-icon>mode_edit</md-icon>
          </md-button>
          <md-button class="sg-icon-button"
                     label:aria-label="Delete"
                     ng-show="editor.currentFolder.acls.objectEraser"
                     ng-click="editor.confirmDelete()">
            <md-tooltip><var:string label:value="Delete"/></md-tooltip>
            <md-icon>delete</md-icon>
          </md-button>
          <md-menu ng-hide="editor.currentFolder.isRemote">
            <md-button label:aria-label="More options" class="sg-icon-button" ng-click="$mdMenu.open($event)">
              <md-icon>more_vert</md-icon>
            </md-button>
            <md-menu-content>
              <md-menu-item>
                <md-button label:aria-label="Export"
                           ng-click="editor.card.export()">
                  <var:string label:value="Export"/>
                </md-button>
              </md-menu-item>
              <md-menu-item>
                <md-button label:aria-label="View Raw Source"
                           ng-click="editor.toggleRawSource($event)">
                  <var:string label:value="View Raw Source"/>
                </md-button>
              </md-menu-item>
            </md-menu-content>
          </md-menu>
        </md-card-actions>
        <md-card-content>
          <header class="msg-header">
            <sg-avatar-image class="md-avatar md-tile-left"
                             sg-email="editor.card.$preferredEmail()"
                             sg-src="editor.card.photoURL"
                             size="40">{{ editor.card.$avatarIcon }}</sg-avatar-image>
            <div class="msg-header-content">
              <div class="sg-md-display-2--thin" ng-bind-html="editor.card.$fullname({html: true})"><!-- fullname --></div>
              <div class="sg-md-display-2-subheader--thin">{{editor.card.$description()}}</div>
              <md-chips ng-model="editor.card.categories"
                        class="sg-readonly" readonly="true">
                <md-chip-template>
                  {{$chip.value}}
                </md-chip-template>
              </md-chips>
            </div>
          </header>
          <section class="msg-body">

            <div class="pseudo-input-container" ng-show="editor.card.birthday">
              <label class="pseudo-input-label"><var:string label:value="Birthday"/></label>
              <div class="pseudo-input-field">
                <span>{{editor.card.$birthday}}</span>
              </div>
            </div>

            <!-- list members -->
            <div class="section" ng-show="editor.card.refs.length > 0">
              <label class="pseudo-input-label"><var:string label:value="Members"/></label>
              <md-list>
                <md-list-item class="md-2-line" ng-repeat="ref in editor.card.refs track by ref.reference">
                  <sg-avatar-image class="md-tile-left"
                                   sg-email="ref.$preferredEmail()"
                                   size="48">person</sg-avatar-image>
                  <div class="md-list-item-text">
                    <h3>
                      <a ui-sref="app.addressbook.card.view({cardId: ref.reference})">{{ ref.$fullname() }}</a>
                    </h3>
                    <h4 ng-show="ref.$preferredEmail()">
                      <a href="#" ng-bind="ref.$preferredEmail()"
                         ng-click="addressbook.newMessageWithRecipient($event, ref.$preferredEmail(), ref.$fullname())"><!-- contact email --></a>
                    </h4>
                  </div>
                </md-list-item>
              </md-list>
            </div>

            <!-- S/MIME certificate -->
            <div class="section" ng-if="editor.card.hasCertificate">
              <div class="pseudo-input-container">
                <label class="pseudo-input-label"><var:string label:value="Security"/></label>
                <sg-block-toggle class="hide-print" layout="column">
                  <md-list-item class="sg-button-toggle">
                    <p class="md-flex">
                      <md-icon rsrc:md-svg-src="img/certificate.svg"><!-- certificate --></md-icon>
                      {{::'S/MIME Certificate' | loc}}
                    </p>
                    <md-icon class="sg-icon-toggle">expand_more</md-icon>
                  </md-list-item>
                  <div class="sg-block-toggle">
                    <div class="md-margin" md-whiteframe="3">
                      <div class="md-padding" layout="row" layout-wrap="layout-wrap">
                        <div flex="50" flex-xs="100">
                          <div class="sg-padded--bottom" ng-if="editor.certificate.emails.length">
                            <div class="md-subhead md-default-theme md-fg md-primary"
                                 ng-bind="::'Email Addresses' | loc"><!-- Email Addresses --></div>
                            <div class="pseudo-input-field md-body-1"
                                 ng-repeat="email in ::editor.certificate.emails"
                                 ng-bind="email"><!-- email address --></div>
                          </div>
                          <div class="md-subhead md-default-theme md-fg md-primary"
                               ng-bind="::'Subject Name' | loc"><!-- Subject Name --></div>
                          <div ng-repeat="field in editor.certificate.subject">
                            <div class="pseudo-input-label" ng-bind="field[0] | loc"><!-- label --></div>
                            <div class="pseudo-input-field md-body-1" ng-bind="field[1]"><!-- value --></div>
                          </div>
                        </div>
                        <div flex="50" flex-xs="100">
                          <div class="md-subhead md-default-theme md-fg md-primary"
                               ng-bind="::'Issuer' | loc"><!-- Issuer --></div>
                          <div ng-repeat="field in editor.certificate.issuer">
                            <div class="pseudo-input-label" ng-bind="field[0] | loc"><!-- label --></div>
                            <div class="pseudo-input-field md-body-1" ng-bind="field[1]"><!-- value --></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </sg-block-toggle>
              </div>
            </div>

            <div class="section" ng-show="editor.card.emails.length > 0">
              <div class="pseudo-input-container" ng-repeat="email in editor.card.emails">
                <label class="pseudo-input-label"><var:entity const:name="nbsp"/>{{email.type.capitalize() | loc}}</label>
                <div class="pseudo-input-field">
                  <a href="#" ng-bind="email.value"
                     ng-click="addressbook.newMessageWithRecipient($event, email.value, editor.card.$fullname())"><!-- recipient --></a>
                </div>
              </div>
            </div>

            <div class="section" ng-show="editor.card.c_screenname">
              <div class="pseudo-input-container">
                <label class="pseudo-input-label"><var:string label:value="Screen Name"/></label>
                <div class="pseudo-input-field">{{editor.card.c_screenname}}</div>
              </div>
            </div>

            <div class="section" ng-show="editor.card.phones.length > 0">
              <div class="pseudo-input-container" ng-repeat="phone in editor.card.phones">
                <label class="pseudo-input-label">{{phone.type.capitalize() | loc}}</label>
                <div class="pseudo-input-field">
                  <a href="tel:{{phone.value}}">{{phone.value}}</a>
                </div>
              </div>
            </div>

            <div class="section" ng-show="editor.card.urls">
              <div class="pseudo-input-container" ng-repeat="url in editor.card.urls">
                <label class="pseudo-input-label"><var:entity const:name="nbsp"/>{{url.type.capitalize() | loc}}</label>
                <div class="pseudo-input-field">
                  <a href="#" rel="noopener" target="_new" ng-href="{{url.value}}">{{url.value}}</a>
                </div>
              </div>
            </div>

            <div class="section" ng-show="editor.card.addresses">
              <div class="pseudo-input-container" ng-repeat="address in editor.card.addresses">
                <label class="pseudo-input-label">{{address.type.capitalize() | loc}}</label>
                <div class="pseudo-input-field">
                  <div sg-address="address"><!-- address --></div>
                </div>
              </div>
            </div>

	    <div class="section" ng-show="editor.card.customFields">
              <div class="pseudo-input-container" ng-show="editor.card.customFields['1']">
                <label class="pseudo-input-label"><var:string label:value="Custom 1"/></label>
		<div class="pseudo-input-field">
                  <span>{{editor.card.customFields['1']}}</span>
		</div>
              </div>
	      <div class="pseudo-input-container" ng-show="editor.card.customFields['2']">
                <label class="pseudo-input-label"><var:string label:value="Custom 2"/></label>
		<div class="pseudo-input-field">
                  <span>{{editor.card.customFields['2']}}</span>
		</div>
              </div>
	      <div class="pseudo-input-container" ng-show="editor.card.customFields['3']">
                <label class="pseudo-input-label"><var:string label:value="Custom 3"/></label>
		<div class="pseudo-input-field">
                  <span>{{editor.card.customFields['3']}}</span>
		</div>
              </div>
	      <div class="pseudo-input-container" ng-show="editor.card.customFields['4']">
                <label class="pseudo-input-label"><var:string label:value="Custom 4"/></label>
		<div class="pseudo-input-field">
                  <span>{{editor.card.customFields['4']}}</span>
		</div>
              </div>
            </div>

            <div class="section" ng-show="editor.card.notes[0].value.length">
              <div class="pseudo-input-container" ng-repeat="note in editor.card.notes">
                <label class="pseudo-input-label"><var:string label:value="Note"/></label>
                <div class="pseudo-input-field">
                  <div ng-bind-html="::note.value | txt2html"><!-- note --></div>
                </div>
              </div>
            </div>

          </section>
        </md-card-content>
      </md-card>
    </div>
    <div class="sg-back" layout="column" layout-fill="layout-fill">
      <md-card>
        <md-card-actions flex-none="flex-none" layout="row" layout-align="end center">
          <md-button class="md-icon-button"
                     label:aria-label="Close"
                     ng-click="editor.toggleRawSource()">
            <md-icon>arrow_forward</md-icon>
          </md-button>
        </md-card-actions>
        <md-card-content>
          <pre ng-bind-html="editor.rawSource"><!-- raw --></pre>
        </md-card-content>
      </md-card>
    </div>
  </div>
</container>
