import * as i0 from '@angular/core';
import { inject, Input, Component } from '@angular/core';
import * as i3 from '@angular/forms';
import { FormBuilder, NgForm, Validators, ControlContainer, ReactiveFormsModule } from '@angular/forms';
import * as i1 from '@c8y/ngx-components';
import { CoreModule, CommonModule, C8yTranslatePipe } from '@c8y/ngx-components';

class ComputedPropertyEventCountConfigComponent {
    constructor() {
        this.formBuilder = inject(FormBuilder);
        this.form = inject(NgForm);
    }
    ngOnInit() {
        this.initForm();
    }
    onBeforeSave(config) {
        if (this.formGroup.valid) {
            Object.assign(config, this.formGroup.value);
            return true;
        }
        return false;
    }
    initForm() {
        this.formGroup = this.createForm();
        this.form.form.addControl('config', this.formGroup);
        this.formGroup.patchValue(this.config);
    }
    createForm() {
        return this.formBuilder.group({
            type: ['', [Validators.required]]
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: ComputedPropertyEventCountConfigComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: ComputedPropertyEventCountConfigComponent, isStandalone: true, selector: "c8y-event-count-config", inputs: { config: "config" }, ngImport: i0, template: "<form class=\"row d-flex-md\" [formGroup]=\"formGroup\">\n  <div class=\"col-md-6\">\n    <c8y-form-group class=\"m-b-16\">\n      <label\n        [title]=\"'Event type' | translate\"\n        translate\n      >\n        Event type\n      </label>\n      <input\n        class=\"form-control\"\n        name=\"type\"\n        type=\"string\"\n        formControlName=\"type\"\n        placeholder=\"{{ 'e.g. {{ example }}' | translate: { example: 'c8y_LocationUpdate' } }}\"\n      />\n      <c8y-messages\n        [show]=\"formGroup.controls?.type?.touched && formGroup?.controls?.type?.errors\"\n      ></c8y-messages>\n    </c8y-form-group>\n  </div>\n</form>\n", dependencies: [{ kind: "ngmodule", type: CoreModule }, { kind: "directive", type: i1.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i3.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { 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: "component", type: i1.FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "component", type: i1.MessagesComponent, selector: "c8y-messages", inputs: ["show", "defaults", "helpMessage"] }, { kind: "directive", type: i1.RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { 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: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "pipe", type: i1.C8yTranslatePipe, name: "translate" }], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: ComputedPropertyEventCountConfigComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-event-count-config', imports: [CoreModule, CommonModule, C8yTranslatePipe, ReactiveFormsModule], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], template: "<form class=\"row d-flex-md\" [formGroup]=\"formGroup\">\n  <div class=\"col-md-6\">\n    <c8y-form-group class=\"m-b-16\">\n      <label\n        [title]=\"'Event type' | translate\"\n        translate\n      >\n        Event type\n      </label>\n      <input\n        class=\"form-control\"\n        name=\"type\"\n        type=\"string\"\n        formControlName=\"type\"\n        placeholder=\"{{ 'e.g. {{ example }}' | translate: { example: 'c8y_LocationUpdate' } }}\"\n      />\n      <c8y-messages\n        [show]=\"formGroup.controls?.type?.touched && formGroup?.controls?.type?.errors\"\n      ></c8y-messages>\n    </c8y-form-group>\n  </div>\n</form>\n" }]
        }], propDecorators: { config: [{
                type: Input
            }] } });

export { ComputedPropertyEventCountConfigComponent };
//# sourceMappingURL=c8y-ngx-components-computed-asset-properties-event-count-config.component-DVCbhO9J.mjs.map
