import * as i1 from '@angular/router';
import { Router, RoutesRecognized, RouterModule } from '@angular/router';
import { LocalizationService, LocalizationModule } from '@esfaenza/localizations';
import { filter, take } from 'rxjs/operators';
import { AppState } from '@esfaenza/core/services';
import * as i0 from '@angular/core';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ModalModule } from 'ngx-bootstrap/modal';
import { DragDropModule } from '@angular/cdk/drag-drop';
import { DirectivesModule } from '@esfaenza/core/directives';
import { PipesModule } from '@esfaenza/core/pipes';
import { AccessControlModule } from '@esfaenza/access-control';
import { EsCronModule } from '@esfaenza/cron';
import { EsChartsModule } from '@esfaenza/es-charts';
import { EsTableModule } from '@esfaenza/es-table';
import { ExtensionsModule } from '@esfaenza/extensions';
import { FormsAndValidationsModule } from '@esfaenza/forms-and-validations';
import { UtilityComponentsModule } from '@esfaenza/utility-components';
import { EsGertrudeModule } from '@esfaenza/gertrude';
import { EsMatrixValuesModule } from '@esfaenza/matrix-values';
import { ContextMenuModule } from '@esfaenza/ngx-contextmenu';
import { DragulaModule } from '@esfaenza/ngx-dragula';
import { EsParametersModule } from '@esfaenza/parameters';
import { EsQueryBuilderModule } from '@esfaenza/query-builder';
import { EsTagChooserModule } from '@esfaenza/tag-chooser';
import { EsWizardModule } from '@esfaenza/wizard';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
import { TimepickerModule } from 'ngx-bootstrap/timepicker';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { TooltipModule as TooltipModule$1 } from 'primeng/tooltip';
import { TabberModule } from '@esfaenza/tabber';
import { ComponentsModule, EmbeddingComponent } from '@esfaenza/core/components';

class BaseLazyModule {
    constructor(injector) {
        let _state = injector.get(AppState);
        let router = injector.get(Router);
        let moduleLoc = injector.get(LocalizationService, null, { optional: true });
        if (!moduleLoc)
            return;
        router.events.pipe(filter(event => event instanceof RoutesRecognized), take(1))
            .subscribe((route) => {
            /*
             *  Router State
             *      V
             *  Root ("#")
             *      firstChild (url: [{path: "pages" | "pages_ext"}])
             *          firstChild (url: [{path: "{modulo}"}])
             *
             * Attenzione: Se la prima navigazione avviene verso una pagina non applicativa (pagina di errore ecc) devo ignorare il caricamento della localizzazione
             * Sinceramente non pensavo che in quel caso sarebbe stato caricato un modulo lazy, ma tant'è
             */
            let modulePath = route.state.root.firstChild?.firstChild?.url?.[0]?.path;
            if (modulePath)
                _state.ModulesLocalizations[modulePath] = moduleLoc;
        });
    }
}

// Angular
const MODULES_TO_EXPORT$1 = [
    CommonModule,
    FormsModule,
    RouterModule,
    DirectivesModule,
    PipesModule,
    ModalModule,
    //Material
    DragDropModule
];
class TemplateCommon {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: TemplateCommon, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.25", ngImport: i0, type: TemplateCommon, imports: [CommonModule,
            FormsModule,
            RouterModule,
            DirectivesModule,
            PipesModule,
            ModalModule,
            //Material
            DragDropModule], exports: [CommonModule,
            FormsModule,
            RouterModule,
            DirectivesModule,
            PipesModule,
            ModalModule,
            //Material
            DragDropModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: TemplateCommon, imports: [MODULES_TO_EXPORT$1, CommonModule,
            FormsModule,
            RouterModule,
            DirectivesModule,
            PipesModule,
            ModalModule,
            //Material
            DragDropModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: TemplateCommon, decorators: [{
            type: NgModule,
            args: [{ imports: [...MODULES_TO_EXPORT$1], exports: [...MODULES_TO_EXPORT$1] }]
        }] });

// Angular
// TODO: BaseSelectorComponent
const MODULES_TO_EXPORT = [
    ContextMenuModule, TabberModule, ComponentsModule,
    TimepickerModule, BsDropdownModule, TooltipModule, TooltipModule$1, ProgressbarModule, DragulaModule, LocalizationModule, ExtensionsModule, AccessControlModule, EsChartsModule, UtilityComponentsModule,
    EsWizardModule, EsCronModule, EsGertrudeModule, EsMatrixValuesModule, EsTagChooserModule, EsQueryBuilderModule, EsParametersModule, FormsAndValidationsModule, EsTableModule
];
class SharedCommon {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SharedCommon, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.25", ngImport: i0, type: SharedCommon, imports: [ContextMenuModule, TabberModule, ComponentsModule,
            TimepickerModule, BsDropdownModule, TooltipModule, TooltipModule$1, ProgressbarModule, DragulaModule, LocalizationModule, ExtensionsModule, AccessControlModule, EsChartsModule, UtilityComponentsModule,
            EsWizardModule, EsCronModule, EsGertrudeModule, EsMatrixValuesModule, EsTagChooserModule, EsQueryBuilderModule, EsParametersModule, FormsAndValidationsModule, EsTableModule], exports: [ContextMenuModule, TabberModule, ComponentsModule,
            TimepickerModule, BsDropdownModule, TooltipModule, TooltipModule$1, ProgressbarModule, DragulaModule, LocalizationModule, ExtensionsModule, AccessControlModule, EsChartsModule, UtilityComponentsModule,
            EsWizardModule, EsCronModule, EsGertrudeModule, EsMatrixValuesModule, EsTagChooserModule, EsQueryBuilderModule, EsParametersModule, FormsAndValidationsModule, EsTableModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SharedCommon, imports: [MODULES_TO_EXPORT, ContextMenuModule, TabberModule, ComponentsModule,
            TimepickerModule, BsDropdownModule, TooltipModule, TooltipModule$1, ProgressbarModule, DragulaModule, LocalizationModule, ExtensionsModule, AccessControlModule, EsChartsModule, UtilityComponentsModule,
            EsWizardModule, EsCronModule, EsGertrudeModule, EsMatrixValuesModule, EsTagChooserModule, EsQueryBuilderModule, EsParametersModule, FormsAndValidationsModule, EsTableModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: SharedCommon, decorators: [{
            type: NgModule,
            args: [{ imports: [...MODULES_TO_EXPORT], exports: [...MODULES_TO_EXPORT] }]
        }] });

//Angular
const routes = [
    {
        path: "",
        children: [
            { path: "**", component: EmbeddingComponent, data: null },
        ]
    }
];
class EmbeddingModule extends BaseLazyModule {
    constructor(injector) { super(injector); }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: EmbeddingModule, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.25", ngImport: i0, type: EmbeddingModule, imports: [TemplateCommon, i1.RouterModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: EmbeddingModule, imports: [TemplateCommon, RouterModule.forChild(routes)] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.25", ngImport: i0, type: EmbeddingModule, decorators: [{
            type: NgModule,
            args: [{ imports: [TemplateCommon, RouterModule.forChild(routes)] }]
        }], ctorParameters: () => [{ type: i0.Injector }] });

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

export { BaseLazyModule, EmbeddingModule, SharedCommon, TemplateCommon };
//# sourceMappingURL=esfaenza-core-modules.mjs.map
