import { Component, EventEmitter, Input, Output, ViewEncapsulation, } from '@angular/core';
import * as Onfido from 'onfido-sdk-ui';
// https://github.com/onfido/onfido-sdk-ui/tree/8.0.0
// https://documentation.onfido.com/sdk/web/
// https://capacitorjs.com/docs/plugins/android
// https://capacitorjs.com/docs/v2/plugins/android
// https://documentation.onfido.com/sdk/android/#no--4-configure-the-sdk-with-a-token
// https://github.com/rewireltd1/cordova-plugin-onfido/blob/master/src/android/OnfidoActivity.java
// https://blog.theodo.com/2021/07/writing-a-native-ionic-plugin-for-capacitor/
import { registerPlugin } from '@capacitor/core';
import * as i0 from "@angular/core";
import * as i1 from "@ionic/angular";
import * as i2 from "@angular/common";
export const onFidoPlugin = registerPlugin('OnFidoPlugin');
export class OnfidoComponent {
    constructor() {
        this.language = 'es_ES';
        this.steps = [];
        this.disabled = false;
        this.complete = new EventEmitter();
        this.error = new EventEmitter();
        this.userExitCode = new EventEmitter();
        this.response = new EventEmitter();
        this.onPreviousStep = new EventEmitter();
        this.step = 'intro';
        this._onfidoContainer = 'onfido-container';
    }
    ngOnInit() {
        this._initOnfido();
    }
    ngOnDestroy() {
        this._destroyOnfido();
    }
    ngOnChanges(changes) {
        if (changes && changes.token) {
            this._destroyOnfido();
            this._initOnfido();
        }
    }
    initOnfido() {
        this.step = 'onfido';
        this._destroyOnfido();
        setTimeout(() => {
            this._initOnfido();
        }, 0);
    }
    async _initOnfido() {
        if (this.token && this.step === 'onfido') {
            // if (Capacitor.getPlatform() === 'android') {
            //   await onFidoPlugin.init({ token: this.token });
            // } else {
            this._onfido = Onfido.init({
                token: this.token,
                language: this.language,
                containerId: this._onfidoContainer,
                steps: [
                    // 'welcome',
                    ...this.steps.map((type) => {
                        if (type === 'document') {
                            return {
                                type: 'document',
                                options: {
                                    documentTypes: {
                                        passport: true,
                                        // residence_permit: true,
                                        // driving_licence: true,
                                        national_identity_card: true,
                                    },
                                },
                            };
                        }
                        else {
                            return type;
                        }
                    }),
                    // 'complete'
                ],
                customUI: {
                    // Typography options.
                    fontFamilyTitle: 'Montserrat, serif',
                    fontFamilySubtitle: 'Montserrat, serif',
                    fontFamilyBody: 'Montserrat, serif',
                    // fontSizeTitle: null,
                    // fontSizeSubtitle: null,
                    // fontSizeBody: null,
                    // fontWeightTitle: null,
                    // fontWeightSubtitle: null,
                    // fontWeightBody: null,
                    colorContentTitle: '#274156',
                    colorContentSubtitle: '#274156',
                    colorContentBody: '#274156',
                    // Modal (sdk main container)
                    colorBackgroundSurfaceModal: 'transparent',
                    colorBorderSurfaceModal: 'transparent',
                    borderWidthSurfaceModal: 'transparent',
                    borderStyleSurfaceModal: 'transparent',
                    borderRadiusSurfaceModal: 'transparent',
                    // Primary buttons.
                    colorContentButtonPrimaryText: 'white',
                    colorBackgroundButtonPrimary: '#19D7DB',
                    colorBackgroundButtonPrimaryHover: 'rgba(25,215,219,0.8)',
                    colorBackgroundButtonPrimaryActive: 'rgba(25,215,219,0.8)',
                    colorBorderButtonPrimary: 'transparent',
                    // Secondary buttons.
                    colorContentButtonSecondaryText: 'white',
                    colorBackgroundButtonSecondary: '#274156',
                    colorBackgroundButtonSecondaryHover: 'rgba(39,65,86,0.8)',
                    colorBackgroundButtonSecondaryActive: 'rgba(39,65,86,0.8)',
                    colorBorderButtonSecondary: 'transparent',
                    // Document type buttons.
                    // colorContentDocTypeButton: null,
                    colorBackgroundDocTypeButton: '#e9e9e9',
                    colorBorderDocTypeButton: '#274156',
                    colorBorderDocTypeButtonHover: '#4cdb9a',
                    colorBorderDocTypeButtonActive: '#4cdb9a',
                    // Icon background option.
                    colorBackgroundIcon: '#274156',
                    // Shared button options.
                    borderRadiusButton: '8px',
                    buttonGroupStacked: true,
                    // Links.
                    // colorContentLinkTextHover: null,
                    // colorBorderLinkUnderline: null,
                    // colorBackgroundLinkHover: null,
                    // colorBackgroundLinkActive: null,
                    // Warning popups.
                    // colorContentAlertInfo: null,
                    // colorBackgroundAlertInfo: null,
                    // colorContentAlertInfoLinkHover: null,
                    // colorContentAlertInfoLinkActive: null,
                    // Error popups.
                    // colorContentAlertError: null,
                    // colorBackgroundAlertError: null,
                    // colorContentAlertErrorLinkHover: null,
                    // colorContentAlertErrorLinkActive: null,
                    // Info header/highlight pills.
                    // colorBackgroundInfoPill: null,
                    // colorContentInfoPill: null,
                    // Icon buttons.
                    // colorBackgroundButtonIconHover: null,
                    // colorBackgroundButtonIconActive: null,
                    // Camera shutter button.
                    // colorBackgroundButtonCameraHover: null,
                    // colorBackgroundButtonCameraActive: null,
                },
                onComplete: (data) => {
                    this.step = 'final';
                    this.complete.emit({ identifyVerified: data });
                    this._response = { identifyVerified: data };
                },
                onError: (error) => this.error.emit(error),
                onUserExit: (userExitCode) => this.userExitCode.emit(userExitCode),
            });
            // }
        }
    }
    async _destroyOnfido() {
        if (this._onfido) {
            this._onfido.tearDown();
        }
    }
    onResponse() {
        this.response.emit(this._response);
    }
}
OnfidoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OnfidoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
OnfidoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: OnfidoComponent, selector: "app-onfido", inputs: { token: "token", language: "language", steps: "steps", disabled: "disabled" }, outputs: { complete: "complete", error: "error", userExitCode: "userExitCode", response: "response", onPreviousStep: "onPreviousStep" }, usesOnChanges: true, ngImport: i0, template: "<div *ngIf=\"step==='intro'\" class=\"onfido-content\">\r\n  <div class=\"btn-back-container\">\r\n    <ion-icon name=\"arrow-back-outline\" class=\"dd-float-icon\" (click)=\"onPreviousStep.next()\"></ion-icon>\r\n    <p>atr\u00E1s</p>\r\n  </div>\r\n  <div class=\"ion-padding\">\r\n    <div class=\"ion-text-center\">\r\n      <h1 class=\"ion-margin-top onfido-title\">\u00A1Ya casi est\u00E1 todo listo!</h1>\r\n      <p class=\"ion-margin-top ion-text-justify\">Ahora tenemos que asegurarnos de que eres t\u00FA del otro lado.</p>\r\n      <p class=\"ion-margin-top ion-text-justify\"><strong>Para eso necesitamos algunas cosas:</strong></p>\r\n      <ol class=\"ion-margin-top\">\r\n        <li class=\"ion-margin-top\">Una foto frontal del documento de identidad.</li>\r\n        <li class=\"ion-margin-top\">Una foto del reverso del documento.</li>\r\n      </ol>\r\n      <img class=\"onfido-image-intro\" src=\"assets/onfido/intro.png\" alt=\"onfido-intro\">\r\n    </div>\r\n    <button class=\"fortesza-btn fortesza-btn-block ion-margin-top\" (click)=\"initOnfido()\" [disabled]=\"disabled\">\r\n      Continuar\r\n    </button>\r\n  </div>\r\n</div>\r\n\r\n<div *ngIf=\"step==='onfido'\" id=\"onfido-container\"></div>\r\n\r\n<div *ngIf=\"step==='final'\" class=\"onfido-content\">\r\n  <div class=\"ion-padding\">\r\n    <div class=\"ion-text-center\">\r\n      <h1 class=\"ion-margin-top onfido-title\">\u00A1Verificaci\u00F3n completada!</h1>\r\n      <p class=\"ion-margin-top ion-text-justify\">Ahora ya tenemos tus datos y ser\u00E1n verificados en un plazo de 24 a 48 horas, puedes continuar de finalizar el formulario.</p>\r\n      <img class=\"onfido-image-intro\" src=\"assets/onfido/intro.png\" alt=\"onfido-intro\">\r\n    </div>\r\n    <button class=\"fortesza-btn fortesza-btn-block ion-margin-top\" (click)=\"onResponse()\" [disabled]=\"disabled\">\r\n      Finalizar\r\n    </button>\r\n  </div>\r\n</div>\r\n", styles: ["app-onfido{overflow:auto}app-onfido .btn-back-container{display:flex;align-items:center;justify-content:flex-start}app-onfido .btn-back-container .dd-float-icon{font-size:20px;color:#203a4e;cursor:pointer;margin-right:.5rem}app-onfido .btn-back-container p{font-size:12px;margin:0}app-onfido *{outline:none}app-onfido .onfido-content{max-width:32em;margin:0 auto;height:100%;padding-top:2rem;padding-bottom:2rem}app-onfido .onfido-content>.ion-padding{display:flex;flex-direction:column;justify-content:space-between;height:100%;overflow-y:auto}app-onfido .onfido-content .onfido-title{font-size:30px;line-height:1.34;color:#274156;font-weight:600;margin-bottom:1rem}app-onfido .onfido-content .onfido-image-intro{max-width:100%;margin:2rem}app-onfido a.onfido-sdk-ui-Theme-link{border-radius:8px;padding:11px 23px;text-transform:uppercase;font-weight:700;color:#fff!important;height:auto;background-color:#19d7db;border:0;line-height:1.5rem;box-shadow:0 0 20px -8px #19d7db!important}app-onfido a.onfido-sdk-ui-Theme-link:hover{background-color:#19d7dbcc!important}app-onfido a.onfido-sdk-ui-Theme-link:before{display:none}app-onfido p{color:#274156;font-size:16px}app-onfido button{border-radius:8px!important}app-onfido button.ods-button{text-transform:uppercase;font-weight:700;border:0;box-shadow:0 0 20px -8px #19d7db!important}app-onfido button.ods-button.-action--secondary{background:transparent;border:1px solid #284156;color:#284156}app-onfido button.ods-button.-action--secondary:hover{color:#fff!important}app-onfido button.fortesza-btn,app-onfido button.onfido-sdk-ui-Theme-textButton,app-onfido button.onfido-sdk-ui-Theme-link{padding:11px 23px;text-transform:uppercase;font-weight:700;color:#fff!important;height:auto;background-color:#19d7db;border:0;line-height:1.5rem;box-shadow:0 0 20px -8px #19d7db!important}app-onfido button.fortesza-btn:hover,app-onfido button.onfido-sdk-ui-Theme-textButton:hover,app-onfido button.onfido-sdk-ui-Theme-link:hover{background-color:#19d7dbcc!important}app-onfido button.onfido-sdk-ui-Theme-button-centered{margin-bottom:1rem}app-onfido button.fortesza-btn-block{width:100%}app-onfido button.-action--secondary{box-shadow:none!important}app-onfido button:disabled{box-shadow:none!important;opacity:.5;background-color:#19d7db!important}app-onfido button:disabled:hover{opacity:.5;background-color:#19d7db!important}app-onfido ol{color:#274156;font-size:16px;text-align:left}app-onfido ol li::marker{color:#19d7db;font-weight:900}app-onfido .onfido-sdk-ui-Theme-header{background-color:#274156}app-onfido .onfido-sdk-ui-NavigationBar-label{visibility:visible}app-onfido .onfido-sdk-ui-DocumentSelector-option{margin-bottom:1rem;box-shadow:none!important;border:0!important}app-onfido .onfido-sdk-ui-DocumentSelector-option:hover{background-color:#4cdb9a;border-color:#4cdb9a}app-onfido .onfido-sdk-ui-DocumentSelector-option:hover p,app-onfido .onfido-sdk-ui-DocumentSelector-option:hover div{color:#fff}app-onfido .onfido-sdk-ui-Welcome-instructions>ol li::marker{color:#19d7db;font-weight:900}app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-linkContainer,app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-inputContainer{display:flex;align-items:center}app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-numberInputSection,app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-btn{height:4rem;border-bottom-left-radius:0!important;border-top-left-radius:0!important}app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-actionContainer:before,app-onfido .onfido-sdk-ui-QRCode-qrCodeHelpIcon,app-onfido .onfido-sdk-ui-Theme-footer{display:none!important}app-onfido .onfido-sdk-ui-CountrySelector-dropdownIcon{top:.6em}app-onfido .onfido-sdk-ui-ProofOfAddress-PoAIntro-requirement:before{background-color:#19d7db}app-onfido .onfido-sdk-ui-Modal-inner{height:100%;inset:0;position:absolute;padding-top:2rem;padding-bottom:2rem}@media (max-width: 479px){app-onfido .onfido-sdk-ui-Theme-iconContainer .onfido-sdk-ui-Theme-icon{filter:invert(91%) sepia(71%) saturate(2652%) hue-rotate(121deg) brightness(87%) contrast(96%)}}\n"], components: [{ type: i1.IonIcon, selector: "ion-icon", inputs: ["color", "flipRtl", "icon", "ios", "lazy", "md", "mode", "name", "sanitize", "size", "src"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], encapsulation: i0.ViewEncapsulation.None });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: OnfidoComponent, decorators: [{
            type: Component,
            args: [{ selector: 'app-onfido', encapsulation: ViewEncapsulation.None, template: "<div *ngIf=\"step==='intro'\" class=\"onfido-content\">\r\n  <div class=\"btn-back-container\">\r\n    <ion-icon name=\"arrow-back-outline\" class=\"dd-float-icon\" (click)=\"onPreviousStep.next()\"></ion-icon>\r\n    <p>atr\u00E1s</p>\r\n  </div>\r\n  <div class=\"ion-padding\">\r\n    <div class=\"ion-text-center\">\r\n      <h1 class=\"ion-margin-top onfido-title\">\u00A1Ya casi est\u00E1 todo listo!</h1>\r\n      <p class=\"ion-margin-top ion-text-justify\">Ahora tenemos que asegurarnos de que eres t\u00FA del otro lado.</p>\r\n      <p class=\"ion-margin-top ion-text-justify\"><strong>Para eso necesitamos algunas cosas:</strong></p>\r\n      <ol class=\"ion-margin-top\">\r\n        <li class=\"ion-margin-top\">Una foto frontal del documento de identidad.</li>\r\n        <li class=\"ion-margin-top\">Una foto del reverso del documento.</li>\r\n      </ol>\r\n      <img class=\"onfido-image-intro\" src=\"assets/onfido/intro.png\" alt=\"onfido-intro\">\r\n    </div>\r\n    <button class=\"fortesza-btn fortesza-btn-block ion-margin-top\" (click)=\"initOnfido()\" [disabled]=\"disabled\">\r\n      Continuar\r\n    </button>\r\n  </div>\r\n</div>\r\n\r\n<div *ngIf=\"step==='onfido'\" id=\"onfido-container\"></div>\r\n\r\n<div *ngIf=\"step==='final'\" class=\"onfido-content\">\r\n  <div class=\"ion-padding\">\r\n    <div class=\"ion-text-center\">\r\n      <h1 class=\"ion-margin-top onfido-title\">\u00A1Verificaci\u00F3n completada!</h1>\r\n      <p class=\"ion-margin-top ion-text-justify\">Ahora ya tenemos tus datos y ser\u00E1n verificados en un plazo de 24 a 48 horas, puedes continuar de finalizar el formulario.</p>\r\n      <img class=\"onfido-image-intro\" src=\"assets/onfido/intro.png\" alt=\"onfido-intro\">\r\n    </div>\r\n    <button class=\"fortesza-btn fortesza-btn-block ion-margin-top\" (click)=\"onResponse()\" [disabled]=\"disabled\">\r\n      Finalizar\r\n    </button>\r\n  </div>\r\n</div>\r\n", styles: ["app-onfido{overflow:auto}app-onfido .btn-back-container{display:flex;align-items:center;justify-content:flex-start}app-onfido .btn-back-container .dd-float-icon{font-size:20px;color:#203a4e;cursor:pointer;margin-right:.5rem}app-onfido .btn-back-container p{font-size:12px;margin:0}app-onfido *{outline:none}app-onfido .onfido-content{max-width:32em;margin:0 auto;height:100%;padding-top:2rem;padding-bottom:2rem}app-onfido .onfido-content>.ion-padding{display:flex;flex-direction:column;justify-content:space-between;height:100%;overflow-y:auto}app-onfido .onfido-content .onfido-title{font-size:30px;line-height:1.34;color:#274156;font-weight:600;margin-bottom:1rem}app-onfido .onfido-content .onfido-image-intro{max-width:100%;margin:2rem}app-onfido a.onfido-sdk-ui-Theme-link{border-radius:8px;padding:11px 23px;text-transform:uppercase;font-weight:700;color:#fff!important;height:auto;background-color:#19d7db;border:0;line-height:1.5rem;box-shadow:0 0 20px -8px #19d7db!important}app-onfido a.onfido-sdk-ui-Theme-link:hover{background-color:#19d7dbcc!important}app-onfido a.onfido-sdk-ui-Theme-link:before{display:none}app-onfido p{color:#274156;font-size:16px}app-onfido button{border-radius:8px!important}app-onfido button.ods-button{text-transform:uppercase;font-weight:700;border:0;box-shadow:0 0 20px -8px #19d7db!important}app-onfido button.ods-button.-action--secondary{background:transparent;border:1px solid #284156;color:#284156}app-onfido button.ods-button.-action--secondary:hover{color:#fff!important}app-onfido button.fortesza-btn,app-onfido button.onfido-sdk-ui-Theme-textButton,app-onfido button.onfido-sdk-ui-Theme-link{padding:11px 23px;text-transform:uppercase;font-weight:700;color:#fff!important;height:auto;background-color:#19d7db;border:0;line-height:1.5rem;box-shadow:0 0 20px -8px #19d7db!important}app-onfido button.fortesza-btn:hover,app-onfido button.onfido-sdk-ui-Theme-textButton:hover,app-onfido button.onfido-sdk-ui-Theme-link:hover{background-color:#19d7dbcc!important}app-onfido button.onfido-sdk-ui-Theme-button-centered{margin-bottom:1rem}app-onfido button.fortesza-btn-block{width:100%}app-onfido button.-action--secondary{box-shadow:none!important}app-onfido button:disabled{box-shadow:none!important;opacity:.5;background-color:#19d7db!important}app-onfido button:disabled:hover{opacity:.5;background-color:#19d7db!important}app-onfido ol{color:#274156;font-size:16px;text-align:left}app-onfido ol li::marker{color:#19d7db;font-weight:900}app-onfido .onfido-sdk-ui-Theme-header{background-color:#274156}app-onfido .onfido-sdk-ui-NavigationBar-label{visibility:visible}app-onfido .onfido-sdk-ui-DocumentSelector-option{margin-bottom:1rem;box-shadow:none!important;border:0!important}app-onfido .onfido-sdk-ui-DocumentSelector-option:hover{background-color:#4cdb9a;border-color:#4cdb9a}app-onfido .onfido-sdk-ui-DocumentSelector-option:hover p,app-onfido .onfido-sdk-ui-DocumentSelector-option:hover div{color:#fff}app-onfido .onfido-sdk-ui-Welcome-instructions>ol li::marker{color:#19d7db;font-weight:900}app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-linkContainer,app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-inputContainer{display:flex;align-items:center}app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-numberInputSection,app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-btn{height:4rem;border-bottom-left-radius:0!important;border-top-left-radius:0!important}app-onfido .onfido-sdk-ui-crossDevice-CrossDeviceLink-actionContainer:before,app-onfido .onfido-sdk-ui-QRCode-qrCodeHelpIcon,app-onfido .onfido-sdk-ui-Theme-footer{display:none!important}app-onfido .onfido-sdk-ui-CountrySelector-dropdownIcon{top:.6em}app-onfido .onfido-sdk-ui-ProofOfAddress-PoAIntro-requirement:before{background-color:#19d7db}app-onfido .onfido-sdk-ui-Modal-inner{height:100%;inset:0;position:absolute;padding-top:2rem;padding-bottom:2rem}@media (max-width: 479px){app-onfido .onfido-sdk-ui-Theme-iconContainer .onfido-sdk-ui-Theme-icon{filter:invert(91%) sepia(71%) saturate(2652%) hue-rotate(121deg) brightness(87%) contrast(96%)}}\n"] }]
        }], propDecorators: { token: [{
                type: Input
            }], language: [{
                type: Input
            }], steps: [{
                type: Input
            }], disabled: [{
                type: Input
            }], complete: [{
                type: Output
            }], error: [{
                type: Output
            }], userExitCode: [{
                type: Output
            }], response: [{
                type: Output
            }], onPreviousStep: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 