import { KeyUtility } from "../../utility/key-utility";
var PageElement = /** @class */ (function () {
    function PageElement(app) {
        this._visible = true;
        this._newRow = false;
        this._listElement = false;
        this._app = app;
    }
    PageElement.buildShortName = function (str) {
        if (str == null || str.length === 0) {
            return "";
        }
        if (str.length > 63) {
            return str.substr(0, 60) + "...";
        }
        return str;
    };
    PageElement.prototype.getShortName = function () {
        return PageElement.buildShortName(this.name);
    };
    Object.defineProperty(PageElement.prototype, "app", {
        get: function () {
            return this._app;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageElement.prototype, "name", {
        get: function () {
            return this._name;
        },
        set: function (value) {
            this._name = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageElement.prototype, "type", {
        get: function () {
            return this._type;
        },
        set: function (value) {
            this._type = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageElement.prototype, "id", {
        get: function () {
            return this._id;
        },
        set: function (value) {
            this._id = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageElement.prototype, "width", {
        get: function () {
            return this._width;
        },
        set: function (value) {
            this._width = value;
        },
        enumerable: false,
        configurable: true
    });
    PageElement.prototype.getKey = function () {
        return this._key;
    };
    Object.defineProperty(PageElement.prototype, "key", {
        get: function () {
            return this._key;
        },
        set: function (value) {
            this._key = value;
        },
        enumerable: false,
        configurable: true
    });
    PageElement.prototype.getParent = function () {
        return this.parentPageElement;
    };
    Object.defineProperty(PageElement.prototype, "visible", {
        get: function () {
            return this._visible;
        },
        set: function (value) {
            this._visible = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageElement.prototype, "newRow", {
        get: function () {
            return this._newRow;
        },
        set: function (value) {
            this._newRow = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageElement.prototype, "parentPageElement", {
        get: function () {
            return this._parentPageElement;
        },
        set: function (value) {
            this._parentPageElement = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(PageElement.prototype, "listElement", {
        get: function () {
            return this._listElement;
        },
        set: function (value) {
            this._listElement = value;
        },
        enumerable: false,
        configurable: true
    });
    PageElement.prototype.fromJson = function (modelElement) {
        this.visible = true;
        if (modelElement["id"] != null) {
            this.id = modelElement["id"];
        }
        if (modelElement["key"] != null) {
            var name_1 = modelElement["key"]["name"];
            if (name_1 && !modelElement["key"]["key"]) {
                this.key = KeyUtility.findKey(this.parentPageElement, name_1);
            }
            else {
                this.key = new Key(modelElement["key"]["key"], name_1);
            }
        }
        if (modelElement["visible"] != null) {
            this.visible = modelElement["visible"];
        }
        if (modelElement["newRow"] != null) {
            this.newRow = modelElement["newRow"];
        }
        if (modelElement["width"] != null) {
            this.width = modelElement["width"];
        }
        else {
            this.width = 1;
        }
    };
    return PageElement;
}());
export { PageElement };
var Key = /** @class */ (function () {
    function Key(key, name) {
        this._key = key;
        this._name = name;
    }
    Key.prototype.getName = function () {
        return this._name;
    };
    Object.defineProperty(Key.prototype, "key", {
        set: function (value) {
            this._key = value;
        },
        enumerable: false,
        configurable: true
    });
    Key.prototype.getKey = function () {
        return this._key;
    };
    Object.defineProperty(Key.prototype, "name", {
        set: function (value) {
            this._name = value;
        },
        enumerable: false,
        configurable: true
    });
    Key.prototype.equals = function (otherKey) {
        if (otherKey != null &&
            otherKey.getName() &&
            otherKey.getKey() &&
            this.getName() &&
            this.getKey() &&
            otherKey.getName() === this.getName() &&
            otherKey.getKey() === this.getKey()) {
            return true;
        }
        return false;
    };
    return Key;
}());
export { Key };
//# sourceMappingURL=page-element.js.map