@php
    $field = 'dim' . $dimension->slot . '_id';
    $selectedId = isset($line) && $line ? ($line->{$field} ?? '') : old("lines.$i.$field", '');
@endphp
<td class="d-none d-lg-table-cell voucher-dimension-cell" style="vertical-align:middle;min-width:150px">
    <div class="voucher-dimension-picker" data-slot="{{ $dimension->slot }}">
        <input type="hidden"
               name="lines[{{ $i }}][{{ $field }}]"
               value="{{ $selectedId }}"
               class="voucher-dimension-input">
        <button type="button" class="form-select form-select-sm voucher-dimension-picker-toggle text-start">
            <span class="voucher-dimension-picker-label">— Select —</span>
        </button>
        <div class="voucher-dimension-picker-menu d-none">
            <div class="voucher-dimension-picker-search">
                <i class="bi bi-search"></i>
                <input type="search" class="form-control form-control-sm voucher-dimension-picker-search-input" placeholder="Search..." autocomplete="off">
            </div>
            <div class="voucher-dimension-picker-tree"></div>
            <div class="voucher-dimension-picker-empty d-none">No matching values</div>
            <div class="voucher-dimension-picker-actions">
                <button type="button" class="btn btn-link btn-sm p-0 voucher-dimension-picker-clear">Clear</button>
            </div>
        </div>
    </div>
</td>
