import { __awaiter, __decorate } from "tslib";
import { Component, ChangeDetectionStrategy, Input } from '@angular/core';
import { LayoutComponentBase } from '@anglr/dynamic/layout';
import { LayoutEditorDesignerType, LayoutEditorMetadata } from '@anglr/dynamic/layout-editor';
import { RelationsEditorMetadata } from '@anglr/dynamic/relations-editor';
import { HostDisplayBlockStyle } from '@anglr/common';
import { nameof } from '@jscrpt/common';
import Handlebars from 'handlebars';
import { DataBlockLayoutDesignerTypeLoader, DataBlockLayoutMetadataLoader, DataBlockRelationsMetadataLoader } from './dataBlock.metadata';
import * as i0 from "@angular/core";
/**
 * Component used for displaying data block
 */
let DataBlockSAComponent = class DataBlockSAComponent extends LayoutComponentBase {
    //######################### public methods - implementation of OnChanges #########################
    /**
     * Called when input value changes
     */
    ngOnChanges(changes) {
        const _super = Object.create(null, {
            ngOnChanges: { get: () => super.ngOnChanges }
        });
        var _a, _b;
        return __awaiter(this, void 0, void 0, function* () {
            yield _super.ngOnChanges.call(this, changes);
            if (nameof('data') in changes) {
                this.componentElement.nativeElement.innerHTML = (_b = (_a = this.compiledTemplate) === null || _a === void 0 ? void 0 : _a.call(this, this.data)) !== null && _b !== void 0 ? _b : '';
            }
        });
    }
    //######################### protected methods - overrides #########################
    /**
     * @inheritdoc
     */
    onOptionsSet() {
        var _a, _b, _c;
        if (!this.initialized) {
            return;
        }
        if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.template) {
            this.compiledTemplate = Handlebars.compile(this.options.template);
        }
        this.componentElement.nativeElement.innerHTML = (_c = (_b = this.compiledTemplate) === null || _b === void 0 ? void 0 : _b.call(this, this.data)) !== null && _c !== void 0 ? _c : '';
    }
};
DataBlockSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: DataBlockSAComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
DataBlockSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: DataBlockSAComponent, isStandalone: true, selector: "data-block", inputs: { data: "data" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: '', isInline: true, styles: [":host{display: block;}"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
DataBlockSAComponent = __decorate([
    LayoutEditorDesignerType(DataBlockLayoutDesignerTypeLoader),
    RelationsEditorMetadata(DataBlockRelationsMetadataLoader),
    LayoutEditorMetadata(DataBlockLayoutMetadataLoader)
], DataBlockSAComponent);
export { DataBlockSAComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: DataBlockSAComponent, decorators: [{
            type: Component,
            args: [{ selector: 'data-block', template: '', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display: block;}"] }]
        }], propDecorators: { data: [{
                type: Input
            }] } });
//# sourceMappingURL=dataBlock.component.js.map