import{i as e,n as t}from"./rolldown-runtime-BKYq3fBv.js";import{Co as n,Do as r,Eo as i,So as a,To as o,at as s,ca as c,co as l,it as u,sa as d,so as f,wo as p}from"./dialogService-Cr3DyAja.js";var m,h=t((()=>{m=[{combo:{ctrl:!0,key:`Enter`},commandId:`Comfy.QueuePrompt`},{combo:{ctrl:!0,shift:!0,key:`Enter`},commandId:`Comfy.QueuePromptFront`},{combo:{ctrl:!0,alt:!0,key:`Enter`},commandId:`Comfy.Interrupt`},{combo:{key:`r`},commandId:`Comfy.RefreshNodeDefinitions`},{combo:{key:`w`},commandId:`Workspace.ToggleSidebarTab.workflows`},{combo:{key:`n`},commandId:`Workspace.ToggleSidebarTab.node-library`},{combo:{key:`m`},commandId:`Workspace.ToggleSidebarTab.model-library`},{combo:{key:`s`,ctrl:!0},commandId:`Comfy.SaveWorkflow`},{combo:{key:`o`,ctrl:!0},commandId:`Comfy.OpenWorkflow`},{combo:{key:`g`,ctrl:!0},commandId:`Comfy.Graph.GroupSelectedNodes`},{combo:{key:`,`,ctrl:!0},commandId:`Comfy.ShowSettingsDialog`},{combo:{key:`=`,alt:!0},commandId:`Comfy.Canvas.ZoomIn`,targetElementId:`graph-canvas`},{combo:{key:`+`,alt:!0,shift:!0},commandId:`Comfy.Canvas.ZoomIn`,targetElementId:`graph-canvas`},{combo:{key:`+`,alt:!0},commandId:`Comfy.Canvas.ZoomIn`,targetElementId:`graph-canvas`},{combo:{key:`-`,alt:!0},commandId:`Comfy.Canvas.ZoomOut`,targetElementId:`graph-canvas`},{combo:{key:`.`},commandId:`Comfy.Canvas.FitView`,targetElementId:`graph-canvas-container`},{combo:{key:`p`},commandId:`Comfy.Canvas.ToggleSelected.Pin`,targetElementId:`graph-canvas-container`},{combo:{key:`c`,alt:!0},commandId:`Comfy.Canvas.ToggleSelectedNodes.Collapse`,targetElementId:`graph-canvas-container`},{combo:{key:`b`,ctrl:!0},commandId:`Comfy.Canvas.ToggleSelectedNodes.Bypass`,targetElementId:`graph-canvas-container`},{combo:{key:`m`,ctrl:!0},commandId:`Comfy.Canvas.ToggleSelectedNodes.Mute`,targetElementId:`graph-canvas-container`},{combo:{key:"`",ctrl:!0},commandId:`Workspace.ToggleBottomPanelTab.logs-terminal`},{combo:{key:`e`,ctrl:!0,shift:!0},commandId:`Comfy.Graph.ConvertToSubgraph`},{combo:{key:`m`,alt:!0},commandId:`Comfy.Canvas.ToggleMinimap`},{combo:{ctrl:!0,shift:!0,key:`k`},commandId:`Workspace.ToggleBottomPanel.Shortcuts`},{combo:{key:`v`},commandId:`Comfy.Canvas.Unlock`},{combo:{key:`h`},commandId:`Comfy.Canvas.Lock`},{combo:{key:`Escape`},commandId:`Comfy.Graph.ExitSubgraph`}]})),useKeybindingService,g=t((()=>{h(),f(),s(),a(),d(),i(),useKeybindingService=()=>{let e=r(),t=n(),i=l(),a=c(),shouldForwardToCanvas=e=>e.ctrlKey||e.altKey||e.metaKey?!1:[`Delete`,`Backspace`].includes(e.key),keybindHandler=async function(n){let r=p.fromEvent(n);if(r.isModifier)return;let i=n.composedPath()[0];if(r.isReservedByTextInput&&(i.tagName===`TEXTAREA`||i.tagName===`INPUT`||i.contentEditable===`true`||i.tagName===`SPAN`&&i.classList.contains(`property_value`)))return;let o=e.getKeybinding(r);if(o&&o.targetElementId!==`graph-canvas`){if(n.key===`Escape`&&!n.ctrlKey&&!n.altKey&&!n.metaKey&&a.dialogStack.length>0)return;n.preventDefault(),new Set([`Comfy.QueuePrompt`,`Comfy.QueuePromptFront`,`Comfy.QueueSelectedOutputNodes`]).has(o.commandId)?await t.execute(o.commandId,{metadata:{trigger_source:`keybinding`}}):await t.execute(o.commandId);return}if(!o&&shouldForwardToCanvas(n)){let e=u.canvas;if(e&&e.processKey&&typeof e.processKey==`function`){e.processKey(n);return}}if(!(n.ctrlKey||n.altKey||n.metaKey)&&n.key===`Escape`){let e=document.querySelectorAll(`.comfy-modal`);for(let t of e)if(window.getComputedStyle(t).getPropertyValue(`display`)!==`none`){t.style.display=`none`;break}for(let e of document.querySelectorAll(`dialog`))e.close()}},registerCoreKeybindings=()=>{for(let t of m)e.addDefaultKeybinding(new o(t))};function registerUserKeybindings(){let t=i.get(`Comfy.Keybinding.UnsetBindings`);for(let n of t)e.unsetKeybinding(new o(n));let n=i.get(`Comfy.Keybinding.NewBindings`);for(let t of n)e.addUserKeybinding(new o(t))}async function persistUserKeybindings(){await i.set(`Comfy.Keybinding.NewBindings`,Object.values(e.getUserKeybindings())),await i.set(`Comfy.Keybinding.UnsetBindings`,Object.values(e.getUserUnsetKeybindings()))}return{keybindHandler,registerCoreKeybindings,registerUserKeybindings,persistUserKeybindings}}}));export{useKeybindingService as n,g as t};
//# sourceMappingURL=keybindingService-DYQ7KAte.js.map