{{#if threads}}
    {{> threads}}
{{else}}
    {{> collapseAggregations}}
{{/if}}

{{#*inline "threads"}}
{{#each threads}}
<div class="">
    <div>
        <a class="collapse-trigger collapsed" data-toggle="collapse" href="#thread-folder-{{@index}}" role="button" aria-expanded="true"
            aria-controls="collapseExample">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-fill" viewBox="0 0 16 16">
                <path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/>
            </svg>
            <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-caret-right-fill" fill="currentColor"
                xmlns="http://www.w3.org/2000/svg">
                <path
                    d="M12.14 8.753l-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z" />
            </svg>
            {{i18n "reporter.thread"}} {{add @index 1}}
        </a>
    </div>
    <br />
    <div class="collapse" id="thread-folder-{{@index}}">
        {{> rounds}}
    </div>
</div>
<br />
{{/each}}
{{/inline}}


{{#*inline "rounds"}}
{{#each this}}
<div class="">
    <div>
        <a class="collapse-trigger collapsed" data-toggle="collapse" href="#round-folder-{{@../index}}-{{@index}}" role="button" aria-expanded="true"
            aria-controls="collapseExample">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-fill" viewBox="0 0 16 16">
                <path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/>
            </svg>
            <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-caret-right-fill" fill="currentColor"
                xmlns="http://www.w3.org/2000/svg">
                <path
                    d="M12.14 8.753l-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z" />
            </svg>
            {{i18n "reporter.the"}} {{add @index 1}} {{i18n "reporter.round"}}
        </a>
    </div>
    <br />
    <div class="collapse" id="round-folder-{{@../index}}-{{@index}}">
        {{> testCases}}
    </div>
</div>
{{/each}}
{{/inline}}

{{#*inline "testCases"}}
{{#each this}}
{{#each aggregations}}
{{#if parent.name}}
<div class="">
    <div>
        <a class="collapse-trigger collapsed" data-toggle="collapse" href="#folder-{{parent.id}}-{{@index}}" role="button" aria-expanded="true"
            aria-controls="collapseExample">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-fill" viewBox="0 0 16 16">
                <path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/>
            </svg>
            <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-caret-right-fill" fill="currentColor"
                xmlns="http://www.w3.org/2000/svg">
                <path
                    d="M12.14 8.753l-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z" />
            </svg>
            {{parent.name}}
        </a>
    </div>
    <br />
    <div class="collapse" id="folder-{{parent.id}}-{{@index}}">
        {{> aggregations}}
    </div>
</div>
{{else}}
{{> aggregations}}
{{/if}}
<br />
{{/each}}
{{#if failures.length}}
<br />
<h4>{{i18n "reporter.head.failure"}}</h4>

{{#each failures}}
<div class="card">
    <h6 class="card-header"> {{this.name}}:
        {{#if this.test}}{{this.test}}{{else}}{{this.message}}{{/if}} </h6>
    <div class="card-body">
        <div class="row">
            {{#if this.test}}
            <div class="col-md-2">{{i18n "reporter.description"}}</div>
            <div class="col-md-10">{{this.message}}</div><br />
            {{/if}}
            <div class="col-md-2">{{i18n "reporter.head.detail"}}</div>
            <div class="col-md-10">{{this.stack}}</div><br />
            <div class="col-md-2">{{i18n "reporter.requestName"}}</div>
            <div class="col-md-10">
                <a href="#request-{{this.source.id}}">{{this.source.name}}</a>
            </div>
            {{#gt this.source.cursor.cycles 1}}
            <div class="col-md-2">{{i18n "reporter.iterationRound"}}</div>
            <div class="col-md-10">{{add this.source.cursor.iteration 1}}</div><br />
            {{/gt}}
        </div>
    </div>
</div>
<br />
{{/each}}
{{/if}}
{{/each}}
{{/inline}}


{{#*inline "collapseAggregations"}}
{{#each aggregations}}
{{#if parent.name}}
<div class="">
    <div>
        <a data-toggle="collapse" href="#folder-{{parent.id}}-{{@index}}" role="button" aria-expanded="true" class="collapse-trigger collapsed" aria-controls="collapseExample">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-caret-down-fill" viewBox="0 0 16 16">
                <path d="M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z"/>
            </svg>
            <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-caret-right-fill" fill="currentColor"
                xmlns="http://www.w3.org/2000/svg">
                <path
                    d="M12.14 8.753l-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z" />
            </svg>
            {{parent.name}}
        </a>
    </div>
    <br />
    <div class="collapse" id="folder-{{parent.id}}-{{@index}}">
        {{> aggregations}}
    </div>
</div>
{{else}}
{{> aggregations}}
{{/if}}
<br />
{{/each}}
{{/inline}}


{{#*inline "aggregations"}}
{{#each executions}}
{{#if this.aggregations}}
    {{> collapseAggregations}}
{{else if this.threads}}
    {{> threads}}
{{else}}
<div class="card" id="request-{{item.id}}">
    <h5 class="card-header"> {{item.name}} </h5>
    <div class="card-body">
        <div id="requestData-{{item.id}}" class="card-text">
            <div class="row">
                {{#with request}}
                {{#if description.content}}
                <div class="col-md-4">{{i18n "reporter.info"}}</div>
                <div class="col-md-8" style="white-space: pre-wrap;">{{description.content}}</div>
                <div class="col-md-12">&nbsp;</div>
                {{/if}}
                {{#if url}}
                <div class="col-md-4">Method</div>
                <div class="col-md-8">{{method}}</div>
                <div class="col-md-4">URL</div>
                <div class="col-md-8"><a href="{{url}}" target="_blank">{{url}}</a></div>
                {{/if}}
                {{#if host}}
                <div class="col-md-4">{{i18n "reporter.address"}}</div>
                <div class="col-md-8">{{host}}:{{port}}</div>
                {{/if}}
                {{/with}}
                <div class="col-md-12">&nbsp;</div>
                {{#if requestError}}
                <div class="col-md-4"><b>{{i18n "reporter.error"}}</b></div>
                <div class="col-md-8"><b>{{i18n "reporter.requestError"}}</b></div>
                <div class="col-md-4"><b>{{i18n "reporter.errorCode"}}</b></div>
                <div class="col-md-8"><b>{{requestError.code}}</b></div>
                {{#if requestError.connect}}
                <div class="col-md-4"><b>{{i18n "reporter.detail"}}</b></div>
                <div class="col-md-8"><b>{{i18n "reporter.connectTimeout"}}</b></div>
                {{/if}}
                {{/if}}

                <div class="col-md-12">&nbsp;</div>
                <div class="col-md-4">{{i18n "reporter.timeConsuming"}}</div>
                <div class="col-md-8">{{mean.time}}</div><br />
                {{#if response}}
                <div class="col-md-4">{{i18n "reporter.responseSize"}}</div>
                <div class="col-md-8">{{mean.size}}</div><br />
                {{/if}}

                {{#if response}}
                <div class="col-md-12">&nbsp;</div>
                <br />
                <div class="col-md-4">{{i18n "reporter.httpStatusCode"}}</div>
                <div class="col-md-8">{{response.code}}</div><br />
                {{/if}}

                <div class="col-md-12">&nbsp;</div>
                <br />
                <div class="col-md-4">{{i18n "reporter.assertionPassed"}}</div>
                <div class="col-md-8">{{cumulativeTests.passed}}</div>
                <div class="col-md-4">{{i18n "reporter.assertionFailed"}}</div>
                <div class="col-md-8">{{cumulativeTests.failed}}</div><br />


                {{#if assertions.length}}
                <div class="col-md-12">&nbsp;</div>
                <div class="col-md-4">{{i18n "reporter.assertionDetail"}}</div>

                <div class="col-md-8">
                    <table class="table">
                        <thead>
                            <tr>
                                <th>{{i18n "reporter.head.name"}}</th>
                                <th style="width: 80px;">{{i18n "reporter.head.result"}}</th>
                                <th>{{i18n "reporter.head.detail"}}</th>
                            </tr>
                        </thead>
                        <tbody>{{#each assertions}}<tr>
                                <td>{{this.name}}</td>
                                {{#if this.passed}}<td class="text-success">{{i18n "reporter.passed"}}</td>{{else}}<td class="text-danger">{{i18n "reporter.failed"}}
                                </td>{{/if}}
                                <td>{{this.error.stack}}</td>
                            </tr>{{/each}}</tbody>
                    </table>
                </div>
                {{/if}}
                {{#if requestSerialized}}
                <div class="col-md-12">&nbsp;</div>
                <div class="col-md-12">
                    <div class="btn-link text-left" style="cursor: pointer;" data-toggle="collapse"
                        data-target="#requestSerialized-{{item.id}}" aria-expanded="true" aria-controls="requestSerialized-{{item.id}}">
                        <b>{{i18n "reporter.actualRequest"}}</b>
                    </div>
                    <div id="requestSerialized-{{item.id}}" class="collapse">
                        <pre><code>{{requestSerialized}}</code></pre>
                    </div>
                </div>
                {{/if}}
                {{#if responseSerialized}}
                <div class="col-md-12">&nbsp;</div>
                <div class="col-md-2"><b>{{i18n "reporter.response"}}</b></div>
                <div class="col-md-10">
                    <pre><code>{{responseSerialized}}</code></pre>
                </div>
                {{/if}}
            </div>
        </div>
    </div>
</div>
<br />
{{/if}}
{{/each}}
{{/inline}}