import { h } from "@stencil/core";
import firebase from 'firebase/app';
import { initializeFirebaseApp } from '../../firebase';
var LoggedInState;
(function (LoggedInState) {
    LoggedInState[LoggedInState["LOADING"] = 0] = "LOADING";
    LoggedInState[LoggedInState["LOGGED_IN"] = 1] = "LOGGED_IN";
    LoggedInState[LoggedInState["LOGGED_OUT"] = 2] = "LOGGED_OUT";
})(LoggedInState || (LoggedInState = {}));
export class Picker {
    constructor() {
        this.loggedIn = LoggedInState.LOADING;
        initializeFirebaseApp();
        firebase.app().auth().onAuthStateChanged(auth => {
            if (!auth) {
                this.loggedIn = LoggedInState.LOGGED_OUT;
            }
            else if (Boolean(auth.uid)) {
                this.loggedIn = LoggedInState.LOGGED_IN;
            }
        });
    }
    render() {
        if (this.loggedIn === LoggedInState.LOADING) {
            return h("eva-config-picker-spinner", null);
        }
        else if (this.loggedIn === LoggedInState.LOGGED_IN) {
            return h("eva-config-picker-customer", null);
        }
        else if (this.loggedIn === LoggedInState.LOGGED_OUT) {
            return h("eva-config-picker-login", null);
        }
    }
    static get is() { return "eva-config-picker"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() { return {
        "$": ["picker.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["picker.css"]
    }; }
    static get states() { return {
        "loggedIn": {}
    }; }
}
