(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "./AtomControl"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.AtomTemplateControl = void 0;
    const AtomControl_1 = require("./AtomControl");
    class AtomTemplateControl extends AtomControl_1.AtomControl {
        onPropertyChanged(name) {
            if (name === "contentTemplate") {
                this.createContent();
            }
        }
        onUpdateUI() {
            super.onUpdateUI();
            if (this.content) {
                return;
            }
            if (this.contentTemplate) {
                this.createContent();
            }
        }
        preCreate() {
            this.contentTemplate = null;
            this.content = null;
        }
        createContent() {
            const t = this.contentTemplate;
            if (!t) {
                return;
            }
            const tc = this.content;
            if (tc) {
                tc.dispose();
                this.content = null;
            }
            const ntc = this.content = new (t)(this.app);
            this.append(ntc);
        }
    }
    exports.AtomTemplateControl = AtomTemplateControl;
});
//# sourceMappingURL=AtomTemplateControl.js.map