import { EventEmitter, Component, Output, Input, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { Validators, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TargetS3PProtocolConfiguration } from '@iotize/tap/service/impl/target';
import { IonicModule } from '@ionic/angular';

/**
 * @fileoverview added by tsickle
 * Generated from: lib/tap-s3p-configuration-form/tap-s3p-configuration-form.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
var TapS3pConfigurationFormComponent = /** @class */ (function () {
    function TapS3pConfigurationFormComponent(formBuilder) {
        var _this = this;
        this.valueChanges = new EventEmitter();
        this.modes = [
            {
                title: 'Indexed',
                value: TargetS3PProtocolConfiguration.Mode.INDEXED,
            },
            {
                title: 'Emulation',
                value: TargetS3PProtocolConfiguration.Mode.EMULATION,
            }
        ];
        this.form = formBuilder.group({
            mode: [TargetS3PProtocolConfiguration.Mode.INDEXED, [
                    Validators.required,
                ]],
            delay: [1, [
                    Validators.required,
                    Validators.min(1),
                    Validators.max(255)
                ]]
        });
        this.form.valueChanges.subscribe((/**
         * @param {?} event
         * @return {?}
         */
        function (event) {
            // if (this.form.valid){
            _this.valueChanges.emit(event);
            // }
        }));
    }
    Object.defineProperty(TapS3pConfigurationFormComponent.prototype, "values", {
        set: /**
         * @param {?} obs
         * @return {?}
         */
        function (obs) {
            var _this = this;
            var _a;
            (_a = this.valueSub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
            this.valueSub = obs === null || obs === void 0 ? void 0 : obs.subscribe((/**
             * @param {?} newValue
             * @return {?}
             */
            function (newValue) {
                _this.form.setValue(newValue, {
                    emitEvent: false
                });
            }));
        },
        enumerable: true,
        configurable: true
    });
    /**
     * @return {?}
     */
    TapS3pConfigurationFormComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () { };
    TapS3pConfigurationFormComponent.decorators = [
        { type: Component, args: [{
                    selector: 'tap-s3p-configuration-form',
                    template: "<form [formGroup]=\"form\">\r\n\t<ion-item>\r\n\t\t<ion-label>\r\n\t\t\tMode\r\n\t\t</ion-label>\r\n\t\t<ion-select slot=\"end\" [formControlName]=\"'mode'\">\r\n\t\t\t<ion-select-option *ngFor=\"let mode of modes\" [value]=\"mode.value\">\r\n\t\t\t\t{{mode.title}}\r\n\t\t\t</ion-select-option>\r\n\t\t</ion-select>\r\n\t</ion-item>\r\n\t<ion-item>\r\n\t\t<ion-label>\r\n\t\t\tDelay\r\n\t\t</ion-label>\r\n\t\t<ion-input type=\"number\" slot=\"end\" [formControlName]=\"'delay'\"></ion-input>\r\n\t</ion-item>\r\n</form>\r\n",
                    styles: ["ion-input{text-align:right}"]
                }] }
    ];
    /** @nocollapse */
    TapS3pConfigurationFormComponent.ctorParameters = function () { return [
        { type: FormBuilder }
    ]; };
    TapS3pConfigurationFormComponent.propDecorators = {
        valueChanges: [{ type: Output }],
        values: [{ type: Input }]
    };
    return TapS3pConfigurationFormComponent;
}());
if (false) {
    /** @type {?} */
    TapS3pConfigurationFormComponent.prototype.form;
    /** @type {?} */
    TapS3pConfigurationFormComponent.prototype.valueChanges;
    /**
     * @type {?}
     * @private
     */
    TapS3pConfigurationFormComponent.prototype.valueSub;
    /** @type {?} */
    TapS3pConfigurationFormComponent.prototype.modes;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/tap-target-s3p.module.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
var TapTargetS3PModule = /** @class */ (function () {
    function TapTargetS3PModule() {
    }
    TapTargetS3PModule.decorators = [
        { type: NgModule, args: [{
                    declarations: [
                        TapS3pConfigurationFormComponent
                    ],
                    exports: [
                        TapS3pConfigurationFormComponent
                    ],
                    imports: [
                        CommonModule,
                        IonicModule,
                        FormsModule,
                        ReactiveFormsModule
                    ]
                },] }
    ];
    return TapTargetS3PModule;
}());

/**
 * @fileoverview added by tsickle
 * Generated from: public_api.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */

/**
 * @fileoverview added by tsickle
 * Generated from: iotize-ionic-target-s3p.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */

export { TapS3pConfigurationFormComponent, TapTargetS3PModule };
//# sourceMappingURL=iotize-ionic-target-s3p.js.map
