import * as i0 from '@angular/core';
import { Component, Injectable, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule, ViewEncapsulation, Injector, Inject, enableProdMode, ApplicationRef } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { __param, __metadata, __decorate } from 'tslib';
import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import * as i1 from '@angular/router';
import { RouterModule, RouteReuseStrategy } from '@angular/router';
import * as i1$1 from '@angular/common/http';
import { HttpClientXsrfModule, HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
import { TimepickerModule } from 'ngx-bootstrap/timepicker';
import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
import { PaginationModule } from 'ngx-bootstrap/pagination';
import { ModalModule } from 'ngx-bootstrap/modal';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { PopoverModule } from 'ngx-bootstrap/popover';
import { NgCircleProgressModule } from 'ng-circle-progress';
import { ToastNoAnimationModule } from 'ngx-toastr';
import { CarouselModule } from 'ngx-bootstrap/carousel';
import * as i5 from '@wm/core';
import { appendScriptToHead, UserDefinedExecutionContext, getValidJSON, getWmProjectProperties, PartialRefProvider, App } from '@wm/core';
import { BasicModule } from '@wm/components/basic';
import { ProgressModule } from '@wm/components/basic/progress';
import { RichTextEditorModule } from '@wm/components/basic/rich-text-editor';
import { SearchModule } from '@wm/components/basic/search';
import { TreeModule } from '@wm/components/basic/tree';
import { InputModule } from '@wm/components/input';
import { CalendarModule } from '@wm/components/input/calendar';
import { ChipsModule } from '@wm/components/input/chips';
import { ColorPickerModule } from '@wm/components/input/color-picker';
import { CurrencyModule } from '@wm/components/input/currency';
import { EpochModule } from '@wm/components/input/epoch';
import { FileUploadModule } from '@wm/components/input/file-upload';
import { RatingModule } from '@wm/components/input/rating';
import { SliderModule } from '@wm/components/input/slider';
import { MOBILE_COMPONENT_MODULES_FOR_ROOT, MobileRuntimeDynamicModule } from '@wm/mobile/runtime/dynamic';
import { CardModule } from '@wm/components/data/card';
import { FormModule } from '@wm/components/data/form';
import { ListModule } from '@wm/components/data/list';
import { LiveTableModule } from '@wm/components/data/live-table';
import { PaginationModule as PaginationModule$1 } from '@wm/components/data/pagination';
import { TableModule } from '@wm/components/data/table';
import { ChartModule } from '@wm/components/chart';
import { AccordionModule } from '@wm/components/containers/accordion';
import { LinearLayoutModule } from '@wm/components/containers/linear-layout';
import { LayoutGridModule } from '@wm/components/containers/layout-grid';
import { PanelModule } from '@wm/components/containers/panel';
import { TabsModule } from '@wm/components/containers/tabs';
import { TileModule } from '@wm/components/containers/tile';
import { WizardModule } from '@wm/components/containers/wizard';
import { AlertDialogModule } from '@wm/components/dialogs/alert-dialog';
import { IframeDialogModule } from '@wm/components/dialogs/iframe-dialog';
import { LoginDialogModule } from '@wm/components/dialogs/login-dialog';
import { PartialDialogModule } from '@wm/components/dialogs/partial-dialog';
import { BreadcrumbModule } from '@wm/components/navigation/breadcrumb';
import { MenuModule } from '@wm/components/navigation/menu';
import { NavbarModule } from '@wm/components/navigation/navbar';
import { PopoverModule as PopoverModule$1 } from '@wm/components/navigation/popover';
import { CarouselModule as CarouselModule$1 } from '@wm/components/advanced/carousel';
import { LoginModule } from '@wm/components/advanced/login';
import { MarqueeModule } from '@wm/components/advanced/marquee';
import { PageModule } from '@wm/components/page';
import { FooterModule } from '@wm/components/page/footer';
import { HeaderModule } from '@wm/components/page/header';
import { LeftPanelModule } from '@wm/components/page/left-panel';
import { RightPanelModule } from '@wm/components/page/right-panel';
import { TopNavModule } from '@wm/components/page/top-nav';
import { PrefabModule } from '@wm/components/prefab';
import * as i4 from '@wm/runtime/base';
import { ComponentType, BasePageComponent, SecurityConfigResolve, MetadataResolve, AppExtensionJSResolve, EmptyPageComponent, PrefabPreviewComponent, CanDeactivatePageGuard, AppJSProvider, AppVariablesProvider, AppExtensionProvider, getPrefabPartialJsonUrl, getPrefabMinJsonUrl, RuntimeBaseModule, BasePrefabComponent, BasePartialComponent, ComponentRefProvider, PrefabConfigProvider, getPrefabConfigUrl, REQUIRED_MODULES_FOR_DYNAMIC_COMPONENTS, WM_MODULES_FOR_ROOT, WmRouteReuseStrategy, AppComponent } from '@wm/runtime/base';
import * as i2 from '@wm/variables';
import * as i3 from '@wm/security';
import { transpile, scopeComponentStyles } from '@wm/transpiler';
import { isUndefined, isString, isEmpty } from 'lodash-es';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

class PageWrapperComponent {
    constructor(injector, route, vcRef, appRef, metadataService, securityService, appManager, app, ngZone, elRef, spinnerService, componentRefProvider, router) {
        this.injector = injector;
        this.route = route;
        this.vcRef = vcRef;
        this.appRef = appRef;
        this.metadataService = metadataService;
        this.securityService = securityService;
        this.appManager = appManager;
        this.app = app;
        this.ngZone = ngZone;
        this.elRef = elRef;
        this.spinnerService = spinnerService;
        this.componentRefProvider = componentRefProvider;
        this.router = router;
    }
    getTargetNode() {
        return this.elRef.nativeElement;
    }
    resetViewContainer() {
        this.vcRef.clear();
        const $target = this.getTargetNode();
        $target.innerHTML = '';
    }
    renderPage(pageName) {
        const $target = this.getTargetNode();
        this.appManager.loadAppVariables()
            .then(async () => {
            const pageComponentFactoryRef = await this.componentRefProvider.getComponentFactoryRef(pageName, ComponentType.PAGE);
            if (pageComponentFactoryRef) {
                const componentRef = this.vcRef.createComponent(pageComponentFactoryRef, 0, this.injector);
                this.instance = componentRef.instance;
                $target.appendChild(componentRef.location.nativeElement);
            }
            else {
                BasePageComponent.clear();
            }
            if (this.vcRef.length > 1) {
                this.vcRef.remove(1);
            }
        });
    }
    renderPrefabPreviewPage() {
        this.router.navigate(['prefab-preview']);
    }
    loadPage(pageName) {
        this.ngZone.run(() => {
            if (pageName) {
                this.renderPage(pageName);
            }
        });
    }
    ngOnInit() {
        if (this.app.isPrefabType) {
            // there is only one route
            this.renderPrefabPreviewPage();
        }
        else {
            $(this.getTargetNode()).find('>div').first().remove();
            this.subscription = this.route.params.subscribe(({ pageName }) => {
                this.loadPage(pageName);
            });
        }
    }
    ngOnDestroy() {
        this.vcRef.clear();
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }
    ngOnAttach() {
        this.getTargetNode().appendChild(this.instance.$page[0]);
        this.instance.ngOnAttach();
    }
    ngOnDetach() {
        this.instance.ngOnDetach();
    }
    static { this.ɵfac = function PageWrapperComponent_Factory(t) { return new (t || PageWrapperComponent)(i0.ɵɵdirectiveInject(i0.Injector), i0.ɵɵdirectiveInject(i1.ActivatedRoute), i0.ɵɵdirectiveInject(i0.ViewContainerRef), i0.ɵɵdirectiveInject(i0.ApplicationRef), i0.ɵɵdirectiveInject(i2.MetadataService), i0.ɵɵdirectiveInject(i3.SecurityService), i0.ɵɵdirectiveInject(i4.AppManagerService), i0.ɵɵdirectiveInject(i5.App), i0.ɵɵdirectiveInject(i0.NgZone), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i5.AbstractSpinnerService), i0.ɵɵdirectiveInject(i4.ComponentRefProvider), i0.ɵɵdirectiveInject(i1.Router)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: PageWrapperComponent, selectors: [["app-page-outlet"]], decls: 1, vars: 0, template: function PageWrapperComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelement(0, "div");
        } }, encapsulation: 2 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PageWrapperComponent, [{
        type: Component,
        args: [{
                selector: 'app-page-outlet',
                template: '<div></div>'
            }]
    }], () => [{ type: i0.Injector }, { type: i1.ActivatedRoute }, { type: i0.ViewContainerRef }, { type: i0.ApplicationRef }, { type: i2.MetadataService }, { type: i3.SecurityService }, { type: i4.AppManagerService }, { type: i5.App }, { type: i0.NgZone }, { type: i0.ElementRef }, { type: i5.AbstractSpinnerService }, { type: i4.ComponentRefProvider }, { type: i1.Router }], null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PageWrapperComponent, { className: "PageWrapperComponent", filePath: "app/components/page-wrapper.component.ts", lineNumber: 25 }); })();

