var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promise, generator) {
    return new Promise(function (resolve, reject) {
        generator = generator.call(thisArg, _arguments);
        function cast(value) { return value instanceof Promise && value.constructor === Promise ? value : new Promise(function (resolve) { resolve(value); }); }
        function onfulfill(value) { try { step("next", value); } catch (e) { reject(e); } }
        function onreject(value) { try { step("throw", value); } catch (e) { reject(e); } }
        function step(verb, value) {
            var result = generator[verb](value);
            result.done ? resolve(result.value) : cast(result.value).then(onfulfill, onreject);
        }
        step("next", void 0);
    });
};
export class Base {
    constructor() {
        /*
        * Application base class: initializes global '_abl' namespace
        * */
        this._environment = { type: 'js', namespace: '_abl' };
        this._settings = {};
        this.settings = {};
        // browser
        if (typeof window !== 'undefined') {
            this._environment.type = 'browser';
            if (window['angular']) {
                this._environment.framework = 'angular-js';
            }
            if (!window['angular']) {
                this._environment.framework = 'angular';
            }
            if (!window[this._environment.namespace]) {
                window[this._environment.namespace] = {};
            }
        }
        // nodejs
        if (typeof window === 'undefined') {
            this._environment.type = 'nodejs';
            this._environment.framework = 'nodejs';
        }
        this._environment.date = new Date();
        this._environment.started = Math.round(+new Date() / 1000);
    }
    init(settings) {
        const self = this;
        return new Promise(function (resolve, reject) {
            if (typeof settings === 'string') {
                fetch(settings)
                    .then(function (response) {
                    return response.json();
                })
                    .then(function (json) {
                    self.settings = json;
                    resolve();
                });
            }
            else {
                self.settings = settings;
                resolve();
            }
        });
    }
}
//# sourceMappingURL=base.js.map