/**
 * @fileoverview added by tsickle
 * Generated from: lib/tap-connect/connect-mqtt/connect-mqtt.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, EventEmitter, Output, Input } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { Platform } from '@ionic/angular';
import { CurrentDeviceService } from '../../current-device.service';
import { ProtocolFactoryService } from '../../protocol-factory.service';
/**
 * @record
 */
export function TapConnectMqttComponentFormData() { }
if (false) {
    /** @type {?|undefined} */
    TapConnectMqttComponentFormData.prototype.endpoint;
    /** @type {?|undefined} */
    TapConnectMqttComponentFormData.prototype.serialNumber;
    /** @type {?|undefined} */
    TapConnectMqttComponentFormData.prototype.password;
    /** @type {?|undefined} */
    TapConnectMqttComponentFormData.prototype.netKey;
    /** @type {?|undefined} */
    TapConnectMqttComponentFormData.prototype.username;
}
var TapConnectMqttComponent = /** @class */ (function () {
    function TapConnectMqttComponent(currentDevice, formBuilder, platform, protocolFactory) {
        this.currentDevice = currentDevice;
        this.formBuilder = formBuilder;
        this.platform = platform;
        this.protocolFactory = protocolFactory;
        this.onProtocolSelected = new EventEmitter();
        this.onError = new EventEmitter();
        this.defaults = {
            endpoint: 'wss://user.cloud.iotize.com:9883',
            netKey: 'testnetkey',
            password: '',
            serialNumber: 'IoTize00410000000D',
            username: 'IoTize00410000000D',
        };
        this.validation_messages = {
            'username': [],
            'serialNumber': [
                { type: 'required', message: 'Username is required.' },
                { type: 'minlength', message: 'Username must be at least 5 characters long.' },
                { type: 'maxlength', message: 'Username cannot be more than 25 characters long.' },
            ],
            'netKey': [
                { type: 'required', message: 'Net key is required.' }
            ],
        };
        this.loading = false;
        this.rememberGroupName = 'MqttForm';
    }
    Object.defineProperty(TapConnectMqttComponent.prototype, "password", {
        // tslint:disable-next-line: no-non-null-assertion
        get: 
        // tslint:disable-next-line: no-non-null-assertion
        /**
         * @return {?}
         */
        function () { return (/** @type {?} */ (this.form.get('password'))); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TapConnectMqttComponent.prototype, "username", {
        // tslint:disable-next-line: no-non-null-assertion
        get: 
        // tslint:disable-next-line: no-non-null-assertion
        /**
         * @return {?}
         */
        function () { return (/** @type {?} */ (this.form.get('username'))); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TapConnectMqttComponent.prototype, "serialNumber", {
        // tslint:disable-next-line: no-non-null-assertion
        get: 
        // tslint:disable-next-line: no-non-null-assertion
        /**
         * @return {?}
         */
        function () { return (/** @type {?} */ (this.form.get('serialNumber'))); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TapConnectMqttComponent.prototype, "netKey", {
        // tslint:disable-next-line: no-non-null-assertion
        get: 
        // tslint:disable-next-line: no-non-null-assertion
        /**
         * @return {?}
         */
        function () { return (/** @type {?} */ (this.form.get('netKey'))); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TapConnectMqttComponent.prototype, "endpoint", {
        // tslint:disable-next-line: no-non-null-assertion
        get: 
        // tslint:disable-next-line: no-non-null-assertion
        /**
         * @return {?}
         */
        function () { return (/** @type {?} */ (this.form.get('endpoint'))); },
        enumerable: true,
        configurable: true
    });
    /**
     * @return {?}
     */
    TapConnectMqttComponent.prototype.ngOnInit = /**
     * @return {?}
     */
    function () {
        this.form = this.formBuilder.group({
            endpoint: [this.defaults.endpoint, Validators.required],
            serialNumber: [this.defaults.serialNumber],
            password: [this.defaults.password],
            netKey: [this.defaults.netKey],
            username: [this.defaults.username],
        });
    };
    /**
     * @return {?}
     */
    TapConnectMqttComponent.prototype.onSubmit = /**
     * @return {?}
     */
    function () {
        /** @type {?} */
        var meta = {
            type: 'mqtt',
            info: {
                endpoint: this.endpoint.value,
                username: this.username.value,
                serialNumber: this.serialNumber.value,
                password: this.password.value,
                clientId: this.serialNumber.value
            }
        };
        this.onProtocolSelected.emit({
            meta: meta
        });
    };
    /**
     * @param {?} err
     * @return {?}
     */
    TapConnectMqttComponent.prototype._onError = /**
     * @param {?} err
     * @return {?}
     */
    function (err) {
        this.onError.emit(err);
    };
    TapConnectMqttComponent.decorators = [
        { type: Component, args: [{
                    selector: 'tap-connect-mqtt',
                    template: "<form *ngIf=\"form\" (ngSubmit)=\"onSubmit()\" [formGroup]=\"form\" (keydown.enter)=\"onSubmit()\">\r\n\t<ion-progress-bar *ngIf=\"loading\" type=\"indeterminate\"></ion-progress-bar>\r\n\t<ion-grid>\r\n\t\t<ion-row>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\">\r\n\t\t\t\t<ion-label>\r\n\t\t\t\t\tUrl\r\n\t\t\t\t\t<p>\r\n\t\t\t\t\t\tMQTT broker url\r\n\t\t\t\t\t</p>\r\n\t\t\t\t</ion-label>\r\n\t\t\t</ion-col>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\" class=\"col-input\">\r\n\t\t\t\t<ion-item>\r\n\t\t\t\t\t<div class=\"col-input-container\">\r\n\t\t\t\t\t\t<ion-input slot=\"start\" [rememberValueControl]=\"rememberGroupName\" name=\"endpoint\" [formControlName]=\"'endpoint'\" placeholder=\"Broker url\" required slot=\"end\" autocapitalize=\"none\" spellcheck=\"false\" autocorrect=\"off\" type=\"text\"></ion-input>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</ion-item>\r\n\t\t\t</ion-col>\r\n\t\t</ion-row>\r\n\t\t<ion-row>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\">\r\n\t\t\t\t<ion-label>\r\n\t\t\t\t\tSerial number\r\n\t\t\t\t\t<p>\r\n\t\t\t\t\t\tTap serial number you want to connect to.\r\n\t\t\t\t\t</p>\r\n\t\t\t\t</ion-label>\r\n\t\t\t</ion-col>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\" class=\"col-input\">\r\n\t\t\t\t<ion-item>\r\n\t\t\t\t\t<div class=\"col-input-container\">\r\n\t\t\t\t\t\t<ion-input [rememberValueControl]=\"rememberGroupName\" name=\"serialNumber\" [formControlName]=\"'serialNumber'\" placeholder=\"Device serial number\" slot=\"end\" autocapitalize=\"none\" spellcheck=\"false\" autocorrect=\"off\" type=\"text\"></ion-input>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</ion-item>\r\n\t\t\t\t<ion-item *ngIf=\"serialNumber.invalid && (serialNumber.dirty || serialNumber.touched)\" class=\"validation-errors\">\r\n\t\t\t\t\t<ion-text *ngFor=\"let validation of validation_messages.serialNumber\">\r\n\t\t\t\t\t\t<div *ngIf=\"serialNumber.hasError(validation.type) && (serialNumber.dirty || serialNumber.touched)\" class=\"error-message\">\r\n\t\t\t\t\t\t\t{{ validation.message }}\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</ion-text>\r\n\t\t\t\t</ion-item>\r\n\t\t\t</ion-col>\r\n\t\t</ion-row>\r\n\t\t<ion-row>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\">\r\n\t\t\t\t<ion-label>\r\n\t\t\t\t\tUsername\r\n\t\t\t\t\t<p>\r\n\t\t\t\t\t\tLeave blank if the broker does not require username/password authentication\r\n\t\t\t\t\t</p>\r\n\t\t\t\t</ion-label>\r\n\t\t\t</ion-col>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\" class=\"col-input\">\r\n\t\t\t\t<ion-item>\r\n\t\t\t\t\t<div class=\"col-input-container\">\r\n\t\t\t\t\t\t<ion-input [rememberValueControl]=\"rememberGroupName\" name=\"username\" [formControlName]=\"'username'\" placeholder=\"MQTT broker username...\" slot=\"end\" autocapitalize=\"none\" spellcheck=\"false\" autocorrect=\"off\" type=\"text\"></ion-input>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</ion-item>\r\n\t\t\t\t<ion-item *ngIf=\"username.invalid && (username.dirty || username.touched)\" class=\"validation-errors\">\r\n\t\t\t\t\t<ion-text *ngFor=\"let validation of validation_messages.username\">\r\n\t\t\t\t\t\t<div *ngIf=\"username.hasError(validation.type) && (username.dirty || username.touched)\" class=\"error-message\">\r\n\t\t\t\t\t\t\t{{ validation.message }}\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</ion-text>\r\n\t\t\t\t</ion-item>\r\n\t\t\t</ion-col>\r\n\t\t</ion-row>\r\n\t\t<ion-row>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\">\r\n\t\t\t\t<ion-label>\r\n\t\t\t\t\tPassword\r\n\t\t\t\t\t<p>\r\n\t\t\t\t\t\tLeave blank if the broker does not require username/password authentication\r\n\t\t\t\t\t</p>\r\n\t\t\t\t</ion-label>\r\n\t\t\t</ion-col>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\" class=\"col-input\">\r\n\t\t\t\t<ion-item>\r\n\t\t\t\t\t<div class=\"col-input-container\">\r\n\t\t\t\t\t\t<ion-input [formControlName]=\"'password'\" name=\"password\" placeholder=\"MQTT broker password...\" slot=\"end\" type=\"password\"></ion-input>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</ion-item>\r\n\t\t\t</ion-col>\r\n\t\t</ion-row>\r\n\t\t<ion-row>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\">\r\n\t\t\t\t<ion-label>\r\n\t\t\t\t\tSecurity key\r\n\t\t\t\t\t<p>\r\n\t\t\t\t\t\tThe key used to create a unique topic identifer. Must be the same key configured on your device.\r\n\t\t\t\t\t</p>\r\n\t\t\t\t</ion-label>\r\n\t\t\t</ion-col>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\" class=\"col-input\">\r\n\t\t\t\t<ion-item>\r\n\t\t\t\t\t<div class=\"col-input-container\">\r\n\t\t\t\t\t\t<ion-input [rememberValueControl]=\"rememberGroupName\" name=\"netKey\" [formControlName]=\"'netKey'\" placeholder=\"Net key\" slot=\"end\" autocapitalize=\"none\" spellcheck=\"false\" autocorrect=\"off\" type=\"string\"></ion-input>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</ion-item>\r\n\t\t\t\t<ion-item *ngIf=\"netKey.invalid && (netKey.dirty || netKey.touched)\" class=\"validation-errors\">\r\n\t\t\t\t\t<ion-text *ngFor=\"let validation of validation_messages.netKey\">\r\n\t\t\t\t\t\t<div *ngIf=\"netKey.hasError(validation.type) && (netKey.dirty || netKey.touched)\" class=\"error-message\">\r\n\t\t\t\t\t\t\t{{ validation.message }}\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</ion-text>\r\n\t\t\t\t</ion-item>\r\n\t\t\t</ion-col>\r\n\t\t</ion-row>\r\n\t\t<!-- <ion-row>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\">\r\n\t\t\t\t<ion-label>\r\n\t\t\t\t\tRequest topic\r\n\t\t\t\t\t<p>\r\n\t\t\t\t\t\tTopic used for requests\r\n\t\t\t\t\t</p>\r\n\t\t\t\t</ion-label>\r\n\t\t\t</ion-col>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\" class=\"col-input\">\r\n\t\t\t\t<ion-item>\r\n\t\t\t\t\t<div class=\"col-input-container\">\r\n\t\t\t\t\t\t<ion-input [rememberValueControl]=\"rememberGroupName\" [formControlName]=\"'requestTopic'\" placeholder=\"Request topic\" slot=\"end\" autocapitalize=\"none\" spellcheck=\"false\" autocorrect=\"off\" type=\"string\"></ion-input>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</ion-item>\r\n\t\t\t</ion-col>\r\n\t\t</ion-row>\r\n\t\t<ion-row>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\">\r\n\t\t\t\t<ion-label>\r\n\t\t\t\t\tResponse topic\r\n\t\t\t\t\t<p>\r\n\t\t\t\t\t\tTopic used for response\r\n\t\t\t\t\t</p>\r\n\t\t\t\t</ion-label>\r\n\t\t\t</ion-col>\r\n\t\t\t<ion-col size-xs=\"12\" size-sm=\"6\" class=\"col-input\">\r\n\t\t\t\t<ion-item>\r\n\t\t\t\t\t<div class=\"col-input-container\">\r\n\t\t\t\t\t\t<ion-input [rememberValueControl]=\"rememberGroupName\" [formControlName]=\"'responseTopic'\" placeholder=\"Response topic\" slot=\"end\" autocapitalize=\"none\" spellcheck=\"false\" autocorrect=\"off\" type=\"string\"></ion-input>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</ion-item>\r\n\t\t\t</ion-col>\r\n\t\t</ion-row> -->\r\n\t</ion-grid>\r\n\t<div class=\"ion-padding\">\r\n\t\t<ion-button [disabled]=\"form['invalid']\" expand=\"block\" size=\"large\" type=\"submit\">\r\n          <ion-icon name=\"log-in-outline\"></ion-icon> &nbsp;\r\n          Connect\r\n        </ion-button>\r\n\t</div>\r\n</form>\r\n",
                    styles: [".col-input{padding-left:var(--ion-grid-column-padding-xs,var(--ion-grid-column-padding,5px))}.col-input .col-input-container{width:100%}.col-input ion-input,.col-input ion-item{--padding-start:0px}"]
                }] }
    ];
    /** @nocollapse */
    TapConnectMqttComponent.ctorParameters = function () { return [
        { type: CurrentDeviceService },
        { type: FormBuilder },
        { type: Platform },
        { type: ProtocolFactoryService }
    ]; };
    TapConnectMqttComponent.propDecorators = {
        onProtocolSelected: [{ type: Output }],
        onError: [{ type: Output }],
        defaults: [{ type: Input }]
    };
    return TapConnectMqttComponent;
}());
export { TapConnectMqttComponent };
if (false) {
    /** @type {?} */
    TapConnectMqttComponent.prototype.onProtocolSelected;
    /** @type {?} */
    TapConnectMqttComponent.prototype.onError;
    /** @type {?} */
    TapConnectMqttComponent.prototype.defaults;
    /** @type {?} */
    TapConnectMqttComponent.prototype.validation_messages;
    /** @type {?} */
    TapConnectMqttComponent.prototype.form;
    /** @type {?} */
    TapConnectMqttComponent.prototype.loading;
    /** @type {?} */
    TapConnectMqttComponent.prototype.rememberGroupName;
    /**
     * @type {?}
     * @protected
     */
    TapConnectMqttComponent.prototype.currentDevice;
    /**
     * @type {?}
     * @private
     */
    TapConnectMqttComponent.prototype.formBuilder;
    /**
     * @type {?}
     * @private
     */
    TapConnectMqttComponent.prototype.platform;
    /**
     * @type {?}
     * @private
     */
    TapConnectMqttComponent.prototype.protocolFactory;
}
//# sourceMappingURL=data:application/json;base64, 