import React, { useEffect } from 'react';
import { AutoScrollActivator, closestCenter, DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors, } from '@wix/wix-style-react-incubator/dnd-kit/core';
import { restrictToWindowEdges } from '@wix/wix-style-react-incubator/dnd-kit/modifiers';
import { observer } from 'mobx-react-lite';
import { usePageContext } from '@wix/bex-core/react';
function _KanbanDragAndDropContext(props) {
    const { state: kanbanState, children } = props;
    const { modalsContainerRef } = usePageContext();
    const dragAndDropState = kanbanState.dragAndDropState;
    const pointerSensor = useSensor(PointerSensor, {
        activationConstraint: {
            distance: 3,
        },
    });
    const keyboardSensor = useSensor(KeyboardSensor, {
        keyboardCodes: kanbanState.dragAndDropState.keyboardCodes,
        coordinateGetter: () => ({ x: 0, y: 25 }),
    });
    const sensors = useSensors(...(process.env.NODE_ENV === 'test' ? [] : [pointerSensor, keyboardSensor]));
    useEffect(() => dragAndDropState.init(), [dragAndDropState]);
    const handleDragStart = (event) => {
        dragAndDropState.handleDragStart(event);
    };
    const handleDragOver = () => { };
    const handleDragEnd = (event) => {
        dragAndDropState.handleDragEnd(event);
    };
    const handleDragCancel = () => {
        dragAndDropState.handleDragCancel();
    };
    return (React.createElement(DndContext, { sensors: sensors, autoScroll: {
            activator: AutoScrollActivator.DraggableRect,
            acceleration: 4,
            threshold: {
                y: 0.01,
                x: 0.2,
            },
        }, accessibility: {
            container: modalsContainerRef.current,
            announcements: {
                onDragStart: () => 'Item picked up for dragging',
                onDragOver: () => 'Item moved over droppable area',
                onDragEnd: () => 'Item dropped',
                onDragCancel: () => 'Dragging cancelled',
            },
            screenReaderInstructions: {
                draggable: 'To pick up a draggable item, press the space bar.',
            },
            restoreFocus: false,
        }, collisionDetection: closestCenter, modifiers: [restrictToWindowEdges], onDragStart: handleDragStart, onDragOver: handleDragOver, onDragEnd: handleDragEnd, onDragCancel: handleDragCancel }, children));
}
export const KanbanDragAndDropContext = observer(_KanbanDragAndDropContext);
//# sourceMappingURL=KanbanDragAndDropContext.js.map