{{!-- HEALTH --}}
<header>
    <h2>{{localize "PF2E.HitPointsHeader"}}</h2>
    <button
        type="button"
        class="hover"
        data-tooltip-content="#{{options.id}}-hp-modifiers">{{localize "PF2E.ModifiersTitle"}}</button>
</header>
<div class="hitpoints">
    <div class="hp-big">
        <div class="container temp-hp">
            <label for="{{options.id}}-pc-hp-temp" class="sidebar_label">{{localize "PF2E.TempHitPointsShortLabel"}}</label>
            <div class="data-value">
                <input name="system.attributes.hp.temp" id="{{options.id}}-pc-hp-temp" type="text" value="{{data.attributes.hp.temp}}" placeholder="0" data-dtype="Number" data-allow-delta data-min="0" />
            </div>
        </div>
        <div class="container current-hp">
            <label for="{{options.id}}-pc-hp" class="sidebar_label">{{localize "PF2E.CurrentHitPointsShortLabel"}}</label>
            <div class="data-value">
                <input name="system.attributes.hp.value" id="{{options.id}}-pc-hp" type="text" value="{{data.attributes.hp.value}}" placeholder="10" data-dtype="Number" data-allow-delta data-min="0" data-max="{{data.attributes.hp.max}}" />
            </div>
        </div>
        <div class="container max-hp">
            <span class="sidebar_label">{{localize "PF2E.MaxHitPointsShortLabel"}}</span>
            <div class="data-value">
                <h2>
                    {{~data.attributes.hp.max~}}
                    {{~#if data.attributes.hp.unrecoverable~}}
                        <span class="unrecoverable" data-tooltip="{{localize "PF2E.Actor.HitPoints.Unrecoverable" value=data.attributes.hp.unrecoverable}}">*</span>
                    {{~/if~}}
                </h2>
            </div>
        </div>
    </div>
    <div class="hp-small">
        <a
            class="roll-icon{{#if (not data.attributes.dying.value)}} disabled{{/if}}"
            data-action="recovery-check"
            data-tooltip="{{localize "PF2E.Check.Specific.Recovery"}}"
        >
            {{> "systems/pf2e/templates/actors/character/icons/d20.hbs"}}
        </a>
        <a class="condition-pips" data-action="adjust-condition-value" data-condition="dying">
            <span class="sidebar_label">{{localize "PF2E.condition.dying.name"}}</span>
            {{> "systems/pf2e/templates/actors/partials/dying-pips.hbs"}}
        </a>
        <a class="condition-pips" data-action="adjust-condition-value" data-condition="wounded">
            <span class="sidebar_label">{{localize "PF2E.condition.wounded.name"}}</span>
            <span class="pips">
                {{#times data.attributes.wounded.value}}<i class="fa-solid fa-dot-circle"></i>{{/times}}
                {{#times dying.remainingWounded}}<i class="fa-regular fa-circle"></i>{{/times}}
            </span>
        </a>
        <a class="roll-icon rest" data-action="rest" data-tooltip="PF2E.Actor.Character.Rest.Label">
            <i class="fa-solid fa-bed"></i>
        </a>
    </div>
</div>
{{#with data.attributes.hp}}
    {{> "systems/pf2e/templates/actors/partials/modifiers-tooltip.hbs" title="PF2E.HitPointsHeader"}}
{{/with}}

{{!-- STAMINA (if enabled) --}}
{{#if hasStamina}}
    <header>
        <h2>{{localize "PF2E.StaminaPointsHeader"}}</h2>
    </header>
    <ol class="stamina">
        <li class="sp">
            <label for="{{options.id}}-pc-stamina" class="sidebar_label">{{localize "PF2E.StaminaPointsShortLabel"}}</label>
            <div class="hp-current stamina-group">
                <input
                    id="{{options.id}}-pc-stamina"
                    class="left"
                    type="number"
                    min="0"
                    max="{{data.attributes.hp.sp.max}}"
                    name="system.attributes.hp.sp.value"
                    value="{{data.attributes.hp.sp.value}}"
                />
                <span class="divider">&sol;</span>
                <input class="right" type="number" value="{{data.attributes.hp.sp.max}}" disabled="disabled" />
            </div>
        </li>
        <li class="resolve">
            <label for="{{options.id}}-pc-resolve" class="sidebar_label">{{localize "PF2E.Actor.Resource.Resolve"}}</label>
            <div class="hp-max stamina-group">
                <input
                    id="{{options.id}}-pc-resolve"
                    class="left"
                    type="number"
                    min="0"
                    max="{{data.resources.resolve.max}}"
                    name="system.resources.resolve.value"
                    value="{{data.resources.resolve.value}}"
                />
                <span class="divider">&sol;</span>
                <input class="right" type="number" value="{{data.resources.resolve.max}}" disabled="disabled" />
            </div>
        </li>
    </ol>
{{/if}}

{{!-- ARMOR CLASS --}}
<header>
    <h2>{{localize "PF2E.ArmorClassLabel"}}</h2>
    <button
        type="button"
        class="hover"
        data-tooltip-content="#{{options.id}}-ac-modifiers">{{localize "PF2E.ModifiersTitle"}}</button>
</header>
<div class="armor-class">
    <div class="ac">
        <div class="data-value">
            <h2>{{data.attributes.ac.value}}</h2>
        </div>
        <span class="sidebar_label">{{localize "PF2E.ArmorClassShortLabel"}}</span>
    </div>
    <div class="shield hp{{#unless data.attributes.shield.hp.max}} disabled{{/unless}}">
        <div class="data-value">
            {{#if data.attributes.shield.hp.max}}
                <input
                    id="{{@root.options.id}}-shield-hp"
                    type="text"
                    placeholder="0"
                    name="system.attributes.shield.hp.value"
                    value="{{data.attributes.shield.hp.value}}"
                    data-dtype="Number" data-allow-delta data-max="{{data.attributes.shield.hp.max}}"
                    {{disabled (not data.attributes.shield.hp.max)}}
                />
            {{else}}
                <input id="{{@root.options.id}}-shield-hp" type="text" value="&mdash;" disabled />
            {{/if}}
        </div>
        <label for="{{@root.options.id}}-shield-hp" class="sidebar_label">{{localize "PF2E.Actor.Creature.Shield.HitPoints.Value"}}</label>
    </div>
    {{#if data.attributes.shield.hp.max}}
        <div class="shield-stats">
            <ul>
                <li data-tooltip="PF2E.Actor.Creature.Shield.ACBonus">
                    <div class="shield-label">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11.9 14">
                            <path
                                d="M5.9 13.5c-.9-.4-1.9-1-2.7-1.6-.7-.5-1.3-1.1-1.9-1.7C.8 9.6.5 8.9.5 8.1v-6L6 .5l5.4 1.6v6c0 .7-.3 1.5-.8 2.1-.6.7-1.2 1.3-1.9 1.7-.9.6-1.8 1.2-2.8 1.6z"
                                fill="#fff"
                            />
                            <text x="6" y="8.5" font-family="Verdana" text-anchor="middle" font-size="5" fill="black">{{localize "PF2E.ArmorClassShortLabel"}}</text>
                        </svg>
                    </div>
                    <span class="data-value">{{data.attributes.shield.ac}}</span>
                </li>
                <li data-tooltip="PF2E.Actor.Creature.Shield.Hardness.Hint">
                    <div class="shield-label">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11.9 14">
                            <path
                                d="M5.9 13.5c-.9-.4-1.9-1-2.7-1.6-.7-.5-1.3-1.1-1.9-1.7C.8 9.6.5 8.9.5 8.1v-6L6 .5l5.4 1.6v6c0 .7-.3 1.5-.8 2.1-.6.7-1.2 1.3-1.9 1.7-.9.6-1.8 1.2-2.8 1.6z"
                                fill="#fff"
                            />
                            <text x="6" y="8.5" font-family="Verdana" text-anchor="middle" font-size="5" fill="black">{{localize "PF2E.Actor.Creature.Shield.Hardness.Label"}}</text>
                        </svg>
                    </div>
                    <span class="data-value">{{data.attributes.shield.hardness}}</span>
                </li>
                <li data-tooltip="PF2E.Actor.Creature.Shield.BrokenThreshold">
                    <div class="shield-label">
                        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 11.9 14">
                            <path
                                d="M5.9 13.5c-.9-.4-1.9-1-2.7-1.6-.7-.5-1.3-1.1-1.9-1.7C.8 9.6.5 8.9.5 8.1v-6L6 .5l5.4 1.6v6c0 .7-.3 1.5-.8 2.1-.6.7-1.2 1.3-1.9 1.7-.9.6-1.8 1.2-2.8 1.6z"
                                fill="#fff"
                            />
                            <text x="6" y="8.5" font-family="Verdana" text-anchor="middle" font-size="5" fill="black">{{localize "PF2E.Item.Physical.BrokenThreshold.ShortLabel"}}</text>
                        </svg>
                    </div>
                    <span class="data-value">{{data.attributes.shield.brokenThreshold}}</span>
                </li>
            </ul>
        </div>
    {{/if}}
    <div class="shield-max-status{{#unless data.attributes.shield.hp.max}} disabled{{/unless}}">
        <div class="max">
            <label class="sidebar_label">{{localize "PF2E.Actor.Creature.Shield.HitPoints.Max"}}</label>
            <span class="data-value">{{#if data.attributes.shield.hp.max}}{{data.attributes.shield.hp.max}}{{else}}&mdash;{{/if}}</span>
        </div>
        <div class="status">
            {{#if data.attributes.shield.destroyed}}
                <span class="sidebar_label">{{localize "PF2E.Item.Physical.Destroyed"}}</span>
                <i class="fa-regular fa-circle-xmark"></i>
            {{else}}
                <span class="sidebar_label">{{localize "PF2E.Item.Physical.Broken"}}</span>
                {{#if data.attributes.shield.broken}}<i class="fa-regular fa-circle-xmark"></i>{{else}}<i class="fa-regular fa-circle"></i>{{/if}}
            {{/if}}
        </div>
    </div>
</div>
{{#with data.attributes.ac}}
    {{> "systems/pf2e/templates/actors/partials/modifiers-tooltip.hbs" title="PF2E.ArmorClassLabel"}}
{{/with}}

{{#if specialResources}}
    <header>
        <h2>{{localize "PF2E.Actor.Resources"}}</h2>
    </header>
    <ol>
        {{#each specialResources as |resource|}}
            <li class="special-resource">
                <span class="label">{{resource.label}}</span>
                <input type="text" data-dtype="Number" data-allow-delta data-min="0" data-max="{{resource.max}}" data-resource="{{resource.slug}}" value="{{resource.value}}" />
                / {{resource.max}}
            </li>
        {{/each}}
    </ol>
{{/if}}

{{!-- Perception --}}
<header>
    <h2>{{localize "PF2E.PerceptionHeader"}}</h2>
</header>
<section class="perception">
    <div class="roll-data">
        <a class="roll-icon" data-action="roll-check" data-statistic="perception" data-tooltip="PF2E.Check.Specific.Perception.Label">
            {{> "systems/pf2e/templates/actors/character/icons/d20.hbs"}}
        </a>
        <a
            class="roll-icon"
            data-action="roll-check"
            data-statistic="perception"
            data-secret
            data-tooltip="PF2E.Check.Specific.Perception.Secret"
        ><i class="fa-solid fa-eye-slash"></i></a>
        <a class="modifier hover" data-tooltip-content="#{{options.id}}-perception-modifiers">
            {{numberFormat data.perception.value decimals=0 sign=true}}
        </a>
        <span class="pf-rank" data-rank="{{data.perception.rank}}">{{lookup @root.numberToRank data.perception.rank}}</span>
    </div>
    {{#if senses.length}}
        <ol class="tags senses">
            {{#each senses as |sense slug|}}
                {{#if sense.label}}
                    <li class="tag tag_secondary" data-slug="{{slug}}">{{sense.label}}</li>
                {{/if}}
            {{/each}}
        </ol>
    {{/if}}
</section>
{{#with data.perception}}
    {{> "systems/pf2e/templates/actors/partials/modifiers-tooltip.hbs" title="PF2E.PerceptionHeader"}}
{{/with}}

{{!-- Initiative --}}
<header>
    <h2>{{localize "PF2E.InitiativeLabel"}}</h2>
</header>
<section class="roll-data initiative">
    <a
        class="roll-icon"
        data-action="roll-initiative"
        data-tooltip="COMBAT.InitiativeRoll"
    >{{> "systems/pf2e/templates/actors/character/icons/d20.hbs"}}</a>
    <a class="modifier hover" data-tooltip-content="#{{options.id}}-initiative-modifiers">
        {{numberFormat data.initiative.totalModifier decimals=0 sign=true}}
    </a>
    <select name="system.initiative.statistic">
        {{selectOptions initiativeOptions selected=data.initiative.statistic localize=true sort=true}}
    </select>
</section>
{{#with data.initiative}}
    {{> "systems/pf2e/templates/actors/partials/modifiers-tooltip.hbs" title=label}}
{{/with}}

{{!-- Saves --}}
<header>
    <h2>{{localize "PF2E.SavesHeader"}}</h2>
</header>
<ul class="saves">
    {{#each data.saves as |save slug|}}
        <li class="roll-data" data-save="{{slug}}">
            <h2 class="sidebar_label">{{localize save.label}}</h2>
            <span class="pf-rank" data-rank="{{save.rank}}">{{lookup @root.numberToRank save.rank}}</span>

            <div class="save-roll">
                <a class="roll-icon" data-action="roll-check" data-statistic="{{save.slug}}">
                    {{> "systems/pf2e/templates/actors/character/icons/d20.hbs"}}
                </a>
                <a class="modifier hover" data-tooltip-content="#{{@root.options.id}}-{{save.slug}}-modifiers">{{numberFormat save.totalModifier decimals=0 sign=true}}</a>
            </div>
            {{#with save}}
                {{> "systems/pf2e/templates/actors/partials/modifiers-tooltip.hbs" title=label}}
            {{/with}}
        </li>
    {{/each}}
</ul>

{{!-- Immunities --}}
<header>
    <h2>{{localize "PF2E.ImmunitiesLabel"}}</h2>
    {{#if editable}}
        <button type="button" data-action="edit-immunities">
            <i class="fa-solid fa-pen-to-square"></i> {{localize "PF2E.Edit"}}
        </a>
    {{/if}}
</header>
<ol class="immunities tags">
    {{#each data.attributes.immunities as |immunity|}}
        <li class="tag tag_secondary" data-immunity="{{immunity.type}}">{{immunity.label}}</li>
    {{/each}}
</ol>

{{!-- Weaknesses --}}
<header>
    <h2>{{localize "PF2E.WeaknessesLabel"}}</h2>
    {{#if editable}}
        <button type="button" data-action="edit-weaknesses">
            <i class="fa-solid fa-pen-to-square"></i> {{localize "PF2E.Edit"}}
        </button>
    {{/if}}
</header>
<ol class="weaknesses tags">
    {{#each data.attributes.weaknesses as |weakness|}}
        <li class="tag tag_secondary" data-weakness="{{weakness.type}}">{{weakness.label}}</li>
    {{/each}}
</ol>

{{!-- Resistances --}}
<header>
    <h2>{{localize "PF2E.ResistancesLabel"}}</h2>
    {{#if editable}}
        <button type="button" data-action="edit-resistances">
            <i class="fa-solid fa-pen-to-square"></i> {{localize "PF2E.Edit"}}
        </button>
    {{/if}}
</header>
<ol class="resistances tags">
    {{#each data.attributes.resistances as |resistance|}}
        <li class="tag tag_secondary" data-resistance="{{resistance.type}}">{{resistance.label}}</li>
    {{/each}}
</ol>
