'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-1141a245.js');
const dark = require('./dark-f2d90718.js');
const light = require('./light-d6947636.js');
const index$1 = require('./index-c7be53b8.js');
const theme = require('./theme-d6d90347.js');
require('./colors-a0e2d25f.js');
require('./kimlik-api-d3c479a3.js');
require('./apiBase-e4ebaf8b.js');
require('./data-transfer-field-e8417d5f.js');
require('./BaseField-381327a9.js');
require('./filter-d5040f65.js');
require('./cookie-135bf612.js');
require('./_commonjsHelpers-206db00d.js');

function wrapContent(theme, content) {
  return (index.h(index.Host, null, index.h("mentornity-console-app-context-injector", { theme: theme }, index.h("dvn-theme-provider", { colorBackground: true, fitHeight: true, theme: theme }, index.h("dvn-global-table", null), index.h("dvn-global-grid", null), index.h("dvn-global-text", null), index.h("notifier-wrapper", null, content)))));
}
const MentornityConsoleAppRoot = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.theme = light.light;
    this.navigate = (config) => {
      this.path = config.path;
      history.pushState({}, '', this.path);
    };
  }
  onThemeChange(event) {
    if (event.detail === 'dvn-dark') {
      this.theme = dark.dark;
    }
    else {
      this.theme = light.light;
    }
  }
  componentWillLoad() {
    // get the current appearance from device and start watching the appearance change events
    if (theme.watchDeviceAppearance(appearance => this.theme = appearance === 'dark' ? dark.dark : light.light) === 'dark') {
      this.theme = dark.dark;
    }
    this.path = location.pathname;
  }
  render() {
    if (!index$1.isUserLoggedIn()) {
      return wrapContent(this.theme, index.h("dvn-app-anonymous", { navigate: this.navigate, path: this.path }));
    }
    return wrapContent(this.theme, index.h("dvn-app", { navigate: this.navigate, path: this.path }));
  }
};

exports.mentornity_console_app_root = MentornityConsoleAppRoot;
