"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get keys () {
        return keys;
    },
    get useKeyNavigation () {
        return useKeyNavigation;
    }
});
const keys = {
    Space: 'Space',
    Escape: 'Escape'
};
const useKeyNavigation = ({ opened, closeOnEsc, onToggle })=>{
    const onKeyDown = (event)=>{
        switch(event.code){
            case keys.Space:
                {
                    if (!opened) {
                        event.preventDefault();
                        onToggle(true, event);
                    }
                    break;
                }
            case keys.Escape:
                {
                    if (opened && closeOnEsc) {
                        event.preventDefault();
                        onToggle(false, event);
                    }
                    break;
                }
            default:
                {
                    break;
                }
        }
    };
    return {
        onKeyDown
    };
};
