"use strict";

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.DomEventManager = void 0;

class DomEventManager {
    constructor(sheet) {
        this.boundHandlers = new Map, this.sheet = sheet, this.setupEventListeners();
    }
    setupEventListeners() {
        this.addEvent(window, "resize", this.handleWindowResize.bind(this));
    }
    addEvent(target, eventType, handler) {
        target.addEventListener(eventType, handler), this.boundHandlers.set(`${eventType}-${handler.toString()}`, handler);
    }
    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();
    }
}

exports.DomEventManager = DomEventManager;
//# sourceMappingURL=dom-event-manager.js.map