{"version":3,"file":"Shortcuts.DO0n3JBw.mjs","names":[],"sources":["https:/framerusercontent.com/modules/dKn09hyvkf1AQQBnNFhU/FvjyzcfnI1564Lsxf0Cv/Shortcuts.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import React from\"react\";export function withKeyboardShortcuts(Component){const handleKeyDown=event=>{// Don't capture input if the user is typing in an input field/textarea or a meta key is pressed\nif(event.target instanceof HTMLInputElement||event.target instanceof HTMLTextAreaElement){return;}if(event.shiftKey||event.ctrlKey||event.altKey||event.metaKey){return;}// Save pressed keys to session storage\nlet pressedKeys=JSON.parse(sessionStorage.getItem(\"pressedKeys\")||\"[]\");pressedKeys.push(event.key);if(pressedKeys.length>1)pressedKeys.shift();sessionStorage.setItem(\"pressedKeys\",JSON.stringify(pressedKeys));if(typeof window!==\"undefined\"){// Notify other components\nconst customEvent=new CustomEvent(\"pressedKeysChanged\",{detail:pressedKeys});window.dispatchEvent(customEvent);}};const handleBeforeUnload=()=>{sessionStorage.removeItem(\"pressedKeys\");};return props=>{if(typeof window!==\"undefined\"){React.useEffect(()=>{// Focus window on load\nwindow.focus();window.addEventListener(\"keydown\",handleKeyDown);window.addEventListener(\"beforeunload\",handleBeforeUnload);return()=>{window.removeEventListener(\"keydown\",handleKeyDown);window.removeEventListener(\"beforeunload\",handleBeforeUnload);};},[]);}return /*#__PURE__*/_jsx(Component,{...props});};}export function withShortcutTrigger(Component){const handlePressedKeysChanged=(event,key,containerRef)=>{const pressedKeys=event.detail;// Check if the last pressed key matches the shortcut\nif(pressedKeys[pressedKeys.length-1].toLowerCase()===key.toLowerCase()){event.preventDefault();setTimeout(()=>{if(containerRef.current){const button=containerRef.current.querySelector(\"button\");const link=containerRef.current.querySelector(\"a\");if(button){button.click();}else if(link){link.click();}else{console.error(`🦎 Error: The shortcut trigger element ${key} isn't working properly. Check the docs for help.`);}}else{console.error(`🦎 Error: The shortcut trigger element ${key} isn't working properly. Check the docs for help.`);}sessionStorage.removeItem(\"pressedKeys\");},0);}};return props=>{var _props_name;const regExp=/\\[(.*?)\\]/;let lizardKeyRegex=(_props_name=props.name)===null||_props_name===void 0?void 0:_props_name.match(regExp);let lizardKey=\"\";let lizardContainerRef=React.useRef(null);if(lizardKeyRegex){lizardKey=lizardKeyRegex[1];}else{console.error(`🦎 Error: Your shortcut trigger layer (${props.name}) is missing a key in its layer name.`);}if(typeof window!==\"undefined\"){React.useEffect(()=>{const handlePressedKeysEvent=event=>{const customEvent=event;handlePressedKeysChanged(customEvent,lizardKey,lizardContainerRef);};window.addEventListener(\"pressedKeysChanged\",handlePressedKeysEvent);},[]);}return /*#__PURE__*/_jsx(\"span\",{ref:lizardContainerRef,\"data-lizard-shortcuts-trigger\":lizardKey,children:/*#__PURE__*/_jsx(Component,{...props})});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withKeyboardShortcuts\":{\"type\":\"reactHoc\",\"name\":\"withKeyboardShortcuts\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withShortcutTrigger\":{\"type\":\"reactHoc\",\"name\":\"withShortcutTrigger\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Shortcuts.map"],"mappings":"gIAAoE,SAAgB,EAAsB,EAAU,CAAC,IAAM,EAAc,GAAO,CAC9C,GAA/F,EAAM,kBAAkB,kBAAkB,EAAM,kBAAkB,qBAAgC,EAAM,UAAU,EAAM,SAAS,EAAM,QAAQ,EAAM,QAAS,OACjK,IAAI,EAAY,KAAK,MAAM,eAAe,QAAQ,cAAc,EAAE,KAAK,CAA2I,GAA1I,EAAY,KAAK,EAAM,IAAI,CAAI,EAAY,OAAO,GAAE,EAAY,OAAO,CAAC,eAAe,QAAQ,cAAc,KAAK,UAAU,EAAY,CAAC,CAAW,IAAS,OAAY,CACjP,IAAM,EAAY,IAAI,YAAY,qBAAqB,CAAC,OAAO,EAAY,CAAC,CAAC,EAAO,cAAc,EAAY,GAAU,MAAuB,CAAC,eAAe,WAAW,cAAc,EAAG,MAAO,KAAkB,IAAS,QAAa,EAAM,eAChP,EAAO,OAAO,CAAC,EAAO,iBAAiB,UAAU,EAAc,CAAC,EAAO,iBAAiB,eAAe,EAAmB,KAAW,CAAC,EAAO,oBAAoB,UAAU,EAAc,CAAC,EAAO,oBAAoB,eAAe,EAAmB,GAAK,EAAE,CAAC,CAAsB,EAAK,EAAU,CAAC,GAAG,EAAM,CAAC,uBAJpQ,IAAyB"}