const appDependenciesResolve = {
    securityConfig: SecurityConfigResolve,
    metadata: MetadataResolve,
    appMetaConfig: AppExtensionJSResolve
};
const routes = [
    {
        path: '',
        pathMatch: 'full',
        resolve: appDependenciesResolve,
        component: EmptyPageComponent
    },
    {
        path: 'prefab-preview',
        pathMatch: 'full',
        resolve: appDependenciesResolve,
        component: PrefabPreviewComponent
    },
    {
        path: ':pageName',
        pathMatch: 'full',
        resolve: appDependenciesResolve,
        component: PageWrapperComponent,
        canDeactivate: [CanDeactivatePageGuard]
    }
];

class AppJSProviderService extends AppJSProvider {
    constructor($http) {
        super();
        this.$http = $http;
    }
    getAppScriptFn() {
        return this.$http.get('./app.js', { responseType: 'text' })
            .toPromise()
            .then(script => new Function('App', 'Utils', 'Injector', script));
    }
    static { this.ɵfac = function AppJSProviderService_Factory(t) { return new (t || AppJSProviderService)(i0.ɵɵinject(i1$1.HttpClient)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AppJSProviderService, factory: AppJSProviderService.ɵfac, providedIn: 'root' }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppJSProviderService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], () => [{ type: i1$1.HttpClient }], null); })();

