"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const api_1 = require("./api");
const registries_1 = require("./registries");
const Context_1 = require("./Context");
const react_1 = tslib_1.__importDefault(require("react"));
const themes_1 = require("./themes");
const getComponent_1 = require("./getComponent");
const hooks_1 = tslib_1.__importDefault(require("./hooks"));
class BlueBase {
    constructor() {
        // APIs
        this.Analytics = new api_1.Analytics(this);
        this.Logger = new api_1.Logger(this);
        // Registries
        this.Components = new registries_1.ComponentRegistry(this);
        this.Configs = new registries_1.ConfigRegistry(this);
        this.Hooks = new registries_1.HookRegistry(this);
        this.Plugins = new registries_1.PluginRegistry(this);
        this.Themes = new registries_1.ThemeRegistry(this);
        // Flags
        this.booted = false;
        this.bootOptions = {
            components: {},
            configs: {},
            hooks: {},
            plugins: [],
            themes: [],
        };
    }
    async boot(options) {
        this.bootOptions = Object.assign({}, this.bootOptions, options);
        await this.Hooks.registerNestedCollection(hooks_1.default);
        await this.Hooks.registerNestedCollection(this.bootOptions.hooks);
        await this.Hooks.run('bluebase.boot', this.bootOptions);
        const SystemApp = getComponent_1.getComponent('SystemApp');
        // Set View
        // const SystemApp = this.Components.resolve('SystemApp');
        // SystemApp = await this.Hooks.run('bluebase.system.app', SystemApp);
        const BlueBaseRoot = () => (react_1.default.createElement(Context_1.BlueBaseProvider, { value: this },
            react_1.default.createElement(themes_1.ThemeProvider, null,
                react_1.default.createElement(SystemApp, null, options && options.children))));
        this.booted = true;
        return BlueBaseRoot;
    }
}
exports.BlueBase = BlueBase;
