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nC,CAAExB,GAAQ,UACV,CAAED,GAAOyB,EAAU,SAAW;;AAE9B,KAAKW,EAAAA,EAAAA,IAAI;;AAET,KAAKA,EAAAA,EAAAA,IAAI;;AAET,KAAKA,EAAAA,EAAAA,IAAI,aAGV,MAAO,IAAKhB,EAAUb,GAAYc,GAChCgB,KAAOzE,IAASoE,EAAAA,EAAAA,aAAY/D,EAAAA,EAAAA,KAAKyD,EAAmB9D,EAAKA,MACzD2D,KAAME,EAAU,IAAM,UAY1B,SAASa,EAAmBC,GAC3B,MAAyC,CACxCvC,EACAC,EACAC,EACAC,GACGqC,QACD5E,GACD2E,EACiE,GAAG3E,UAmBhE,MAAM6E,GAAkBtB,EAAAA,EAAAA,WAAWd,GAAaqC,GACtD,SACCH,EACAlB,GAEI,IADJd,EACI,uDADO5B,EAEX,MAAMgE,EAAOD,EAAcnC,GACrBqC,EAAYN,EAAmBC,GAErC,IAAKM,EAAAA,EAAAA,KAAKF,EAAMC,GAAYE,OAC3B,OAAO,EAGR,IAAIlF,EAAM2E,EAAM3E,IAAI0D,cAEpB,OAAOD,GAIFkB,EAAMQ,QAA+B,IAArB1B,EAAUyB,SAC9BlF,EAAMoF,OAAOC,aAAcV,EAAMW,SAAU5B,eAIzB,QAAdD,IACJA,EAAY,UAGNzD,IAAQyD,EAAUC,gBAZjBtC,EAAAA,EAAAA,UAAU2D,EAAM/E,O","sources":["webpack://wp/webpack/bootstrap","webpack://wp/webpack/runtime/define property getters","webpack://wp/webpack/runtime/hasOwnProperty shorthand","webpack://wp/webpack/runtime/make namespace object","webpack://wp/external window \"lodash\"","webpack://wp/external window [\"wp\",\"i18n\"]","webpack://wp/./packages/keycodes/build-module/@wordpress/keycodes/src/platform.js","webpack://wp/./packages/keycodes/build-module/@wordpress/keycodes/src/index.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var __WEBPACK_NAMESPACE_OBJECT__ = window[\"lodash\"];","var __WEBPACK_NAMESPACE_OBJECT__ = window[\"wp\"][\"i18n\"];","/**\n * External dependencies\n */\nimport { includes } from 'lodash';\n\n/**\n * Return true if platform is MacOS.\n *\n * @param {Window?} _window window object by default; used for DI testing.\n *\n * @return {boolean} True if MacOS; false otherwise.\n */\nexport function isAppleOS( _window = null ) {\n\tif ( ! _window ) {\n\t\tif ( typeof window === 'undefined' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t_window = window;\n\t}\n\n\tconst { platform } = _window.navigator;\n\n\treturn (\n\t\tplatform.indexOf( 'Mac' ) !== -1 ||\n\t\tincludes( [ 'iPad', 'iPhone' ], platform )\n\t);\n}\n","/**\n * Note: The order of the modifier keys in many of the [foo]Shortcut()\n * functions in this file are intentional and should not be changed. They're\n * designed to fit with the standard menu keyboard shortcuts shown in the\n * user's platform.\n *\n * For example, on MacOS menu shortcuts will place Shift before Command, but\n * on Windows Control will usually come first. So don't provide your own\n * shortcut combos directly to keyboardShortcut().\n */\n\n/**\n * External dependencies\n */\nimport { get, mapValues, includes, capitalize, xor } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { isAppleOS } from './platform';\n\n/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */\n\n/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */\n\n/**\n * An object of handler functions for each of the possible modifier\n * combinations. A handler will return a value for a given key.\n *\n * @template T\n *\n * @typedef {Record} WPModifierHandler\n */\n\n/**\n * @template T\n *\n * @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler\n */\n/** @typedef {(event: KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */\n\n/**\n * Keycode for BACKSPACE key.\n */\nexport const BACKSPACE = 8;\n\n/**\n * Keycode for TAB key.\n */\nexport const TAB = 9;\n\n/**\n * Keycode for ENTER key.\n */\nexport const ENTER = 13;\n\n/**\n * Keycode for ESCAPE key.\n */\nexport const ESCAPE = 27;\n\n/**\n * Keycode for SPACE key.\n */\nexport const SPACE = 32;\n\n/**\n * Keycode for PAGEUP key.\n */\nexport const PAGEUP = 33;\n\n/**\n * Keycode for PAGEDOWN key.\n */\nexport const PAGEDOWN = 34;\n\n/**\n * Keycode for END key.\n */\nexport const END = 35;\n\n/**\n * Keycode for HOME key.\n */\nexport const HOME = 36;\n\n/**\n * Keycode for LEFT key.\n */\nexport const LEFT = 37;\n\n/**\n * Keycode for UP key.\n */\nexport const UP = 38;\n\n/**\n * Keycode for RIGHT key.\n */\nexport const RIGHT = 39;\n\n/**\n * Keycode for DOWN key.\n */\nexport const DOWN = 40;\n\n/**\n * Keycode for DELETE key.\n */\nexport const DELETE = 46;\n\n/**\n * Keycode for F10 key.\n */\nexport const F10 = 121;\n\n/**\n * Keycode for ALT key.\n */\nexport const ALT = 'alt';\n\n/**\n * Keycode for CTRL key.\n */\nexport const CTRL = 'ctrl';\n\n/**\n * Keycode for COMMAND/META key.\n */\nexport const COMMAND = 'meta';\n\n/**\n * Keycode for SHIFT key.\n */\nexport const SHIFT = 'shift';\n\n/**\n * Keycode for ZERO key.\n */\nexport const ZERO = 48;\n\n/**\n * Object that contains functions that return the available modifier\n * depending on platform.\n *\n * @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}\n */\nexport const modifiers = {\n\tprimary: ( _isApple ) => ( _isApple() ? [ COMMAND ] : [ CTRL ] ),\n\tprimaryShift: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, COMMAND ] : [ CTRL, SHIFT ],\n\tprimaryAlt: ( _isApple ) =>\n\t\t_isApple() ? [ ALT, COMMAND ] : [ CTRL, ALT ],\n\tsecondary: ( _isApple ) =>\n\t\t_isApple() ? [ SHIFT, ALT, COMMAND ] : [ CTRL, SHIFT, ALT ],\n\taccess: ( _isApple ) => ( _isApple() ? [ CTRL, ALT ] : [ SHIFT, ALT ] ),\n\tctrl: () => [ CTRL ],\n\talt: () => [ ALT ],\n\tctrlShift: () => [ CTRL, SHIFT ],\n\tshift: () => [ SHIFT ],\n\tshiftAlt: () => [ SHIFT, ALT ],\n\tundefined: () => [],\n};\n\n/**\n * An object that contains functions to get raw shortcuts.\n *\n * These are intended for user with the KeyboardShortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * rawShortcut.primary( 'm' )\n * // \"meta+m\"\"\n * ```\n *\n * @type {WPModifierHandler>} Keyed map of functions to raw\n * shortcuts.\n */\nexport const rawShortcut = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\treturn [ ...modifier( _isApple ), character.toLowerCase() ].join( '+' );\n\t};\n} );\n\n/**\n * Return an array of the parts of a keyboard shortcut chord for display.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcutList.primary( 'm' );\n * // [ \"⌘\", \"M\" ]\n * ```\n *\n * @type {WPModifierHandler>} Keyed map of functions to\n * shortcut sequences.\n */\nexport const displayShortcutList = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ ALT ]: isApple ? '⌥' : 'Alt',\n\t\t\t[ CTRL ]: isApple ? '⌃' : 'Ctrl', // Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.\n\t\t\t[ COMMAND ]: '⌘',\n\t\t\t[ SHIFT ]: isApple ? '⇧' : 'Shift',\n\t\t};\n\n\t\tconst modifierKeys = modifier( _isApple ).reduce(\n\t\t\t( accumulator, key ) => {\n\t\t\t\tconst replacementKey = get( replacementKeyMap, key, key );\n\t\t\t\t// If on the Mac, adhere to platform convention and don't show plus between keys.\n\t\t\t\tif ( isApple ) {\n\t\t\t\t\treturn [ ...accumulator, replacementKey ];\n\t\t\t\t}\n\n\t\t\t\treturn [ ...accumulator, replacementKey, '+' ];\n\t\t\t},\n\t\t\t/** @type {string[]} */ ( [] )\n\t\t);\n\n\t\tconst capitalizedCharacter = capitalize( character );\n\t\treturn [ ...modifierKeys, capitalizedCharacter ];\n\t};\n} );\n\n/**\n * An object that contains functions to display shortcuts.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * displayShortcut.primary( 'm' );\n * // \"⌘M\"\n * ```\n *\n * @type {WPModifierHandler>} Keyed map of functions to\n * display shortcuts.\n */\nexport const displayShortcut = mapValues(\n\tdisplayShortcutList,\n\t( shortcutList ) => {\n\t\treturn /** @type {WPKeyHandler} */ (\n\t\t\tcharacter,\n\t\t\t_isApple = isAppleOS\n\t\t) => shortcutList( character, _isApple ).join( '' );\n\t}\n);\n\n/**\n * An object that contains functions to return an aria label for a keyboard\n * shortcut.\n *\n * @example\n * ```js\n * // Assuming macOS:\n * shortcutAriaLabel.primary( '.' );\n * // \"Command + Period\"\n * ```\n *\n * @type {WPModifierHandler>} Keyed map of functions to\n * shortcut ARIA labels.\n */\nexport const shortcutAriaLabel = mapValues( modifiers, ( modifier ) => {\n\treturn /** @type {WPKeyHandler} */ (\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst isApple = _isApple();\n\t\tconst replacementKeyMap = {\n\t\t\t[ SHIFT ]: 'Shift',\n\t\t\t[ COMMAND ]: isApple ? 'Command' : 'Control',\n\t\t\t[ CTRL ]: 'Control',\n\t\t\t[ ALT ]: isApple ? 'Option' : 'Alt',\n\t\t\t/* translators: comma as in the character ',' */\n\t\t\t',': __( 'Comma' ),\n\t\t\t/* translators: period as in the character '.' */\n\t\t\t'.': __( 'Period' ),\n\t\t\t/* translators: backtick as in the character '`' */\n\t\t\t'`': __( 'Backtick' ),\n\t\t};\n\n\t\treturn [ ...modifier( _isApple ), character ]\n\t\t\t.map( ( key ) => capitalize( get( replacementKeyMap, key, key ) ) )\n\t\t\t.join( isApple ? ' ' : ' + ' );\n\t};\n} );\n\n/**\n * From a given KeyboardEvent, returns an array of active modifier constants for\n * the event.\n *\n * @param {KeyboardEvent} event Keyboard event.\n *\n * @return {Array} Active modifier constants.\n */\nfunction getEventModifiers( event ) {\n\treturn /** @type {WPModifierPart[]} */ ( [\n\t\tALT,\n\t\tCTRL,\n\t\tCOMMAND,\n\t\tSHIFT,\n\t] ).filter(\n\t\t( key ) =>\n\t\t\tevent[\n\t\t\t\t/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */ ( `${ key }Key` )\n\t\t\t]\n\t);\n}\n\n/**\n * An object that contains functions to check if a keyboard event matches a\n * predefined shortcut combination.\n *\n * @example\n * ```js\n * // Assuming an event for ⌘M key press:\n * isKeyboardEvent.primary( event, 'm' );\n * // true\n * ```\n *\n * @type {WPModifierHandler} Keyed map of functions\n * to match events.\n */\nexport const isKeyboardEvent = mapValues( modifiers, ( getModifiers ) => {\n\treturn /** @type {WPEventKeyHandler} */ (\n\t\tevent,\n\t\tcharacter,\n\t\t_isApple = isAppleOS\n\t) => {\n\t\tconst mods = getModifiers( _isApple );\n\t\tconst eventMods = getEventModifiers( event );\n\n\t\tif ( xor( mods, eventMods ).length ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet key = event.key.toLowerCase();\n\n\t\tif ( ! character ) {\n\t\t\treturn includes( mods, key );\n\t\t}\n\n\t\tif ( event.altKey && character.length === 1 ) {\n\t\t\tkey = String.fromCharCode( event.keyCode ).toLowerCase();\n\t\t}\n\n\t\t// For backwards compatibility.\n\t\tif ( character === 'del' ) {\n\t\t\tcharacter = 'delete';\n\t\t}\n\n\t\treturn key === character.toLowerCase();\n\t};\n} );\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","window","isAppleOS","_window","platform","navigator","indexOf","includes","BACKSPACE","TAB","ENTER","ESCAPE","SPACE","PAGEUP","PAGEDOWN","END","HOME","LEFT","UP","RIGHT","DOWN","DELETE","F10","ALT","CTRL","COMMAND","SHIFT","ZERO","modifiers","primary","_isApple","primaryShift","primaryAlt","secondary","access","ctrl","alt","ctrlShift","shift","shiftAlt","undefined","rawShortcut","mapValues","modifier","character","toLowerCase","join","displayShortcutList","isApple","replacementKeyMap","modifierKeys","reduce","accumulator","replacementKey","capitalizedCharacter","capitalize","displayShortcut","shortcutList","shortcutAriaLabel","__","map","getEventModifiers","event","filter","isKeyboardEvent","getModifiers","mods","eventMods","xor","length","altKey","String","fromCharCode","keyCode"],"sourceRoot":""}