<div class='container'>
  {{custom-html "top"}}
  {{global-notice}}
</div>

<div class="container">
  <section class='user-main'>
    <section {{bind-attr class="collapsedInfo :about profileBackground:has-background:no-background"}}  {{bind-attr style="profileBackground"}}>
    <div class='staff-counters'>
      {{#if number_of_flags_given}}
        <div><span class="helpful-flags">{{number_of_flags_given}}</span>&nbsp;{{i18n 'user.staff_counters.flags_given'}}</div>
      {{/if}}
      {{#if number_of_flagged_posts}}
        <div>
          {{#link-to 'user.flaggedPosts' this}}
            <span class="flagged-posts">{{number_of_flagged_posts}}</span>&nbsp;{{i18n 'user.staff_counters.flagged_posts'}}
          {{/link-to}}
        </div>
      {{/if}}
      {{#if number_of_deleted_posts}}
        <div>
          {{#link-to 'user.deletedPosts' this}}
            <span class="deleted-posts">{{number_of_deleted_posts}}</span>&nbsp;{{i18n 'user.staff_counters.deleted_posts'}}
          {{/link-to}}
        </div>
      {{/if}}
      {{#if number_of_suspensions}}
        <div><span class="suspensions">{{number_of_suspensions}}</span>&nbsp;{{i18n 'user.staff_counters.suspensions'}}</div>
      {{/if}}
      {{#if number_of_warnings}}
        <div><span class="warnings-received">{{number_of_warnings}}</span>&nbsp;{{i18n 'user.staff_counters.warnings_received'}}</div>
      {{/if}}
    </div>
      <div class='profile-image'></div>
      <div class='details'>
        <div class='primary'>
          {{bound-avatar model "huge"}}
          <section class='controls'>
            <ul>
              {{#if can_send_private_message_to_user}}
              <li>
                <a class='btn btn-primary right' {{action "composePrivateMessage" model}}>
                  {{fa-icon "envelope"}}
                  {{i18n 'user.private_message'}}
                </a>
              </li>
              {{/if}}
              {{#if viewingSelf}}
                <li><a {{action "logout"}} class='btn btn-danger right'>{{fa-icon "sign-out"}}{{i18n 'user.log_out'}}</a></li>
              {{/if}}
              {{#if currentUser.staff}}
                <li><a {{bind-attr href="adminPath"}} class='btn right'>{{fa-icon "wrench"}}{{i18n 'admin.user.show_admin_profile'}}</a></li>
              {{/if}}
              {{#if can_edit}}
                <li>{{#link-to 'preferences' class="btn right"}}{{fa-icon "cog"}}{{i18n 'user.preferences'}}{{/link-to}}</li>
              {{/if}}
              {{#if canInviteToForum}}
                <li>{{#link-to 'user.invited' class="btn right"}}{{fa-icon "user-plus"}}{{i18n 'user.invited.title'}}{{/link-to}}</li>
              {{/if}}
            </ul>
          </section>

          <div class="primary-textual">
            <h1>{{username}} {{user-status model currentUser=currentUser}}</h1>
            <h2>{{name}}</h2>
            {{#if title}}
              <h3>{{title}}</h3>
            {{/if}}
            <h3>
            {{#if location}}{{fa-icon "map-maker"}}{{location}}{{/if}}
            {{#if websiteName}}
              {{fa-icon "globe"}}
              {{#if linkWebsite}}
                <a {{bind-attr href="website"}} rel="nofollow" target="_blank">{{websiteName}}</a>
              {{else}}
                <span {{bind-attr title="website"}}>{{websiteName}}</span>
              {{/if}}
            {{/if}}
            </h3>

            <div class='bio'>
              {{#if isSuspended}}
                <div class='suspended'>
                  {{fa-icon "ban"}}
                  <b>{{i18n 'user.suspended_notice' date=suspendedTillDate}}</b><br/>
                  <b>{{i18n 'user.suspended_reason'}}</b> {{suspend_reason}}
                </div>
              {{/if}}
              {{{bio_cooked}}}
            </div>

            {{#if publicUserFields}}
              <div class="public-user-fields">
                {{#each uf in publicUserFields}}
                  {{#if uf.value}}
                    <div class="public-user-field">
                      <span class="user-field-name">{{uf.field.name}}</span>:
                      <span class="user-field-value">{{uf.value}}</span>
                    </div>
                  {{/if}}
                {{/each}}
              </div>
            {{/if}}

            {{plugin-outlet "user-profile-primary"}}

          </div>
        </div>
        <div style='clear: both'></div>
      </div>

      <div class='secondary'>
        <dl>
          {{#if created_at}}
            <dt>{{i18n 'user.created'}}</dt><dd>{{bound-date created_at}}</dd>
          {{/if}}
          {{#if last_posted_at}}
            <dt>{{i18n 'user.last_posted'}}</dt><dd>{{bound-date last_posted_at}}</dd>
          {{/if}}
          {{#if last_seen_at}}
            <dt>{{i18n 'user.last_seen'}}</dt><dd>{{bound-date last_seen_at}}</dd>
          {{/if}}
          {{#if invited_by}}
            <dt>{{i18n 'user.invited_by'}}</dt><dd>{{#link-to 'user' invited_by}}{{invited_by.username}}{{/link-to}}</dd>
          {{/if}}
          <dt>{{i18n 'user.trust_level'}}</dt><dd>{{trustLevel.name}}</dd>
          {{#if canCheckEmails}}
            <dt>{{i18n 'user.email.title'}}</dt>
            <dd {{bind-attr title="email"}}>
              {{#if email}}
                {{email}}
              {{else}}
                {{d-button action="checkEmail" actionParam=model icon="envelope-o" label="admin.users.check_email.text" class="btn-primary"}}
              {{/if}}
            </dd>
          {{/if}}
          {{#if custom_groups}}
            <dt>{{i18n 'groups.title' count=custom_groups.length}}</dt>
            <dd class='groups'>
              {{#each group in custom_groups}}
                <span>{{#link-to 'group' group class="group-link"}}{{group.name}}{{/link-to}}</span>
              {{/each}}
            </dd>
          {{/if}}
          {{#if canDeleteUser}}
            {{d-button action="adminDelete" icon="exclamation-triangle" label="user.admin_delete" class="btn-danger"}}
          {{/if}}
        </dl>
        {{plugin-outlet "user-profile-secondary"}}
      </div>
    </section>

    <section class='user-navigation'>
      <ul class='action-list nav-stacked'>
        {{activity-filter count=statsCountNonPM user=model userActionType=userActionType indexStream=indexStream}}
        {{#each stat in statsExcludingPms}}
          {{activity-filter content=stat user=model userActionType=userActionType indexStream=indexStream}}
        {{/each}}
        {{#if showBadges}}
          {{#link-to 'user.badges' tagName="li"}}
            {{#link-to 'user.badges'}}
              <i class='glyph fa fa-certificate'></i>
              {{i18n 'badges.title'}}
              <span class='count'>({{badge_count}})</span>
            {{/link-to}}
          {{/link-to}}
        {{/if}}
        {{#if canSeeNotificationHistory}}
          {{#link-to 'user.notifications' tagName="li"}}
            {{#link-to 'user.notifications'}}
              <i class='glyph fa fa-comment'></i>
              {{i18n 'user.notifications'}}
              <span class='count'>({{notification_count}})</span>
            {{/link-to}}
          {{/link-to}}
        {{/if}}
      </ul>

      {{#if canSeePrivateMessages}}
        <h3>{{fa-icon "envelope"}} {{i18n 'user.private_messages'}}</h3>
        <ul class='action-list nav-stacked'>
          <li {{bind-attr class=":noGlyph privateMessagesActive:active"}}>
            {{#link-to 'userPrivateMessages.index' model}}
              {{i18n 'user.messages.all'}}
              {{#if hasPMs}}<span class='count'>({{private_messages_stats.all}})</span>{{/if}}
            {{/link-to}}
          </li>
          <li {{bind-attr class=":noGlyph privateMessagesMineActive:active"}}>
            {{#link-to 'userPrivateMessages.mine' model}}
              {{i18n 'user.messages.mine'}}
              {{#if hasStartedPMs}}<span class='count'>({{private_messages_stats.mine}})</span>{{/if}}
            {{/link-to}}
          </li>
          <li {{bind-attr class=":noGlyph privateMessagesUnreadActive:active"}}>
            {{#link-to 'userPrivateMessages.unread' model}}
              {{i18n 'user.messages.unread'}}
              {{#if hasUnreadPMs}}<span class='badge-notification unread-private-messages'>{{private_messages_stats.unread}}</span>{{/if}}
            {{/link-to}}
          </li>
        </ul>
      {{/if}}

      {{#if viewingSelf}}
        <div class='user-archive'>
          {{d-button action="exportUserArchive" label="user.download_archive" icon="download"}}
        </div>
      {{/if}}
    </section>

    <section class='user-right'>
      {{outlet}}
    </section>

  </section>
</div>