const cache$1 = new Map();
class AppResourceManagerService {
    get(url, useCache) {
        const cachedResponse = cache$1.get(url);
        if (cachedResponse) {
            return Promise.resolve(cachedResponse);
        }
        return this.$http.get(url).then(response => {
            if (useCache) {
                cache$1.set(url, response);
            }
            return response;
        });
    }
    clearCache() {
        cache$1.clear();
    }
    constructor($http) {
        this.$http = $http;
    }
    static { this.ɵfac = function AppResourceManagerService_Factory(t) { return new (t || AppResourceManagerService)(i0.ɵɵinject(i5.AbstractHttpService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AppResourceManagerService, factory: AppResourceManagerService.ɵfac }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppResourceManagerService, [{
        type: Injectable
    }], () => [{ type: i5.AbstractHttpService }], null); })();

class AppVariablesProviderService extends AppVariablesProvider {
    constructor(resourceManager) {
        super();
        this.resourceManager = resourceManager;
    }
    async getAppVariables() {
        return this.resourceManager.get('./app.variables.json');
    }
    static { this.ɵfac = function AppVariablesProviderService_Factory(t) { return new (t || AppVariablesProviderService)(i0.ɵɵinject(AppResourceManagerService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AppVariablesProviderService, factory: AppVariablesProviderService.ɵfac, providedIn: 'root' }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppVariablesProviderService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], () => [{ type: AppResourceManagerService }], null); })();

class AppExtensionProviderService extends AppExtensionProvider {
    // With renderer create element, added onloaded callback the append to the body
    loadFormatterConfigScript(callback) {
        try {
            appendScriptToHead(callback);
        }
        catch (e) {
            console.warn('Error while loading the formatters.js file');
        }
    }
    static { this.ɵfac = /*@__PURE__*/ (() => { let ɵAppExtensionProviderService_BaseFactory; return function AppExtensionProviderService_Factory(t) { return (ɵAppExtensionProviderService_BaseFactory || (ɵAppExtensionProviderService_BaseFactory = i0.ɵɵgetInheritedFactory(AppExtensionProviderService)))(t || AppExtensionProviderService); }; })(); }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: AppExtensionProviderService, factory: AppExtensionProviderService.ɵfac, providedIn: 'root' }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AppExtensionProviderService, [{
        type: Injectable,
        args: [{
                providedIn: 'root'
            }]
    }], null, null); })();

