<form class="{{cssClass}} flexcol" autocomplete="off">

    {{!-- Item Sheet Header --}}
    <header class="sheet-header flexrow">
        <img class="profile" src="{{item.img}}" data-tooltip="{{item.name}}" data-edit="img">

        <div class="header-details flexrow">
            <h1 class="charname">
                {{#if system.identified}}
                <input name="name" type="text" value="{{item.name}}" placeholder="{{ localize 'DND5E.ItemName' }}">
                {{else}}
                <input name="system.unidentified.name" type="text" value="{{system.unidentified.name}}"
                       placeholder="{{ localize 'DND5E.NameUnidentified' }}">
                {{/if}}
            </h1>

            <div class="item-subtitle">
                <h4 class="item-type">{{itemType}}</h4>
                <label class="equipped">
                    <input type="checkbox" name="system.equipped" {{checked system.equipped}}>
                    {{#if system.equipped}}
                        {{ localize "DND5E.Equipped" }}
                        {{#if editable}}<i class="fa-solid fa-toggle-on"></i>{{/if}}
                    {{else}}
                        {{ localize "DND5E.Unequipped" }}
                        {{#if editable}}<i class="fa-solid fa-toggle-off"></i>{{/if}}
                    {{/if}}
                </label>
                <label class="identified">
                    <input type="checkbox" name="system.identified" {{checked system.identified}}>
                    {{#if system.identified}}
                        {{ localize "DND5E.Identified" }}
                        {{#if editable}}<i class="fa-solid fa-toggle-on"></i>{{/if}}
                    {{else}}
                        {{ localize "DND5E.Unidentified.Title" }}
                        {{#if editable}}<i class="fa-solid fa-toggle-off"></i>{{/if}}
                    {{/if}}
                </label>
            </div>

            <ul class="summary flexrow">
                <li>{{ system.type.label }}</li>
                <li>
                    {{#if concealDetails}}
                    <span>{{ localize "DND5E.Unidentified.Title" }}</span>
                    {{else}}
                    <select name="system.rarity" {{~#if concealDetails}} inert{{/if}}>
                        {{selectOptions config.itemRarity selected=system.rarity blank=""}}
                    </select>
                    {{/if}}
                </li>
                <li>
                    {{> "dnd5e.item-source"}}
                </li>
            </ul>
        </div>
    </header>

    {{!-- Item Sheet Navigation --}}
    <nav class="sheet-navigation tabs" data-group="primary">
        <a class="item active" data-tab="description">{{ localize "DND5E.Description" }}</a>
        <a class="item" data-tab="details">{{ localize "DND5E.Details" }}</a>
        <a class="item" data-tab="effects">{{ localize "DND5E.Effects" }}</a>
    </nav>

    {{!-- Item Sheet Body --}}
    <section class="sheet-body">

        {{!-- Description Tab --}}
        {{> "dnd5e.item-description"}}

        {{!-- Details Tab --}}
        <div class="tab details" data-group="primary" data-tab="details">
            {{#dnd5e-concealSection concealDetails}}

            <h3 class="form-header">{{ localize "DND5E.ItemToolDetails" }}</h3>

            {{!-- Tool Type --}}
            <div class="form-group">
                <label>{{ localize "DND5E.ItemToolType" }}</label>
                <select name="system.type.value">
                    {{selectOptions config.toolTypes selected=system.type.value blank=""}}
                </select>
            </div>

            {{#if baseItems}}
            <div class="form-group">
                <label>{{ localize "DND5E.ItemToolBase" }}</label>
                <select name="system.type.baseItem">
                    {{selectOptions baseItems selected=system.type.baseItem blank=""}}
                </select>
            </div>
            {{/if}}

            {{!-- Tool Properties --}}
            <div class="form-group stacked tool-properties">
                <label>{{ localize "DND5E.ItemToolProperties" }}</label>
                {{#each properties}}
                <label class="checkbox">
                    <input type="checkbox" name="system.properties.{{ @key }}" {{ checked selected }}>
                    {{ label }}
                </label>
                {{/each}}
            </div>

            <div class="form-group input-select">
                <label>{{localize "DND5E.Attunement"}}</label>
                <div class="form-fields">
                    <input type="checkbox" name="system.attuned" {{ checked system.attuned }}
                           {{ disabled (not system.attunement) }}
                           data-tooltip="DND5E.Attuned" aria-label="{{ localize 'DND5E.Attuned' }}">
                    <select name="system.attunement">
                        {{selectOptions config.attunementTypes selected=system.attunement
                                        blank=(localize "DND5E.AttunementNone")}}
                    </select>
                </div>
            </div>

            {{!-- Tool Proficiency --}}
            <div class="form-group">
                <label>{{ localize "DND5E.ItemToolProficiency" }}</label>
                <select name="system.proficient" data-dtype="Number">
                    {{selectOptions config.proficiencyLevels selected=system.proficient
                                    blank=(localize "DND5E.Automatic")}}
                </select>
            </div>

            {{!-- Ability Check --}}
            <div class="form-group">
                <label>{{ localize "DND5E.DefaultAbilityCheck" }}</label>
                <select name="system.ability">
                    {{selectOptions config.abilities selected=system.ability labelAttr="label"
                                    blank=(localize "DND5E.Default")}}
                </select>
            </div>

            {{!-- Tool Bonus --}}
            <div class="form-group">
                <label>{{ localize "DND5E.ItemToolBonus" }}</label>
                <input type="text" name="system.bonus" value="{{system.bonus}}" data-formula-editor/>
            </div>

            <h3 class="form-header">{{ localize "DND5E.ItemToolUsage" }}</h3>

            {{!-- Item Activation Template --}}
            {{> "dnd5e.item-activation"}}

            {{!-- Chat Message Flavor --}}
            <div class="form-group stacked">
                <label>{{ localize "DND5E.ChatFlavor" }}</label>
                <input type="text" name="system.chatFlavor" value="{{system.chatFlavor}}"/>
            </div>

            {{/dnd5e-concealSection}}
        </div>

        {{!-- Effects Tab --}}
        <div class="tab effects flexcol" data-group="primary" data-tab="effects">
            {{> "dnd5e.active-effects"}}
        </div>
    </section>
</form>
