{{!
  Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.

  WSO2 Inc. licenses this file to you under the Apache License,
  Version 2.0 (the "License"); you may not use this file except
  in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied. See the License for the
  specific language governing permissions and limitations
  under the License.
}}
{{unit "cdmf.unit.ui.modal"}}
<ul class="nav navbar-right float-remove-xs text-center-xs">
    {{#each Main}}
        <li class="visible-inline-block">
            <a href="{{this.url}}" target="{{this.target}}"
                {{#if this.dropDownVisible}}
               class="dropdown" data-toggle="dropdown"
                {{/if}}
               title="
                {{#if this.isDomain }}
                   {{@user.domain}}
               {{else}}
                   {{#if this.label}}
                       {{this.label}}
                   {{else}}
                       {{@key}}
                   {{/if}}
               {{/if}}
            ">
                <span class="icon fw-stack fw-lg" {{#if this.isSupport}} style="color: #ff8c27;" {{/if}} {{#if this.color}} style="color: {{this.color}};" {{/if}}>
                    <i class="{{this.icon}} fw-stack-1x" title="
                    {{#if this.isDomain }}
                        {{@user.domain}}
                    {{else}}
                        {{#if this.label}}
                            {{this.label}}
                        {{else}}
                            {{@key}}
                        {{/if}}
                    {{/if}}
                    "></i>
                </span>
                <span class="hidden-xs {{#if this.isDomain }} username {{/if}}" {{#if this.color}} style="color: {{this.color}};" {{/if}}>
                    {{#if this.isDomain }}
                        {{@user.domain}}
                    {{else}}
                        {{#if this.label}}
                            {{this.label}}
                        {{else}}
                            {{@key}}
                        {{/if}}
                    {{/if}}
                </span>
                {{#if this.dropDownVisible}}
                    <span class="caret"></span>
                {{/if}}
            </a>
            {{#if this.dropDownVisible}}

                <ul class="dropdown-menu dropdown-menu-right float-remove-xs position-static-xs text-center-xs remove-margin-xs slideInDown"
                    role="menu">
                    {{#each this.dropDown}}
                        {{#if this.dropDown}}
                            <li>
                                <a title="{{@key}}"
                                   href="{{this.url}}"
                                   target="{{this.target}}">
                                    <i class="{{this.icon}}" title="{{@key}}"></i> {{@key}}
                                </a>
                            </li>
                        {{/if}}
                    {{/each}}
                </ul>
            {{/if}}
        </li>
    {{/each}}

    <li class="visible-inline-block">
        <a href="{{UserMenu.url}}" class="dropdown" data-toggle="dropdown" title="User">
                    <span class="icon fw-stack fw-lg">
                        <i class="fw fw-circle-outline fw-stack-2x" title="User"></i>
                        <i class="{{UserMenu.icon}} fw-stack-1x" title="User"></i>
                    </span>
            <span class="hidden-xs username">
                {{@user.username}}</span><span class="caret"></span>
        </a>
        <ul class="dropdown-menu dropdown-menu-right float-remove-xs position-static-xs text-center-xs remove-margin-xs slideInDown"
            role="menu">

            {{#each UserMenu.dropDown}}
                {{#if this.dropDown}}
                    <li>
                        <a title="{{@key}}"
                           href="{{this.url}}"
                           target="{{target}}">
                            <i class="{{this.icon}}" title="{{@key}}"></i> {{@key}}
                        </a>
                    </li>

                {{/if}}
            {{/each}}
        </ul>
    </li>
    <li class="visible-inline-block cloud-menu">
        <a href="#" id="cloud-menu-popover">
                    <span class="icon fw-stack fw-lg">
                        <i class="fw fw-tiles fw-stack-1x" data-toggle="popover" data-placement="bottom"
                           data-original-title="" title=""></i>
                    </span>
            <span class="hidden-xs">

                    </span>
        </a>
    </li>
</ul>

<div class="cloud-menu-content hide">
    <div id="popover-head" class="hide">Navigate to Cloud</div>
    <div id="popover-content" class="hide">
        <div class="cloud-apps">
            {{#each Expand.Clouds}}
                {{#if this.dropDown}}
                    <a href="{{this.url}}" target="_self" class="cloud-block add-padding-top-3x">
                        <i class="{{this.icon}}"></i>
                        <div class="cloud-name">{{@key}}</div>
                    </a>
                {{/if}}
            {{/each}}
            <div class="clearfix"></div>
        </div>
        <div class="cloud-actions">
            <h3>Manage your cloud</h3>
            {{#each Expand.Actions}}
                {{#if this.dropDown}}
                    <a href="{{this.url}}" target="{{this.target}}" class="cloud-block-invert add-padding-top-3x">
                        <i class="{{this.icon}}"></i>
                        <div class="cloud-name">{{@key}}</div>
                    </a>
                {{/if}}
            {{/each}}
        </div>
    </div>
</div>

{{#if Main.Account.isExpired}}
    <div id="expire-modal-content" class="hide">
        <div class="modal-header">
            <h3 class="pull-left modal-title">
       	    <span>
       		<span class="fw-stack">
       	    <i class="fw fw-circle-outline fw-stack-2x"></i>
       		    <i class="fw fw-alert fw-stack-1x"></i>
       		</span> Trial Expired
       	    </span>
            </h3>
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
                    class="fw fw-cancel"></i></button>
        </div>
        <div class="modal-body add-margin-top-2x add-margin-bottom-2x">
            <div id="notification-error-msg" class="alert alert-danger hidden" role="alert">
                <i class="icon fw fw-error"></i><span></span>
            </div>
            <div id="user-groups">Was it a successful trial? Your trial unfortunately expired, however it is really easy to upgrade to a paid plan and keep using WSO2 Device Cloud</div>
        </div>
        <div class="modal-footer">
            <div class="buttons">
                <a data-url="{{Main.Account.dropDown.[Upgrade Now].url}}" id="expire-upgrade-now-link" class="btn-operations">
                    Upgrade Now
                </a>
                <a data-url="{{Main.Account.dropDown.[Request Extension].url}}" id="expire-req-ext-link" class="btn-operations">
                    Request Extension
                </a>
            </div>
        </div>
    </div>
{{/if}}

{{#zone "bottomJs"}}
    {{#if Main.Account.isExpired}}
        {{js "/js/monetize.js"}}
    {{/if}}
    {{js "/js/user-menu.js"}}
{{/zone}}