"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "computeKeyPressData", {
    enumerable: true,
    get: function() {
        return computeKeyPressData;
    }
});
var KeyboardSupport = {
    PageUp: 33,
    PageDown: 34,
    End: 35,
    Home: 36,
    ArrowLeft: 37,
    ArrowUp: 38,
    ArrowRight: 39,
    ArrowDown: 40
};
var ArrowUp = KeyboardSupport.ArrowUp, ArrowRight = KeyboardSupport.ArrowRight, ArrowDown = KeyboardSupport.ArrowDown, ArrowLeft = KeyboardSupport.ArrowLeft, Home = KeyboardSupport.Home, End = KeyboardSupport.End, PageDown = KeyboardSupport.PageDown, PageUp = KeyboardSupport.PageUp;
var computeVerticalMovement = function computeVerticalMovement(event, param) {
    var stepSize = param.stepSize, position = param.position, max = param.max, computedMultipleSteps = param.computedMultipleSteps;
    var keyCode = event.keyCode, target = event.target;
    var data = {
        x: 0,
        deltaX: 0,
        lastX: 0,
        y: 0,
        deltaY: stepSize,
        lastY: position,
        node: target
    };
    switch(keyCode){
        case ArrowUp:
        case ArrowRight:
            data.y = position - stepSize;
            data.deltaY = -stepSize;
            break;
        case ArrowDown:
        case ArrowLeft:
            data.y = position + stepSize;
            break;
        case PageUp:
            data.y = position - computedMultipleSteps;
            data.deltaY = -computedMultipleSteps;
            break;
        case PageDown:
            data.y = position + computedMultipleSteps;
            data.deltaY = computedMultipleSteps;
            break;
        case End:
            data.y = max * stepSize;
            break;
        case Home:
            data.y = 0;
            break;
        default:
            data.y = 0;
    }
    return data;
};
var computeHorizontalMovement = function computeHorizontalMovement(event, param) {
    var stepSize = param.stepSize, position = param.position, max = param.max, computedMultipleSteps = param.computedMultipleSteps;
    var keyCode = event.keyCode, target = event.target;
    var data = {
        x: 0,
        deltaX: stepSize,
        lastX: position,
        y: 0,
        deltaY: 0,
        lastY: 0,
        node: target
    };
    switch(keyCode){
        case ArrowUp:
        case ArrowRight:
            data.x = position + stepSize;
            break;
        case ArrowDown:
        case ArrowLeft:
            data.x = position - stepSize;
            data.deltaX = -stepSize;
            break;
        case PageUp:
            data.x = position + computedMultipleSteps;
            data.deltaX = computedMultipleSteps;
            break;
        case PageDown:
            data.x = position - computedMultipleSteps;
            data.deltaX = -computedMultipleSteps;
            break;
        case End:
            data.x = max * stepSize;
            break;
        case Home:
            data.x = 0;
            break;
        default:
            data.x = 0;
    }
    return data;
};
var computeKeyPressData = function computeKeyPressData(event, params) {
    var keyCode = event.keyCode;
    if (!Object.values(KeyboardSupport).includes(keyCode)) {
        return null;
    }
    return params.isVertical ? computeVerticalMovement(event, params) : computeHorizontalMovement(event, params);
};
