<ng-container *transloco="let t; read: 'draggable-ordered-list'">

    <ng-container *ngIf="items.length > 100; else dragList">
        <div class="example-list list-group-flush">
            <virtual-scroller #scroll [items]="items" [bufferAmount]="BufferAmount" [parentScroll]="parentScroll">
                <div class="example-box" *ngFor="let item of scroll.viewPortItems; index as i; trackBy: trackByIdentity">
                    <div class="d-flex list-container">
                        <div class="me-3 align-middle">
                            <div style="padding-top: 40px">
                                <label for="reorder-{{item.order}}" class="form-label visually-hidden">{{t('reorder-label')}}</label>
                                <input *ngIf="accessibilityMode" id="reorder-{{i}}" class="form-control" type="number" inputmode="numeric" min="0" [max]="items.length - 1" [value]="item.order" style="width: 60px"
                                (focusout)="updateIndex(item.order, item)" (keydown.enter)="updateIndex(item.order, item)" aria-describedby="instructions">
                            </div>
                        </div>

                        <ng-container [ngTemplateOutlet]="itemTemplate" [ngTemplateOutletContext]="{ $implicit: item, idx: i }"></ng-container>

                        <button class="btn btn-icon float-end" (click)="removeItem(item, i)" *ngIf="showRemoveButton">
                            <i class="fa fa-times" aria-hidden="true"></i>
                            <span class="visually-hidden" attr.aria-labelledby="item.id--{{i}}">{{t('remove-item-alt')}}</span>
                        </button>
                    </div>
                </div>
            </virtual-scroller>
        </div>
    </ng-container>
    <ng-template #dragList>
        <div cdkDropList class="{{items.length > 0 ? 'example-list list-group-flush' : ''}}" (cdkDropListDropped)="drop($event)">
            <div class="example-box" *ngFor="let item of items; index as i" cdkDrag [cdkDragData]="item" cdkDragBoundary=".example-list">
                <div class="d-flex list-container">
                    <div class="me-3 align-middle">
                        <div class="align-middle" style="padding-top: 40px" *ngIf="accessibilityMode">
                            <label for="reorder-{{i}}" class="form-label visually-hidden">{{t('reorder-label')}}</label>
                            <input id="reorder-{{i}}" class="form-control" type="number" inputmode="numeric" min="0" [max]="items.length - 1" [value]="i" style="width: 60px"
                            (focusout)="updateIndex(i, item)" (keydown.enter)="updateIndex(i, item)" aria-describedby="instructions">
                        </div>
                        <i *ngIf="!accessibilityMode" class="fa fa-grip-vertical drag-handle" aria-hidden="true" cdkDragHandle></i>
                    </div>

                    <ng-container [ngTemplateOutlet]="itemTemplate" [ngTemplateOutletContext]="{ $implicit: item, idx: i }"></ng-container>

                    <button class="btn btn-icon float-end" (click)="removeItem(item, i)" *ngIf="showRemoveButton">
                        <i class="fa fa-times" aria-hidden="true"></i>
                        <span class="visually-hidden" attr.aria-labelledby="item.id--{{i}}">{{t('remove-item')}}</span>
                    </button>
                </div>
            </div>
        </div>
    </ng-template>



    <p class="visually-hidden" id="instructions">
        {{t('instructions-alt')}}
    </p>


</ng-container>
