import{FlowNode as e}from"../components/flow-node";import{ConnectionLine as o}from"../components/connection-line";import{input as t,project as n}from"../components/flow-editor";export class Shortcuts{constructor(){this.actions=[{keys:["Delete","Backspace"],action:()=>{n.createUndoSnapshot();let c=t.selected.filter(o=>o instanceof e&&o.selected&&!o.frozen);t.selected.filter(e=>e instanceof o&&e.selected).forEach(e=>n.removeConnection(e.connection)),c.forEach(e=>n.removeNode(e.node)),n.notifyChange()}},{keys:["KeyA"],requireCtrl:!0,action:()=>{t.selected.length>0?t.clearSelection(!0):t.selectables.forEach(e=>{t.select(e,!0)})}},{keys:["KeyZ"],requireCtrl:!0,action:()=>{n.undo()}},{keys:["KeyY"],requireCtrl:!0,action:()=>{n.redo()}}],window.addEventListener("keydown",e=>{document.activeElement instanceof HTMLBodyElement&&this.actions.forEach(o=>{(o.keys.includes(e.key)||o.keys.includes(e.code))&&(!o.requireCtrl||e.ctrlKey)&&o.action()})})}}