import * as i0 from '@angular/core';
import { Optional, Inject, Injectable, signal } from '@angular/core';
import { JaceIdentity, USE_FAKE_ACCESS_TOKEN, ANONYMOUS_MODE, ActiveModuleView, UpdateProfilePictureDto, UpdateAccountRecoverySettingsDto, UpdatePasswordDto } from '@esfaenza/core/domain';
import * as i1 from 'ngx-cookie-service';
import { of, Subject, firstValueFrom, filter, forkJoin } from 'rxjs';
import * as i2 from '@angular/common/http';
import { HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http';
import * as i1$1 from '@angular/router';
import { Router } from '@angular/router';
import * as i5 from '@esfaenza/extensions';
import { MessageService, InboundMessageTypes, CallResult } from '@esfaenza/extensions';
import * as i1$2 from '@esfaenza/localizations';
import { LocalizationService } from '@esfaenza/localizations';
import { HTTPService } from '@esfaenza/httpservice';
import * as i4 from '@esfaenza/preferences';
import { CachePersistor, PreferencesPersistor } from '@esfaenza/preferences';
import * as i4$1 from '@esfaenza/signalr-notifications';
import * as i5$1 from '@esfaenza/access-control';
import { AccessControlRouteGuard } from '@esfaenza/access-control';
import { catchError, map, mergeMap } from 'rxjs/operators';
import { DomSanitizer } from '@angular/platform-browser';

// Angular
class TokenService {
    constructor(cs, USE_FAKE_ACCESS_TOKEN, ANONYMOUS_MODE) {
        this.cs = cs;
        this.USE_FAKE_ACCESS_TOKEN = USE_FAKE_ACCESS_TOKEN;
        this.ANONYMOUS_MODE = ANONYMOUS_MODE;
        if (this.USE_FAKE_ACCESS_TOKEN)
            this.accountScope = this.getFakeAccountScope();
    }
    clearTokens() {
        this.cs.delete("access_token");
    }
    getAccessToken() {
        if (this.ANONYMOUS_MODE)
            return "";
        return this.USE_FAKE_ACCESS_TOKEN ? this.getFakeToken() : this.cs.get("accessToken");
    }
    getJaceIdentity() {
        if (this.ANONYMOUS_MODE)
            return null;
        let token = this.USE_FAKE_ACCESS_TOKEN ? this.getFakeToken() : this.cs.get("accessToken");
        if (!token)
            return null;
        let base64Url = token.split(".")[1];
        let base64 = base64Url.replace("-", "+").replace("_", "/");
        let tokenData = JSON.parse(decodeURIComponent(window.atob(base64).split("").map(c => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("")));
        let identity = new JaceIdentity(this.accountScope);
        identity.IdActor = tokenData.ACTORID;
        identity.IdActorRole = tokenData.ACTORROLEID;
        identity.IdAccount = tokenData.ACCOUNTID;
        identity.IdUser = tokenData.USERID;
        identity.DsUser = tokenData.USERNAME;
        identity.FullName = tokenData.USERDESCRIPTION;
        identity.Idtenant = tokenData.TENANT;
        identity.TenantName = tokenData.TENANTNAME;
        identity.ExpirationTime = new Date(tokenData.exp * 1000); //unix-epoch in secondi -> millisecondi
        return identity;
    }
    //Accesstoken fittizio ma valido, per simulare la connession corretta col backend
    getFakeToken() {
        /*  Il Token generato è il seguente:

            {
            "nbf": 1590415846,
            "exp": 1990420065,
            "iss": "http://authapi.jace.energysoftware.priv",
            "aud": [ "http://authapi.jace.energysoftware.priv/resources", "authentication" ],
            "client_id": "application",
            "sub": "1003",
            "auth_time": 1590415846,
            "idp": "local",
            "ACCOUNTID": "1003",
            "USERID": "259",
            "USERDESCRIPTION": "Test User",
            "USERNAME": "TEST",
            "TENANT": "FX",
            "TENANTNAME": "Fenix Srl",
            "jti": "0e5307561606e444e2885b11a3144421",
            "scope": [ "auth", "offline_access" ],
            "amr": ["password" ],
            "iat": 1590416465
            }
        */
        return "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYmYiOjE1OTA0MTU4NDYsImV4cCI6MTk5MDQyMDA2NSwiaXNzIjoiaHR0cDovL2F1dGhhcGlzdGFnaW5nYS5qYWNlLmVuZXJneXNvZnR3YXJlLnByaXYiLCJhdWQiOlsiaHR0cDovL2F1dGhhcGlzdGFnaW5nYS5qYWNlLmVuZXJneXNvZnR3YXJlLnByaXYvcmVzb3VyY2VzIiwiYXV0aGVudGljYXRpbyJdLCJjbGllbnRfaWQiOiJtZXRlcmluZ3N0YWdpbmciLCJzdWIiOiIxMDAzIiwiYXV0aF90aW1lIjoxNTkwNDE1ODQ2LCJpZHAiOiJsb2NhbCIsIkFDQ09VTlRJRCI6IjEwMDMiLCJVU0VSSUQiOiIyNTkiLCJVU0VSREVTQ1JJUFRJT04iOiJUZXN0IFVzZXIiLCJVU0VSTkFNRSI6IlRFU1QiLCJURU5BTlQiOiJGWCIsIlRFTkFOVE5BTUUiOiJGZW5peCBTcmwiLCJqdGkiOiIwZTUzMDc1NjE2MDZlNDQ0ZTI4ODViMTFhMzE0NDQyMSIsInNjb3BlIjpbImF1dGgiLCJvZmZsaW5lX2FjY2VzcyJdLCJhbXIiOlsicGFzc3dvcmQiXSwiaWF0IjoxNTkwNDE2NDY1fQ.aev_Txa9tIaEZvZ_KWDqb2Ob95Nf-3rqsNyJX4BPKXE";
    }
    getFakeAccountScope() {
        let accountScope = {
            "modules": [
                {
                    "idmodule": 36,
                    "dsname": "Auth",
                    "dscategory": "Infrastructure",
                    "idmodulealt": "auth"
                },
                {
                    "idmodule": 14,
                    "dsname": "Compliance Dati Catastali",
                    "dscategory": "Compliance",
                    "idmodulealt": "complianceade"
                },
                {
                    "idmodule": 2,
                    "dsname": "Forecasting & Metering",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "mdm"
                },
                {
                    "idmodule": 48,
                    "dsname": "Sales Management",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "sales"
                },
                {
                    "idmodule": 42,
                    "dsname": "SII Connector",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "sii"
                },
                {
                    "idmodule": 5,
                    "dsname": "Billing",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "billing"
                },
                {
                    "idmodule": 7,
                    "dsname": "Cost checking & Reconciliation",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "ccr"
                },
                {
                    "idmodule": 8,
                    "dsname": "Compliance REMIT",
                    "dscategory": "Compliance",
                    "idmodulealt": "remit"
                },
                {
                    "idmodule": 51,
                    "dsname": "CRM",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "crm"
                },
                {
                    "idmodule": 11,
                    "dsname": "Compliance ARERA",
                    "dscategory": "Compliance",
                    "idmodulealt": "compliance"
                },
                {
                    "idmodule": 54,
                    "dsname": "Partner Portal",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "pp"
                },
                {
                    "idmodule": 35,
                    "dsname": "Scheduler",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "scheduler"
                },
                {
                    "idmodule": 34,
                    "dsname": "Jace Dashboard",
                    "dscategory": "Infrastructure",
                    "idmodulealt": "jace"
                },
                {
                    "idmodule": 1,
                    "dsname": "Market Data",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "marketdata"
                },
                {
                    "idmodule": 31,
                    "dsname": "Toolset",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "toolset"
                },
                {
                    "idmodule": 32,
                    "dsname": "Customer Portal Admin",
                    "dscategory": "Administration",
                    "idmodulealt": "customerportal"
                },
                {
                    "idmodule": 10,
                    "dsname": "Compliance Dogane",
                    "dscategory": "Compliance",
                    "idmodulealt": "dogane"
                },
                {
                    "idmodule": 40,
                    "dsname": "Data Manager",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "dmg"
                },
                {
                    "idmodule": 12,
                    "dsname": "Credit Management",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "credit"
                },
                {
                    "idmodule": 52,
                    "dsname": "Business Process Manager",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "BPM"
                },
                {
                    "idmodule": 46,
                    "dsname": "Logistic",
                    "dscategory": "Data Treatment",
                    "idmodulealt": "lgs"
                }
            ],
            "roles": [
                {
                    "idrole": 1,
                    "idrolealt": "Tenant Admin",
                    "dsrole": "Tenant Admin",
                    "dsnote": "Per generici permessi di amministrazione/configurazione di un modulo: Es. Billi",
                    "idparent": 0,
                    "sydatains": new Date("2018-05-02T11:03:35+02:00"),
                    "syuserins": "AUTH"
                },
                {
                    "idrole": 9,
                    "idrolealt": "Tenant Reader",
                    "dsrole": "Tenant Reader",
                    "dsnote": "Per generico permesso di lettura su tutti i moduli abilitati del Tenant",
                    "idparent": 0,
                    "sydatains": new Date("2018-07-23T16:13:38+02:00"),
                    "syuserins": "FRANCEM",
                    "sydataupd": new Date("2018-12-03T19:42:41+01:00"),
                    "syuserupd": "FRANCEM"
                },
                {
                    "idrole": 11,
                    "idrolealt": "Compl. ARERA Reader",
                    "dsrole": "Compl. ARERA Reader",
                    "dsnote": "Permesso di lettura al solo modulo Compl. ARERA",
                    "idparent": 0,
                    "sydatains": new Date("2018-07-23T16:22:56+02:00"),
                    "syuserins": "FRANCEM"
                },
                {
                    "idrole": 13,
                    "idrolealt": "Compl. ARERA Writer L1",
                    "dsrole": "Compl. ARERA Writer L1",
                    "dsnote": "Responsabile business del modulo Compl. ARERA: può chiudere indagini",
                    "idparent": 0,
                    "sydatains": new Date("2018-07-23T16:23:15+02:00"),
                    "syuserins": "FRANCEM"
                },
                {
                    "idrole": 15,
                    "idrolealt": "Compl. ARERA Writer L2",
                    "dsrole": "Compl. ARERA Writer L2",
                    "dsnote": "Operatore business del modulo Compl. ARERA: può elaborare, ma non chiudere indagini",
                    "idparent": 0,
                    "sydatains": new Date("2018-07-23T16:23:27+02:00"),
                    "syuserins": "FRANCEM"
                },
                {
                    "idrole": 28,
                    "idrolealt": "Jace Admin",
                    "dsrole": "Jace Admin",
                    "dsnote": "Amministratore generico per l'intera suite.",
                    "idparent": 0,
                    "sydatains": new Date("2018-07-25T17:20:41+02:00"),
                    "syuserins": "RIVOLAM"
                },
                {
                    "idrole": 88,
                    "idrolealt": "Metering: Reader",
                    "dsrole": "Metering: Reader",
                    "dsnote": "Sola lettura",
                    "idparent": 0,
                    "sydatains": new Date("2019-04-30T12:29:12+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 89,
                    "idrolealt": "Metering: Writer L1",
                    "dsrole": "Metering: Writer L1",
                    "dsnote": "Gestione entità semplici",
                    "idparent": 0,
                    "sydatains": new Date("2019-04-30T12:29:17+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 90,
                    "idrolealt": "Metering: Writer L2",
                    "dsrole": "Metering: Writer L2",
                    "dsnote": "Gestione entità complesse",
                    "idparent": 0,
                    "sydatains": new Date("2019-04-30T12:29:21+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 91,
                    "idrolealt": "Metering: Admin",
                    "dsrole": "Metering: Admin",
                    "dsnote": "Customizzazione",
                    "idparent": 0,
                    "sydatains": new Date("2019-04-30T12:29:29+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 269,
                    "idrolealt": "dgn_op",
                    "dsrole": "Dogane Operator",
                    "dsnote": "Consente di fare operazioni come ad esempio generare un pagamento massivo, una comunicazione massiva o modificare le posizioni / comunicaizoni",
                    "idparent": 0,
                    "sydatains": new Date("2020-07-01T12:31:32+02:00"),
                    "syuserins": "RONDINC"
                },
                {
                    "idrole": 349,
                    "idrolealt": "cost_admin",
                    "dsrole": "Costchecking Writer L2",
                    "dsnote": "Ruolo di admin per il costchecking che consente di utilizzare qualunque funzionalità del modulo",
                    "idparent": 0,
                    "sydatains": new Date("2020-11-17T09:44:48+01:00"),
                    "syuserins": "RONDINC"
                },
                {
                    "idrole": 370,
                    "idrolealt": "toolset_reader",
                    "dsrole": "Toolset Reader",
                    "idparent": 0,
                    "sydatains": new Date("2020-11-24T10:48:33+01:00"),
                    "syuserins": "RONDINC"
                },
                {
                    "idrole": 489,
                    "idrolealt": "lgs_read",
                    "dsrole": "Logistica Reader",
                    "idparent": 0,
                    "sydatains": new Date("2021-03-30T16:50:54+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 491,
                    "idrolealt": "lgs_md_write",
                    "dsrole": "Logistica Writer Ana",
                    "idparent": 0,
                    "sydatains": new Date("2021-03-30T16:51:09+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 492,
                    "idrolealt": "lgs_eap_write",
                    "dsrole": "Logistica Writer Aggr",
                    "idparent": 0,
                    "sydatains": new Date("2021-03-30T16:52:46+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 493,
                    "idrolealt": "lgs_pce",
                    "dsrole": "Logistica Writer PCE",
                    "idparent": 0,
                    "sydatains": new Date("2021-03-30T16:53:09+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 494,
                    "idrolealt": "lgs_ipex",
                    "dsrole": "Logistica Writer IPEX",
                    "idparent": 0,
                    "sydatains": new Date("2021-03-30T16:53:18+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 495,
                    "idrolealt": "lgs_invauth",
                    "dsrole": "Logistica Writer Benestari GME",
                    "idparent": 0,
                    "sydatains": new Date("2021-03-30T16:53:30+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 496,
                    "idrolealt": "lgs_terna",
                    "dsrole": "Logistica Writer Settlement Terna",
                    "idparent": 0,
                    "sydatains": new Date("2021-03-30T16:53:44+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 497,
                    "idrolealt": "lgs_writer_full",
                    "dsrole": "Logistica Full Writer",
                    "idparent": 0,
                    "sydatains": new Date("2021-03-30T16:53:56+02:00"),
                    "syuserins": "FERNIAA"
                },
                {
                    "idrole": 688,
                    "idrolealt": "blg_business",
                    "dsrole": "Billing Business",
                    "idparent": 0,
                    "sydatains": new Date("2022-09-20T09:26:42+02:00"),
                    "syuserins": "RONDINC"
                },
                {
                    "idrole": 708,
                    "idrolealt": "cus_admin",
                    "dsrole": "CustomerPortal Admin",
                    "dsnote": "Amministrazione utenti CustomerPortal",
                    "idparent": 0,
                    "sydatains": new Date("2022-11-16T10:17:01+01:00"),
                    "syuserins": "TURCHII"
                },
                {
                    "idrole": 808,
                    "idrolealt": "crm_fo_rd",
                    "dsrole": "CRM FrontOffice Reader",
                    "idparent": 0,
                    "sydatains": new Date("2023-07-19T13:18:34+02:00"),
                    "syuserins": "GHETTIE"
                },
                {
                    "idrole": 809,
                    "idrolealt": "crm_bo_rd",
                    "dsrole": "CRM BackOffice Reader",
                    "idparent": 0,
                    "sydatains": new Date("2023-07-19T13:18:45+02:00"),
                    "syuserins": "GHETTIE"
                },
                {
                    "idrole": 810,
                    "idrolealt": "crm_bo_wr_l1",
                    "dsrole": "CRM BackOffice Writer L1",
                    "idparent": 0,
                    "sydatains": new Date("2023-07-19T13:18:52+02:00"),
                    "syuserins": "GHETTIE"
                },
                {
                    "idrole": 811,
                    "idrolealt": "crm_bo_wr_l2",
                    "dsrole": "CRM BackOffice Writer L2",
                    "idparent": 0,
                    "sydatains": new Date("2023-07-19T13:18:59+02:00"),
                    "syuserins": "GHETTIE"
                },
                {
                    "idrole": 812,
                    "idrolealt": "crm_fo_wr_l1",
                    "dsrole": "CRM FrontOffice Writer L1",
                    "idparent": 0,
                    "sydatains": new Date("2023-07-19T13:19:04+02:00"),
                    "syuserins": "GHETTIE"
                },
                {
                    "idrole": 813,
                    "idrolealt": "crm_fo_wr_l2",
                    "dsrole": "CRM FrontOffice Writer L2",
                    "idparent": 0,
                    "sydatains": new Date("2023-07-19T13:19:09+02:00"),
                    "syuserins": "GHETTIE"
                }
            ],
            "permissions": [
                {
                    "idpermission": 51,
                    "dspermission": "Operazioni massive forecasting su metering",
                    "idpermissionalt": "mdm_mass_fct",
                    "sydatains": null
                },
                {
                    "idpermission": 134,
                    "dspermission": "Dogane apri / chiudi posizioni",
                    "idpermissionalt": "dgn_pos_op",
                    "sydatains": null
                },
                {
                    "idpermission": 211,
                    "dspermission": "Scarico dati sistemi AMI metering",
                    "idpermissionalt": "mdm_ami_dl",
                    "sydatains": null
                },
                {
                    "idpermission": 271,
                    "dspermission": "Dogane Elimina Importazione",
                    "idpermissionalt": "dgn_flow_delete",
                    "sydatains": null
                },
                {
                    "idpermission": 131,
                    "dspermission": "Dogane Read",
                    "idpermissionalt": "dgn_read",
                    "sydatains": null
                },
                {
                    "idpermission": 133,
                    "dspermission": "Dogane operazioni su rate e pagamenti ",
                    "idpermissionalt": "dgn_payments_op",
                    "sydatains": null
                },
                {
                    "idpermission": 291,
                    "dspermission": "Logistica - modifica dati anagrafica",
                    "idpermissionalt": "lgs_md_write",
                    "sydatains": null
                },
                {
                    "idpermission": 292,
                    "dspermission": "Logistica - lettura dati PCE",
                    "idpermissionalt": "lgs_pce_read",
                    "sydatains": null
                },
                {
                    "idpermission": 293,
                    "dspermission": "Logistica - scrittura dati PCE",
                    "idpermissionalt": "lgs_pce_write",
                    "sydatains": null
                },
                {
                    "idpermission": 294,
                    "dspermission": "Logistica - lettura dati IPEX",
                    "idpermissionalt": "lgs_ipex_read",
                    "sydatains": null
                },
                {
                    "idpermission": 296,
                    "dspermission": "Logistica - scrittura dati IPEX",
                    "idpermissionalt": "lgs_ipex_write",
                    "sydatains": null
                },
                {
                    "idpermission": 297,
                    "dspermission": "Logistica - lettura dati benestari",
                    "idpermissionalt": "lgs_invauth_read",
                    "sydatains": null
                },
                {
                    "idpermission": 298,
                    "dspermission": "Logistica - scrittura dati benestari",
                    "idpermissionalt": "lgs_invauth_write",
                    "sydatains": null
                },
                {
                    "idpermission": 299,
                    "dspermission": "Logistica - lettura settlement terna",
                    "idpermissionalt": "lgs_terna_read",
                    "sydatains": null
                },
                {
                    "idpermission": 300,
                    "dspermission": "Logistica - scrittura settlement terna",
                    "idpermissionalt": "lgs_terna_write",
                    "sydatains": null
                },
                {
                    "idpermission": 301,
                    "dspermission": "Logistica - Gestione servizi",
                    "idpermissionalt": "lgs_gme_services",
                    "sydatains": null
                },
                {
                    "idpermission": 302,
                    "dspermission": "Logistica - Lettura",
                    "idpermissionalt": "lgs_read",
                    "sydatains": null
                },
                {
                    "idpermission": 303,
                    "dspermission": "Logistica - Gestione Programmi aggregati/chiusure",
                    "idpermissionalt": "lgs_eap_write",
                    "sydatains": null
                },
                {
                    "idpermission": 304,
                    "dspermission": "Logistica - Gestione Programmi aggregati - riaperture",
                    "idpermissionalt": "lgs_eap_reopen",
                    "sydatains": null
                },
                {
                    "idpermission": 411,
                    "dspermission": "Billing - Lettura dati  'Lotti di fatturazione'",
                    "idpermissionalt": "blg_elblot_read",
                    "sydatains": null
                },
                {
                    "idpermission": 511,
                    "dspermission": "CRM Cap/Floor",
                    "idpermissionalt": "crm_capfloor",
                    "sydatains": null
                },
                {
                    "idpermission": 611,
                    "dspermission": "Crm - Mandati SEDA lettura",
                    "idpermissionalt": "crm_back_seda_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 613,
                    "dspermission": "Crm - Mandati SEDA scrittura",
                    "idpermissionalt": "crm_back_seda_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 172,
                    "dspermission": "Costchecking Writer L1",
                    "idpermissionalt": "ccc_writer_l1",
                    "sydatains": null
                },
                {
                    "idpermission": 173,
                    "dspermission": "Costchecking Writer L2",
                    "idpermissionalt": "ccc_writer_l2",
                    "sydatains": null
                },
                {
                    "idpermission": 171,
                    "dspermission": "Costchecking Reader",
                    "idpermissionalt": "ccc_reader",
                    "sydatains": null
                },
                {
                    "idpermission": 471,
                    "dspermission": "Crm - Lead lettura",
                    "idpermissionalt": "crm_lead_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 472,
                    "dspermission": "Crm - Lead scrittura",
                    "idpermissionalt": "crm_lead_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 473,
                    "dspermission": "Crm - Opportunity lettura",
                    "idpermissionalt": "crm_opp_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 474,
                    "dspermission": "Crm - Opportunity scrittura",
                    "idpermissionalt": "crm_opp_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 475,
                    "dspermission": "Crm - Controparti lettura",
                    "idpermissionalt": "crm_prt_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 476,
                    "dspermission": "Crm - Controparti scrittura",
                    "idpermissionalt": "crm_prt_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 477,
                    "dspermission": "Crm - Punti lettura",
                    "idpermissionalt": "crm_sp_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 478,
                    "dspermission": "Crm - Punti scrittura",
                    "idpermissionalt": "crm_sp_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 479,
                    "dspermission": "Crm - Contatti lettura",
                    "idpermissionalt": "crm_cnt_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 480,
                    "dspermission": "Crm - Contatti scrittura",
                    "idpermissionalt": "crm_cnt_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 481,
                    "dspermission": "Crm - Case lettura",
                    "idpermissionalt": "crm_cas_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 482,
                    "dspermission": "Crm - Case scrittura",
                    "idpermissionalt": "crm_cas_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 483,
                    "dspermission": "Crm - Richieste lettura",
                    "idpermissionalt": "crm_bpm_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 484,
                    "dspermission": "Crm - Richieste scrittura",
                    "idpermissionalt": "crm_bpm_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 485,
                    "dspermission": "Crm - Prodotti lettura",
                    "idpermissionalt": "crm_prd_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 486,
                    "dspermission": "Crm - Prodotti scrittura",
                    "idpermissionalt": "crm_prd_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 487,
                    "dspermission": "Crm - Tipi prodotti lettura",
                    "idpermissionalt": "crm_tprd_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 488,
                    "dspermission": "Crm - Tipi prodotti scrittura",
                    "idpermissionalt": "crm_tprd_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 489,
                    "dspermission": "Crm - Contratti lettura",
                    "idpermissionalt": "crm_ctr_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 490,
                    "dspermission": "Crm - Contratti scrittura",
                    "idpermissionalt": "crm_ctr_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 491,
                    "dspermission": "Crm - Campagne lettura",
                    "idpermissionalt": "crm_cmp_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 492,
                    "dspermission": "Crm - Campagne scrittura",
                    "idpermissionalt": "crm_cmp_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 493,
                    "dspermission": "Crm - Email services lettura",
                    "idpermissionalt": "crm_email_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 494,
                    "dspermission": "Crm - Email services scrittura",
                    "idpermissionalt": "crm_email_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 495,
                    "dspermission": "Crm - Backoffice lettura",
                    "idpermissionalt": "crm_back_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 496,
                    "dspermission": "Crm - Backoffice scrittura",
                    "idpermissionalt": "crm_back_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 497,
                    "dspermission": "Crm - Backoffice amministrazione lettura",
                    "idpermissionalt": "crm_back_adm_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 499,
                    "dspermission": "Crm - Backoffice amministrazione scrittura",
                    "idpermissionalt": "crm_back_adm_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 500,
                    "dspermission": "Crm - File import",
                    "idpermissionalt": "crm_import",
                    "sydatains": null
                },
                {
                    "idpermission": 571,
                    "dspermission": "Crm - Backoffice Banche scrittura",
                    "idpermissionalt": "crm_back_banks_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 572,
                    "dspermission": "Crm - Backoffice Banche lettura",
                    "idpermissionalt": "crm_back_banks_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 573,
                    "dspermission": "Crm - Backoffice Termini di Pagamento scrittura",
                    "idpermissionalt": "crm_back_paymentterms_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 574,
                    "dspermission": "Crm - Backoffice Termini di Pagamento lettura",
                    "idpermissionalt": "crm_back_paymentterms_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 575,
                    "dspermission": "Crm - Backoffice Prodotti scrittura",
                    "idpermissionalt": "crm_back_products_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 576,
                    "dspermission": "Crm - Backoffice Prodotti lettura",
                    "idpermissionalt": "crm_back_products_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 591,
                    "dspermission": "Crm - Backend Aggiungi/Modifica CAB",
                    "idpermissionalt": "crm_back_cab_wr",
                    "sydatains": null
                },
                {
                    "idpermission": 14,
                    "dspermission": "Operazioni base metering",
                    "idpermissionalt": "mdm_op",
                    "sydatains": null
                },
                {
                    "idpermission": 15,
                    "dspermission": "Operazioni massive metering",
                    "idpermissionalt": "mdm_mass_op",
                    "sydatains": null
                },
                {
                    "idpermission": 16,
                    "dspermission": "Operazioni avanzate metering",
                    "idpermissionalt": "mdm_adv_op",
                    "sydatains": null
                },
                {
                    "idpermission": 17,
                    "dspermission": "Operazioni forecasting su metering",
                    "idpermissionalt": "mdm_fct",
                    "sydatains": null
                },
                {
                    "idpermission": 18,
                    "dspermission": "Operazioni configurazione base metering",
                    "idpermissionalt": "mdm_cfg_base",
                    "sydatains": null
                },
                {
                    "idpermission": 19,
                    "dspermission": "Operazioni configurazione avanzata metering",
                    "idpermissionalt": "mdm_cfg_adv",
                    "sydatains": null
                },
                {
                    "idpermission": 21,
                    "dspermission": "Operazioni customizzazione metering",
                    "idpermissionalt": "mdm_customize",
                    "sydatains": null
                },
                {
                    "idpermission": 22,
                    "dspermission": "Visualizzazione dati metering",
                    "idpermissionalt": "mdm_read",
                    "sydatains": null
                },
                {
                    "idpermission": 151,
                    "dspermission": "Dogane Operazioni Comunicazioni",
                    "idpermissionalt": "dgn_comm_op",
                    "sydatains": null
                },
                {
                    "idpermission": 153,
                    "dspermission": "Dogane Admin Comunicazioni",
                    "idpermissionalt": "dgn_comm_adm",
                    "sydatains": null
                },
                {
                    "idpermission": 154,
                    "dspermission": "Dogane Operazioni Pagamenti Massivi",
                    "idpermissionalt": "dgn_pag_op",
                    "sydatains": null
                },
                {
                    "idpermission": 155,
                    "dspermission": "Dogane Pagamenti Retro",
                    "idpermissionalt": "dgn_pag_rt",
                    "sydatains": null
                },
                {
                    "idpermission": 156,
                    "dspermission": "Dogane Pagamenti Admin",
                    "idpermissionalt": "dgn_pag_adm",
                    "sydatains": null
                },
                {
                    "idpermission": 157,
                    "dspermission": "Dogane Dichiarazioni di consumo Read",
                    "idpermissionalt": "dgn_dich_read",
                    "sydatains": null
                },
                {
                    "idpermission": 158,
                    "dspermission": "Dogane Operazioni Dichiarazioni di consumo",
                    "idpermissionalt": "dgn_dich_op",
                    "sydatains": null
                },
                {
                    "idpermission": 159,
                    "dspermission": "Dogane Cod. Ditta Read",
                    "idpermissionalt": "dgn_codditta_read",
                    "sydatains": null
                },
                {
                    "idpermission": 161,
                    "dspermission": "Dogane modifica template",
                    "idpermissionalt": "dgn_templ_op",
                    "sydatains": null
                },
                {
                    "idpermission": 162,
                    "dspermission": "Dogane gestione credito",
                    "idpermissionalt": "dgn_pos_credit_op",
                    "sydatains": null
                },
                {
                    "idpermission": 231,
                    "dspermission": "Dogane Import Read",
                    "idpermissionalt": "dgn_import_read",
                    "sydatains": null
                },
                {
                    "idpermission": 232,
                    "dspermission": "Dogane Import Writer",
                    "idpermissionalt": "dgn_import_writer",
                    "sydatains": null
                },
                {
                    "idpermission": 305,
                    "dspermission": "Logistica - Scrittura generica (es: import file, ecc.)",
                    "idpermissionalt": "lgs_write",
                    "sydatains": null
                },
                {
                    "idpermission": 306,
                    "dspermission": "Logistica - permessi admin",
                    "idpermissionalt": "lgs_admin",
                    "sydatains": null
                },
                {
                    "idpermission": 431,
                    "dspermission": "Billing  - Riesegui 'Lotti di fatturazione'",
                    "idpermissionalt": "blg_elblot_exec",
                    "sydatains": null
                },
                {
                    "idpermission": 501,
                    "dspermission": "AutoConsumo Diffuso - lettura",
                    "idpermissionalt": "acd_rd",
                    "sydatains": null
                },
                {
                    "idpermission": 1,
                    "dspermission": "Gestione utenti tenant",
                    "idpermissionalt": "manage_user",
                    "sydatains": null
                },
                {
                    "idpermission": 2,
                    "dspermission": "View moduli tenant",
                    "idpermissionalt": "manage_modules",
                    "sydatains": null
                },
                {
                    "idpermission": 192,
                    "dspermission": "Modifica configurazione sistemi AMI metering",
                    "idpermissionalt": "mdm_ami_customize",
                    "sydatains": null
                },
                {
                    "idpermission": 132,
                    "dspermission": "Dogane esegui data checks",
                    "idpermissionalt": "dgn_datachecks_op",
                    "sydatains": null
                },
                {
                    "idpermission": 191,
                    "dspermission": "Lettura info AMI metering",
                    "idpermissionalt": "mdm_ami_read",
                    "sydatains": null
                },
                {
                    "idpermission": 31,
                    "dspermission": "Visualizzazione dati avanzati metering",
                    "idpermissionalt": "mdm_adv_read",
                    "sydatains": null
                },
                {
                    "idpermission": 32,
                    "dspermission": "Visualizzazione configurazione metering",
                    "idpermissionalt": "mdm_cfg_read",
                    "sydatains": null
                },
                {
                    "idpermission": 33,
                    "dspermission": "Operazioni massive eliminazione metering",
                    "idpermissionalt": "mdm_mass_del",
                    "sydatains": null
                },
                {
                    "idpermission": 135,
                    "dspermission": "Dogane Operazioni su Forniture",
                    "idpermissionalt": "dgn_for_op",
                    "sydatains": null
                }
            ]
        };
        return accountScope;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: TokenService, deps: [{ token: i1.CookieService }, { token: USE_FAKE_ACCESS_TOKEN, optional: true }, { token: ANONYMOUS_MODE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: TokenService, providedIn: "root" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: TokenService, decorators: [{
            type: Injectable,
            args: [{ providedIn: "root" }]
        }], ctorParameters: () => [{ type: i1.CookieService }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [USE_FAKE_ACCESS_TOKEN]
                }] }, { type: undefined, decorators: [{
                    type: Optional
                }, {
                    type: Inject,
                    args: [ANONYMOUS_MODE]
                }] }] });

// Angular
class GlobalSearchService {
    constructor() {
        this.Enabled = false;
    }
    /**
     * Effettua una ricerca in base a un termine generico
     *
     * @param term Termine da cercare
     * @returns {SearchResultContainer} Contenitore della ricerca
     */
    search(term) {
        return of(null);
    }
    /**
     * Data la definizione semplice di una colonna restituisce un oggetto che indica se bisogna presentere un link su di essa
     *
     * @param column Colonna per cui verificare la presentazione di un link. Esempio: {id: "IDPARTY", description: "Cod. Controparte"}
     * @returns {{ routePath: string, routeProperties: string[] }} Oggetto che indica un link con i propri binding. Ad esempio: {routePath: "['/pages/parties/parties_details', { 'idModel': '{0}' }]", routeProperties: ["IDPARTY"]}
     */
    generateColumnLink(column) {
        return null;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: GlobalSearchService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: GlobalSearchService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: GlobalSearchService, decorators: [{
            type: Injectable
        }] });

// Angular
class APPErrorHandler {
    constructor(injector) {
        this.injector = injector;
    }
    handleError(error) {
        if (this.router == null)
            this.router = this.injector.get(Router);
        if (this.msgsExts == null)
            this.msgsExts = this.injector.get(MessageService);
        //Ignoro eventuali errori di javascript quando il redirect è attivo
        if (myconfig && myconfig.redirectInProgress) {
            console.log("Javascript error on redirect in progress, ignoring this event");
            return;
        }
        //In caso io abbia impostato succesresultmandatory nell'httprequest e questa abbia dato errore tiro fuori un exception che dev'essere mostrata come si deve
        var newError = "";
        if (!error.message && !error.stack)
            newError = error;
        else if (error instanceof HttpErrorResponse)
            newError = error.message;
        else
            newError = error.stack && error.stack.length > 1000 ? error.stack.substring(0, 999) + "[...]" : error.stack;
        if (!newError)
            newError = JSON.stringify(error);
        if (newError.includes("Failed to fetch dynamically imported module"))
            this.msgsExts.simpleError("L'applicativo non risulta sincronizzato con il Server. Si prega di ricaricare la pagina");
        else
            this.router.navigate([`err/9999`, { errorMessage: this.b64EncodeUnicode(newError), fromUrl: this.router.url }]);
    }
    b64EncodeUnicode(str) {
        // first we use encodeURIComponent to get percent-encoded UTF-8,
        // then we convert the percent encodings into raw bytes which
        // can be fed into btoa.
        return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(("0x" + p1))));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: APPErrorHandler, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: APPErrorHandler }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: APPErrorHandler, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

// Angular
class OutZoneEventPlugin {
    constructor(zone) {
        this.zone = zone;
    }
    supports(eventName) {
        return eventName.endsWith('out-zone');
    }
    addEventListener(element, eventName, originalHandler) {
        let eventOriginalName = eventName.split('.')[0];
        let standardHandler = (event) => originalHandler(event);
        if (eventName.endsWith('out-zone'))
            this.zone.runOutsideAngular(() => { element.addEventListener(eventOriginalName, standardHandler); });
        else
            element.addEventListener(eventOriginalName, standardHandler);
        return () => element.removeEventListener(eventOriginalName, standardHandler);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: OutZoneEventPlugin, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: OutZoneEventPlugin, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: OutZoneEventPlugin, decorators: [{
            type: Injectable,
            args: [{ providedIn: 'root' }]
        }], ctorParameters: () => [{ type: i0.NgZone }] });

class HTTPServiceExtensionsLoc extends LocalizationService {
    constructor(injector) {
        super(injector);
        super.set("it->en", "Il Server sembra essere offline, prova a ricaricare la pagina", ["Server seems to be offline, try to reload this page"]);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: HTTPServiceExtensionsLoc, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: HTTPServiceExtensionsLoc }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: HTTPServiceExtensionsLoc, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

// Chiamate ai Repository
const GET_Jace_GetActiveJaceModules = "/api/Jace/GetActiveJaceModules";
class AppState {
    set Modules(modules) {
        this._modules = modules;
        this.notifyDataChanged("modules.Retrieved", this._modules);
    }
    get Modules() { return this._modules; }
    constructor(router, prefs, inj, bts, notifications, MessageDef, intercom, emb, fakeToken, anonymousMode) {
        this.router = router;
        this.prefs = prefs;
        this.inj = inj;
        this.bts = bts;
        this.notifications = notifications;
        this.MessageDef = MessageDef;
        this.intercom = intercom;
        this.emb = emb;
        this.fakeToken = fakeToken;
        this.anonymousMode = anonymousMode;
        this.PREFS_DISABLE_EFFECTS = "PREFS_DISABLE_EFFECTS";
        this.graphicEffects = signal(true, ...(ngDevMode ? [{ debugName: "graphicEffects" }] : []));
        this.redirectingToLogin = false;
        this.handlingError = false;
        this.christmasTime = signal(false, ...(ngDevMode ? [{ debugName: "christmasTime" }] : []));
        this.halloweenTime = signal(false, ...(ngDevMode ? [{ debugName: "halloweenTime" }] : []));
        this.jobsInProgress = 0;
        this.allJobs = [];
        this.jobWithIdsCache = {};
        this.notifyOnCompletedJobs = true;
        this._data = new Subject();
        this._subscriptions = new Map();
        this.ModulesLocalizations = {};
        this.hookEmbedding();
        this.hookPreferences();
        this.setupSignalRJobListening();
        this.getActiveJaceModules();
        this.JaceIdentity = null;
        this._data.subscribe((data) => this._onEvent(data));
        //Decide se siamo attorno a natale
        var today = dayjs();
        var thisYear = today.year();
        var lowerBound = dayjs("18/12/" + thisYear, "DD/MM/YYYY");
        var upperBound = dayjs("07/01/" + (thisYear + 1), "DD/MM/YYYY");
        this.christmasTime.set(today > lowerBound && today < upperBound);
        //Decide se siamo attorno ad halloween
        var lowerBound = dayjs("28/10/" + thisYear, "DD/MM/YYYY");
        var upperBound = dayjs("05/11/" + thisYear, "DD/MM/YYYY");
        this.halloweenTime.set(today > lowerBound && today < upperBound);
        this.intercom.inbounds.subscribe((t) => { this.handleInboundMessage(t); });
    }
    async hookPreferences() {
        let originalRes = await firstValueFrom(this.prefs.getItem(this.PREFS_DISABLE_EFFECTS, false, true));
        let effectsOff = originalRes?.value || false;
        this.graphicEffects.set(!effectsOff);
    }
    getActiveJaceModules() {
        // Recupero i moduli dopo un frame. mi assicuro che l'injection tree sia stabile. 
        // Altrimenti l'httpservice che prende l'httpserviceextensions providato da core quando anche l'appstate è providedin root
        // si incasina e va in loop
        requestAnimationFrame(() => {
            let http = this.inj.get(HTTPService);
            if (this.fakeToken) {
                this.Modules = [new ActiveModuleView("Modulo Esempio 1"), new ActiveModuleView("Modulo Esempio 2"), new ActiveModuleView("Modulo Esempio 3")];
                this.Modules = this.Modules;
                return;
            }
            http.get(GET_Jace_GetActiveJaceModules).subscribe(res => {
                this.Modules = res;
                this.Modules = this.Modules;
            });
        });
    }
    // Collego le informazioni dell'embedding che devono appoggiarsi all'app state in modo che possano comunicare col resto dell'applicazione
    hookEmbedding() {
        this.emb.MessageObserver.pipe(filter(ev => ev.event == "navigation")).subscribe(event => {
            var navigationOp = event?.data?.internalNavigation ? "menu.adjustSubNavigationTo" : "menu.adjustNavigationTo";
            this.notifyDataChanged(navigationOp, event?.data?.title);
        });
        this.emb.MessageObserver.pipe(filter(ev => ev.event == "window-message")).subscribe(event => {
            this.notifyDataChanged("window-message", event?.data);
        });
        this._data.pipe(filter(e => e.event == "menu.isCollapsed")).subscribe(_ => {
            this.emb.refreshBoundariesOnMenuCollapse();
        });
    }
    // Stesso codice in AppSession, vedere se si può compattare
    /** Tenant§Account§User§APPNAME */
    getSessionIdentity() {
        if (this.SessionIdentity)
            return this.SessionIdentity;
        // Se non ho un id mi manca il login, quindi via di qua
        var id = this.getJaceIDentity();
        if (!id) {
            if (this.anonymousMode)
                return "";
            this.router.navigate(["login"]);
            return "";
        }
        this.SessionIdentity = "" + id.Idtenant + "§" + id.IdAccount + "§" + id.IdUser + "§" + myconfig?.AppData?.ModuleId;
        return this.SessionIdentity;
    }
    registerNavigationIfMeaningful(route) {
        let title = route.data["title"];
        let internal = route.data["internalNavigation"];
        // Permette di chiamare sto registerNavigation a prescindere e fare opt out se non è una route navigabile
        if (!title)
            return;
        /*
         *  Parent ({url: [{path: "{module}"}]})
         *      Parent ({url: [{path: ""}]}) (Root del modulo lazy)
         *          -> Navigazione attuale <-
         */
        let module = route.parent?.parent?.url[0]?.path;
        let loc = module ? this.ModulesLocalizations[module] : null;
        if (!module)
            console.error("Impossibile estrapolare il modulo dalla navigazione (Atteso Modulo al secondo livello di parentela partendo dal componente attuale): " + route.pathFromRoot.map(v => v.url.map(segment => segment.toString()).join('/')).join('/'));
        this.notifyDataChanged(internal ? "menu.adjustSubNavigationTo" : "menu.adjustNavigationTo", loc ? loc.loc(title) : title);
    }
    handleInboundMessage(t) {
        switch (t.type) {
            case InboundMessageTypes.Navigation:
                this.notifyDataChanged(t.message.sub ? "menu.adjustSubNavigationTo" : "menu.adjustNavigationTo", t.message.routeTitle);
                // export const MK_ADM = "EsAdminModule";
                // AdmMessageTypes.Message = 0;
                // definita in admin-module.
                // admin-module usa core quindi referenze circolari no-no-no
                this.intercom.send(0, "Navigation Message Received", "EsAdminModule");
                break;
        }
    }
    setupSignalRJobListening() {
        this.notifications.observe(this.MessageDef.IN_JobProgressNotification).subscribe((ev) => {
            var identity = this.getJaceIDentity();
            if (!identity)
                return;
            var desc = (ev.description || ev.actionid) + " (" + (ev.user || identity.DsUser) + ")";
            let job = {
                id: ev.instance,
                description: desc,
                smalldescription: desc.length > 35 ? desc.substring(0, 30) + "..." : desc,
                percentage: this.roundToTwo(ev.progress),
                completed: ev.type == 'Completed',
                fileid: ev.resultfile,
                reportid: ev.resultreport,
                reportpars: ev.resultreportparams,
                complexreportid: ev.resultcomplexreport
            };
            switch (ev.type) {
                case "Started":
                    if (this.jobWithIdsCache[ev.instance]) {
                        console.warn("Job already registered on the 'Started' callback");
                        return;
                    }
                    this.jobWithIdsCache[ev.instance] = job;
                    this.allJobs.splice(0, 0, job);
                    this.notifyDataChanged("app.startedJob", job.description);
                    break;
                case "Progress":
                    // Se mi arriva un progress di un job che non ho significa che mi sono loggato ora con dei Job in corso
                    // quindi per prima cosa devo metterlo in lista
                    if (!this.jobWithIdsCache[ev.instance]) {
                        this.jobWithIdsCache[ev.instance] = job;
                        this.allJobs.splice(0, 0, job);
                    }
                    this.jobWithIdsCache[ev.instance].percentage = this.roundToTwo(ev.progress);
                    this.notifyDataChanged("app.progressJob", { description: job.description, progress: this.jobWithIdsCache[ev.instance].percentage });
                    break;
                case "Completed":
                    if (!this.jobWithIdsCache[ev.instance]) {
                        this.jobWithIdsCache[ev.instance] = job;
                        this.allJobs.splice(0, 0, job);
                    }
                    var jobToUpdate = this.jobWithIdsCache[ev.instance];
                    jobToUpdate.percentage = 100;
                    jobToUpdate.fileid = ev.resultfile;
                    jobToUpdate.reportid = ev.resultreport;
                    jobToUpdate.reportpars = ev.resultreportparams;
                    jobToUpdate.completed = true;
                    if (this.notifyOnCompletedJobs)
                        this.notifyDataChanged("app.completedJob", jobToUpdate.description);
                    break;
            }
            this.jobsInProgress = this.allJobs.filter(t => !t.completed).length;
        });
    }
    roundToTwo(num) {
        return Math.round(num * 100) / 100;
    }
    getJaceIDentity() {
        if (this.JaceIdentity)
            return this.JaceIdentity;
        this.JaceIdentity = this.bts.getJaceIdentity();
        return this.JaceIdentity;
    }
    notifyDataChanged(event, value) {
        this._data[event] = value;
        this._data.next({
            event: event,
            data: this._data[event]
        });
    }
    subscribe(event, callback) {
        var subscribers = this._subscriptions.get(event) || [];
        subscribers.push(callback);
        this._subscriptions.set(event, subscribers);
    }
    _onEvent(data) {
        var subscribers = this._subscriptions.get(data["event"]) || [];
        subscribers.forEach((callback) => {
            callback.call(null, data["data"]);
        });
    }
    setSidebarWidth(width) {
        this.sidebarWidth = width;
    }
    setHeaderHeight(height) {
        this.headerHeight = height;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: AppState, deps: [{ token: i1$1.Router }, { token: i4.PreferencesService }, { token: i0.Injector }, { token: TokenService }, { token: i4$1.NotificationsService }, { token: i4$1.BaseMessageService }, { token: i5.InterComService }, { token: i5.AppEmbeddingExtensions }, { token: USE_FAKE_ACCESS_TOKEN }, { token: ANONYMOUS_MODE }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: AppState, providedIn: "root" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: AppState, decorators: [{
            type: Injectable,
            args: [{ providedIn: "root" }]
        }], ctorParameters: () => [{ type: i1$1.Router }, { type: i4.PreferencesService }, { type: i0.Injector }, { type: TokenService }, { type: i4$1.NotificationsService }, { type: i4$1.BaseMessageService }, { type: i5.InterComService }, { type: i5.AppEmbeddingExtensions }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [USE_FAKE_ACCESS_TOKEN]
                }] }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [ANONYMOUS_MODE]
                }] }] });

// Angular
class HTTPServiceExtensions {
    constructor(lc, tks, as, router, ac, msgs) {
        this.lc = lc;
        this.tks = tks;
        this.as = as;
        this.router = router;
        this.ac = ac;
        this.msgs = msgs;
        this.lc = this.lc.generateFromType(HTTPServiceExtensionsLoc);
    }
    //Gestione Auth
    retrieveAccessToken() {
        return this.tks.getAccessToken().toString();
    }
    retrieveIdentity() {
        return this.tks.getJaceIdentity();
    }
    //Gestione ridirezione al login / altre pagine
    readRedirectingToLogin() {
        return this.as.redirectingToLogin;
    }
    writeRedirectingToLogin(status) {
        this.as.redirectingToLogin = status;
    }
    redirectToLogin() {
        console.log("HTTPServiceExtensions - redirecting to login");
        this.router.navigate(["login", { fromUrl: this.router.url }]);
    }
    readRedirectionStatus() {
        return myconfig?.redirectInProgress;
    }
    writeRedirectionStatus(status) {
        myconfig.redirectInProgress = status;
    }
    //Gestione error handling flag
    readHandlingErrorStatus() {
        return this.as.handlingError;
    }
    writeHandlingErrorStatus(status) {
        this.as.handlingError = status;
    }
    // 444, se false passa a handleBlockingException
    handleNotConfiguredException() {
        if (this.ac.has("P:mdm_customize")) {
            myconfig.redirectInProgress = true;
            this.as.handlingError = false;
            this.router.navigate(["pages/adm/tenantconfig"]);
            return true;
        }
        return false;
    }
    // 400, 403, 404, 444
    handleBlockingException(status, text) {
        if (status == 403)
            this.msgs.simpleError("Non si dispone dei permessi necessari ad effettuare questa operazione.");
        else
            this.msgs.simpleError(status + ": " + text);
        this.as.handlingError = false;
    }
    // Tutto quello che non è gestito da handleBlockingException
    handleException(status, text) {
        if (status == 503)
            this.msgs.simpleError(this.lc.loc("Il Server sembra essere offline, prova a ricaricare la pagina"));
        else if (status == 0)
            this.msgs.simpleError(this.lc.loc("Impossibile connettersi alla suite Jace. Controllare le impostazioni di rete e riprovare. Se il problema persiste, provare a ricaricare la pagina"));
        else if (status == 542)
            this.msgs.simpleError(text);
        else {
            var st = btoa(encodeURIComponent(text).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(("0x" + p1))));
            var pars = { statusText: st, fromUrl: this.router.url };
            this.router.navigate([`err/${status}`, pars]);
        }
        this.as.handlingError = false;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: HTTPServiceExtensions, deps: [{ token: i1$2.LocalizationService }, { token: TokenService }, { token: AppState }, { token: i1$1.Router }, { token: i5$1.AccessControlService }, { token: i5.MessageService }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: HTTPServiceExtensions }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: HTTPServiceExtensions, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i1$2.LocalizationService }, { type: TokenService }, { type: AppState }, { type: i1$1.Router }, { type: i5$1.AccessControlService }, { type: i5.MessageService }] });

// Angular
class MenuFilteringService {
    /**
     * Applica un filtro agli elementi di menù in modo da poterli filtrare in base a condizioni arbitrarie (inclusi check lato BE)
     *
     * @param rawMenus Menù originali, non filtrati
     * @returns {Observable<ApplicationMenu[]>} Menù filtrati
     */
    filter(rawMenus) {
        return of(rawMenus);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: MenuFilteringService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: MenuFilteringService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: MenuFilteringService, decorators: [{
            type: Injectable
        }] });

// Angular
class CompletedJobRedirectionService {
    /**
     * Effettua un'operazione di redirect basata sul Job Completato
     *
     * @param completedJob Job appena completato per cui effettuare un redirect
     */
    redirect(completedJob) {
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: CompletedJobRedirectionService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: CompletedJobRedirectionService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: CompletedJobRedirectionService, decorators: [{
            type: Injectable
        }] });

// Angular
class SessionRetriever {
    constructor(bts, router, anonymousMode) {
        this.bts = bts;
        this.router = router;
        this.anonymousMode = anonymousMode;
    }
    /** Tenant§Account§User§ModuleId */
    getSessionKey(global) {
        // Se non ho un id mi manca il login, quindi via di qua
        var id = this.bts.getJaceIdentity();
        if (!id) {
            if (this.anonymousMode)
                return "";
            console.log("SessionRetriever - no identity, redirecting to login");
            this.router.navigate(["login"]);
            return "";
        }
        return `${id.Idtenant}§${id.IdAccount}§${id.IdUser}§${global ? "GLOBAL" : (myconfig?.AppData?.ModuleId) || ""}`;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: SessionRetriever, deps: [{ token: TokenService }, { token: i1$1.Router }, { token: ANONYMOUS_MODE }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: SessionRetriever, providedIn: "root" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: SessionRetriever, decorators: [{
            type: Injectable,
            args: [{ providedIn: "root" }]
        }], ctorParameters: () => [{ type: TokenService }, { type: i1$1.Router }, { type: undefined, decorators: [{
                    type: Inject,
                    args: [ANONYMOUS_MODE]
                }] }] });

// Angular
// Chiamate ai Repository
const BASE_Cache_Sessions = "/api/Cache/sessions";
class ApplicationCachePersistor extends CachePersistor {
    // Passo direttamente dall'HttpClient nativo in quanto non posso passare dall'HttpService dato che 
    // lui richiede il PreferencesService che richiede questa classe che richiede l'HttpService ecc ecc...
    constructor(lc, http, tks, session) {
        super(session);
        this.lc = lc;
        this.http = http;
        this.tks = tks;
    }
    persist(key, item) {
        let sk = this.session.getSessionKey();
        if (!sk)
            return of(false);
        return this.http.post(this.getItemUrl(sk, key), JSON.stringify(item), { headers: this.getHeaders() }).pipe(catchError(e => of(false)));
    }
    recover(key) {
        let sk = this.session.getSessionKey();
        if (!sk)
            return of(null);
        return this.http.get(this.getItemUrl(sk, key), { headers: this.getHeaders() }).pipe(catchError(e => of(null)), map((res) => {
            var resProp = null;
            try {
                resProp = JSON.parse(res);
            }
            catch { }
            return resProp;
        }));
    }
    recoverAll() {
        let sk = this.session.getSessionKey();
        if (!sk)
            return of(null);
        return this.http.get(this.getSessionUrl(sk), { headers: this.getHeaders() }).pipe(catchError(e => of(null)), map((res) => {
            for (var prop in res) {
                var resProp = null;
                try {
                    resProp = JSON.parse(res[prop]);
                }
                catch { }
                res[prop] = resProp;
            }
            return res;
        }));
    }
    remove(key) {
        let sk = this.session.getSessionKey();
        if (!sk)
            return of(false);
        return this.http.delete(this.getItemUrl(sk, key), { headers: this.getHeaders() }).pipe(catchError(e => of(false)));
    }
    clear() {
        let sk = this.session.getSessionKey();
        if (!sk)
            return of(false);
        return this.http.delete(this.getItemsUrl(sk), { headers: this.getHeaders() }).pipe(catchError(e => of(false)));
    }
    getHeaders(contentType = 'application/json') {
        return new HttpHeaders()
            .append("Content-Type", contentType)
            .append("Accept", "application/json")
            .append("Authorization", "Bearer " + this.tks.getAccessToken())
            .append("Accept-Language", this.lc.Locale);
    }
    getSessionUrl(sessionKey) {
        return `${BASE_Cache_Sessions}/${sessionKey}`;
    }
    getItemsUrl(sessionKey) {
        return `${this.getSessionUrl(sessionKey)}/items`;
    }
    getItemUrl(sessionKey, itemKey) {
        return `${this.getItemsUrl(sessionKey)}/${itemKey}`;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: ApplicationCachePersistor, deps: [{ token: i1$2.LocalizationService }, { token: i2.HttpClient }, { token: TokenService }, { token: i4.BaseSessionRetriever }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: ApplicationCachePersistor }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: ApplicationCachePersistor, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i1$2.LocalizationService }, { type: i2.HttpClient }, { type: TokenService }, { type: i4.BaseSessionRetriever }] });

// Angular
// Chiamate ai Repository
const BASE_Preferences_Sessions = "/api/Preferences/sessions";
class ApplicationPreferencesPersistor extends PreferencesPersistor {
    // Passo direttamente dall'HttpClient nativo in quanto non posso passare dall'HttpService dato che 
    // lui richiede il PreferencesService che richiede questa classe che richiede l'HttpService ecc ecc...
    constructor(lc, http, tks, session) {
        super(session);
        this.lc = lc;
        this.http = http;
        this.tks = tks;
    }
    persist(key, item, global) {
        let sk = this.session.getSessionKey(global);
        if (!sk)
            return of(false);
        return this.http.post(this.getItemUrl(sk, key), JSON.stringify(item), { headers: this.getHeaders() }).pipe(catchError(e => of(false)));
    }
    recover(key, global) {
        let sk = this.session.getSessionKey(global);
        if (!sk)
            return of(null);
        return this.http.get(this.getItemUrl(sk, key), { headers: this.getHeaders() }).pipe(map((res) => {
            var resProp = null;
            try {
                resProp = JSON.parse(res);
            }
            catch { }
            return resProp;
        }));
    }
    // Se globale recupero sia quelle lovali che globali. Comportamento di default
    recoverAll(global = true) {
        let sk = this.session.getSessionKey();
        if (!sk)
            return of(null);
        var call1 = this.http.get(this.getSessionUrl(sk), { headers: this.getHeaders() }).pipe(catchError(e => of(null)), map((res) => {
            for (var prop in res) {
                var resProp = null;
                try {
                    resProp = JSON.parse(res[prop]);
                }
                catch { }
                res[prop] = resProp;
            }
            return res;
        }));
        if (!global)
            return call1;
        let skGlobal = this.session.getSessionKey(global);
        var call2 = this.http.get(this.getSessionUrl(skGlobal), { headers: this.getHeaders() }).pipe(catchError(e => of(null)), map((res) => {
            for (var prop in res) {
                var resProp = null;
                try {
                    resProp = JSON.parse(res[prop]);
                }
                catch { }
                res[prop] = resProp;
            }
            return res;
        }));
        return forkJoin([call1, call2]).pipe(mergeMap((values) => {
            var dic1 = values[0];
            var dic2 = values[1];
            var finalDick = { ...dic1, ...dic2 };
            return of(finalDick);
        }));
    }
    remove(key, global) {
        let sk = this.session.getSessionKey(global);
        if (!sk)
            return of(false);
        return this.http.delete(this.getItemUrl(sk, key), { headers: this.getHeaders() }).pipe(catchError(e => of(false)));
    }
    clear(global) {
        if (global) {
            console.error("Impossibile pulire la cache globale da un applicativo singolo");
            return of(true);
        }
        let sk = this.session.getSessionKey();
        if (!sk)
            return of(false);
        return this.http.delete(this.getItemsUrl(sk), { headers: this.getHeaders() }).pipe(catchError(e => of(false)));
    }
    getHeaders(contentType = 'application/json') {
        return new HttpHeaders()
            .append("Content-Type", contentType)
            .append("Accept", "application/json")
            .append("Authorization", "Bearer " + this.tks.getAccessToken())
            .append("Accept-Language", this.lc.Locale);
    }
    getSessionUrl(sessionKey) {
        return `${BASE_Preferences_Sessions}/${sessionKey}`;
    }
    getItemsUrl(sessionKey) {
        return `${this.getSessionUrl(sessionKey)}/items`;
    }
    getItemUrl(sessionKey, itemKey) {
        return `${this.getItemsUrl(sessionKey)}/${itemKey}`;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: ApplicationPreferencesPersistor, deps: [{ token: i1$2.LocalizationService }, { token: i2.HttpClient }, { token: TokenService }, { token: i4.BaseSessionRetriever }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: ApplicationPreferencesPersistor }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: ApplicationPreferencesPersistor, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i1$2.LocalizationService }, { type: i2.HttpClient }, { type: TokenService }, { type: i4.BaseSessionRetriever }] });

// Angular
// Chiamate ai Repository
const GET_UserProfile_GetAccountPicture = "/api/UserProfile/GetAccountPicture";
const POST_UserProfile_UpdateAccountPicture = "/api/UserProfile/UpdateAccountPicture";
const POST_UserProfile_UpdateAccountRecoveryInfos = "/api/UserProfile/UpdateAccountRecoveryInfos";
const POST_UserProfile_UpdateAccountPassword = "/api/UserProfile/UpdateAccountPassword";
const GET_UserProfile_DeleteAccountPicture = "/api/UserProfile/DeleteAccountPicture";
const GET_UserProfile_GetEntityAccount = "/api/UserProfile/GetEntityAccount";
class UserPreferencesService {
    constructor(injector) {
        this.injector = injector;
        let tks = this.injector.get(TokenService);
        this.sanitizer = this.injector.get(DomSanitizer);
        this.http = this.injector.get(HTTPService);
        this.msgExts = this.injector.get(MessageService);
        this.fakeToken = this.injector.get(USE_FAKE_ACCESS_TOKEN) || false;
        var identity = tks.getJaceIdentity();
        if (identity) {
            this.AccountId = identity.IdAccount.toString();
            this.doReloadProfilePicture();
        }
    }
    async getAccountProfile() {
        let pars = new HttpParams().set("idAccount", this.AccountId);
        let ret = await firstValueFrom(this.http.get(GET_UserProfile_GetEntityAccount, pars));
        return ret;
    }
    async doReloadProfilePicture() {
        this.ProfilePicture = null;
        let tmpPict = await this.getCurrentProfilePicture();
        this.ProfilePicture = this.sanitizer.bypassSecurityTrustResourceUrl(`data:image/png;base64,${tmpPict}`);
    }
    async getCurrentProfilePicture() {
        // Se fake token restituisco la stock image dell'utente
        if (this.fakeToken)
            return " ";
        let pictureb64 = await firstValueFrom(this.http.get(GET_UserProfile_GetAccountPicture, new HttpParams().set('idAccount', this.AccountId)));
        return pictureb64;
    }
    async doUpdateProfilePicture(image) {
        if (this.fakeToken) {
            var ret = new CallResult();
            ret.success = true;
            return ret;
        }
        let dtoPic = new UpdateProfilePictureDto(this.AccountId);
        let cr = await firstValueFrom(this.http.postwithFiles(POST_UserProfile_UpdateAccountPicture, dtoPic, image ?? []));
        if (cr.success)
            this.doReloadProfilePicture();
        return cr;
    }
    async doUpdateRecoverySettings(email) {
        if (this.fakeToken) {
            var ret = new CallResult();
            ret.success = true;
            return ret;
        }
        let dto = new UpdateAccountRecoverySettingsDto(this.AccountId, email);
        let cr = await firstValueFrom(this.http.post(POST_UserProfile_UpdateAccountRecoveryInfos, dto));
        return cr;
    }
    async doUpdatePassword(oldPassword, newPassword, newPasswordConfirm) {
        if (this.fakeToken) {
            var ret = new CallResult();
            ret.success = true;
            return ret;
        }
        let dto = new UpdatePasswordDto(this.AccountId, oldPassword, newPassword, newPasswordConfirm);
        let cr = await firstValueFrom(this.http.post(POST_UserProfile_UpdateAccountPassword, dto));
        return cr;
    }
    async doDeleteProfilePicture() {
        if (this.fakeToken) {
            var ret = new CallResult();
            ret.success = true;
            return ret;
        }
        let pars = new HttpParams().set('idAccount', this.AccountId);
        let cr = await firstValueFrom(this.http.get(GET_UserProfile_DeleteAccountPicture, pars));
        if (cr.success)
            this.ProfilePicture = null;
        return cr;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: UserPreferencesService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: UserPreferencesService }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: UserPreferencesService, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

// Angular
class BaseRouterGuard extends AccessControlRouteGuard {
    constructor(ms, acc, router, ts) {
        super(ms, acc, router);
        let identity = ts.getJaceIdentity();
        if (!acc.Initialized)
            acc.initializeIdentity(identity);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: BaseRouterGuard, deps: [{ token: i5.MessageService }, { token: i5$1.AccessControlService }, { token: i1$1.Router }, { token: TokenService }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: BaseRouterGuard }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.24", ngImport: i0, type: BaseRouterGuard, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i5.MessageService }, { type: i5$1.AccessControlService }, { type: i1$1.Router }, { type: TokenService }] });

/**
 * Generated bundle index. Do not edit.
 */

export { APPErrorHandler, AppState, ApplicationCachePersistor, ApplicationPreferencesPersistor, BaseRouterGuard, CompletedJobRedirectionService, GlobalSearchService, HTTPServiceExtensions, MenuFilteringService, OutZoneEventPlugin, SessionRetriever, TokenService, UserPreferencesService };
//# sourceMappingURL=esfaenza-core-services.mjs.map
