"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "useKeyNavigation", {
    enumerable: true,
    get: function() {
        return useKeyNavigation;
    }
});
const useKeyNavigation = ({ isCalendarOpen, closeOnEsc, format, maskWithFormat, delimiter, onToggle })=>{
    const onKeyDown = (event)=>{
        if (event.key === delimiter && maskWithFormat && format) {
            event.preventDefault();
            return;
        }
        if (event.code === 'Space' && !isCalendarOpen) {
            event.preventDefault();
            onToggle(true, event);
        }
        if (event.code === 'Escape' && isCalendarOpen && closeOnEsc) {
            event.preventDefault();
            onToggle(false, event);
        }
    };
    return {
        onKeyDown
    };
};
