{% block toolbar %}
    {% set icon %}
    <a href="{{ url("webprofiler.dashboard", {profile: token}, {fragment: 'assets'}) }}" title="{{ 'Assets'|t }}">
        <img width="20" height="28" alt="{{ 'Assets'|t }}"
             src="data:image/png;base64,{{ collector.icon }}"/>
        <span class="sf-toolbar-info-piece-additional sf-toolbar-status">{{ collector.getcsscount + collector.getjscount }}</span>
    </a>
    {% endset %}
    {% set text %}

    <div class="sf-toolbar-info-piece">
        <b>CSS</b>
        <span>{{ collector.getcsscount }}</span>
    </div>
    <div class="sf-toolbar-info-piece">
        <b>JS</b>
        <span>{{ collector.getjscount }}</span>
    </div>
    {% endset %}

    <div class="sf-toolbar-block">
        <div class="sf-toolbar-icon">{{ icon|default('') }}</div>
        <div class="sf-toolbar-info">{{ text|default('') }}</div>
    </div>
{% endblock %}

{% block panel %}
    <script id="assets" type="text/template">
        <h2 class="panel__title">{{ 'Assets'|t }}</h2>
        <div class="tabs">
            <% if( data.js.length != 0){ %>
            <input class="tabs__radio" type="radio" id="js" name="tabs" checked/>
            <% } %>
            <% if( data.js.length != 0){ %>
            <input class="tabs__radio" type="radio" id="css" name="tabs"/>
            <% } %>
            <ul class="tabs__tabs list--inline">
                <% if( data.js.length != 0){ %>
                <li><label class="tabs__label" for="js">JS</label></li>
                <% } %>
                <% if( data.js.length != 0){ %>
                <li><label class="tabs__label" for="css">CSS</label></li>
                <% } %>
            </ul>
            <div class="tabs__panels">
                <div class="tabs__panel">
                    <% if( data.js.length != 0){ %>
                    <% _.each( data.js, function( item, key ){ %>
                    <% if( key === 'drupalSettings' ){ %>
                    <div class="panel__container">
                        <div class="panel__expand-header ">
                            <ul class="list--inline">
                                <li><b>asset</b> <%- key %></li>
                            </ul>
                            <div class="button--flat l-right js--panel-toggle">{{ 'Data'|t }}</div>
                        </div>
                        <div class="panel__expand-content">
                            <% if(item.data && item.data.length != 0){ %>
                        <pre>
                            <code class="code--json "><%= JSON.stringify(item.data, null, 4) %></code>
                        </pre>
                            <% } %>
                            <table class="table--duo">
                                <% _.each( item, function( item, key ){ %>
                                <tr>
                                    <% if(key != 'data'){ %>
                                    <th><%- key %></th>
                                    <td><%= Drupal.webprofiler.helpers.frm(item) %></td>
                                    <% } %>
                                </tr>
                                <% }); %>
                            </table>
                        </div>
                    </div>
                    <% } else { %>
                    <div class="panel__container">
                        <div class="panel__expand-header ">
                            <ul class="list--inline">
                                <li><b>asset</b> <%= Drupal.webprofiler.helpers.classLink({"file":
                                    data.assets.installation_path + key, "class": key, "line": 0}) %>
                                </li>
                                <li><b>version</b> <%- item.version %></li>
                                <li><b>scope</b> <%- item.scope %></li>
                            </ul>
                            <div class="button--flat l-right js--panel-toggle">{{ 'Data'|t }}</div>
                        </div>
                        <div class="panel__expand-content">
                            <table class="table--duo">
                                <% _.each( item, function( item, key ){ %>
                                <tr>
                                    <th><%- key %></th>
                                    <td><%= Drupal.webprofiler.helpers.frm(item) %></td>
                                </tr>
                                <% }); %>
                            </table>
                        </div>
                    </div>
                    <% } %>
                    <% }); %>
                    <% } %>
                </div>
                <div class="tabs__panel">
                    <% if( data.css.length != 0){ %>
                    <% _.each( data.css, function( item, key ){ %>
                    <div class="panel__container">
                        <div class="panel__expand-header ">
                            <ul class="list--inline">
                                <li><b>asset</b> <%= Drupal.webprofiler.helpers.classLink({"file":
                                    data.assets.installation_path + key, "class": key, "line": 0}) %>
                                </li>
                                <li><b>version</b> <%- item.version %></li>
                            </ul>
                            <div class="button--flat l-right js--panel-toggle">{{ 'Data'|t }}</div>
                        </div>
                        <div class="panel__expand-content">
                            <table class="table--duo">
                                <% _.each( item, function( item, key ){ %>
                                <tr>
                                    <th><%- key %></th>
                                    <td><%= Drupal.webprofiler.helpers.frm(item) %></td>
                                </tr>
                                <% }); %>
                            </table>
                        </div>
                    </div>
                    <% }); %>
                </div>
            </div>
        </div>

        <% } %>
    </script>
{% endblock %}
