var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import { RibbonGroupBase } from '../ribbon-interfaces';
// History group constants
export var HISTORY_GROUP_ID = '_history_group';
export var UNDO_ID = '_undo';
export var REDO_ID = '_redo';
/**
 * HistoryGroup class for handling history operations in Document Editor ribbon
 * @private
 */
var HistoryGroup = /** @class */ (function (_super) {
    __extends(HistoryGroup, _super);
    function HistoryGroup() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    /**
     * Get the Ribbon group model for History
     * @returns {RibbonGroupModel} - The Ribbon group model for History
     * @private
     */
    HistoryGroup.prototype.getGroupModel = function () {
        var _this = this;
        var id = this.ribbonId;
        return {
            id: id + HISTORY_GROUP_ID,
            cssClass: 'e-history-group',
            header: this.localObj.getConstant('Undo'),
            enableGroupOverflow: true,
            overflowHeader: this.localObj.getConstant('Undo'),
            groupIconCss: 'e-icons e-de-ctnr-undo',
            collections: [
                {
                    id: id + '_history-collection',
                    items: [
                        {
                            type: 'Button',
                            keyTip: 'ZZ',
                            buttonSettings: {
                                content: this.localObj.getConstant('Undo'),
                                iconCss: 'e-icons e-de-ctnr-undo',
                                clicked: function () {
                                    if (!_this.documentEditor.isReadOnly && _this.documentEditor.editorHistory) {
                                        _this.documentEditor.editorHistory.undo();
                                    }
                                }
                            },
                            id: id + UNDO_ID,
                            ribbonTooltipSettings: { content: this.localObj.getConstant('Undo Tooltip') }
                        },
                        {
                            type: 'Button',
                            keyTip: 'O',
                            buttonSettings: {
                                content: this.localObj.getConstant('Redo'),
                                iconCss: 'e-icons e-de-ctnr-redo',
                                clicked: function () {
                                    if (!_this.documentEditor.isReadOnly && _this.documentEditor.editorHistory) {
                                        _this.documentEditor.editorHistory.redo();
                                    }
                                }
                            },
                            id: id + REDO_ID,
                            ribbonTooltipSettings: { content: this.localObj.getConstant('Redo Tooltip') }
                        }
                    ]
                }
            ]
        };
    };
    /**
     * Update undo/redo buttons based on history state
     * @returns {void}
     * @private
     */
    HistoryGroup.prototype.updateContentChanged = function () {
        // Get the ribbon from container
        var ribbon = this.container.ribbonModule.ribbon;
        if (!ribbon) {
            return;
        }
        var id = this.ribbonId;
        // For undo button
        if (this.container.documentEditor.editorHistory.canUndo()) {
            ribbon.enableItem(id + UNDO_ID);
        }
        else {
            ribbon.disableItem(id + UNDO_ID);
        }
        // For redo button
        if (this.container.documentEditor.editorHistory.canRedo()) {
            ribbon.enableItem(id + REDO_ID);
        }
        else {
            ribbon.disableItem(id + REDO_ID);
        }
    };
    return HistoryGroup;
}(RibbonGroupBase));
export { HistoryGroup };
