(()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ShortcutProvider:()=>O,__unstableUseShortcutEventMatch:()=>g,store:()=>b,useShortcut:()=>E});var o={};e.r(o),e.d(o,{registerShortcut:()=>i,unregisterShortcut:()=>c});var r={};e.r(r),e.d(r,{getAllShortcutKeyCombinations:()=>m,getAllShortcutRawKeyCombinations:()=>w,getCategoryShortcuts:()=>p,getShortcutAliases:()=>f,getShortcutDescription:()=>S,getShortcutKeyCombination:()=>l,getShortcutRepresentation:()=>y});const n=window.wp.data;function i({name:e,category:t,description:o,keyCombination:r,aliases:n}){return{type:"REGISTER_SHORTCUT",name:e,category:t,keyCombination:r,aliases:n,description:o}}function c(e){return{type:"UNREGISTER_SHORTCUT",name:e}}const a=window.wp.keycodes,s=[],u={display:a.displayShortcut,raw:a.rawShortcut,ariaLabel:a.shortcutAriaLabel};function d(e,t){return e?e.modifier?u[t][e.modifier](e.character):e.character:null}function l(e,t){return e[t]?e[t].keyCombination:null}function y(e,t,o="display"){return d(l(e,t),o)}function S(e,t){return e[t]?e[t].description:null}function f(e,t){return e[t]&&e[t].aliases?e[t].aliases:s}const m=(0,n.createSelector)((e,t)=>[l(e,t),...f(e,t)].filter(Boolean),(e,t)=>[e[t]]),w=(0,n.createSelector)((e,t)=>m(e,t).map(e=>d(e,"raw")),(e,t)=>[e[t]]),p=(0,n.createSelector)((e,t)=>Object.entries(e).filter(([,e])=>e.category===t).map(([e])=>e),e=>[e]),b=(0,n.createReduxStore)("core/keyboard-shortcuts",{reducer:function(e={},t){switch(t.type){case"REGISTER_SHORTCUT":return{...e,[t.name]:{category:t.category,keyCombination:t.keyCombination,aliases:t.aliases,description:t.description}};case"UNREGISTER_SHORTCUT":const{[t.name]:o,...r}=e;return r}return e},actions:o,selectors:r});(0,n.register)(b);const h=window.wp.element;function g(){const{getAllShortcutKeyCombinations:e}=(0,n.useSelect)(b);return function(t,o){return e(t).some(({modifier:e,character:t})=>a.isKeyboardEvent[e](o,t))}}const R=new Set,C=e=>{for(const t of R)t(e)},v=(0,h.createContext)({add:e=>{0===R.size&&document.addEventListener("keydown",C),R.add(e)},delete:e=>{R.delete(e),0===R.size&&document.removeEventListener("keydown",C)}});function E(e,t,{isDisabled:o=!1}={}){const r=(0,h.useContext)(v),n=g(),i=(0,h.useRef)();(0,h.useEffect)(()=>{i.current=t},[t]),(0,h.useEffect)(()=>{if(!o)return r.add(t),()=>{r.delete(t)};function t(t){n(e,t)&&i.current(t)}},[e,o,r])}v.displayName="KeyboardShortcutsContext";const T=window.ReactJSXRuntime,{Provider:k}=v;function O(e){const[t]=(0,h.useState)(()=>new Set);return(0,T.jsx)(k,{value:t,children:(0,T.jsx)("div",{...e,onKeyDown:function(o){e.onKeyDown&&e.onKeyDown(o);for(const e of t)e(o)}})})}(window.wp=window.wp||{}).keyboardShortcuts=t})();