import { h } from "@stencil/core";
import firebase from 'firebase/app';
export class PickerLogin {
    async loginWithGoogle() {
        try {
            await firebase.auth().signInWithPopup(new firebase.auth.GoogleAuthProvider());
        }
        catch (error) {
            console.error('[eva-config-picker-login] Error calling signInWithPopup with the GoogleAuthProvider sign-in', error);
        }
    }
    async loginWithMicrosoft() {
        try {
            await firebase.auth().signInWithPopup(new firebase.auth.OAuthProvider('microsoft.com'));
        }
        catch (error) {
            console.error('[eva-config-picker-login] Error calling signInWithPopup with the microsoft.com OAuthProvider', error);
        }
    }
    async loginWithGithub() {
        try {
            const githubProvider = new firebase.auth.GithubAuthProvider();
            await firebase.auth().signInWithPopup(githubProvider);
        }
        catch (error) {
            console.error('[eva-config-picker-login] Error calling signInWithPopup with the microsoft.com OAuthProvider', error);
            if (error.code === 'auth/account-exists-with-different-credential') {
                alert(error.message);
            }
        }
    }
    render() {
        return (h("div", null,
            h("div", { class: "login-button google", role: "login button", onClick: () => this.loginWithGoogle() },
                h("img", { src: "assets/images/btn_google_dark_normal_ios.svg" }),
                h("span", null, "Sign in with Google")),
            h("img", { onClick: () => this.loginWithMicrosoft(), class: "ms-login-button", src: "assets/images/ms-login-button.svg" }),
            h("div", { class: "login-button github", onClick: () => this.loginWithGithub() },
                h("img", { src: "assets/images/github_logo.png", alt: "github logo" }),
                h("span", null, "Sign in with Github"))));
    }
    static get is() { return "eva-config-picker-login"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() { return {
        "$": ["picker-login.scss"]
    }; }
    static get styleUrls() { return {
        "$": ["picker-login.css"]
    }; }
}
