System.register(["lodash", "@stratusjs/runtime/stratus", "@angular/core", "./angular.module", "../../map/src/map.module", "../../stripe/src/stripe.module"], function (exports_1, context_1) {
    "use strict";
    var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    var __metadata = (this && this.__metadata) || function (k, v) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
    };
    var lodash_1, stratus_1, core_1, angular_module_1, map_module_1, stripe_module_1, ngModuleImports, appModuleComponents, stratusPackages, AppModule;
    var __moduleName = context_1 && context_1.id;
    return {
        setters: [
            function (lodash_1_1) {
                lodash_1 = lodash_1_1;
            },
            function (stratus_1_1) {
                stratus_1 = stratus_1_1;
            },
            function (core_1_1) {
                core_1 = core_1_1;
            },
            function (angular_module_1_1) {
                angular_module_1 = angular_module_1_1;
            },
            function (map_module_1_1) {
                map_module_1 = map_module_1_1;
            },
            function (stripe_module_1_1) {
                stripe_module_1 = stripe_module_1_1;
            }
        ],
        execute: function () {
            ngModuleImports = [];
            appModuleComponents = {};
            stratusPackages = [
                angular_module_1.AngularPackage,
                map_module_1.MapPackage,
                stripe_module_1.StripePackage
            ];
            stratusPackages.forEach((stratusPackage) => {
                ngModuleImports.push(stratusPackage.stratusModule);
                if (stratusPackage.hasOwnProperty('stratusComponents')) {
                    lodash_1.extend(appModuleComponents, stratusPackage.stratusComponents);
                }
            });
            AppModule = class AppModule {
                initialTimeout = 1000;
                instances = {};
                modules = appModuleComponents;
                constructor() {
                    stratus_1.Stratus.Instances[lodash_1.uniqueId('sa_app_module_')] = this;
                }
                ngDoBootstrap(appRef) {
                    this.detectBoot(appRef);
                }
                exponentialTimeout(limit) {
                    if (lodash_1.isNumber(limit) && limit < this.initialTimeout) {
                        return limit;
                    }
                    const currentTimeout = this.initialTimeout;
                    this.initialTimeout = this.initialTimeout * 1.01;
                    return currentTimeout;
                }
                detectBoot(appRef) {
                    lodash_1.forEach(this.modules, (module, selector) => {
                        const elements = document.getElementsByTagName(selector);
                        if (!elements || !elements.length) {
                            return;
                        }
                        lodash_1.forEach(elements, (node) => {
                            if (node.hasAttribute('ng-version')) {
                                return;
                            }
                            appRef.bootstrap(module, node);
                        });
                    });
                    setTimeout(() => {
                        this.detectBoot(appRef);
                    }, this.exponentialTimeout(4000));
                }
            };
            AppModule = __decorate([
                core_1.NgModule({
                    imports: ngModuleImports,
                    providers: [
                        { provide: Window, useValue: window }
                    ]
                }),
                __metadata("design:paramtypes", [])
            ], AppModule);
            exports_1("AppModule", AppModule);
        }
    };
});

//# sourceMappingURL=app.module.js.map
