<fieldset>
    <legend>{{ localize "DND5E.ItemWeaponDetails" }}</legend>

    {{!-- Weapon Type --}}
    {{ formField fields.type.fields.value value=source.type.value label="DND5E.ItemWeaponType" localize=true
                 choices=CONFIG.weaponTypes rootId=partId }}

    {{!-- Weapon Base --}}
    {{#if baseItemOptions.length}}
    {{ formField fields.type.fields.baseItem value=source.type.baseItem label="DND5E.ItemWeaponBase" localize=true
                 options=baseItemOptions rootId=partId }}
    {{/if}}

    {{!-- Proficiency --}}
    {{#unless system.isMountable}}
    {{ formField fields.proficient value=source.proficient blank="DND5E.Automatic" localize=true
                 choices=CONFIG.weaponAndArmorProficiencyLevels rootId=partId }}
    {{/unless}}

    {{!-- Weapon Mastery --}}
    {{ formField fields.mastery value=source.mastery choices=CONFIG.weaponMasteries labelAttr="label" rootId=partId }}

    {{!-- Weapon Properties --}}
    {{ formField fields.properties options=properties.options label="DND5E.ItemWeaponProperties" localize=true
                 input=inputs.createMultiCheckboxInput stacked=true classes="checkbox-grid" }}

    {{!-- Magical Properties --}}
    {{#if properties.object.mgc}}
    <div class="form-group split-group">
        <label>{{ localize "DND5E.ITEM.Property.Magical" }}</label>
        <div class="form-fields">

            {{!-- Attunement --}}
            {{#unless system.isMountable}}
            <div class="form-group label-top">
                <label>{{ localize "DND5E.Attunement" }}</label>
                <div class="form-fields">

                    {{!-- Attuned --}}
                    {{#if source.attunement}}
                    {{ formInput fields.attuned value=source.attuned input=inputs.createCheckboxInput
                                 ariaLabel=(localize "DND5E.Attuned") dataset=(dnd5e-object tooltip="DND5E.Attuned") }}
                    {{/if}}

                    {{!-- Attunement --}}
                    {{ formInput fields.attunement value=source.attunement choices=CONFIG.attunementTypes
                                 blank="DND5E.AttunementNone" localize=true }}
                </div>
            </div>
            {{/unless}}

            {{!-- Magical Bonus --}}
            {{ formField fields.magicalBonus value=source.magicalBonus step=1 placeholder="0" label="DND5E.Bonus"
                         localize=true classes="label-top" rootId=partId }}
        </div>
    </div>
    {{/if}}

    {{!-- Ammunition Type --}}
    {{#if properties.object.amm}}
    {{ formField fields.ammunition.fields.type value=source.ammunition.type choices=CONFIG.consumableTypes.ammo.subtypes
                 rootId=partId }}
    {{/if}}
</fieldset>

<fieldset>
    <legend>{{ localize "DND5E.Range" }}</legend>

    {{#if (or system.hasRange (not system.attackType))}}

    <div class="form-group split-group">
        <label>{{ localize "DND5E.RangeDistance" }}</label>
        <div class="form-fields">

            {{!-- Normal --}}
            {{ formField fields.range.fields.value value=source.range.value label="DND5E.Normal" localize=true
                         hint=false classes="label-top" rootId=partId }}

            {{!-- Long --}}
            {{ formField fields.range.fields.long value=source.range.long label="DND5E.Long" localize=true
                         hint=false classes="label-top" rootId=partId }}

            {{!-- Reach --}}
            {{#if (or system.isMountable (not (eq system.attackType "ranged")))}}
            {{ formField fields.range.fields.reach value=source.range.reach label="DND5E.RANGE.FIELDS.range.reach.label"
                         placeholder=(ifThen (eq system.range.reach null) "—" system.range.reach) localize=true
                         classes="label-top" rootId=partId }}
            {{/if}}
        </div>
    </div>

    {{!-- Units --}}
    {{ formField fields.range.fields.units value=source.range.units label="DND5E.Unit" localize=true hint=false
                 choices=CONFIG.movementUnits rootId=partId }}

    {{else}}

    <div class="form-group split-group">
        <label>{{ localize "DND5E.RangeDistance" }}</label>
        <div class="form-fields">

            {{!-- Reach --}}
            {{#if (eq system.attackType "melee")}}
            {{ formField fields.range.fields.reach value=source.range.reach label="DND5E.RANGE.FIELDS.range.reach.label"
                         placeholder=(ifThen (eq system.range.reach null) "—" system.range.reach) classes="label-top"
                         localize=true rootId=partId }}
            {{/if}}

            {{!-- Units --}}
            {{ formField fields.range.fields.units value=source.range.units label="DND5E.Unit" localize=true
                         hint=false choices=CONFIG.movementUnits classes="label-top" rootId=partId }}
        </div>
    </div>

    {{/if}}
</fieldset>

{{#if system.isMountable}}
    {{> "dnd5e.details-mountable" }}
{{/if}}

<fieldset>
    <legend>{{ localize "DND5E.DAMAGE.Title" }}</legend>
    <div class="form-fields">
        <p class="hint">{{ localize "DND5E.WEAPON.FIELDS.damage.hint" }}</p>
    </div>
    {{> "dnd5e.field-damage" fields=fields.damage.fields.base.fields source=source.damage.base types=damageTypes
        prefix="system.damage.base." denominationOptions=denominationOptions.base }}
</fieldset>

{{#if properties.object.ver}}
<fieldset>
    <legend>{{ localize "DND5E.Versatile" }}</legend>
    {{> "dnd5e.field-damage" fields=fields.damage.fields.versatile.fields source=source.damage.versatile
        prefix="system.damage.versatile." bonus=false numberPlaceholder=source.damage.base.number
        denominationOptions=denominationOptions.versatile }}
</fieldset>
{{/if}}
