import { __decorate, __extends } from "tslib";
import Vue from 'vue';
import Component from 'vue-class-component';
import { Prop } from 'vue-property-decorator';
import WithRender from './dynamic-template.html';
import uuid from '../../utils/uuid/uuid';
import { DYNAMIC_TEMPLATE_NAME } from '../component-names';
var MDynamicTemplate = /** @class */ (function (_super) {
    __extends(MDynamicTemplate, _super);
    function MDynamicTemplate() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.tag = 'm-dt-' + uuid.generate();
        return _this;
    }
    MDynamicTemplate.prototype.mounted = function () {
        this.$emit('mounted', this.$children);
    };
    MDynamicTemplate.prototype.updated = function () {
        this.$emit('updated', this.$children);
    };
    Object.defineProperty(MDynamicTemplate.prototype, "internalTemplate", {
        get: function () {
            if (typeof this.template === 'string') {
                Vue.component(this.tag, {
                    template: "<div>" + this.template + "</div>"
                });
            }
            else {
                Vue.component(this.tag, this.template);
            }
            return this.tag;
        },
        enumerable: true,
        configurable: true
    });
    __decorate([
        Prop()
    ], MDynamicTemplate.prototype, "template", void 0);
    MDynamicTemplate = __decorate([
        WithRender,
        Component
    ], MDynamicTemplate);
    return MDynamicTemplate;
}(Vue));
export { MDynamicTemplate };
var DynamicTemplatePlugin = {
    install: function (v, options) {
        v.component(DYNAMIC_TEMPLATE_NAME, MDynamicTemplate);
    }
};
export default DynamicTemplatePlugin;
//# sourceMappingURL=dynamic-template.js.map