const fragmentCache = new Map();
window.resourceCache = fragmentCache;
const componentFactoryRefCache = new Map();
componentFactoryRefCache.set(ComponentType.PAGE, new Map());
componentFactoryRefCache.set(ComponentType.PARTIAL, new Map());
componentFactoryRefCache.set(ComponentType.PREFAB, new Map());
const _decodeURIComponent = (str) => decodeURIComponent(str.replace(/\+/g, ' '));
const getFragmentUrl = (fragmentName, type, options) => {
    if (type === ComponentType.PAGE || type === ComponentType.PARTIAL) {
        return options && options.prefab ? getPrefabPartialJsonUrl(options.prefab, fragmentName) : `./pages/${fragmentName}/page.min.json`;
    }
    else if (type === ComponentType.PREFAB) {
        return getPrefabMinJsonUrl(fragmentName);
    }
};
const scriptCache = new Map();
const execScript = (script, identifier, ctx, instance, app, utils) => {
    let fn = scriptCache.get(identifier);
    // Fix for [WMS-21196]: Incorrect script is being assigned,  when 2 prefabs have same partial name (i.e. same identifier).
    if ((ctx === 'Partial' && !isUndefined(instance.Prefab)) || !fn) {
        fn = new Function(ctx, 'App', 'Utils', script);
        scriptCache.set(identifier, fn);
    }
    fn(instance, app, utils);
};
class BaseDynamicComponent {
    init() { }
}
const getDynamicModule = (componentRef) => {
    return NgModule({
        declarations: [componentRef],
        imports: [
            RuntimeBaseModule,
        ],
        schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA]
    })(class DynamicModule {
    });
};
const getDynamicComponent = (componentName, type, template, css, script, variables) => {
    const componentDef = {
        template,
        styles: [css],
        encapsulation: ViewEncapsulation.None
    };
    let BaseClass = BaseDynamicComponent;
    let selector = '';
    let context = '';
    switch (type) {
        case ComponentType.PAGE:
            BaseClass = BasePageComponent;
            selector = `app-page-${componentName}`;
            context = 'Page';
            break;
        case ComponentType.PARTIAL:
            BaseClass = BasePartialComponent;
            selector = `app-partial-${componentName}`;
            context = 'Partial';
            break;
        case ComponentType.PREFAB:
            BaseClass = BasePrefabComponent;
            selector = `app-prefab-${componentName}`;
            context = 'Prefab';
            break;
    }
    let DynamicComponent = class DynamicComponent extends BaseClass {
        constructor(injector) {
            super();
            this.injector = injector;
            this.isDynamicComponent = true;
            this.injector = injector;
            switch (type) {
                case ComponentType.PAGE:
                    this.pageName = componentName;
                    break;
                case ComponentType.PARTIAL:
                    this.partialName = componentName;
                    break;
                case ComponentType.PREFAB:
                    this.prefabName = componentName;
                    break;
            }
            super.init();
        }
        evalUserScript(instance, appContext, utils) {
            execScript(script, selector, context, instance, appContext, utils);
        }
        getVariables() {
            return JSON.parse(variables);
        }
        // in preview mode, there will be no function registered. functions will be generated dynamically through $parseEvent and $parseExpr
        getExpressions() {
            return {};
        }
    };
    DynamicComponent = __decorate([
        __param(0, Inject(Injector)),
        __metadata("design:paramtypes", [Injector])
    ], DynamicComponent);
    const component = Component({
        ...componentDef,
        selector,
        providers: [
            {
                provide: UserDefinedExecutionContext,
                useExisting: DynamicComponent
            }
        ]
    })(DynamicComponent);
    return component;
};
class ComponentRefProviderService extends ComponentRefProvider {
    loadResourcesOfFragment(componentName, componentType, options) {
        const url = getFragmentUrl(componentName, componentType, options);
        const resource = fragmentCache.get(url);
        if (resource) {
            return Promise.resolve(resource);
        }
        return this.resouceMngr.get(url, true)
            .then(({ markup, script, styles, variables }) => {
            const response = {
                markup: transpile(_decodeURIComponent(markup)).markup,
                script: _decodeURIComponent(script),
                styles: scopeComponentStyles(componentName, componentType, _decodeURIComponent(styles)),
                variables: getValidJSON(_decodeURIComponent(variables))
            };
            fragmentCache.set(url, response);
            return response;
        }, e => {
            const status = e.details.status;
            const errorMsgMap = {
                404: this.app.appLocale.MESSAGE_PAGE_NOT_FOUND || 'The page you are trying to reach is not available',
                403: this.app.appLocale.LABEL_ACCESS_DENIED || 'Access Denied'
            };
            return Promise.reject(errorMsgMap[status]);
        });
    }
    constructor(resouceMngr, app, appManager, compiler) {
        super();
        this.resouceMngr = resouceMngr;
        this.app = app;
        this.appManager = appManager;
        this.compiler = compiler;
    }
    async getComponentFactoryRef(componentName, componentType, options) {
        // check in the cache.
        const componentFactoryMap = componentFactoryRefCache.get(componentType);
        let componentFactoryRef;
        if (componentFactoryMap) {
            const updatedComponentName = (options && options['prefab']) ? options['prefab'] + componentName : componentName;
            componentFactoryRef = componentFactoryMap.get(updatedComponentName);
            if (componentFactoryRef) {
                return componentFactoryRef;
            }
        }
        return this.loadResourcesOfFragment(componentName, componentType, options)
            .then(({ markup, script, styles, variables }) => {
            const componentDef = getDynamicComponent(componentName, componentType, markup, styles, script, JSON.stringify(variables));
            const moduleDef = getDynamicModule(componentDef);
            componentFactoryRef = this.compiler
                .compileModuleAndAllComponentsSync(moduleDef)
                .componentFactories
                .filter(factory => // @ts-ignore
             factory.componentType === componentDef)[0];
            const updatedComponentName = (options && options['prefab']) ? options['prefab'] + componentName : componentName;
            componentFactoryRefCache.get(componentType).set(updatedComponentName, componentFactoryRef);
            return componentFactoryRef;
        }, (err) => {
            if (err) {
                const msg = "Error while loading page";
                // console the error for easy debugging
                console.log(msg, err);
                this.appManager.notifyApp(isString(err) ? err : msg + ', check browser console for error details', 'error');
            }
        });
    }
    // clears the cache map
    clearComponentFactoryRefCache() {
        this.resouceMngr.clearCache();
        fragmentCache.clear();
        componentFactoryRefCache.forEach(map => {
            map.clear();
        });
    }
    static { this.ɵfac = function ComponentRefProviderService_Factory(t) { return new (t || ComponentRefProviderService)(i0.ɵɵinject(AppResourceManagerService), i0.ɵɵinject(i5.App), i0.ɵɵinject(i4.AppManagerService), i0.ɵɵinject(i0.Compiler)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ComponentRefProviderService, factory: ComponentRefProviderService.ɵfac }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ComponentRefProviderService, [{
        type: Injectable
    }], () => [{ type: AppResourceManagerService }, { type: i5.App }, { type: i4.AppManagerService }, { type: i0.Compiler }], null); })();

