<section class="trade-goods-catalog-shell">
    <header class="trade-goods-catalog-toolbar">
        <label><i class="fas fa-magnifying-glass"></i><input type="search" value="{{query}}" data-trade-catalog-search placeholder="Find a trade good…" autofocus></label>
        <span><b>{{activeCount}}</b> goods · <b>{{customCount}}</b> custom</span>
        {{#if hasOverrides}}<button type="button" data-action="resetAllPrices"><i class="fas fa-rotate-left"></i> Reset Default Prices</button>{{/if}}
        <button type="button" class="bright" data-action="addCustomGood"><i class="fas fa-plus"></i> Add Custom Good</button>
    </header>

    <section class="trade-goods-market-rates">
        <div class="trade-goods-market-rates-heading">
            <i class="fas fa-scale-balanced"></i>
            <span><strong>World Trade Rates</strong><small>Used by every settlement Marketplace.</small></span>
        </div>
        <label>
            <span>Local export price<small>Buying where a good is produced, or selling it where it is already supplied.</small></span>
            <span class="trade-goods-rate-input"><input type="number" name="sourcePercent" min="0" max="500" step="1" value="{{marketRates.sourcePercent}}" data-trade-rate><b>%</b></span>
        </label>
        <label>
            <span>City demand price<small>Paid by a city whose trade network cannot supply the good.</small></span>
            <span class="trade-goods-rate-input"><input type="number" name="cityImportPercent" min="100" max="500" step="1" value="{{marketRates.cityImportPercent}}" data-trade-rate><b>%</b></span>
        </label>
        <p><strong>Town demand:</strong> 100% of base price.</p>
    </section>

    <div class="trade-goods-catalog-columns" aria-hidden="true"><span>Trade Good</span><span>Base Price</span><span>Actions</span></div>
    <div class="trade-goods-catalog-list">
        {{#each goods}}
        <article class="trade-goods-catalog-row {{#if archived}}is-archived{{/if}}" data-trade-catalog-good data-search-text="{{searchText}}">
            <span class="nexus-entity-image">{{#if imageSrc}}<img src="{{imageSrc}}" alt="">{{else}}<i class="fas fa-box"></i>{{/if}}</span>
            <span class="trade-goods-catalog-name"><strong>{{name}}</strong><small>{{sourceLabel}} · {{familyLabel}} · {{lot.label}}{{#if archived}} · Archived{{/if}}</small></span>
            <label class="trade-goods-catalog-price"><input type="number" min="0" step="0.01" value="{{tradeValue}}" data-trade-good-price data-good-id="{{id}}"><span>gp / lot</span></label>
            <span class="trade-goods-catalog-actions">
                {{#if custom}}
                    {{#if archived}}<button type="button" data-action="restoreCustomGood" data-good-id="{{id}}" title="Restore"><i class="fas fa-box-open"></i></button>{{else}}<button type="button" data-action="editCustomGood" data-good-id="{{id}}" title="Edit"><i class="fas fa-pen"></i></button><button type="button" data-action="archiveCustomGood" data-good-id="{{id}}" title="Archive"><i class="fas fa-box-archive"></i></button>{{/if}}
                {{else}}
                    {{#if overridden}}<button type="button" data-action="resetGoodPrice" data-good-id="{{id}}" title="Reset default price"><i class="fas fa-rotate-left"></i></button>{{else}}<i class="fas fa-lock" title="Standard trade good"></i>{{/if}}
                {{/if}}
            </span>
        </article>
        {{else}}<div class="trade-goods-catalog-empty"><i class="fas fa-box-open"></i><strong>No trade goods found.</strong></div>{{/each}}
    </div>
    <footer>Base prices apply to every region. Assign a custom good to a Location to introduce it into that region's trade network.</footer>
</section>
