import { useLingui } from '../../../../../../node_modules/@lingui/react/dist/index.mjs';
import React__default from 'react';
import Button from '../../components/atoms/Button.mjs';
import { usePresentation, getButtonId } from '../../components/PresentationConfig.mjs';
import { useStytch } from '../GlobalContextProvider.mjs';
import { OAuthProviders } from '../../../../../core/src/public/ui.mjs';

const providerInfo = {
    [OAuthProviders.Google]: {
        messageDescriptor: {
            id: "oauth.continueWithGoogle",
            message: "Continue with Google"
        }
    },
    [OAuthProviders.Microsoft]: {
        messageDescriptor: {
            id: "oauth.continueWithMicrosoft",
            message: "Continue with Microsoft"
        }
    },
    [OAuthProviders.Apple]: {
        messageDescriptor: {
            id: "oauth.continueWithApple",
            message: "Continue with Apple"
        }
    },
    [OAuthProviders.Github]: {
        messageDescriptor: {
            id: "oauth.continueWithGitHub",
            message: "Continue with GitHub"
        }
    },
    [OAuthProviders.GitLab]: {
        messageDescriptor: {
            id: "oauth.continueWithGitLab",
            message: "Continue with GitLab"
        }
    },
    [OAuthProviders.Facebook]: {
        messageDescriptor: {
            id: "oauth.continueWithFacebook",
            message: "Continue with Facebook"
        }
    },
    [OAuthProviders.Discord]: {
        messageDescriptor: {
            id: "oauth.continueWithDiscord",
            message: "Continue with Discord"
        }
    },
    [OAuthProviders.Salesforce]: {
        messageDescriptor: {
            id: "oauth.continueWithSalesforce",
            message: "Continue with Salesforce"
        }
    },
    [OAuthProviders.Slack]: {
        messageDescriptor: {
            id: "oauth.continueWithSlack",
            message: "Continue with Slack"
        }
    },
    [OAuthProviders.Amazon]: {
        messageDescriptor: {
            id: "oauth.continueWithAmazon",
            message: "Continue with Amazon"
        }
    },
    [OAuthProviders.Bitbucket]: {
        messageDescriptor: {
            id: "oauth.continueWithBitbucket",
            message: "Continue with Bitbucket"
        }
    },
    [OAuthProviders.LinkedIn]: {
        messageDescriptor: {
            id: "oauth.continueWithLinkedIn",
            message: "Continue with LinkedIn"
        }
    },
    [OAuthProviders.Coinbase]: {
        messageDescriptor: {
            id: "oauth.continueWithCoinbase",
            message: "Continue with Coinbase"
        }
    },
    [OAuthProviders.Twitch]: {
        messageDescriptor: {
            id: "oauth.continueWithTwitch",
            message: "Continue with Twitch"
        }
    },
    [OAuthProviders.Twitter]: {
        messageDescriptor: {
            id: "oauth.continueWithX",
            message: "Continue with X"
        }
    },
    [OAuthProviders.TikTok]: {
        messageDescriptor: {
            id: "oauth.continueWithTikTok",
            message: "Continue with TikTok"
        }
    },
    [OAuthProviders.Snapchat]: {
        messageDescriptor: {
            id: "oauth.continueWithSnapchat",
            message: "Continue with Snapchat"
        }
    },
    [OAuthProviders.Figma]: {
        messageDescriptor: {
            id: "oauth.continueWithFigma",
            message: "Continue with Figma"
        }
    },
    [OAuthProviders.Yahoo]: {
        messageDescriptor: {
            id: "oauth.continueWithYahoo",
            message: "Continue with Yahoo"
        }
    }
};
const OAuthButton = ({ providerType, loginRedirectUrl, signupRedirectUrl, customScopes, providerParams, onSuccess })=>{
    const { i18n: $__i18n, _: $__ } = useLingui();
    const stytchClient = useStytch();
    const presentation = usePresentation();
    const iconRegistry = presentation.iconRegistry;
    const id = getButtonId(`oauth-${providerType}`, presentation.options);
    const provider = providerInfo[providerType];
    let label = providerType;
    let icon = null;
    if (provider) {
        const { messageDescriptor } = provider;
        const iconName = providerType === 'twitter' ? 'xTwitter' : providerType;
        const Icon = iconRegistry[iconName];
        label = $__i18n._(messageDescriptor);
        icon = /*#__PURE__*/ React__default.createElement(Icon, null);
    }
    const onButtonClick = async ()=>{
        await stytchClient.oauth[providerType].start({
            login_redirect_url: loginRedirectUrl,
            signup_redirect_url: signupRedirectUrl,
            custom_scopes: customScopes,
            provider_params: providerParams
        });
        onSuccess?.();
    };
    return /*#__PURE__*/ React__default.createElement(Button, {
        onClick: onButtonClick,
        variant: "outline",
        icon: icon,
        id: id
    }, label);
};

export { OAuthButton };
//# sourceMappingURL=OAuthButton.mjs.map
