System.register(["@stratusjs/core/environment", "lodash", "@stratusjs/runtime/stratus"], function (exports_1, context_1) {
    "use strict";
    var environment_1, lodash_1, stratus_1, ResponsiveComponent;
    var __moduleName = context_1 && context_1.id;
    return {
        setters: [
            function (environment_1_1) {
                environment_1 = environment_1_1;
            },
            function (lodash_1_1) {
                lodash_1 = lodash_1_1;
            },
            function (stratus_1_1) {
                stratus_1 = stratus_1_1;
            }
        ],
        execute: function () {
            ResponsiveComponent = class ResponsiveComponent {
                constructor() {
                    this.disableRefresh = false;
                    this.stagger = true;
                    this.reloading = false;
                }
                refresh() {
                    return new Promise((resolve, reject) => {
                        if (this.disableRefresh) {
                            resolve();
                            return;
                        }
                        if (!this.ref) {
                            console.error('ChangeDetectorRef not set:', this.uid);
                            reject();
                            return;
                        }
                        if (this.reloading && this.stagger) {
                            if (environment_1.cookie('env')) {
                                console.warn('[flow control] waiting to refresh component:', this.uid);
                            }
                            setTimeout(() => {
                                this.refresh()
                                    .then(() => resolve());
                            }, 100);
                            return;
                        }
                        this.reloading = true;
                        this.ref.detectChanges();
                        this.reloading = false;
                        resolve();
                    });
                }
                ngOnDestroy() {
                    if (!lodash_1.default.isEmpty(this.uid)) {
                        return;
                    }
                    delete stratus_1.Stratus.Instances[this.uid];
                }
            };
            exports_1("ResponsiveComponent", ResponsiveComponent);
        }
    };
});

//# sourceMappingURL=responsive.component.js.map