const cache = new Map();
class PrefabConfigProviderService extends PrefabConfigProvider {
    constructor(resourceMngr) {
        super();
        this.resourceMngr = resourceMngr;
    }
    getConfig(prefabName) {
        const config = cache.get(prefabName);
        if (config) {
            return Promise.resolve(config);
        }
        return this.resourceMngr.get(getPrefabConfigUrl(prefabName))
            .then(_config => {
            cache.set(prefabName, _config);
            return _config;
        });
    }
    static { this.ɵfac = function PrefabConfigProviderService_Factory(t) { return new (t || PrefabConfigProviderService)(i0.ɵɵinject(AppResourceManagerService)); }; }
    static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: PrefabConfigProviderService, factory: PrefabConfigProviderService.ɵfac }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(PrefabConfigProviderService, [{
        type: Injectable
    }], () => [{ type: AppResourceManagerService }], null); })();

const routerModule = RouterModule.forRoot(routes, { useHash: true, scrollPositionRestoration: 'top' });
const toastrModule = ToastNoAnimationModule.forRoot({ maxOpened: 1, autoDismiss: true });
// In angular 15, xsrf headerName should not be null. Angular 15 is not using default header value like it used to send in calls
// for angular 12 if the headerName is null . The user has to take care of not sending null values. Then ng 15 uses default value for headerName
let xsrfHeaderName = getWmProjectProperties().xsrf_header_name;
let xsrfOptions = {
    cookieName: 'wm_xsrf_token'
};
if (xsrfHeaderName) {
    xsrfOptions['headerName'] = xsrfHeaderName;
}
const httpClientXsrfModule = HttpClientXsrfModule.withOptions(xsrfOptions);
const modalModule = ModalModule.forRoot();
const bsDatePickerModule = BsDatepickerModule.forRoot();
const timepickerModule = TimepickerModule.forRoot();
const bsDropdownModule = BsDropdownModule.forRoot();
const paginationModule = PaginationModule.forRoot();
const typeaheadModule = TypeaheadModule.forRoot();
const progressbarModule = ProgressbarModule.forRoot();
const carouselModule = CarouselModule.forRoot();
const popoverModule = PopoverModule.forRoot();
const ngCircleProgressModule = NgCircleProgressModule.forRoot({});
const tooltipModule = TooltipModule.forRoot();
const componentsModule = [
    // NGX Bootstrap
    BsDatepickerModule,
    TimepickerModule,
    BsDropdownModule,
    PaginationModule,
    TypeaheadModule,
    ProgressbarModule,
    CarouselModule,
    PopoverModule,
    NgCircleProgressModule,
    TooltipModule,
    // Basic widgets
    BasicModule,
    ProgressModule,
    RichTextEditorModule,
    SearchModule,
    TreeModule,
    // Input
    CalendarModule,
    ChipsModule,
    ColorPickerModule,
    CurrencyModule,
    EpochModule,
    FileUploadModule,
    InputModule,
    RatingModule,
    SliderModule,
    // Data
    CardModule,
    FormModule,
    ListModule,
    LiveTableModule,
    PaginationModule$1,
    TableModule,
    // chart
    ChartModule,
    // container modules
    AccordionModule,
    LinearLayoutModule,
    LayoutGridModule,
    PanelModule,
    TabsModule,
    TileModule,
    WizardModule,
    // dialogs
    AlertDialogModule,
    IframeDialogModule,
    LoginDialogModule,
    PartialDialogModule,
    // navigation
    BreadcrumbModule,
    MenuModule,
    NavbarModule,
    PopoverModule$1,
    // Advanced
    CarouselModule$1,
    LoginModule,
    MarqueeModule,
    PageModule,
    FooterModule,
    HeaderModule,
    LeftPanelModule,
    RightPanelModule,
    TopNavModule,
    PrefabModule
];
REQUIRED_MODULES_FOR_DYNAMIC_COMPONENTS.push(...componentsModule);
REQUIRED_MODULES_FOR_DYNAMIC_COMPONENTS.push(...MOBILE_COMPONENT_MODULES_FOR_ROOT);
REQUIRED_MODULES_FOR_DYNAMIC_COMPONENTS.push(FormsModule, ReactiveFormsModule);
let AppModule = class AppModule {
    constructor(app, inj, componentRefProvider) {
        this.app = app;
        this.inj = inj;
        this.componentRefProvider = componentRefProvider;
        if (window['cordova']) {
            // clear the cached urls on logout, to load the Login Page and not the Main Page as app reload(window.location.reload) is not invoked in mobile
            this.app.subscribe('userLoggedOut', this.componentRefProvider.clearComponentFactoryRefCache.bind(this.componentRefProvider));
        }
    }
};
AppModule = __decorate([
    NgModule({
        declarations: [
            PageWrapperComponent
        ],
        imports: [
            BrowserModule,
            BrowserAnimationsModule,
            CommonModule,
            RouterModule,
            HttpClientModule,
            modalModule,
            bsDatePickerModule,
            timepickerModule,
            bsDropdownModule,
            paginationModule,
            typeaheadModule,
            tooltipModule,
            progressbarModule,
            carouselModule,
            popoverModule,
            ngCircleProgressModule,
            routerModule,
            toastrModule,
            httpClientXsrfModule,
            MobileRuntimeDynamicModule,
            WM_MODULES_FOR_ROOT
        ],
        providers: [
            AppResourceManagerService,
            { provide: AppJSProvider, useClass: AppJSProviderService },
            { provide: AppVariablesProvider, useClass: AppVariablesProviderService },
            { provide: AppExtensionProvider, useClass: AppExtensionProviderService },
            { provide: ComponentRefProvider, useClass: ComponentRefProviderService },
            { provide: PartialRefProvider, useClass: ComponentRefProviderService },
            { provide: PrefabConfigProvider, useClass: PrefabConfigProviderService },
            { provide: RouteReuseStrategy, useClass: WmRouteReuseStrategy }
        ],
        bootstrap: [AppComponent]
    }),
    __metadata("design:paramtypes", [App, Injector, ComponentRefProvider])
], AppModule);

