<div class="field-group">
    {{ formInput fields.custom.fields.enabled name=(concat prefix "custom.enabled") value=source.custom.enabled
                 input=@root.inputs.createCheckboxInput classes="singleton"
                 dataset=(dnd5e-object tooltip="DND5E.DAMAGE.FIELDS.damage.parts.FIELDS.custom.enabled.hint")
                 ariaLabel=(localize "DND5E.DAMAGE.FIELDS.damage.parts.FIELDS.custom.enabled.hint")}}
    {{#if source.custom.enabled}}

    {{ formField fields.custom.fields.formula name=(concat prefix "custom.formula") value=source.custom.formula
                 label="DND5E.Formula" hint=false localize=true classes="label-top" rootId=@root.partId }}
    <input type="hidden" name="{{ prefix }}number" value="{{ source.number }}" data-dtype="Number">
    <input type="hidden" name="{{ prefix }}denomination" value="{{ source.denomination }}" data-dtype="Number">
    <input type="hidden" name="{{ prefix }}bonus" value="{{ source.bonus }}">

    {{else}}

    {{ formField fields.number name=(concat prefix "number") value=source.number label="DND5E.Number" hint=false
                 localize=true classes="label-top" rootId=@root.partId }}

    {{ formField fields.denomination name=(concat prefix "denomination") value=source.denomination
                 options=@root.denominationOptions label="DND5E.Die" hint=false localize=true classes="label-top"
                 rootId=@root.partId }}

    {{ formField fields.bonus name=(concat prefix "bonus") value=source.bonus label="DND5E.Bonus" hint=false
                 localize=true classes="label-top" rootId=@root.partId }}

    <input type="hidden" name="{{ prefix }}custom.formula" value="{{ source.custom.formula }}">

    {{/if}}
    {{#unless locked}}
    <button type="button" class="unbutton control-button" data-action="deleteDamagePart"
            data-tooltip aria-label="{{ localize 'DND5E.DAMAGE.Part.Action.Delete' }}">
        <i class="fa-solid fa-minus" inert></i>
    </button>
    {{/unless}}
</div>

<div class="field-group">
    {{ formField fields.types name=(concat prefix "types") value=source.types options=typeOptions hint=false
                 disabled=locked label="DND5E.Type" localize=true classes="label-top multi-select"
                 rootId=@root.partId }}
    <!-- TODO: This disabled is only necessary because of https://github.com/foundryvtt/foundryvtt/issues/11564 -->
</div>

{{#if canScale}}
{{#with fields.scaling.fields as |fields|}}
<div class="field-group">
    {{ formField fields.mode name=(concat ../prefix "scaling.mode") value=../source.scaling.mode
                 options=../scalingOptions label="DND5E.DAMAGE.FIELDS.damage.parts.FIELDS.scaling.abbr" hint=false
                 localize=true classes="label-top" rootId=@root.partId }}
    {{#if ../source.scaling.mode}}
    {{ formField fields.number name=(concat ../prefix "scaling.number") value=../source.scaling.number
                 label="DND5E.DAMAGE.FIELDS.damage.parts.FIELDS.scaling.number.abbr" hint=false localize=true
                 classes="label-top" rootId=@root.partId }}
    {{ formField fields.formula name=(concat ../prefix "scaling.formula") value=../source.scaling.formula
                 label="DND5E.Formula" hint=false localize=true classes="label-top" rootId=@root.partId }}
    {{/if}}
</div>
{{/with}}
{{/if}}
