"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const domUtils_1 = require("../../sharedUtils/domUtils");
class WalkthroughOverlayHandler {
    constructor() {
        this.overlay = document.getElementById(domUtils_1.MABL_WALKTHROUGH_OVERLAY_ID);
    }
    blockBreakingKeypressEvents(event) {
        if (event.key === 'Tab' || event.ctrlKey || event.metaKey) {
            event.preventDefault();
            event.stopPropagation();
        }
    }
    register() {
        if (!this.overlay) {
            (0, domUtils_1.renderWalkthroughOverlay)();
            this.overlay = document.getElementById(domUtils_1.MABL_WALKTHROUGH_OVERLAY_ID);
            document.addEventListener('keydown', this.blockBreakingKeypressEvents, true);
        }
    }
    unregister() {
        if (this.overlay) {
            document.removeEventListener('keydown', this.blockBreakingKeypressEvents, true);
            (0, domUtils_1.destroyWalkthroughOverlay)();
            this.overlay = document.getElementById(domUtils_1.MABL_WALKTHROUGH_OVERLAY_ID);
        }
    }
}
exports.default = WalkthroughOverlayHandler;
