import { __decorate, __metadata } from "tslib";
import { DynamicOutput, PureRelationsComponent } from '@anglr/dynamic/relations';
import { RelationsEditorMetadata } from '@anglr/dynamic/relations-editor';
import { nameof } from '@jscrpt/common';
import Handlebars from 'handlebars';
import { DataTemplateRelationsMetadataLoader } from './dataTemplate.metadata';
/**
 * Data template relations component
 */
let DataTemplateRelations = class DataTemplateRelations {
    //######################### public properties - implementation of RelationsComponent #########################
    /**
     * @inheritdoc
     */
    get relationsOptions() {
        return this.ɵRelationsOptions;
    }
    set relationsOptions(value) {
        this.ɵRelationsOptions = value;
        if (this.ɵRelationsOptions?.template) {
            this.template = this.ɵRelationsOptions?.template;
            this.compiledTemplate = Handlebars.compile(this.template ?? '');
            this.output = this.compiledTemplate(this.data) ?? '';
        }
    }
    //######################### public methods - implementation of RelationsComponent #########################
    /**
     * @inheritdoc
     */
    ngOnChanges(changes) {
        if (nameof('template') in changes) {
            this.compiledTemplate = Handlebars.compile(this.template ?? '');
            this.output = this.compiledTemplate(this.data);
        }
        if (nameof('data') in changes) {
            this.output = this.compiledTemplate?.(this.data) ?? '';
        }
    }
    /**
     * @inheritdoc
     */
    invalidateVisuals() {
    }
};
__decorate([
    DynamicOutput(),
    __metadata("design:type", Object)
], DataTemplateRelations.prototype, "output", void 0);
DataTemplateRelations = __decorate([
    PureRelationsComponent(),
    RelationsEditorMetadata(DataTemplateRelationsMetadataLoader)
], DataTemplateRelations);
export { DataTemplateRelations };
//# sourceMappingURL=dataTemplate.relations.js.map