/*!
 * Built by Revolist OU ❤️
 */
'use strict';

var dimension_helpers = require('./dimension.helpers-B9HgANnM.js');

function isMetaKey(code) {
    const keys = [
        dimension_helpers.KeyCodesEnum.ARROW_DOWN,
        dimension_helpers.KeyCodesEnum.ARROW_UP,
        dimension_helpers.KeyCodesEnum.ARROW_LEFT,
        dimension_helpers.KeyCodesEnum.ARROW_RIGHT,
        dimension_helpers.KeyCodesEnum.HOME,
        dimension_helpers.KeyCodesEnum.END,
        dimension_helpers.KeyCodesEnum.DELETE,
        dimension_helpers.KeyCodesEnum.BACKSPACE,
        dimension_helpers.KeyCodesEnum.F1,
        dimension_helpers.KeyCodesEnum.F2,
        dimension_helpers.KeyCodesEnum.F3,
        dimension_helpers.KeyCodesEnum.F4,
        dimension_helpers.KeyCodesEnum.F5,
        dimension_helpers.KeyCodesEnum.F6,
        dimension_helpers.KeyCodesEnum.F7,
        dimension_helpers.KeyCodesEnum.F8,
        dimension_helpers.KeyCodesEnum.F9,
        dimension_helpers.KeyCodesEnum.F10,
        dimension_helpers.KeyCodesEnum.F11,
        dimension_helpers.KeyCodesEnum.F12,
        dimension_helpers.KeyCodesEnum.TAB,
        dimension_helpers.KeyCodesEnum.PAGE_DOWN,
        dimension_helpers.KeyCodesEnum.PAGE_UP,
        dimension_helpers.KeyCodesEnum.ENTER,
        dimension_helpers.KeyCodesEnum.ESCAPE,
        dimension_helpers.KeyCodesEnum.SHIFT,
        dimension_helpers.KeyCodesEnum.CAPS_LOCK,
        dimension_helpers.KeyCodesEnum.ALT,
    ];
    return keys.indexOf(code) !== -1;
}
// navigator.platform
function isCtrlKey(code, platform) {
    if (platform.includes(dimension_helpers.OsPlatform.mac)) {
        return [
            dimension_helpers.KeyCodesEnum.COMMAND_LEFT,
            dimension_helpers.KeyCodesEnum.COMMAND_RIGHT,
            dimension_helpers.KeyCodesEnum.COMMAND_FIREFOX,
        ].includes(code);
    }
    return code === dimension_helpers.KeyCodesEnum.CONTROL;
}
function isCtrlMetaKey(code) {
    return [
        dimension_helpers.KeyCodesEnum.CONTROL,
        dimension_helpers.KeyCodesEnum.COMMAND_LEFT,
        dimension_helpers.KeyCodesEnum.COMMAND_RIGHT,
        dimension_helpers.KeyCodesEnum.COMMAND_FIREFOX,
    ].includes(code);
}
function isClear(code) {
    return dimension_helpers.codesLetter.BACKSPACE === code || dimension_helpers.codesLetter.DELETE === code;
}
function isTab(code) {
    return dimension_helpers.codesLetter.TAB === code;
}
function isTabKeyValue(key) {
    return dimension_helpers.keyValues.TAB === key;
}
function isEnterKeyValue(key) {
    return dimension_helpers.keyValues.ENTER === key;
}
function isCut(event) {
    return ((event.ctrlKey && event.code === 'KeyX') || // Ctrl + X on Windows
        (event.metaKey && event.code === 'KeyX')); // Cmd + X on Mac
}
function isCopy(event) {
    return ((event.ctrlKey && event.code === 'KeyC') || // Ctrl + C on Windows
        (event.metaKey && event.code === 'KeyC')); // Cmd + C on Mac
}
function isPaste(event) {
    return ((event.ctrlKey && event.code === 'KeyV') || // Ctrl + V on Windows
        (event.metaKey && event.code === 'KeyV')); // Cmd + V on Mac
}
function isAll(event) {
    return ((event.ctrlKey && event.code === 'KeyA') || // Ctrl + A on Windows
        (event.metaKey && event.code === 'KeyA')); // Cmd + A on Mac
}
/**
 * Returns true when a keyboard event represents a shortcut modifier that
 * should not start cell editing from printable `event.key` input.
 *
 * AltGr is intentionally excluded because many Windows/Linux layouts expose
 * printable AltGr characters as Ctrl+Alt key events.
 */
function isShortcutModifier(event) {
    var _a;
    if ((_a = event.getModifierState) === null || _a === void 0 ? void 0 : _a.call(event, 'AltGraph')) {
        return false;
    }
    if (event.ctrlKey &&
        event.altKey &&
        !event.metaKey &&
        event.key.length === 1) {
        return false;
    }
    return event.ctrlKey || event.metaKey;
}

// is edit input
function isEditInput(el) {
    return !!(el === null || el === void 0 ? void 0 : el.closest(`.${dimension_helpers.EDIT_INPUT_WR}`));
}
// Type guard for EditorCtrConstructible
function isEditorCtrConstructible(editor) {
    return typeof editor === 'function' && typeof editor.prototype === 'object';
}

exports.isAll = isAll;
exports.isClear = isClear;
exports.isCopy = isCopy;
exports.isCtrlKey = isCtrlKey;
exports.isCtrlMetaKey = isCtrlMetaKey;
exports.isCut = isCut;
exports.isEditInput = isEditInput;
exports.isEditorCtrConstructible = isEditorCtrConstructible;
exports.isEnterKeyValue = isEnterKeyValue;
exports.isMetaKey = isMetaKey;
exports.isPaste = isPaste;
exports.isShortcutModifier = isShortcutModifier;
exports.isTab = isTab;
exports.isTabKeyValue = isTabKeyValue;
