{{#if (and isGM turns.length)}}
<header>
    {{#if round}}
    <a class="combat-control" data-action="previousRound" data-tooltip="COMBAT.RoundPrev">
        <i class="fa-solid fa-step-backward"></i>
    </a>
    <a class="combat-control" data-action="previousTurn" data-tooltip="COMBAT.TurnPrev">
        <i class="fa-solid fa-arrow-left"></i>
    </a>
    <a class="combat-control title" data-action="endCombat">
        {{localize 'COMBAT.End'}}
    </a>
    <a class="combat-control" data-action="nextTurn" data-tooltip="COMBAT.TurnNext">
        <i class="fa-solid fa-arrow-right"></i>
    </a>
    <a class="combat-control" data-action="nextRound" data-tooltip="COMBAT.RoundNext">
        <i class="fa-solid fa-step-forward"></i>
    </a>
    {{else}}
    <a class="combat-control title" data-action="startCombat">
        {{localize 'COMBAT.Begin'}}
    </a>
    {{/if}}
</header>
{{/if}}
<ol class="combatants">
    {{#if (and expand.collapsed hasStarted (not hasActive) (not isGM))}}
    <section class="fake">
        {{@root.i18n 'fake.secret'}}
    </section>
    {{/if}}
    {{#each turns as |combatant|}}
    <li class="combatant {{combatant.css}}" data-combatant-id="{{combatant.id}}"
        data-initiative="{{combatant.initiative}}" style="--disposition-color: {{color}}">
        <div class="avatar">
            <img class="token-img" src="{{combatant.texture.img}}"
                style="--scaleX: {{combatant.texture.scaleX}}; --scaleY: {{combatant.texture.scaleY}}; --mask: {{combatant.texture.mask}};">
            {{#if combatant.defeated}}
            <img class="defeated-img" src="{{@root.deathImg}}">
            {{/if}}
            <div class="alt" {{{@root.i18n.tooltip 'force-turn' }}}>
                <i class="fa-solid fa-arrow-right-to-bracket"></i>
            </div>
            <div class="targets"></div>
        </div>
        <div class="details">
            <div class="name{{#if (eq combatant.toggleName.active false)}} gm-only{{/if}}">
                {{combatant.name}}
            </div>
            <div class="controls">
                {{!-- if isGM --}}
                {{#if @root.isGM}}
                <a class="combatant-control{{#if combatant.hidden}} active{{/if}}"
                    data-action="toggleHidden" data-tooltip="COMBATANT.{{localize (ifThen combatant.hidden 'Show' 'Hide')}}">
                    <i class="fa-eye-slash fa-solid fa-fw"></i>
                </a>
                <a class="combatant-control{{#if combatant.defeated}} active{{/if}}"
                    data-action="toggleDefeated" data-tooltip="COMBATANT.{{localize (ifThen combatant.defeated 'UnmarkDefeated' 'MarkDefeated')}}">
                    <i class="fa-skull fa-solid fa-fw"></i>
                </a>
                {{!-- end if isGM --}}
                {{/if}}
                <a class="combatant-control" data-action="toggleTarget"
                    data-tooltip="COMBAT.ToggleTargeting">
                    <i class="fa-duotone fa-location-crosshairs fa-fw"></i>
                </a>
                {{#if combatant.canPing}}
                <a class="combatant-control" data-action="pingCombatant"
                    data-tooltip="COMBAT.PingCombatant">
                    <i class="fa-solid fa-fw fa-signal-stream"></i>
                </a>
                {{/if}}
                {{#if combatant.toggleName}}
                <a class="combatant-control visibility{{#if combatant.toggleName.active}} active{{/if}}"
                    data-action="toggleNameVisibility"
                    data-tooltip="{{combatant.toggleName.tooltip}}">
                    <i class="fa-solid fa-signature fa-fw"></i>
                </a>
                {{/if}}
                {{#unless @root.isGM}}
                <a class="combatant-control" data-action="panToCombatant"
                    data-tooltip="COMBAT.PanToCombatant">
                    <i class="fa-solid fa-arrows-to-eye fa-fw"></i>
                </a>
                {{/unless}}
            </div>
            <div class="controls alt">
                {{#each @root.contextMenus as |menu|}}
                <a class="combatant-control-alt" data-action="context-menu-action"
                    data-index="{{@index}}" data-tooltip="{{menu.label}}">
                    <i class="{{menu.icon}}"></i>
                </a>
                {{/each}}
            </div>
        </div>
        <div class="extras">
            {{!-- if hasRolled --}}
            {{#if hasRolled}}
            <div class="group">
                <span class="entry initiative" data-tooltip="PF2E.InitiativeLabel">
                    <span>{{combatant.initiative}}</span>
                    {{!-- is GM --}}
                    {{#if @root.isGM}}
                    <a class="delay" data-action="delay-turn">
                        {{#if combatant.isDelayed}}
                        <i class="fa-solid fa-hourglass-start" {{{@root.i18n.tooltip 'join' }}}></i>
                        {{else}}
                        <i class="fa-solid fa-dice-d20" {{{@root.i18n.tooltip 'delay' }}}></i>
                        {{/if}}
                    </a>
                    {{!-- is not GM --}}
                    {{else}}
                    {{#if combatant.isDelayed}}
                    <i class="fa-solid fa-hourglass-start"></i>
                    {{else}}
                    <i class="fa-solid fa-dice-d20"></i>
                    {{/if}}
                    {{!-- end is GM --}}
                    {{/if}}
                </span>
            </div>
            {{!-- if health --}}
            {{#if combatant.health}}
            <div class="group">
                {{#if canObserve}}
                {{!-- has stamina --}}
                {{#if combatant.health.sp}}
                <span class="entry"
                    data-tooltip="{{localize 'PF2E.StaminaPointsShortLabel'}}: {{combatant.health.sp.value}}/{{combatant.health.sp.max}}">
                    <span style="--hue: {{combatant.health.sp.hue}};">
                        {{combatant.health.sp.value}}
                    </span>
                    <i class="fa-solid fa-heart-pulse"></i>
                </span>
                {{!-- end of has stamina --}}
                {{/if}}
                {{/if}}
                <span class="entry" data-tooltip="{{combatant.health.tooltip}}">
                    <span style="--hue: {{combatant.health.hue}};">
                        {{combatant.health.value}}
                    </span>
                    <i class="fa-solid fa-heart"></i>
                </span>
            </div>
            {{!-- end if health --}}
            {{/if}}
            {{!-- else if hasRolled --}}
            {{else if combatant.isOwner}}
            <a class="combatant-control roll" data-action="rollInitiative"
                data-tooltip="COMBAT.InitiativeRoll"></a>
            {{!-- else hasRolled --}}
            {{else}}
            <span class="roll"></span>
            {{!-- end if hasRolled --}}
            {{/if}}
        </div>
    </li>
    {{/each}}
    {{#if (and expand.collapsed (not hasStarted))}}
    <section class="fake">
        {{@root.i18n 'fake.nothing'}}
    </section>
    {{/if}}

</ol>
<footer>
    <a class="combat-control{{#unless canRoll}} disabled{{/unless}}" data-action="rollAll"
        data-tooltip="COMBAT.RollAll">
        <i class="fa-solid fa-users"></i>
    </a>
    {{#if isGM}}
    <a class="combat-control{{#unless canRollNPCs}} disabled{{/unless}}" data-action="rollNPC"
        data-tooltip="COMBAT.RollNPC">
        <i class="fa-solid fa-users-cog"></i>
    </a>
    <a class="combat-control" data-action="resetAll" data-tooltip="COMBAT.InitiativeReset">
        <i class="fa-solid fa-undo"></i>
    </a>
    {{/if}}
    <span class="title">
        {{#if round}}
        {{localize 'COMBAT.Round' round=round}}
        {{else}}
        {{localize 'COMBAT.NotStarted'}}
        {{/if}}
    </span>
    {{!-- if isGM --}}
    {{#if isGM}}
    {{!-- if metrics --}}
    {{#if metrics}}
    <span class="metrics" data-tooltip="{{metrics.tooltip}}"
        data-tooltip-class="pf2e-hud-element pf2e-hud-metrics">
        <span class="threat {{metrics.threat}}">
            <i class="fa-solid fa-user-graduate"></i>
        </span>
    </span>
    {{!-- end if metrics --}}
    {{/if}}
    <a class="combat-control linked" data-action="toggleSceneLink"
        data-tooltip="{{linked.tooltip}}">
        <i class="{{linked.icon}}"></i>
    </a>
    <a class="settings" data-action="trackerSettings" data-tooltip="COMBAT.Settings">
        <i class="fa-solid fa-cog"></i>
    </a>
    <a class="combat-control history" data-action="clearMovementHistories"
        data-tooltip="COMBAT.ClearMovementHistories">
        <i class="fa-solid fa-shoe-prints"></i>
    </a>
    {{!-- else not isGM --}}
    {{else}}
    <a class="combat-control end-turn{{#unless isOwner}} disabled{{/unless}}" data-action="nextTurn"
        data-tooltip="COMBAT.TurnEnd">
        <i class="fa-solid fa-hourglass-end"></i>
    </a>
    {{!-- end if isGM --}}
    {{/if}}
    <a class="expand" data-action="toggle-expand" {{{@root.i18n.tooltip expand.tooltip}}}>
        <i class="{{expand.icon}}"></i>
    </a>
</footer>
