{% extends "analysis_plugins/general_information.html" %}

{% block analysis_result_details %}

{% for key in firmware.processed_analysis[selected_analysis]['Output'].keys() | sort %}
    <tr>
        <td>
            {{ key }}
        </td>
        <td class="m-0 p-0">
            <div class="clickable pt-2 pl-3" data-toggle="collapse" data-target="#{{ key }}">
                <i class="fas fa-angle-down mb-2 pt-2"></i>
            </div>

            <div class="collapse w-100" id="{{ key }}">
                <table class="table table-bordered mb-0 pb-0">
                    {% if firmware.processed_analysis[selected_analysis]['Output'][key] | is_list %}
                        {% if not firmware.processed_analysis[selected_analysis]['Output'][key] %}
                            <tr>
                                <td style="padding: 5px">None</td>
                            </tr>
                        {% elif firmware.processed_analysis[selected_analysis]['Output'][key][0] is string %}
                                {% for element in firmware.processed_analysis[selected_analysis]['Output'][key] %}
                                    <tr>
                                        <td style="padding: 5px">{{ element }}</td>
                                    </tr>
                                {% endfor %}
                        {% else %}
                            <tr>
                                {% for unique_key in firmware.processed_analysis[selected_analysis]['Output'][key] | get_unique_keys_from_list_of_dicts | sort %}
                                    <th style="padding: 5px">{{ unique_key }}</th>
                                {% endfor %}
                            </tr>
                            {% for dictionary in firmware.processed_analysis[selected_analysis]['Output'][key] %}
                                <tr>
                                    {% for unique_key in firmware.processed_analysis[selected_analysis]['Output'][key] | get_unique_keys_from_list_of_dicts | sort %}
                                        {% if unique_key in dictionary.keys() %}
                                            <td style="padding: 5px">{{ dictionary[unique_key] }}</td>
                                        {% else %}
                                            <td></td>
                                        {% endif %}
                                    {% endfor %}
                                </tr>
                            {% endfor %}
                        {% endif %}
                    {% else %}
                        {% for k, v in firmware.processed_analysis[selected_analysis]['Output'][key].items() %}
                            <tr>
                                <td style="padding: 5px">{{ k }}</td>
                                <td style="padding: 5px">{{ v }}</td>
                            </tr>
                        {% endfor %}
                    {% endif %}

                </table>
            </div>

        </td>
    </tr>
{% endfor %}

{% endblock %}