import { dark } from '@dvn/alaca/theme/dark';
import { light } from '@dvn/alaca/theme/light';
import { isUserLoggedIn } from '@dvn/kimlik/index';
import { Component, h, Host, Listen, Prop, State } from '@stencil/core';
function wrapContent(apiAtama, apiData, apiKimlik, apiTakvim, apiUye, logger, storage, theme, path, content) {
  return (h(Host, null,
    h("dvn-app-context-injector", { apiAtama: apiAtama, apiData: apiData, apiKimlik: apiKimlik, apiTakvim: apiTakvim, apiUye: apiUye, logger: logger, storage: storage, path: path, theme: theme },
      h("dvn-theme-provider", { colorBackground: true, fitHeight: false, theme: theme },
        h("dvn-global-table", null),
        h("dvn-global-grid", null),
        h("dvn-global-text", null),
        h("notifier-wrapper", null, content)))));
}
export class DvnAppRoot {
  constructor() {
    this.path = '/';
  }
  onThemeChange(event) {
    if (event.detail === 'dvn-dark') {
      this.theme = dark;
    }
    else {
      this.theme = light;
    }
  }
  componentWillLoad() {
    const hour = new Date().getHours();
    const isSunGone = 6 > hour || hour > 18;
    this.theme = isSunGone ? dark : light;
  }
  render() {
    if (!isUserLoggedIn(this.storage, this.logger)) {
      return wrapContent(this.apiAtama, this.apiData, this.apiKimlik, this.apiTakvim, this.apiUye, this.logger, this.storage, this.theme, this.path, h("dvn-app-anonymous", { navigate: this.navigate, path: this.path, theme: this.theme }));
    }
    return wrapContent(this.apiAtama, this.apiData, this.apiKimlik, this.apiTakvim, this.apiUye, this.logger, this.storage, this.theme, this.path, h("dvn-app", { navigate: this.navigate, path: this.path }));
  }
  static get is() { return "dvn-app-root"; }
  static get properties() { return {
    "apiAtama": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "AtamaApi",
        "resolved": "AtamaApi",
        "references": {
          "AtamaApi": {
            "location": "import",
            "path": "../../../../atama/src/api/atamaApi"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiData": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "DataApi",
        "resolved": "DataApi",
        "references": {
          "DataApi": {
            "location": "import",
            "path": "@dvn/core/api"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiKimlik": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "KimlikApi",
        "resolved": "KimlikApi",
        "references": {
          "KimlikApi": {
            "location": "import",
            "path": "@dvn/kimlik/api/kimlikApi"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiTakvim": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "TakvimApi",
        "resolved": "TakvimApi",
        "references": {
          "TakvimApi": {
            "location": "import",
            "path": "@dvn/takvim/api/takvimApi"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "apiUye": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "UyeApi",
        "resolved": "UyeApi",
        "references": {
          "UyeApi": {
            "location": "import",
            "path": "@dvn/uye/api"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "navigate": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "NavigationHandler",
        "resolved": "(config: NavigateConfig) => void",
        "references": {
          "NavigationHandler": {
            "location": "import",
            "path": "@dvn/core/routing/routing"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "path": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "path",
      "reflect": false,
      "defaultValue": "'/'"
    },
    "logger": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Logger",
        "resolved": "Logger",
        "references": {
          "Logger": {
            "location": "import",
            "path": "@dvn/core/log/logger"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "storage": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "Storage",
        "resolved": "Storage",
        "references": {
          "Storage": {
            "location": "import",
            "path": "@dvn/kimlik/storage/Storage.interface"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "theme": {}
  }; }
  static get listeners() { return [{
      "name": "themeChange",
      "method": "onThemeChange",
      "target": undefined,
      "capture": false,
      "passive": false
    }]; }
}
