"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseContentEventHandler = void 0;
const mablscriptFind_1 = require("@mablhq/test-model/mablscriptFind");
class BaseContentEventHandler {
    constructor(eventType, name, store, selectorCache) {
        this.eventType = eventType;
        this.name = name;
        this.store = store;
        this.selectorCache = selectorCache;
    }
    register() {
        window.addEventListener(this.eventType ?? '', this.handle, true);
    }
    unregister() {
        window.removeEventListener(this.eventType ?? '', this.handle, true);
    }
    handle(_event) {
        throw new Error('Derived classes must implement a handle(event) function or else override register() and unregister() functions');
    }
    getSelectorCache() {
        this.selectorCache = this.selectorCache || new mablscriptFind_1.ElementFullSelectorCache();
        return this.selectorCache;
    }
}
exports.BaseContentEventHandler = BaseContentEventHandler;
