"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const domUtils_1 = require("../../sharedUtils/domUtils");
class GenerationCursorHandler {
    get cursorStyle() {
        const existingStyle = document.querySelector('#mabl-generation-cursor-styles');
        if (existingStyle) {
            return existingStyle;
        }
        const style = (0, domUtils_1.createIgnoredDomElement)('style');
        style.id = 'mabl-generation-cursor-styles';
        style.textContent = `
      /* Apply not-allowed cursor using body class with higher specificity */
      body.mabl-generation-cursor {
        cursor: not-allowed !important;
      }
      
      /* Inherit cursor for all descendants with body specificity */
      body.mabl-generation-cursor * {
        cursor: inherit !important;
      }
      
      /* Specific interactive elements that might override cursor with maximum specificity */
      body.mabl-generation-cursor a,
      body.mabl-generation-cursor button,
      body.mabl-generation-cursor input,
      body.mabl-generation-cursor select,
      body.mabl-generation-cursor textarea,
      body.mabl-generation-cursor [onclick],
      body.mabl-generation-cursor [role="button"],
      body.mabl-generation-cursor [role="link"],
      body.mabl-generation-cursor [tabindex],
      body.mabl-generation-cursor [contenteditable],
      body.mabl-generation-cursor .clickable,
      body.mabl-generation-cursor .btn,
      body.mabl-generation-cursor .button,
      body.mabl-generation-cursor .link {
        cursor: not-allowed !important;
      }
      
      /* Additional high-specificity rule to override any conflicting styles */
      body.mabl-generation-cursor .clickable {
        cursor: not-allowed !important;
      }
    `;
        document.head.appendChild(style);
        return style;
    }
    static forceCleanupAll() {
        try {
            console.debug('Force GenerationCursorHandler cleanup all instances called');
            document.body.classList.remove('mabl-generation-cursor');
            console.debug('Force GenerationCursorHandler cleanup completed');
        }
        catch (error) {
            console.error('Error in GenerationCursorHandler forceCleanupAll:', error);
        }
    }
    applyCursorStyling() {
        try {
            this.cursorStyle;
            document.body.classList.add('mabl-generation-cursor');
            console.debug('GenerationCursorHandler cursor styling applied successfully');
        }
        catch (error) {
            console.error('Failed to apply GenerationCursorHandler cursor styling:', error);
        }
    }
    removeCursorStyling() {
        try {
            document.body.classList.remove('mabl-generation-cursor');
            console.debug('GenerationCursorHandler cursor styling removed successfully');
        }
        catch (error) {
            console.error('Failed to remove GenerationCursorHandler cursor styling:', error);
        }
    }
    register() {
        if (document.body.classList.contains('mabl-generation-cursor')) {
            return;
        }
        this.applyCursorStyling();
        console.debug('GenerationCursorHandler cursor styling applied');
    }
    unregister() {
        if (!document.body.classList.contains('mabl-generation-cursor')) {
            return;
        }
        console.debug('GenerationCursorHandler unregistering cursor handler');
        this.removeCursorStyling();
        console.debug('GenerationCursorHandler unregistered successfully');
    }
}
exports.default = GenerationCursorHandler;
