import { Component, ChangeDetectionStrategy } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FirstUppercaseLocalizeSAPipe } from '@anglr/common';
import { RelationsNodeBase, RelationNodeInputSAComponent, RelationNodeOutputSAComponent, RelationsNodeHeaderSAComponent } from '@anglr/dynamic/relations-editor';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
/**
 * Relations node component for logical or
 */
export class LogicalOrNodeSAComponent extends RelationsNodeBase {
    //######################### protected properties - template bindings #########################
    /**
     * Gets added properties names
     */
    get properties() {
        var _a, _b;
        var _c;
        if (!this.metadata) {
            return [];
        }
        (_a = (_c = this.metadata).relationsOptions) !== null && _a !== void 0 ? _a : (_c.relationsOptions = {
            properties: []
        });
        return (_b = this.metadata.relationsOptions.properties) !== null && _b !== void 0 ? _b : [];
    }
    /**
     * Adds new property
     */
    addProperty() {
        var _a, _b;
        var _c;
        if ((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.relationsOptions) {
            (_b = (_c = this.metadata.relationsOptions).properties) !== null && _b !== void 0 ? _b : (_c.properties = []);
            this.metadata.relationsOptions.properties.push(`cond${this.properties.length + 3}`);
            this.history.getNewState();
        }
    }
    /**
     * Removes property
     * @param name - Name of property to be removed
     */
    removeProperty(name) {
        var _a, _b, _c;
        let index;
        if (((_c = (_b = (_a = this.metadata) === null || _a === void 0 ? void 0 : _a.relationsOptions) === null || _b === void 0 ? void 0 : _b.properties) === null || _c === void 0 ? void 0 : _c.length) && (index = this.metadata.relationsOptions.properties.indexOf(name)) >= 0) {
            this.metadata.relationsOptions.properties.splice(index, 1);
            this.history.getNewState();
        }
    }
}
LogicalOrNodeSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: LogicalOrNodeSAComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
LogicalOrNodeSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: LogicalOrNodeSAComponent, isStandalone: true, selector: "logical-or-node", usesInheritance: true, ngImport: i0, template: "<relations-node-header [parent]=\"this\" [destroySubject]=\"destroySubject\" [name]=\"'logical OR'|firstUppercaseLocalize\"></relations-node-header>\n\n<div class=\"node-content\">\n    <div class=\"inputs-outputs\">\n        <div class=\"inputs\">\n            <div class=\"input\">\n                <relation-node-input [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"cond1\" [parent]=\"this\"></relation-node-input>\n                <div>{{'cond1'|firstUppercaseLocalize}}</div>\n            </div>\n\n            <div class=\"input\">\n                <relation-node-input [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"cond2\" [parent]=\"this\"></relation-node-input>\n                <div>{{'cond2'|firstUppercaseLocalize}}</div>\n            </div>\n\n            <div class=\"input\" *ngFor=\"let property of properties\">\n                <relation-node-input [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" [name]=\"property\" [parent]=\"this\"></relation-node-input>\n\n                <div class=\"dynamic-flex-row\">\n                    <div>{{property|firstUppercaseLocalize}}</div>\n\n                    <button type=\"button\" class=\"dynamic-btn-icon\" (click)=\"$event.preventDefault(); $event.stopPropagation(); removeProperty(property)\">\n                        <span class=\"fas fa-times\"></span>\n                    </button>\n                </div>\n            </div>\n\n            <div class=\"dynamic-flex-row\">\n                <button type=\"button\" class=\"dynamic-btn-icon dynamic-margin-left-extra-small\" (click)=\"$event.preventDefault(); $event.stopPropagation(); addProperty()\">\n                    <span class=\"fas fa-plus\"></span>\n                </button>\n            </div>\n        </div>\n\n        <div class=\"outputs\">\n            <div class=\"output\">\n                <div>{{'result'|firstUppercaseLocalize}}</div>\n                <relation-node-output [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"result\" [parent]=\"this\"></relation-node-output>\n            </div>\n        </div>\n    </div>\n</div>", dependencies: [{ kind: "component", type: RelationsNodeHeaderSAComponent, selector: "relations-node-header", inputs: ["parent", "destroySubject", "name"] }, { kind: "component", type: RelationNodeInputSAComponent, selector: "relation-node-input" }, { kind: "component", type: RelationNodeOutputSAComponent, selector: "relation-node-output" }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "pipe", type: FirstUppercaseLocalizeSAPipe, name: "firstUppercaseLocalize" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: LogicalOrNodeSAComponent, decorators: [{
            type: Component,
            args: [{ selector: 'logical-or-node', standalone: true, imports: [
                        RelationsNodeHeaderSAComponent,
                        RelationNodeInputSAComponent,
                        RelationNodeOutputSAComponent,
                        CommonModule,
                        FirstUppercaseLocalizeSAPipe,
                    ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<relations-node-header [parent]=\"this\" [destroySubject]=\"destroySubject\" [name]=\"'logical OR'|firstUppercaseLocalize\"></relations-node-header>\n\n<div class=\"node-content\">\n    <div class=\"inputs-outputs\">\n        <div class=\"inputs\">\n            <div class=\"input\">\n                <relation-node-input [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"cond1\" [parent]=\"this\"></relation-node-input>\n                <div>{{'cond1'|firstUppercaseLocalize}}</div>\n            </div>\n\n            <div class=\"input\">\n                <relation-node-input [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"cond2\" [parent]=\"this\"></relation-node-input>\n                <div>{{'cond2'|firstUppercaseLocalize}}</div>\n            </div>\n\n            <div class=\"input\" *ngFor=\"let property of properties\">\n                <relation-node-input [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" [name]=\"property\" [parent]=\"this\"></relation-node-input>\n\n                <div class=\"dynamic-flex-row\">\n                    <div>{{property|firstUppercaseLocalize}}</div>\n\n                    <button type=\"button\" class=\"dynamic-btn-icon\" (click)=\"$event.preventDefault(); $event.stopPropagation(); removeProperty(property)\">\n                        <span class=\"fas fa-times\"></span>\n                    </button>\n                </div>\n            </div>\n\n            <div class=\"dynamic-flex-row\">\n                <button type=\"button\" class=\"dynamic-btn-icon dynamic-margin-left-extra-small\" (click)=\"$event.preventDefault(); $event.stopPropagation(); addProperty()\">\n                    <span class=\"fas fa-plus\"></span>\n                </button>\n            </div>\n        </div>\n\n        <div class=\"outputs\">\n            <div class=\"output\">\n                <div>{{'result'|firstUppercaseLocalize}}</div>\n                <relation-node-output [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"result\" [parent]=\"this\"></relation-node-output>\n            </div>\n        </div>\n    </div>\n</div>" }]
        }] });
//# sourceMappingURL=logicalOrNode.component.js.map