{"version":3,"file":"hotkeys-3jZwLYx5.js","sources":["../../../node_modules/hotkeys-js/dist/hotkeys.esm.js","../../../node_modules/stimulus-use/dist/hotkeys.js"],"sourcesContent":["/**! \n * hotkeys-js v3.13.9 \n * A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies. \n * \n * Copyright (c) 2024 kenny wong \n * https://github.com/jaywcjlove/hotkeys-js.git \n * \n * @website: https://jaywcjlove.github.io/hotkeys-js\n \n * Licensed under the MIT license \n */\n\nconst isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false;\n\n// 绑定事件\nfunction addEvent(object, event, method, useCapture) {\n if (object.addEventListener) {\n object.addEventListener(event, method, useCapture);\n } else if (object.attachEvent) {\n object.attachEvent(\"on\".concat(event), method);\n }\n}\nfunction removeEvent(object, event, method, useCapture) {\n if (object.removeEventListener) {\n object.removeEventListener(event, method, useCapture);\n } else if (object.detachEvent) {\n object.detachEvent(\"on\".concat(event), method);\n }\n}\n\n// 修饰键转换成对应的键码\nfunction getMods(modifier, key) {\n const mods = key.slice(0, key.length - 1);\n for (let i = 0; i < mods.length; i++) mods[i] = modifier[mods[i].toLowerCase()];\n return mods;\n}\n\n// 处理传的key字符串转换成数组\nfunction getKeys(key) {\n if (typeof key !== 'string') key = '';\n key = key.replace(/\\s/g, ''); // 匹配任何空白字符,包括空格、制表符、换页符等等\n const keys = key.split(','); // 同时设置多个快捷键,以','分割\n let index = keys.lastIndexOf('');\n\n // 快捷键可能包含',',需特殊处理\n for (; index >= 0;) {\n keys[index - 1] += ',';\n keys.splice(index, 1);\n index = keys.lastIndexOf('');\n }\n return keys;\n}\n\n// 比较修饰键的数组\nfunction compareArray(a1, a2) {\n const arr1 = a1.length >= a2.length ? a1 : a2;\n const arr2 = a1.length >= a2.length ? a2 : a1;\n let isIndex = true;\n for (let i = 0; i < arr1.length; i++) {\n if (arr2.indexOf(arr1[i]) === -1) isIndex = false;\n }\n return isIndex;\n}\n\n// Special Keys\nconst _keyMap = {\n backspace: 8,\n '⌫': 8,\n tab: 9,\n clear: 12,\n enter: 13,\n '↩': 13,\n return: 13,\n esc: 27,\n escape: 27,\n space: 32,\n left: 37,\n up: 38,\n right: 39,\n down: 40,\n del: 46,\n delete: 46,\n ins: 45,\n insert: 45,\n home: 36,\n end: 35,\n pageup: 33,\n pagedown: 34,\n capslock: 20,\n num_0: 96,\n num_1: 97,\n num_2: 98,\n num_3: 99,\n num_4: 100,\n num_5: 101,\n num_6: 102,\n num_7: 103,\n num_8: 104,\n num_9: 105,\n num_multiply: 106,\n num_add: 107,\n num_enter: 108,\n num_subtract: 109,\n num_decimal: 110,\n num_divide: 111,\n '⇪': 20,\n ',': 188,\n '.': 190,\n '/': 191,\n '`': 192,\n '-': isff ? 173 : 189,\n '=': isff ? 61 : 187,\n ';': isff ? 59 : 186,\n '\\'': 222,\n '[': 219,\n ']': 221,\n '\\\\': 220\n};\n\n// Modifier Keys\nconst _modifier = {\n // shiftKey\n '⇧': 16,\n shift: 16,\n // altKey\n '⌥': 18,\n alt: 18,\n option: 18,\n // ctrlKey\n '⌃': 17,\n ctrl: 17,\n control: 17,\n // metaKey\n '⌘': 91,\n cmd: 91,\n command: 91\n};\nconst modifierMap = {\n 16: 'shiftKey',\n 18: 'altKey',\n 17: 'ctrlKey',\n 91: 'metaKey',\n shiftKey: 16,\n ctrlKey: 17,\n altKey: 18,\n metaKey: 91\n};\nconst _mods = {\n 16: false,\n 18: false,\n 17: false,\n 91: false\n};\nconst _handlers = {};\n\n// F1~F12 special key\nfor (let k = 1; k < 20; k++) {\n _keyMap[\"f\".concat(k)] = 111 + k;\n}\n\nlet _downKeys = []; // 记录摁下的绑定键\nlet winListendFocus = null; // window是否已经监听了focus事件\nlet _scope = 'all'; // 默认热键范围\nconst elementEventMap = new Map(); // 已绑定事件的节点记录\n\n// 返回键码\nconst code = x => _keyMap[x.toLowerCase()] || _modifier[x.toLowerCase()] || x.toUpperCase().charCodeAt(0);\nconst getKey = x => Object.keys(_keyMap).find(k => _keyMap[k] === x);\nconst getModifier = x => Object.keys(_modifier).find(k => _modifier[k] === x);\n\n// 设置获取当前范围(默认为'所有')\nfunction setScope(scope) {\n _scope = scope || 'all';\n}\n// 获取当前范围\nfunction getScope() {\n return _scope || 'all';\n}\n// 获取摁下绑定键的键值\nfunction getPressedKeyCodes() {\n return _downKeys.slice(0);\n}\nfunction getPressedKeyString() {\n return _downKeys.map(c => getKey(c) || getModifier(c) || String.fromCharCode(c));\n}\nfunction getAllKeyCodes() {\n const result = [];\n Object.keys(_handlers).forEach(k => {\n _handlers[k].forEach(_ref => {\n let {\n key,\n scope,\n mods,\n shortcut\n } = _ref;\n result.push({\n scope,\n shortcut,\n mods,\n keys: key.split('+').map(v => code(v))\n });\n });\n });\n return result;\n}\n\n// 表单控件控件判断 返回 Boolean\n// hotkey is effective only when filter return true\nfunction filter(event) {\n const target = event.target || event.srcElement;\n const {\n tagName\n } = target;\n let flag = true;\n const isInput = tagName === 'INPUT' && !['checkbox', 'radio', 'range', 'button', 'file', 'reset', 'submit', 'color'].includes(target.type);\n // ignore: isContentEditable === 'true', and