/**
 * Sortable pending field list with drag and drop reordering
 */
'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, } from '@dnd-kit/core';
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, } from '@dnd-kit/sortable';
import { PendingFieldItem } from './pending_field_item.js';
/**
 * PendingFieldList - DndContext wrapper for sortable pending fields
 */
export function PendingFieldList({ items, available_types, on_reorder, on_type_change, on_remove, on_toggle_expand, on_required_change, on_accept_files_change, on_options_change, on_date_config_change, on_checkbox_config_change, on_file_textbox_config_change, combobox_components, file_textbox_hide_classification, file_textbox_hide_tags, }) {
    const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 8 } }), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
    const handle_drag_end = (event) => {
        const { active, over } = event;
        if (!over || active.id === over.id)
            return;
        const old_index = items.findIndex(item => item.id === active.id);
        const new_index = items.findIndex(item => item.id === over.id);
        if (old_index === -1 || new_index === -1)
            return;
        const new_items = arrayMove(items, old_index, new_index);
        on_reorder(new_items);
    };
    if (items.length === 0) {
        return (_jsx("div", { className: "flex items-center justify-center h-24 text-muted-foreground text-sm border border-dashed rounded-md", children: "No fields added yet. Enter a question above." }));
    }
    return (_jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handle_drag_end, children: _jsx(SortableContext, { items: items.map(i => i.id), strategy: verticalListSortingStrategy, children: _jsx("div", { className: "space-y-2 max-h-[45vh] overflow-y-auto pr-1", children: items.map(item => (_jsx(PendingFieldItem, { item: item, available_types: available_types, on_type_change: on_type_change, on_remove: on_remove, on_toggle_expand: on_toggle_expand, on_required_change: on_required_change, on_accept_files_change: on_accept_files_change, on_options_change: on_options_change, on_date_config_change: on_date_config_change, on_checkbox_config_change: on_checkbox_config_change, on_file_textbox_config_change: on_file_textbox_config_change, combobox_components: combobox_components, file_textbox_hide_classification: file_textbox_hide_classification, file_textbox_hide_tags: file_textbox_hide_tags }, item.id))) }) }) }));
}
//# sourceMappingURL=pending_field_list.js.map