<div class="inventory-filters flexrow">

    {{#unless isNPC}}
    <ol class="currency flexrow">
        <h3>
            {{localize "SW5E.Currency"}}
        </h3>
        {{#each data.currency as |v k|}}
        <label class="denomination {{k}}">{{ lookup ../config.currencies k }}</label>
        <input type="text" name="data.currency.{{k}}" value="{{v}}" data-dtype="Number"/>
        {{/each}}
    </ol>
    {{/unless}}

    {{#unless isVehicle}}
    <ul class="filter-list flexrow" data-filter="inventory">
        <li class="filter-item" data-filter="action">{{localize "SW5E.Action"}}</li>
        <li class="filter-item" data-filter="bonus">{{localize "SW5E.BonusAction"}}</li>
        <li class="filter-item" data-filter="reaction">{{localize "SW5E.Reaction"}}</li>
        <li class="filter-item" data-filter="equipped">{{localize "SW5E.Equipped"}}</li>
    </ul>
    {{/unless}}
</div>

<ol class="items-list inventory-list">
{{#each sections as |section sid|}}
    <li class="items-header flexrow">
        <h3 class="item-name flexrow">{{localize section.label}}</h3>

        {{#if section.columns}}
            {{#each section.columns}}
                <div class="item-detail {{css}}">{{label}}</div>
            {{/each}}
        {{else}}
            {{#if ../isCharacter}}
                <div class="item-detail item-weight">{{localize "SW5E.Weight"}}</div>
            {{/if}}

            <div class="item-detail item-uses">{{localize "SW5E.Charges"}}</div>
            <div class="item-detail item-action">{{localize "SW5E.Usage"}}</div>
        {{/if}}

        {{#if ../owner}}
        <div class="item-controls flexrow">
            <a class="item-control item-create" title='{{localize "SW5E.ItemCreate"}}'
               {{#each section.dataset as |v k|}}data-{{k}}="{{v}}"{{/each}}>
                <i class="fas fa-plus"></i> {{localize "SW5E.Add"}}
            </a>
        </div>
        {{/if}}
    </li>

    <ol class="item-list">
    {{#each section.items as |item iid|}}
        <li class="item flexrow {{section.css}}"
            data-item-id="{{#if section.editableName}}{{iid}}{{else}}{{item._id}}{{/if}}">
            <div class="item-name flexrow rollable">
                {{#if section.editableName}}
                <input type="text" value="{{item.name}}">
                {{else}}
                <div class="item-image" style="background-image: url('{{item.img}}')"></div>
                <h4>
                    {{item.name~}}
                    {{~#if item.isStack}} ({{item.data.quantity}}){{/if}}
                    {{~#if item.data.attuned}} <i class="fas fa-sun attuned" title={{localize "SW5E.Attuned"}}></i>{{/if}}
                </h4>
                {{/if}}
            </div>

            {{#if section.columns}}
                {{#each section.columns}}
                    <div class="item-detail {{css}}">
                        {{#with (getProperty item property)}}
                            {{#if ../editable}}
                                <input type="text" value="{{this}}" placeholder="&mdash;"
                                       data-dtype="{{../editable}}" data-property="{{../property}}">
                            {{else}}
                                {{this}}
                            {{/if}}
                        {{/with}}
                    </div>
                {{/each}}
            {{else}}
                {{#if ../../isCharacter}}
                    <div class="item-detail item-weight">
                        {{#if item.totalWeight}}
                            <div class="item-detail">
                                {{ item.totalWeight }} {{localize "SW5E.AbbreviationLbs"}}
                            </div>
                        {{/if}}
                    </div>
                {{/if}}

                <div class="item-detail item-uses">
                    {{#if item.hasUses }}
                        <input type="text" value="{{item.data.uses.value}}" placeholder="0"/>
                        / {{item.data.uses.max}}
                    {{/if}}
                </div>

                <div class="item-detail item-action">
                    {{#if item.data.activation.type }}
                        {{item.labels.activation}}
                    {{/if}}
                </div>
            {{/if}}

            {{#if ../../owner}}
            <div class="item-controls flexrow">
                {{#unless @root.isVehicle}}
                <a class="item-control item-toggle {{item.toggleClass}}" title='{{item.toggleTitle}}'><i class="fas fa-shield-alt"></i></a>
                {{/unless}}
                {{#unless section.editableName}}
                <a class="item-control item-edit" title='{{localize "SW5E.ItemEdit"}}'><i class="fas fa-edit"></i></a>
                {{/unless}}
                <a class="item-control item-delete" title='{{localize "SW5E.ItemDelete"}}'><i class="fas fa-trash"></i></a>
            </div>
            {{/if}}
        </li>
    {{/each}}
    </ol>
{{/each}}
</ol>


{{#unless isNPC}}
{{#with data.attributes.encumbrance}}
<div class="encumbrance {{#if encumbered}}encumbered{{/if}}">
    <span class="encumbrance-bar" style="width:{{pct}}%"></span>
    <span class="encumbrance-label">{{value}} / {{max}}</span>
    <i class="encumbrance-breakpoint encumbrance-33 arrow-up"></i>
    <i class="encumbrance-breakpoint encumbrance-33 arrow-down"></i>
    <i class="encumbrance-breakpoint encumbrance-66 arrow-up"></i>
    <i class="encumbrance-breakpoint encumbrance-66 arrow-down"></i>
</div>
{{/with}}
{{/unless}}
