<fieldset class="basics">
    {{> "systems/pf2e/templates/items/partials/apex.hbs"}}

    <div class="form-group">
        <label for="{{fieldIdPrefix}}category">{{localize "PF2E.Category"}}</label>
        <select id="{{fieldIdPrefix}}category" data-property="system.category">
            {{selectOptions categories selected=data.category localize=true}}
        </select>
    </div>

    {{#unless item.isBarding}}
        <div class="form-group">
            <label for="{{fieldIdPrefix}}group">{{localize "PF2E.ArmorGroupLabel"}}</label>
            <select id="{{fieldIdPrefix}}group" data-property="system.group">
                {{selectOptions groups selected=item.group blank=""}}
            </select>
        </div>

        <div class="form-group">
            <label for="{{fieldIdPrefix}}base">{{localize "PF2E.Item.Physical.Base"}}</label>
            <select id="{{fieldIdPrefix}}base" data-property="system.baseItem">
                {{selectOptions baseTypes selected=item.baseType blank=""}}
            </select>
        </div>
    {{/unless}}

    <div class="form-group">
        <label for="{{fieldIdPrefix}}ac-bonus">{{localize "PF2E.ArmorArmorLabel"}}</label>
        <input
            type="number"
            id="{{fieldIdPrefix}}ac-bonus"
            value="{{item.system.acBonus}}"
            data-property="system.acBonus"
            {{#if (gt item.acBonus item._source.system.acBonus)}}
                class="adjusted-higher"
            {{else if (lt item.acBonus item._source.system.acBonus)}}
                class="adjusted-lower"
            {{/if}}
        />
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.ArmorDexLabel"}}</label>
        <input
            type="number"
            value="{{data.dexCap}}"
            data-property="system.dexCap"
            {{#if (gt item.dexCap item._source.system.dexCap)}}
                class="adjusted-higher"
            {{else if (lt item.dexCap item._source.system.dexCap)}}
                class="adjusted-lower"
            {{/if}}
        />
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.ArmorCheckLabel"}}</label>
        <input
            type="number"
            value="{{data.checkPenalty}}"
            data-property="system.checkPenalty"
            {{#if (gt item.checkPenalty item._source.system.checkPenalty)}}
                class="adjusted-higher"
            {{else if (lt item.checkPenalty item._source.system.checkPenalty)}}
                class="adjusted-lower"
            {{/if}}
        />
    </div>

    <div class="form-group">
        <label for="{{fieldIdPrefix}}speed-penalty">{{localize "PF2E.ArmorSpeedLabel"}}</label>
        <input
            type="number"
            id="{{fieldIdPrefix}}speed-penalty"
            value="{{data.speedPenalty}}"
            data-property="system.speedPenalty"
            {{#if (gt item.speedPenalty item._source.system.speedPenalty)}}
                class="adjusted-higher"
            {{else if (lt item.speedPenalty item._source.system.speedPenalty)}}
                class="adjusted-lower"
            {{/if}}
        />
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.ArmorStrengthLabel"}}</label>
        <input
            type="number"
            value="{{data.strength}}"
            placeholder="—"
            data-property="system.strength"
            {{#if (gt item.strength item._source.system.strength)}}
                class="adjusted-lower"
            {{else if (lt item.strength item._source.system.strength)}}
                class="adjusted-higher"
            {{/if}}
        />
    </div>

    <div class="form-group">
        <label>{{localize "PF2E.HardnessLabel"}}</label>
        <input
            type="number"
            {{#if (gt item.hardness item._source.system.hardness)}}class="adjusted-higher"{{else if (lt item.hardness item._source.system.hardness)}}class="adjusted-lower"{{/if}}
            data-property="system.hardness" value="{{item.hardness}}"
        />
    </div>

    <div class="form-group">
        <label for="{{fieldIdPrefix}}hp">{{localize "PF2E.HitPointsHeader"}}</label>
        <div class="form-fields">
            <input id="{{fieldIdPrefix}}hp" type="number" name="system.hp.value" value="{{data.hp.value}}" />
            /
            <input type="number"
                {{#if (gt item.system.hp.max item._source.system.hp.max)}}
                    class="adjusted-higher"
                {{else if (lt item.system.hp.max item._source.system.hp.max)}}
                    class="adjusted-lower"
                {{/if}}
                data-property="system.hp.max"
                value="{{data.hp.max}}" />
        </div>
    </div>
</fieldset>

<fieldset class="material-runes">
    <legend>{{localize "PF2E.Item.Physical.MaterialRunes.Label"}}</legend>
    <div class="form-group precious-material">
        <label for="{{fieldIdPrefix}}material">{{localize "PF2E.PreciousMaterialLabel"}}</label>
        <select
            id="{{fieldIdPrefix}}material"
            data-property="system.material"
            data-value-base="{{json item._source.system.material}}"
            data-dtype="JSON"
        >
            {{selectOptions preciousMaterials.materials selected=preciousMaterials.value}}
        </select>
    </div>

    {{#unless item.isBarding}}
        {{#unless abpEnabled}}
            <div class="form-group">
                <label for="{{fieldIdPrefix}}rune-potency">{{localize "PF2E.PotencyRuneLabel"}}</label>
                <select name="system.runes.potency" id="{{fieldIdPrefix}}rune-potency" data-dtype="Number">
                    <option value="0"></option>
                    {{selectOptions (omit runeTypes.potency 0) selected=data.runes.potency labelAttr="name" localize=true}}
                </select>
            </div>
            <div class="form-group">
                <label for="{{fieldIdPrefix}}rune-resilient">{{localize "PF2E.Item.Armor.Rune.Resilient.Label"}}</label>
                <select name="system.runes.resilient" id="{{fieldIdPrefix}}rune-resilient" data-dtype="Number">
                    <option value="0"></option>
                    {{selectOptions (omit runeTypes.resilient 0) selected=data.runes.resilient labelAttr="name" localize=true}}
                </select>
            </div>
        {{/unless}}

        {{#each propertyRuneSlots as |slot index|}}
            <div class="form-group">
                <label
                    for="{{../fieldIdPrefix}}runes-property-{{index}}"
                    {{#if slot.disabled}}class="disabled"{{/if}}
                >
                    {{localize (concat "PF2E.PropertyRuneLabel" (add index 1))}}
                </label>
                <select
                    name="system.runes.property.{{index}}"
                    id="{{../fieldIdPrefix}}runes-property-{{index}}"
                    {{disabled slot.disabled}}
                    {{#if slot.readOnly}}class="readonly"{{/if}}
                >
                    {{selectOptions
                        @root.runeTypes.property
                        selected=slot.slug
                        valueAttr="slug"
                        labelAttr="name"
                        blank=""
                        localize=true}}
                </select>
            </div>
        {{/each}}

        <div class="form-group">
            <label class="large" for="{{../fieldIdPrefix}}specific-magic-{{index}}">
                {{localize "PF2E.Item.Armor.Specific.Label"}}
                <i class="fa-solid fa-circle-info" data-tooltip="PF2E.Item.Armor.Specific.Hint"></i>
            </label>
            <input
                type="checkbox"
                name="system.specific"
                id="{{../fieldIdPrefix}}specific-magic-{{index}}"
                value="{{json specificMagicData}}"
                data-dtype="JSON"
                {{checked data.specific}}
            />
        </div>
    {{/unless}}
</fieldset>


<div class="form-group stacked">
    <label>
        {{localize "PF2E.Item.Physical.OtherTags.Label"}}
        <i class="fa-solid fa-circle-info" data-tooltip="PF2E.Item.Physical.OtherTags.Hint"></i>
        {{#if editable}}
            <a class="tag-selector" data-tag-selector="basic" data-config-types="otherArmorTags" data-title="PF2E.Item.Physical.OtherTags.Label" data-property="system.traits.otherTags"><i class="fa-solid fa-edit"></i></a>
        {{/if}}
    </label>
    <ul class="traits-list tags">
        {{#each otherTags as |tag|}}
            <li class="tag tag_alt">{{tag.label}}</li>
        {{/each}}
    </ul>
</div>