const DEBUG_MODE = 'debugMode';
if (sessionStorage.getItem(DEBUG_MODE) !== 'true') {
    enableProdMode();
}
console.time('bootstrap');
document.addEventListener('DOMContentLoaded', () => {
    new Promise(resolve => {
        if (window['cordova']) {
            document.addEventListener('deviceready', resolve);
        }
        else {
            resolve();
        }
    }).then(() => platformBrowserDynamic().bootstrapModule(AppModule))
        .then((appModuleRef) => {
        const applicationRef = appModuleRef.injector.get(ApplicationRef);
        window.addEventListener('unload', () => {
            applicationRef.components.map(c => c && c.destroy());
        });
        console.timeEnd('bootstrap');
    }, err => console.log(err));
});
window.debugMode = function (on) {
    if (isEmpty(on)) {
        on = true;
    }
    const value = on ? 'true' : 'false';
    if (sessionStorage.getItem(DEBUG_MODE) !== value) {
        sessionStorage.setItem(DEBUG_MODE, value);
        window.location.reload();
    }
};
var main = () => { };

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

export { AppExtensionProviderService, AppJSProviderService, AppModule, AppResourceManagerService, AppVariablesProviderService, ComponentRefProviderService, PageWrapperComponent, PrefabConfigProviderService, bsDatePickerModule, bsDropdownModule, carouselModule, httpClientXsrfModule, modalModule, ngCircleProgressModule, paginationModule, popoverModule, progressbarModule, routerModule, timepickerModule, toastrModule, tooltipModule, typeaheadModule };
//# sourceMappingURL=index.mjs.map
