import { classList } from '@syncfusion/ej2-base';
/**
 * Constants for protect group identification
 */
export var DEVELOPER_PROTECT_GROUP = '_developer_DEVELOPER_PROTECT_GROUP';
export var DEVELOPER_RESTRICT_EDITING_ID = '_restrict_edit';
/**
 * DeveloperProtectGroup module
 */
var DeveloperProtectGroup = /** @class */ (function () {
    /**
     * Constructor for DeveloperProtectGroup class
     * @param {DocumentEditorContainer} container - DocumentEditorContainer instance
     */
    function DeveloperProtectGroup(container) {
        this.container = container;
        this.ribbonId = this.container.element.id + '_ribbon';
    }
    Object.defineProperty(DeveloperProtectGroup.prototype, "documentEditor", {
        /**
         * Get the DocumentEditor instance
         * @returns {DocumentEditor} The document editor instance
         */
        get: function () {
            return this.container.documentEditor;
        },
        enumerable: true,
        configurable: true
    });
    /**
     * Get the Protect group model
     * @returns {RibbonGroupModel} The ribbon group model
     */
    DeveloperProtectGroup.prototype.getGroupModel = function () {
        var locale = this.container.localObj;
        var id = this.ribbonId + DEVELOPER_PROTECT_GROUP;
        return {
            id: id,
            header: locale.getConstant('Protect'),
            orientation: 'Row',
            enableGroupOverflow: true,
            overflowHeader: locale.getConstant('Protect'),
            collections: [
                {
                    items: [
                        this.getRestrictEditingButtonModel()
                    ]
                }
            ]
        };
    };
    /**
     * Get the Restrict Editing button model
     * @returns {RibbonItemModel} The ribbon item model
     */
    DeveloperProtectGroup.prototype.getRestrictEditingButtonModel = function () {
        var locale = this.container.localObj;
        var id = this.ribbonId + DEVELOPER_PROTECT_GROUP;
        return {
            type: 'Button',
            id: id + DEVELOPER_RESTRICT_EDITING_ID,
            buttonSettings: {
                iconCss: 'e-icons e-de-ctnr-lock',
                content: locale.getConstant('Restrict Editing'),
                clicked: this.onRestrictEditingClick.bind(this)
            },
            ribbonTooltipSettings: {
                content: locale.getConstant('Restrict editing')
            }
        };
    };
    /**
     * Handle restrict editing button click
     * @returns {void}
     */
    DeveloperProtectGroup.prototype.onRestrictEditingClick = function () {
        var _this = this;
        this.documentEditor.documentHelper.restrictEditingPane.showHideRestrictPane(true);
        setTimeout(function () {
            _this.documentEditor.focusIn();
        }, 30);
    };
    /**
     * Update UI based on current selection
     * @returns {void}
     */
    DeveloperProtectGroup.prototype.updateSelection = function () {
        // Update UI state based on current selection
        var isReadOnly = this.documentEditor.isReadOnly;
        var isDocumentProtected = this.documentEditor.documentHelper.isDocumentProtected;
        // Enable/disable restrict editing button based on document state
        var enableRestrictEditing = !isReadOnly;
        // Implementation to enable/disable restrict editing button
        /* eslint-disable-next-line max-len */
        var restrictEditingElement = document.getElementById(this.ribbonId + DEVELOPER_PROTECT_GROUP + DEVELOPER_RESTRICT_EDITING_ID);
        if (restrictEditingElement) {
            restrictEditingElement.classList.toggle('e-disabled', !enableRestrictEditing);
            // Update button state if document is protected
            this.toggleButton(restrictEditingElement, this.container.restrictEditing);
        }
    };
    /**
     * Toggle button state
     * @param {HTMLElement} element - The HTML element to toggle
     * @param {boolean} toggle - The toggle state
     * @returns {void}
     */
    DeveloperProtectGroup.prototype.toggleButton = function (element, toggle) {
        if (toggle) {
            classList(element, ['e-btn-toggle'], []);
            element.setAttribute('aria-pressed', 'true');
        }
        else {
            classList(element, [], ['e-btn-toggle']);
            element.setAttribute('aria-pressed', 'false');
        }
    };
    /**
     * Destroy the DeveloperProtectGroup instance
     * @returns {void}
     */
    DeveloperProtectGroup.prototype.destroy = function () {
        // Clear all references
        this.container = undefined;
        this.ribbonId = undefined;
    };
    return DeveloperProtectGroup;
}());
export { DeveloperProtectGroup };
