"use strict";exports.__esModule = true;exports.someKeys = exports.isUnmodified = exports.isShortcutSelectAll = exports.isShortcutPaste = exports.isShortcutJumpCaret = exports.isShortcutCut = exports.isShortcutCopy = exports.isModified = exports.isModShift = exports.isModCtrl = exports.isModAlt = exports.isKeyTab = exports.isKeySpace = exports.isKeyShift = exports.isKeyNumber = exports.isKeyMeta = exports.isKeyInsert = exports.isKeyHome = exports.isKeyFs = exports.isKeyEscape = exports.isKeyEnter = exports.isKeyEnd = exports.isKeyDelete = exports.isKeyControl = exports.isKeyComma = exports.isKeyChar = exports.isKeyCapsLock = exports.isKeyBackspace = exports.isKeyArrowVertical = exports.isKeyArrowUp = exports.isKeyArrowRight = exports.isKeyArrowLeft = exports.isKeyArrowHorizontal = exports.isKeyArrowDown = exports.isKeyArrow = exports.isKeyAlt = exports.isCodeSlash = exports.isCodePeriod = exports.isCodeNumpadSubtract = exports.isCodeNumpadDivide = exports.isCodeNumpadDecimal = exports.isCodeMinus = exports.isCodeIntlBackslash = exports.isCodeComma = exports.isCodeBackslash = void 0;var _globalObject = require("@skbkontur/global-object");

var _client = require("../../client");
var _isInstanceOf = require("../../isInstanceOf");

var _extractCode = require("./extractCode");
var _KeyboardEventCodes = require("./KeyboardEventCodes");






// IE 9+ supports char attribute
// https://developer.mozilla.org/ru/docs/Web/API/KeyboardEvent
var getChar = function getChar(e) {var _e$nativeEvent;return (
    (0, _isInstanceOf.isInstanceOf)(e, _globalObject.globalObject.KeyboardEvent) ? e.char : (_e$nativeEvent = e.nativeEvent) == null ? void 0 : _e$nativeEvent.char);};

