{% extends "basic_template.html" %}
{% block title %}
{{ super() }}
{% endblock %}
{% block head %}
{{ super() }}
{% endblock %}
{% block content %}

<h1>Results</h1>

{% if complete_results %}

<h3>Complete state space search performed</h3>

{% endif %}

<div class="w3-row w3-container">
    <div class="w3-half">
        <header class="w3-container w3-us-blue"><h4>Cycle Counts by Length</h4></header>
        <table class="w3-table-all w3-centered  w3-hoverable">
            <tr><th>Length</th><th>Count</th></tr>
            {% for length, count in cycle_len_counts %}
            <tr><td> {{ length }}</td><td>{{ count }}</td></tr>
            {% endfor %}
        </table>
    </div>
</div>

<div class="w3-row-padding">

    {% for cycle in cycles %}
    <div class="w3-container w3-margin w3-border-large">
        <header class="w3-container w3-us-blue">
            <h3>{% if cycle['len'] == 1 %}Fixed Point{% else %}Length {{ cycle['len'] }} Cycle{% endif %}</h3>
        </header>
        <div style="overflow-x: auto">
            <table class="w3-table-all w3-centered  w3-hoverable">
                <tr class="w3-us-blue">
                    {% for variable in variables %}
                    <th>{{ variable }}</th>
                    {% endfor %}
                </tr>
                {% for state in cycle['states'] %}
                <tr>
                    {% for value in state %}
                    <td>{{ value }}</td>
                    {% endfor %}
                </tr>
                {% endfor %}
            </table>
        </div>
        <footer class="w3-container w3-us-red">
            <div class="w3-half w3-center"> {{ cycle['percent'] }}%</div>
            <div class="w3-half w3-center">Count {{ cycle['count'] }}</div>
        </footer>
        <center>
            {{ cycle['len-dist-image'] }}
        </center>
        <center>
        {% for key in cycle['limit-set-stats-images'] %}
        {{ cycle['limit-set-stats-images'][key] }}
        {% endfor %}
        </center>
    </div>
    {% endfor %}

    <form action="/download-tsv/" method="POST">
    <textarea name="model_result" style="display: none;">Length	sample%	{% for var in variables %}{{ var }}	{% endfor %}
{% for cycle in cycles %}{{ cycle['len'] }}	{{ cycle['percent'] }}
{% for state in cycle['states'] %}		{% for value in state %}{{ value }}	{% endfor %}
{% endfor %}
{% endfor %}      
</textarea>
        <input class="w3-btn w3-us-red w3-margin w3-round" type="submit" value="Download tsv">
    </form>


</div>

{% endblock %}
