/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import * as tslib_1 from "tslib";
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { NzMessageService } from 'ng-zorro-antd';
import { TranslateService } from '@ngx-translate/core';
import { API, DEF } from '../../../../../../api';
var IdentityClientsUpdateClaimCreateComponent = /** @class */ (function () {
    function IdentityClientsUpdateClaimCreateComponent(nzMessageService, translateService) {
        this.nzMessageService = nzMessageService;
        this.translateService = translateService;
        this.visible = false;
        this.visibleChange = new EventEmitter();
        this.clientId = '';
        this.ok = new EventEmitter();
        this.claimCreating = false;
        this.formGroup = new FormGroup({
            type: new FormControl('sub', {
                validators: [Validators.required],
            }),
            value: new FormControl('', {
                validators: [Validators.required],
            }),
        });
    }
    /**
     * @return {?}
     */
    IdentityClientsUpdateClaimCreateComponent.prototype.handleOk = /**
     * @return {?}
     */
    function () {
        var _this = this;
        if (this.formGroup.invalid) {
            return;
        }
        this.claimCreating = true;
        API.Identity.ClientController.SaveClaim({ client: this.clientId }, new DEF.Identity.SaveClientClaimQuery(tslib_1.__assign({}, this.formGroup.getRawValue(), { clientId: this.clientId }))).subscribe({
            next: (/**
             * @return {?}
             */
            function () {
                _this.claimCreating = false;
                _this.visibleChange.emit(false);
                _this.ok.emit();
                _this.nzMessageService.success(_this.translateService.instant('projects/fe-ng/src/lib/page/identity/clients/update/claim/create/identity--clients--update--claim--create.create_successfully'));
            }),
            error: (/**
             * @return {?}
             */
            function () {
                _this.claimCreating = false;
            }),
        });
    };
    /**
     * @return {?}
     */
    IdentityClientsUpdateClaimCreateComponent.prototype.handleCancel = /**
     * @return {?}
     */
    function () {
        this.visibleChange.emit(false);
    };
    /**
     * @return {?}
     */
    IdentityClientsUpdateClaimCreateComponent.prototype.handleAfterClose = /**
     * @return {?}
     */
    function () {
        this.formGroup.reset({
            type: 'sub',
        });
    };
    IdentityClientsUpdateClaimCreateComponent.decorators = [
        { type: Component, args: [{
                    selector: 'kg---identity--clients--update--claim--create',
                    template: "<nz-modal\r\n  (nzAfterClose)=\"handleAfterClose()\"\r\n  (nzOnCancel)=\"handleCancel()\"\r\n  [nzBodyStyle]=\"{\r\n    padding: '12px 16px 6px 16px'\r\n  }\"\r\n  [nzCancelDisabled]=\"claimCreating\"\r\n  [nzClosable]=\"!claimCreating\"\r\n  [nzKeyboard]=\"false\"\r\n  [nzMaskClosable]=\"false\"\r\n  [nzTitle]=\"\r\n    'projects/fe-ng/src/lib/page/identity/clients/update/claim/create/identity--clients--update--claim--create.title'\r\n      | i18n\r\n  \"\r\n  [nzVisible]=\"visible\"\r\n  nzWidth=\"748px\"\r\n>\r\n  <form (ngSubmit)=\"handleOk()\" [formGroup]=\"formGroup\" nz-form nzLayout=\"vertical\">\r\n    <nz-form-item>\r\n      <nz-form-label [nzFor]=\"'type'\">\r\n        {{\r\n          'projects/fe-ng/src/lib/page/identity/clients/update/claim/create/identity--clients--update--claim--create.type'\r\n            | i18n\r\n        }}:\r\n      </nz-form-label>\r\n      <nz-form-control>\r\n        <nz-select [attr.id]=\"'type'\" [formControlName]=\"'type'\">\r\n          <nz-option [nzValue]=\"'sub'\" [nzLabel]=\"'sub'\"></nz-option>\r\n          <nz-option [nzValue]=\"'name'\" [nzLabel]=\"'name'\"></nz-option>\r\n          <nz-option [nzValue]=\"'given_name'\" [nzLabel]=\"'given_name'\"></nz-option>\r\n          <nz-option [nzValue]=\"'family_name'\" [nzLabel]=\"'family_name'\"></nz-option>\r\n          <nz-option [nzValue]=\"'middle_name'\" [nzLabel]=\"'middle_name'\"></nz-option>\r\n          <nz-option [nzValue]=\"'nickname'\" [nzLabel]=\"'nickname'\"></nz-option>\r\n          <nz-option [nzValue]=\"'preferred_username'\" [nzLabel]=\"'preferred_username'\"></nz-option>\r\n          <nz-option [nzValue]=\"'profile'\" [nzLabel]=\"'profile'\"></nz-option>\r\n          <nz-option [nzValue]=\"'picture'\" [nzLabel]=\"'picture'\"></nz-option>\r\n          <nz-option [nzValue]=\"'website'\" [nzLabel]=\"'website'\"></nz-option>\r\n          <nz-option [nzValue]=\"'email'\" [nzLabel]=\"'email'\"></nz-option>\r\n          <nz-option [nzValue]=\"'email_verified'\" [nzLabel]=\"'email_verified'\"></nz-option>\r\n          <nz-option [nzValue]=\"'gender'\" [nzLabel]=\"'gender'\"></nz-option>\r\n          <nz-option [nzValue]=\"'birthdate'\" [nzLabel]=\"'birthdate'\"></nz-option>\r\n          <nz-option [nzValue]=\"'zoneinfo'\" [nzLabel]=\"'zoneinfo'\"></nz-option>\r\n          <nz-option [nzValue]=\"'locale'\" [nzLabel]=\"'locale'\"></nz-option>\r\n          <nz-option [nzValue]=\"'phone_number'\" [nzLabel]=\"'phone_number'\"></nz-option>\r\n          <nz-option [nzValue]=\"'phone_number_verified'\" [nzLabel]=\"'phone_number_verified'\"></nz-option>\r\n          <nz-option [nzValue]=\"'address'\" [nzLabel]=\"'address'\"></nz-option>\r\n          <nz-option [nzValue]=\"'updated_at'\" [nzLabel]=\"'updated_at'\"></nz-option>\r\n        </nz-select>\r\n      </nz-form-control>\r\n    </nz-form-item>\r\n\r\n    <nz-form-item>\r\n      <nz-form-label [nzFor]=\"'value'\" [nzRequired]=\"true\">\r\n        {{\r\n          'projects/fe-ng/src/lib/page/identity/clients/update/claim/create/identity--clients--update--claim--create.value'\r\n            | i18n\r\n        }}:\r\n      </nz-form-label>\r\n      <nz-form-control [nzErrorTip]=\"'app.common.required' | i18n\">\r\n        <input nz-input [formControlName]=\"'value'\" [attr.id]=\"'value'\" />\r\n      </nz-form-control>\r\n    </nz-form-item>\r\n\r\n    <button [hidden]=\"true\"></button>\r\n  </form>\r\n\r\n  <div *nzModalFooter>\r\n    <button (click)=\"handleCancel()\" [disabled]=\"claimCreating\" nz-button nzType=\"default\">\r\n      <i nz-icon nzType=\"stop\" nzTheme=\"outline\"></i>\r\n      {{ 'app.common.cancel' | i18n }}\r\n    </button>\r\n\r\n    <button (click)=\"handleOk()\" [disabled]=\"formGroup.invalid\" [nzLoading]=\"claimCreating\" nz-button nzType=\"primary\">\r\n      <i nz-icon nzType=\"check\" nzTheme=\"outline\"></i>\r\n      {{ 'app.common.ok' | i18n }}\r\n    </button>\r\n  </div>\r\n</nz-modal>\r\n"
                }] }
    ];
    /** @nocollapse */
    IdentityClientsUpdateClaimCreateComponent.ctorParameters = function () { return [
        { type: NzMessageService },
        { type: TranslateService }
    ]; };
    IdentityClientsUpdateClaimCreateComponent.propDecorators = {
        visible: [{ type: Input }],
        visibleChange: [{ type: Output }],
        clientId: [{ type: Input }],
        ok: [{ type: Output }]
    };
    return IdentityClientsUpdateClaimCreateComponent;
}());
export { IdentityClientsUpdateClaimCreateComponent };
if (false) {
    /** @type {?} */
    IdentityClientsUpdateClaimCreateComponent.prototype.visible;
    /** @type {?} */
    IdentityClientsUpdateClaimCreateComponent.prototype.visibleChange;
    /** @type {?} */
    IdentityClientsUpdateClaimCreateComponent.prototype.clientId;
    /** @type {?} */
    IdentityClientsUpdateClaimCreateComponent.prototype.ok;
    /** @type {?} */
    IdentityClientsUpdateClaimCreateComponent.prototype.claimCreating;
    /** @type {?} */
    IdentityClientsUpdateClaimCreateComponent.prototype.formGroup;
    /**
     * @type {?}
     * @private
     */
    IdentityClientsUpdateClaimCreateComponent.prototype.nzMessageService;
    /**
     * @type {?}
     * @private
     */
    IdentityClientsUpdateClaimCreateComponent.prototype.translateService;
}
//# sourceMappingURL=data:application/json;base64, 