var isShortcutCopy = exports.isShortcutCopy = function isShortcutCopy(e) {return (
    (_client.isMac ? e.metaKey : e.ctrlKey) && (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.KeyC ||
    !_client.isMac && e.ctrlKey && isKeyInsert(e) ||
    e.key === 'Copy');};

var isShortcutPaste = exports.isShortcutPaste = function isShortcutPaste(e) {return (
    (_client.isMac ? e.metaKey : e.ctrlKey) && (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.KeyV ||
    !_client.isMac && e.shiftKey && isKeyInsert(e) ||
    e.key === 'Paste');};

var isShortcutCut = exports.isShortcutCut = function isShortcutCut(e) {return (
    (_client.isMac ? e.metaKey : e.ctrlKey) && (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.KeyX ||
    !_client.isMac && e.shiftKey && isKeyDelete(e) ||
    e.key === 'Cut');};

var isShortcutSelectAll = exports.isShortcutSelectAll = function isShortcutSelectAll(e) {return (_client.isMac ? e.metaKey : e.ctrlKey) && (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.KeyA;};

var isShortcutJumpCaret = exports.isShortcutJumpCaret = function isShortcutJumpCaret(e) {return (_client.isMac ? e.altKey : e.ctrlKey) && isKeyArrowHorizontal(e);};

var isKeyEscape = exports.isKeyEscape = function isKeyEscape(e) {return e.key === 'Escape' || e.key === 'Esc';};
var isKeyHome = exports.isKeyHome = function isKeyHome(e) {return e.key === 'Home';};
var isKeyEnd = exports.isKeyEnd = function isKeyEnd(e) {return e.key === 'End';};
var isKeyMeta = exports.isKeyMeta = function isKeyMeta(e) {return e.key === 'Meta' || e.key === 'Win';};
var isKeyControl = exports.isKeyControl = function isKeyControl(e) {return e.key === 'Control';};
var isKeyShift = exports.isKeyShift = function isKeyShift(e) {return e.key === 'Shift';};
var isKeyAlt = exports.isKeyAlt = function isKeyAlt(e) {return e.key === 'Alt';};
var isKeyDelete = exports.isKeyDelete = function isKeyDelete(e) {return e.key === 'Delete' || e.key === 'Del';};
var isKeyBackspace = exports.isKeyBackspace = function isKeyBackspace(e) {return e.key === 'Backspace';};
var isKeyCapsLock = exports.isKeyCapsLock = function isKeyCapsLock(e) {return e.key === 'CapsLock';};
var isKeyInsert = exports.isKeyInsert = function isKeyInsert(e) {return e.key === 'Insert';};
var isKeyTab = exports.isKeyTab = function isKeyTab(e) {return e.key === 'Tab';};
var isKeyEnter = exports.isKeyEnter = function isKeyEnter(e) {return e.key === 'Enter';};
var isKeyArrowUp = exports.isKeyArrowUp = function isKeyArrowUp(e) {return e.key === 'ArrowUp' || e.key === 'Up';};
var isKeyArrowRight = exports.isKeyArrowRight = function isKeyArrowRight(e) {return e.key === 'ArrowRight' || e.key === 'Right';};
var isKeyArrowDown = exports.isKeyArrowDown = function isKeyArrowDown(e) {return e.key === 'ArrowDown' || e.key === 'Down';};
var isKeyArrowLeft = exports.isKeyArrowLeft = function isKeyArrowLeft(e) {return e.key === 'ArrowLeft' || e.key === 'Left';};
var isKeySpace = exports.isKeySpace = function isKeySpace(e) {return e.key === ' ' || e.key === 'Spacebar';};
var isKeyComma = exports.isKeyComma = function isKeyComma(e) {return e.key === ',' || getChar(e) === ',';};

var isCodeMinus = exports.isCodeMinus = function isCodeMinus(e) {return (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.Minus;};
var isCodeNumpadDecimal = exports.isCodeNumpadDecimal = function isCodeNumpadDecimal(e) {return (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.NumpadDecimal;};
var isCodeNumpadDivide = exports.isCodeNumpadDivide = function isCodeNumpadDivide(e) {return (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.NumpadDivide;};
var isCodeNumpadSubtract = exports.isCodeNumpadSubtract = function isCodeNumpadSubtract(e) {return (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.NumpadSubtract;};
var isCodeSlash = exports.isCodeSlash = function isCodeSlash(e) {return (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.Slash;};
var isCodeBackslash = exports.isCodeBackslash = function isCodeBackslash(e) {return (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.Backslash;};
var isCodeIntlBackslash = exports.isCodeIntlBackslash = function isCodeIntlBackslash(e) {return (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.IntlBackslash;};
var isCodeComma = exports.isCodeComma = function isCodeComma(e) {return (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.Comma;};
var isCodePeriod = exports.isCodePeriod = function isCodePeriod(e) {return (0, _extractCode.extractCode)(e) === _KeyboardEventCodes.KeyboardEventCodes.Period;};

var isKeyArrowHorizontal = exports.isKeyArrowHorizontal = function isKeyArrowHorizontal(e) {return isKeyArrowRight(e) || isKeyArrowLeft(e);};
var isKeyArrowVertical = exports.isKeyArrowVertical = function isKeyArrowVertical(e) {return isKeyArrowUp(e) || isKeyArrowDown(e);};
var isKeyArrow = exports.isKeyArrow = function isKeyArrow(e) {return isKeyArrowHorizontal(e) || isKeyArrowVertical(e);};
var isKeyNumber = exports.isKeyNumber = function isKeyNumber(e) {return /^\d+$/.test(e.key);};
var isKeyChar = exports.isKeyChar = function isKeyChar(e) {return e.key.trim().length === 1;};
var isKeyFs = exports.isKeyFs = function isKeyFs(e) {return /^(?:F[1-9]|F1[0-2]|Soft[1-4])$/.test(e.key);};

var isModified = exports.isModified = function isModified(is) {return function (e) {return (
      (e.shiftKey || e.metaKey || e.ctrlKey || e.altKey) && (is ? is(e) : true));};};
var isUnmodified = exports.isUnmodified = function isUnmodified(is) {return function (e) {return !isModified()(e) && (is ? is(e) : true);};};
var isModShift = exports.isModShift = function isModShift(is) {return function (e) {return e.shiftKey && (is ? is(e) : true);};};
var isModCtrl = exports.isModCtrl = function isModCtrl(is) {return function (e) {return e.ctrlKey && (is ? is(e) : true);};};
var isModAlt = exports.isModAlt = function isModAlt(is) {return function (e) {return e.altKey && (is ? is(e) : true);};};

var someKeys = exports.someKeys =
function someKeys() {for (var _len = arguments.length, iss = new Array(_len), _key = 0; _key < _len; _key++) {iss[_key] = arguments[_key];}return (
    function (e) {return (
        iss.some(function (is) {return is(e);}));});};