<div class="drag-drop-overlay"><p class="label">{{localize "MassEdit.common.attach"}}</p></div>
<form autocomplete="off" style="overflow: hidden;">
    <input type="hidden" name="type" value="{{preset.documentName}}"/>


    <!-- Navigation Tabs -->
    <nav class="sheet-tabs tabs" data-group="primary-tabs">
        {{#unless virtual}}
        <a class="item" data-tab="main"><i class="fa-regular fa-book-open"></i> Main</a>
        {{#if isPlaceable}}
        <a class="item" data-tab="spawning"><i class="fa-solid fa-circle-plus"></i> Spawning</a>
        {{/if}}
        {{/unless}}
        <a class="item" data-tab="tags"><i class="fa-solid fa-tag"></i> Tags</a>
    </nav>

    <section class="content">

        {{#unless virtual}}

        <div class="tab" data-tab="main" data-group="primary-tabs">

            <div class="form-group">
                <label>{{localize "Name"}}</label>
                <div class="form-fields">
                    <input type="text" name="name" placeholder="Preset Name" value="{{preset.name}}" minlength="{{minlength}}" {{#if minlength}}required{{/if}} autofocus>
                </div>
            </div>

            <div class="form-group">
                <label>{{localize "COMBAT.CombatantImage"}}</label>
                <div class="form-fields">
                    <file-picker name="img" type="imagevideo" value="{{preset.img}}"></file-picker>
                    {{#if tva}} 
                    <button  class="token-variants-image-select-button" type="button" data-type="imagevideo" data-target="img"><i class="fas fa-images"></i></button>
                    {{/if}}
                </div>
            </div>

            {{#if documentEdit}}
            <fieldset>
                <legend>{{localize "MassEdit.common.data"}}</legend>
                <div class="form-group {{#if editDisabled}}disabled{{/if}}">
                    <label>{{localize "SIDEBAR.Edit"}} [{{documentEdit}}]</label>
                    <div class="form-fields">
                        <button  class="edit-document" type="button" {{#if editDisabled}}disabled{{/if}}><i class="fa-solid fa-gear"></i></button>
                    </div>
                    <p class="notes">{{localize "MassEdit.presets.data-edit" document=documentEdit}}</p>
                </div>
                {{#if displayFieldDelete}}
                <div class="form-group {{#if deleteDisabled}}disabled{{/if}}">
                    <label>{{localize "MassEdit.presets.delete-fields"}}</label>
                    <div class="form-fields">
                        <button  class="delete-fields" type="button" {{#if deleteDisabled}}disabled{{/if}}><i class="fas fa-tasks"></i></button>
                    </div>
                    <p class="notes">{{localize "MassEdit.presets.select-delete"}}</p>
                </div>
                {{/if}}
                {{#if isPlaceable}}
                <div class="form-group {{#if assignDisabled}}disabled{{/if}}">
                    <label>Assign [{{documentEdit}}]</label>
                    <div class="form-fields">
                        <button  class="assign-document" type="button" {{#if assignDisabled}}disabled{{/if}}><i class="fa-solid fa-arrow-right-to-arc"></i></button>
                    </div>
                    <p class="notes">{{localize "MassEdit.presets.data-assign" document=documentEdit}}</p>
                </div>
                {{/if}}

            </fieldset>
            {{/if}}
        </div>

        {{#if isPlaceable}}
        <div class="tab" data-tab="spawning" data-group="primary-tabs">
            {{#unless multiEdit}}
            <div class="form-group">
                <label>{{localize "MassEdit.common.attached"}}</label>

                <div class="form-fields">
                    {{#if attached}}
                    <div style="max-height: 40px; overflow-y: auto;">
                        {{#each attached}}
                        <a class="attached" data-index="{{@index}}"><i class="{{icon}}" data-tooltip="{{tooltip}}"></i></a>
                        {{/each}}
                    </div>
                    {{else}}
                    <div style="border: 2px dashed; text-align: center; color: orangered; padding: 2px;">{{localize "MassEdit.presets.drag-placeable"}}</div>
                    {{/if}}
                    <button class="attach-selected" type="button" data-tooltip="Attach Selected Placeables"><i class="fas fa-plus-square"></i></button>
                </div>
                <p class="notes">{{localize "MassEdit.presets.drag-placeable-hint"}}</p>
            </div>

            <div class="form-group {{#if modifyDisabled}}disabled{{/if}}">
                <label>{{localize "MassEdit.common.modify"}}</label>
                <div class="form-fields">
                    <button  class="spawn-fields" type="button" {{#if modifyDisabled}}disabled{{/if}}><i class="fas fa-tasks"></i></button>
                </div>
                <p class="notes">{{localize "MassEdit.presets.select-modify"}}</p>
            </div>

            <div class="form-group">
                <label>{{localize "MassEdit.common.random"}}</label>
                <div class="form-fields">
                    <input type="checkbox" name="spawnRandom" {{#if preset.spawnRandom}}checked{{/if}} />
                </div>
                <p class="notes">{{localize "MassEdit.presets.spawn-random"}}</p>
            </div>

            <div class="form-group">
                <label>Preserve Links</label>
                <div class="form-fields">
                    <input type="checkbox" name="preserveLinks" {{#if preset.preserveLinks}}checked{{/if}} />
                </div>
                <p class="notes">If not enabled any links present within the preset will be regenerated to ensure uniqueness on the scene after spawn.</p>
            </div>
            {{/unless}}

            <div class="form-group">
                <label>Grid Size</label>
                <div class="form-fields">
                    <input type="number" name="gridSize" value="{{preset.gridSize}}" min="10" step="1" placeholder="Pixels">
                </div>
                <p class="notes">The size of the grid from which the preset has been created. Used to dynamically scale the preset.</p>
            </div>

            {{#unless multiEdit}}
            <div class="form-group stacked command">
                <label>Pre-Spawn Script</label>
                <p class="notes">data | token actor</p>
                <textarea style="height: 120px" name="preSpawnScript">{{preset.preSpawnScript}}</textarea>
            </div>

            <div class="form-group stacked command">
                <label>Post-Spawn Script</label>
                <p class="notes">documents objects | token actor</p>
                <textarea style="height: 120px" name="postSpawnScript">{{preset.postSpawnScript}}</textarea>
            </div>
            {{/unless}}
        </div>
        {{/if}}
        
        {{/unless}}

        <div class="tab" data-tab="tags" data-group="primary-tabs">
        {{#if multiEdit}}
            {{tagInput name="addTags" label="Add Tags"}}
            {{tagInput name="removeTags" label="Remove Tags"}}
        {{else}}
            {{tagInput tags=preset.tags name="tags"}}
        {{/if}}
        </div>

    </section>
    
    <br>
    
    <footer class="sheet-footer flexrow">
        <button type="submit" data-action="apply"><i class="fas fa-check"></i> {{localize "MassEdit.common.apply"}}</button>
    </footer>
</form>
