import { Component, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { FirstUppercaseLocalizeSAPipe } from '@anglr/common';
import { RelationsNodeBase, RelationNodeOutputSAComponent, RelationsNodeHeaderSAComponent, RelationNodeInputSAComponent } from '@anglr/dynamic/relations-editor';
import { FormModelBuilder } from '@anglr/common/forms';
import { TitledDialogService } from '@anglr/common/material';
import { extend } from '@jscrpt/common';
import { MathPowerRelationsOptionsModel } from './power.model';
import * as i0 from "@angular/core";
import * as i1 from "@anglr/common/material";
import * as i2 from "@anglr/common/forms";
import * as i3 from "@angular/forms";
/**
 * Relations node component for math power operation
 */
export class MathPowerNodeSAComponent extends RelationsNodeBase {
    //######################### constructor #########################
    constructor(changeDetector, element, dialog, formModelBuilder) {
        super(changeDetector, element);
        this.dialog = dialog;
        this.form = formModelBuilder.build(new MathPowerRelationsOptionsModel(null));
        this.form.valueChanges.subscribe(value => {
            var _a;
            if ((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.relationsOptions) {
                extend(this.metadata.relationsOptions, value);
                this.history.getNewState();
            }
        });
    }
    //######################### protected methods - overrides #########################
    /**
     * @inheritdoc
     */
    metadataSet() {
        var _a;
        if (!((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.relationsOptions)) {
            return;
        }
        this.form.patchValue(this.metadata.relationsOptions);
    }
}
MathPowerNodeSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: MathPowerNodeSAComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i1.TitledDialogService }, { token: i2.FormModelBuilder }], target: i0.ɵɵFactoryTarget.Component });
MathPowerNodeSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: MathPowerNodeSAComponent, isStandalone: true, selector: "math-power-node", providers: [
        FormModelBuilder
    ], usesInheritance: true, ngImport: i0, template: "<relations-node-header [parent]=\"this\" [destroySubject]=\"destroySubject\" [name]=\"'power'|firstUppercaseLocalize\"></relations-node-header>\n\n<div class=\"node-content\" [formGroup]=\"form\">\n    <div class=\"inputs-outputs\">\n        <div class=\"inputs\">\n            <div class=\"input\">\n                <relation-node-input [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"input\" [parent]=\"this\"></relation-node-input>\n                <div>{{'input'|firstUppercaseLocalize}}</div>\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\n    <div class=\"dynamic-form-group dynamic-margin-bottom-extra-small\">\n        <input type=\"text\" class=\"dynamic-form-control\" [placeholder]=\"'exponent'|firstUppercaseLocalize\" formControlName=\"exponent\" number required>\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: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "pipe", type: FirstUppercaseLocalizeSAPipe, name: "firstUppercaseLocalize" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: MathPowerNodeSAComponent, decorators: [{
            type: Component,
            args: [{ selector: 'math-power-node', standalone: true, imports: [
                        RelationsNodeHeaderSAComponent,
                        RelationNodeInputSAComponent,
                        RelationNodeOutputSAComponent,
                        CommonModule,
                        ReactiveFormsModule,
                        FirstUppercaseLocalizeSAPipe,
                    ], providers: [
                        FormModelBuilder
                    ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<relations-node-header [parent]=\"this\" [destroySubject]=\"destroySubject\" [name]=\"'power'|firstUppercaseLocalize\"></relations-node-header>\n\n<div class=\"node-content\" [formGroup]=\"form\">\n    <div class=\"inputs-outputs\">\n        <div class=\"inputs\">\n            <div class=\"input\">\n                <relation-node-input [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"input\" [parent]=\"this\"></relation-node-input>\n                <div>{{'input'|firstUppercaseLocalize}}</div>\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\n    <div class=\"dynamic-form-group dynamic-margin-bottom-extra-small\">\n        <input type=\"text\" class=\"dynamic-form-control\" [placeholder]=\"'exponent'|firstUppercaseLocalize\" formControlName=\"exponent\" number required>\n    </div>\n</div>" }]
        }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i1.TitledDialogService }, { type: i2.FormModelBuilder }] });
//# sourceMappingURL=power.component.js.map