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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
import { AcCmColor } from '@mlightcad/data-model';
import { AcApAnnotation } from '../app';
import { AcEdCommand, AcEdOpenMode } from '../editor';
/**
 * Base command for revision commands.
 */
var AcApBaseRevCmd = /** @class */ (function (_super) {
    __extends(AcApBaseRevCmd, _super);
    function AcApBaseRevCmd() {
        var _this = _super.call(this) || this;
        _this.mode = AcEdOpenMode.Review;
        _this._isShowEntityDrawStyleToolbar = true;
        return _this;
    }
    Object.defineProperty(AcApBaseRevCmd.prototype, "isShowEntityDrawStyleToolbar", {
        /**
         * Returns true if it is to show entity draw style toolbar
         */
        get: function () {
            return this._isShowEntityDrawStyleToolbar;
        },
        set: function (value) {
            this._isShowEntityDrawStyleToolbar = value;
        },
        enumerable: false,
        configurable: true
    });
    AcApBaseRevCmd.prototype.onCommandWillStart = function (context) {
        var db = context.doc.database;
        var annotation = new AcApAnnotation(db);
        this._previousLayer = db.clayer;
        this._previousCecolor = db.cecolor.toString();
        this._previousCelweight = db.celweight;
        this._revisionLayer = annotation.getAnnotationLayer();
        db.clayer = this._revisionLayer;
    };
    AcApBaseRevCmd.prototype.onCommandEnded = function (context) {
        var _a;
        var db = context.doc.database;
        if (this._previousLayer)
            db.clayer = this._previousLayer;
        if (this._previousCecolor)
            db.cecolor =
                (_a = AcCmColor.fromString(this._previousCecolor)) !== null && _a !== void 0 ? _a : new AcCmColor();
        if (this._previousCelweight)
            db.celweight = this._previousCelweight;
        this._previousLayer = undefined;
        this._revisionLayer = undefined;
    };
    return AcApBaseRevCmd;
}(AcEdCommand));
export { AcApBaseRevCmd };
//# sourceMappingURL=AcApBaseRevCmd.js.map