<div class="sidebar">
    <section>
        <div class="sidebar-title">
            <h2>{{localize "PF2E.DefensesLabel"}}</h2>
        </div>
        {{#if (or editing hasDefenses)}}
            <div class="health-line">
                <div class="health valued-icon">
                    <i class="fa-solid fa-heart"></i>
                    <input name="system.attributes.hp.value" class="current" type="number" value="{{data.attributes.hp.value}}" placeholder="0" />
                    /
                    <input name="system.attributes.hp.max" class="max" type="number" value="{{data.attributes.hp.max}}" placeholder="0" />
                </div>
                <div class="hardness valued-icon">
                    <input name="system.attributes.hardness" type="number" value="{{data.attributes.hardness}}" placeholder="0" />
                    {{localize "PF2E.Actor.Hardness.ShortLabel"}}
                </div>
                <div class="armor-class valued-icon">
                    <input name="system.attributes.ac.value" type="number" value="{{data.attributes.ac.value}}" placeholder="0" />
                    {{localize "PF2E.ArmorClassShortLabel"}}
                </div>
            </div>
            <input class="hp-details" name="system.attributes.hp.details" type="text" value="{{data.attributes.hp.details}}" placeholder="{{localize "PF2E.NPC.HPExtraInfoLabelPlaceholder"}}"/>
        {{else}}
            {{localize "PF2E.NoneOption"}}
        {{/if}}
    </section>

    {{#if document.isComplex}}
        <section>
            <div class="sidebar-title">
                <h2>{{localize "PF2E.InitiativeLabel"}}</h2>
            </div>
            <div>
                <div class="initiative">
                    <div class="valued-icon">
                        <input
                            type="text"
                            value="{{#if hasStealth}}{{numberFormat data.attributes.stealth.totalModifier sign=true}}{{/if}}"
                            data-property="system.attributes.stealth.value"
                            data-modifier
                            data-nullable
                            data-dtype="Number"
                            placeholder="N/A"
                        />
                    </div>
                    <a class="roll-init {{#if (and hasStealth editable)}}rollable{{else}}disabled{{/if}}" data-action="roll-initiative">
                        <i class="fa-solid fa-dice-d20"></i>
                        {{localize "PF2E.StealthLabel"}}
                    </a>
                </div>
            </div>
        </section>
    {{/if}}

    {{#if (or hasSaves editing)}}
        <section>
            <div class="sidebar-title">
                <h2>{{localize "PF2E.SavesHeader"}}</h2>
            </div>
            <div class="sidebar-saves">
                {{#each saves as |save|}}
                    <div class="save">
                        {{#if save.mod includeZero=true~}}
                            <a
                                class="rollable"
                                data-action="roll-check"
                                data-statistic="{{save.type}}"
                            ><i class="fa-solid fa-dice-d20"></i> {{save.label}}</a>
                        {{else if ../editing}}
                            <div>{{save.label}}</div>
                        {{~/if}}
                        <span class="valued-icon">
                            <input
                                type="text"
                                value="{{#if save.mod includeZero=true}}{{numberFormat save.mod sign=true}}{{/if}}"
                                data-property="system.saves.{{save.type}}.value"
                                data-modifier
                                data-nullable
                                data-dtype="Number"
                                placeholder="N/A"
                            />
                        </span>
                    </div>
                {{/each}}
            </div>
        </section>
    {{/if}}

    <section class="emits-sound">
        <div class="sidebar-title">
            <h2>
                <span>{{localize "PF2E.Actor.Hazard.EmitsSound.Title"}}</span>
                <i class="fa-solid fa-circle-info" data-tooltip="PF2E.Actor.Hazard.EmitsSound.Hint" data-tooltip-direction="RIGHT"></i>
            </h2>
        </div>
        <select name="system.attributes.emitsSound">
            {{selectOptions emitsSoundOptions selected=data.attributes.emitsSound localize=true}}
        </select>
    </section>

    {{#if (or editing hasIWR)}}
        <section>
            <div class="sidebar-title">
                <h2>{{localize "PF2E.ImmunitiesLabel"}}</h2>
                {{#if editing}}
                    <a data-action="edit-immunities" data-tooltip="PF2E.NPC.EditImmunities"><i class="fa-solid fa-edit"></i></a>
                {{/if}}
            </div>
            <div class="tags">
                {{#each data.attributes.immunities as |immunity|}}
                    <span class="tag" data-immunity="{{immunity.type}}">{{immunity.label}}</span>
                {{/each}}
            </div>
        </section>

        <section>
            <div class="sidebar-title">
                <h2>{{localize "PF2E.WeaknessesLabel"}}</h2>
                {{#if editing}}
                    <a data-action="edit-weaknesses" data-tooltip="PF2E.NPC.EditWeaknesses"><i class="fa-solid fa-edit"></i></a>
                {{/if}}
            </div>
            <div class="tags">
                {{#each data.attributes.weaknesses as |weakness|}}
                    <span class="tag" data-weakness="{{weakness.type}}">{{weakness.label}}</span>
                {{/each}}
            </div>
        </section>

        <section>
            <div class="sidebar-title">
                <h2>{{localize "PF2E.ResistancesLabel"}}</h2>
                {{#if editing}}
                    <a data-action="edit-resistances" data-tooltip="PF2E.NPC.EditResistances"><i class="fa-solid fa-edit"></i></a>
                {{/if}}
            </div>
            <div class="tags">
                {{#each data.attributes.resistances as |resistance|}}
                    <span class="tag" data-resistance="{{resistance.type}}">{{resistance.label}}</span>
                {{/each}}
            </div>
        </section>
    {{/if}}
</div>
