<div class="form-group">
    <label>{{localize "PF2E.WeaponTypeLabel"}}</label>
    <select name="system.category">
        {{#select data.category}}
            {{#each categories as |label slug|}}
                <option value="{{slug}}">{{label}}</option>
            {{/each}}
        {{/select}}
    </select>
</div>
<div class="form-group">
    <label>{{localize "PF2E.WeaponGroupLabel"}}</label>
    <select name="system.group">
        {{#select data.group}}
            <option value=""></option>
            {{#each groups as |name type|}}
                <option value="{{type}}">{{localize name}}</option>
            {{/each}}
        {{/select}}
    </select>
</div>
<div class="form-group">
    <label>{{localize "PF2E.WeaponBaseLabel"}}</label>
    <select name="system.baseItem">
        {{#select data.baseItem}}
            <option value=""></option>
            {{#each baseTypes as |label slug|}}
                <option value="{{slug}}">{{label}}</option>
            {{/each}}
        {{/select}}
    </select>
</div>
<div class="form-group">
    <label>
        {{localize "PF2E.WeaponRangeLabel"}}
        {{#if mandatoryMelee}}
            <i class="fas fa-info-circle small" title="{{localize "PF2E.Item.Weapon.MandatoryMelee"}}"></i>
        {{/if}}
    </label>
    <select name="system.range" data-dtype="Number" {{disabled mandatoryMelee}}>
        {{#select item._source.system.range}}
            {{#unless mandatoryRanged}}<option value="">{{localize "PF2E.Item.Weapon.NoRangeMelee"}}</option>{{/unless}}
            {{#each weaponRanges as |label range|}}
                <option value="{{range}}">{{localize label range=range}}</option>
            {{/each}}
        {{/select}}
    </select>
</div>
{{#if data.range}}
    <div class="form-group">
        <label>{{localize "PF2E.WeaponReloadLabel"}}</label>
        <select name="system.reload.value">
            {{#select data.reload.value}}
                <option value=""></option>
                {{#each weaponReload as |name type|}}
                    <option value="{{type}}">{{localize name}}</option>
                {{/each}}
            {{/select}}
        </select>
    </div>
{{/if}}

{{#if isBomb}}
    <div class="form-group">
        <label>{{localize "PF2E.WeaponBonusAttackLabel"}}</label>
        <input type="number" name="system.bonus.value" value="{{data.bonus.value}}" />
    </div>
{{/if}}

<div class="form-group">
    <label>{{localize "PF2E.WeaponMAPLabel"}}</label>
    <select name="system.MAP.value">
        {{#select data.MAP.value}}
            <option value="">{{localize "PF2E.WeaponMAPDefaultOption"}}</option>
            {{#each weaponMAP as |name type|}}
                <option value="{{type}}">{{name}}</option>
            {{/each}}
        {{/select}}
    </select>
</div>
{{#unless isBomb}}
    <ol class="form-list">
        <h3>
            {{localize "PF2E.Item.Weapon.MaterialAndRunes.Title"}}
            <i class="fas fa-info-circle large" title="{{localize "PF2E.Item.Weapon.MaterialAndRunes.Hint"}}"></i>
        </h3>
        <div class="form-group precious-material">
            <label>{{localize "PF2E.PreciousMaterialLabel"}}</label>
            <select name="preciousMaterial">
                {{#select preciousMaterials.value}}
                    <option value=""></option>
                    {{#each preciousMaterials.materials as |material materialKey|}}
                        <optgroup label="{{material.label}}">
                            {{#each material.grades as |grade gradeKey|}}
                                <option value="{{materialKey}}|{{gradeKey}}">
                                    {{localize "PF2E.Item.Weapon.MaterialAndRunes.MaterialOption" type=material.label grade=grade.label}}
                                </option>
                            {{/each}}
                        </optgroup>
                    {{/each}}
                {{/select}}
            </select>
        </div>
        {{#unless abpEnabled}}
            <div class="form-group">
                <label>{{localize "PF2E.PotencyRuneLabel"}}</label>
                <select name="system.potencyRune.value" data-dtype="Number">
                    {{#select data.potencyRune.value}}
                        <option value="0"></option>
                        {{#each weaponPotencyRunes as |name type|}}
                            <option value="{{type}}">{{localize name}}</option>
                        {{/each}}
                    {{/select}}
                </select>
            </div>
            <div class="form-group">
                <label>{{localize "PF2E.StrikingRuneLabel"}}</label>
                <select name="system.strikingRune.value">
                    {{#select data.strikingRune.value}}
                        <option value=""></option>
                        {{#each weaponStrikingRunes as |name type|}}
                            <option value="{{type}}">{{localize name}}</option>
                        {{/each}}
                    {{/select}}
                </select>
            </div>
        {{/unless}}
        {{#each propertyRuneSlots as |slot|}}
            <div class="form-group">
                <label>{{slot.label}}</label>
                {{#if @root.data.specific.value}}
                    <input type="hidden" name="{{slot.name}}" value="{{slot.value}}" data-dtype="String" />
                {{/if}}
                <select{{#if (not @root.data.specific.value)}} name="{{slot.name}}"{{/if}} {{disabled @root.data.specific.value}}>
                    {{#select slot.value}}
                        <option value=""></option>
                        {{#each @root.weaponPropertyRunes as |label type|}}
                            <option value="{{type}}">{{localize label}}</option>
                        {{/each}}
                    {{/select}}
                </select>
            </div>
        {{/each}}
        <div class="form-group">
            <label class="large">
                {{localize "PF2E.Item.Weapon.SpecificMagicWeapon.Label"}}
                <i class="fas fa-info-circle large" title="{{localize "PF2E.Item.Weapon.SpecificMagicWeapon.Hint"}}"></i>
            </label>
            <input type="checkbox" name="system.specific.value" {{checked data.specific.value}} />
        </div>
    </ol>
{{/unless}}
<ol class="form-list">
    <h3>
        {{localize "PF2E.DamageLabel"}}
        <i class="fas fa-info-circle large" title="{{localize "PF2E.WeaponBaseDamageTitle"}}"></i>
    </h3>
    <div class="form-group">
        <label>
            {{localize "PF2E.WeaponBaseLabel"}}
            {{#if adjustedDiceHint}}<i class="fas fa-info-circle small" title="{{adjustedDiceHint}}"></i>{{/if}}
        </label>

        <div class="dice-data">
            <input type="number"{{#if adjustedDiceHint}} class="adjusted"{{/if}} data-property="system.damage.dice" data-value-base="{{baseDice}}" value="{{data.damage.dice}}" />
            <select name="system.damage.die">
                {{#select data.damage.die}}
                    <option value=""></option>
                    {{#each damageDie as |name type|}}
                        <option value="{{type}}">{{localize name}}</option>
                    {{/each}}
                {{/select}}
            </select>
            <select name="system.damage.damageType">
                {{#select data.damage.damageType}}
                    {{#each damageTypes as |label slug|}}
                        {{#unless (eq slug "bleed")}}<option value="{{slug}}">{{label}}</option>{{/unless}}
                    {{/each}}
                {{/select}}
            </select>
        </div>
    </div>

    <div class="form-group">
        <label{{#unless data.splashDamage.value}} class="no-data"{{/unless}}>{{localize "PF2E.TraitSplash"}}</label>
        <input type="number" name="system.splashDamage.value" value="{{data.splashDamage.value}}" />
    </div>

    <div class="form-group">
        <label{{#unless data.damage.persistent}} class="no-data"{{/unless}}>{{localize "PF2E.ConditionTypePersistentShort"}}</label>

        <div class="dice-data">
            <input type="number" data-action="update-persistent" data-persistent-field="number" value="{{coalesce data.damage.persistent.number 0}}" />

            <select data-action="update-persistent" data-persistent-field="faces">
                {{#select data.damage.persistent.faces}}
                    <option value=""></option>
                    {{#each damageDieFaces as |label value|}}
                        <option value="{{value}}">{{localize label}}</option>
                    {{/each}}
                {{/select}}
            </select>

            <select data-action="update-persistent" data-persistent-field="type" value="{{data.damage.persistent.damageType}}">
                {{#select data.damage.persistent.type}}
                    <option value=""></option>
                    {{#each damageTypes as |label slug|}}
                        <option value="{{slug}}">{{label}}</option>
                    {{/each}}
                {{/select}}
            </select>
        </div>
    </div>

    <div class="form-group">
        <label{{#unless data.bonusDamage.value}} class="no-data"{{/unless}}>{{localize "PF2E.Bonus"}}</label>
        <input type="number" name="system.bonusDamage.value" value="{{data.bonusDamage.value}}" />
    </div>
</ol>

<ol class="form-list">
    <h3>
        {{localize "PF2E.WeaponCustomDamageLabel"}}
        <i class="fas fa-info-circle large" title="{{localize "PF2E.WeaponCustomDamageTitle"}}"></i>
    </h3>
    <li class="form-group">
        <label>{{localize "PF2E.ItemDescription"}}</label>
        <input type="text" name="system.property1.value" value="{{data.property1.value}}" />
    </li>

    <li class="form-group">
        <label>{{localize "PF2E.WeaponPropertyStrikeDamageLabel"}}</label>
        <div class="dice-data">
            <input type="number" name="system.property1.dice" value="{{data.property1.dice}}" />
            <select name="system.property1.die">
                {{#select data.property1.die}}
                    <option value=""></option>
                    {{#each damageDie as |name type|}}
                        <option value="{{type}}">{{localize name}}</option>
                    {{/each}}
                {{/select}}
            </select>
            <select name="system.property1.damageType">
                {{#select data.property1.damageType}}
                    <option value=""></option>
                    {{#each damageTypes as |label slug|}}
                        <option value="{{slug}}">{{label}}</option>
                    {{/each}}
                {{/select}}
            </select>
        </div>
    </li>
    <li class="form-group">
        <label>{{localize "PF2E.WeaponPropertyStrikeEffectLabel"}}</label>
        <div class="effects-container">
            <select name="system.property1.strikeConditionType">
                {{#select data.property1.strikeConditionType}}
                    <option value=""></option>
                    {{#each conditionTypes as |label slug|}}
                        <option value="{{slug}}">{{label}}</option>
                    {{/each}}
                {{/select}}
            </select>
            <select name="system.property1.strikeConditionValue" data-dtype="Number">
                {{#select data.property1.strikeConditionValue}}
                    <option value=""></option>
                    {{#each damageDice as |name type|}}
                        <option value="{{type}}">{{localize name}}</option>
                    {{/each}}
                {{/select}}
            </select>
        </div>
    </li>
    <li class="form-group">
        <label>{{localize "PF2E.WeaponPropertyCriticalDamageLabel"}}</label>
        <div class="dice-data">
            <input type="number" name="system.property1.critDice" value="{{data.property1.critDice}}" />
            <select name="system.property1.critDie">
                {{#select data.property1.critDie}}
                    <option value=""></option>
                    {{#each damageDie as |name type|}}
                        <option value="{{type}}">{{localize name}}</option>
                    {{/each}}
                {{/select}}
            </select>
            <select name="system.property1.critDamageType">
                {{#select data.property1.critDamageType}}
                    <option value=""></option>
                    {{#each damageTypes as |name type|}}
                        <option value="{{type}}">{{localize name}}</option>
                    {{/each}}
                {{/select}}
            </select>
        </div>
    </li>
    <li class="form-group">
        <label>{{localize "PF2E.WeaponPropertyCriticalEffectLabel"}}</label>
        <div class="effects-container">
            <select name="system.property1.criticalConditionType">
                {{#select data.property1.criticalConditionType}}
                    <option value=""></option>
                    {{#each conditionTypes as |label slug|}}
                        <option value="{{slug}}">{{localize label}}</option>
                    {{/each}}
                {{/select}}
            </select>
            <select name="system.property1.criticalConditionValue" data-dtype="Number">
                {{#select data.property1.criticalConditionValue}}
                    <option value=""></option>
                    {{#each damageDice as |name type|}}
                        <option value="{{type}}">{{localize name}}</option>
                    {{/each}}
                {{/select}}
            </select>
        </div>
    </li>
</ol>
{{#if isComboWeapon}}
    <ol class="form-list">
        <h3>
            {{localize "PF2E.Item.Weapon.MeleeUsage.Label"}}
            <i class="fas fa-info-circle large" title="{{localize "PF2E.Item.Weapon.MeleeUsage.Hint"}}"></i>
        </h3>
        <div class="form-group">
            <label>{{localize "PF2E.WeaponGroupLabel"}}</label>
            <select name="system.meleeUsage.group">
                {{#select meleeUsage.group}}
                    {{#each meleeGroups as |label slug|}}
                        <option value="{{slug}}">{{label}}</option>
                    {{/each}}
                {{/select}}
            </select>
        </div>
        <div class="form-group">
            <label>{{localize "PF2E.WeaponDamageLabel"}}</label>
            <div class="details-container-three-columns">
                <select name="system.meleeUsage.damage.die">
                    {{#select meleeUsage.damage.die}}
                        {{#each damageDie as |value faces|}}
                            <option value="{{faces}}">1{{faces}}</option>
                        {{/each}}
                    {{/select}}
                </select>
                <select name="system.meleeUsage.damage.type">
                    {{#select meleeUsage.damage.type}}
                        {{#each damageTypes as |label type|}}
                            <option value="{{type}}">{{label}}</option>
                        {{/each}}
                    {{/select}}
                </select>
            </div>
        </div>
        <div class="form-group-stacked">
            <label>
                {{localize "PF2E.TraitsLabel"}}
                <a class="tag-selector" data-tag-selector="basic" data-config-types="weaponTraits" data-property="system.meleeUsage.traits" data-no-custom="true" data-flat="true">
                    <i class="fas fa-edit"></i>
                </a>
            </label>
            <ul class="traits-list tags">
                {{#each meleeUsageTraits as |trait|}}
                    <li class="tag">{{trait.label}}</li>
                {{/each}}
            </ul>
        </div>
    </ol>
{{/if}}

<div class="form-group-stacked">
    <label>
        {{localize "PF2E.Item.Physical.OtherTags.Label"}}
        <i class="fas fa-info-circle other-tags-hint" title="PF2E.Item.Physical.OtherTags.Hint"></i>
        {{#if editable}}
            <a class="tag-selector" data-tag-selector="basic" data-config-types="otherWeaponTags" data-title="PF2E.Item.Physical.OtherTags.Label" data-property="system.traits.otherTags"><i class="fas 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>
