export class EventManager {
    constructor(sheet) {
        this.boundHandlers = new Map, this.sheet = sheet, this.handleCellClickBind = this.handleCellClick.bind(this), 
        this.handleCellValueChangedBind = this.handleCellValueChanged.bind(this), this.handleSelectionChangedForRangeModeBind = this.handleSelectionChangedForRangeMode.bind(this), 
        this.setupEventListeners();
    }
    setupEventListeners() {
        const element = this.sheet.getContainer();
        this.addEvent(element, "mousedown", this.handleMouseDown.bind(this)), this.addEvent(element, "mousemove", this.handleMouseMove.bind(this)), 
        this.addEvent(element, "mouseup", this.handleMouseUp.bind(this)), this.addEvent(element, "dblclick", this.handleDoubleClick.bind(this)), 
        this.addEvent(element, "keydown", this.handleKeyDown.bind(this)), this.addEvent(element, "keyup", this.handleKeyUp.bind(this)), 
        this.addEvent(element, "copy", this.handleCopy.bind(this)), this.addEvent(element, "paste", this.handlePaste.bind(this)), 
        this.addEvent(element, "cut", this.handleCut.bind(this)), this.addEvent(element, "focus", this.handleFocus.bind(this)), 
        this.addEvent(element, "blur", this.handleBlur.bind(this)), this.addEvent(window, "resize", this.handleWindowResize.bind(this));
    }
    addEvent(target, eventType, handler) {
        target.addEventListener(eventType, handler), this.boundHandlers.set(`${eventType}-${handler.toString()}`, handler);
    }
    handleCellClick(event) {
        if (this.sheet.formulaManager.formulaWorkingOnCell) return;
        const formulaUIManager = this.sheet.formulaUIManager;
        formulaUIManager.isFormulaBarShowingResult = !1, formulaUIManager.clearFormula(), 
        formulaUIManager.updateFormulaBar();
    }
    handleCellValueChanged(event) {
        this.sheet.formulaManager.formulaRangeSelector.handleCellValueChanged(event);
    }
    handleSelectionChangedForRangeMode(event) {
        this.sheet.formulaManager.formulaRangeSelector.handleSelectionChangedForRangeMode(event);
    }
    handleMouseDown(event) {}
    handleMouseMove(event) {}
    handleMouseUp(event) {}
    handleDoubleClick(event) {}
    handleKeyDown(event) {}
    handleKeyUp(event) {}
    handleCopy(event) {}
    handlePaste(event) {}
    handleCut(event) {}
    handleFocus(event) {}
    handleBlur(event) {}
    handleWindowResize(event) {
        this.sheet.resize();
    }
    release() {
        const element = this.sheet.getContainer();
        for (const [key, handler] of this.boundHandlers.entries()) {
            const eventType = key.split("-")[0];
            "resize" === eventType ? window.removeEventListener(eventType, handler) : element.removeEventListener(eventType, handler);
        }
        this.boundHandlers.clear();
    }
}
//# sourceMappingURL=event-manager.js.map