{"version":3,"file":"GoogleSignIn.cjs","names":[],"sources":["../../src/oauth/GoogleSignIn.tsx"],"sourcesContent":["/**\n * @tempest-limits props-count — component, theme, text, shape, size and width are\n * Google's own button parameters, passed through with their names intact so the\n * reader can match them to Google's documentation;\n * onSuccess/onError/locale/disableOneTap are the wrapper's.\n */\nimport type { CSSProperties, ReactNode } from \"react\";\nimport type { OAuthCredential, OAuthError } from \"./types\";\n\nexport type GoogleSignInTheme = \"filled_blue\" | \"filled_black\" | \"outline\";\nexport type GoogleSignInText = \"signin_with\" | \"signup_with\" | \"continue_with\" | \"signin\";\nexport type GoogleSignInShape = \"rectangular\" | \"pill\" | \"circle\" | \"square\";\nexport type GoogleSignInSize = \"large\" | \"medium\" | \"small\";\n\nexport interface GoogleSignInProps {\n    /**\n     * `GoogleLogin` component from `@react-oauth/google`. The caller imports\n     * it and passes it through so the SDK doesn't take `@react-oauth/google`\n     * as a peer dep.\n     */\n    component: (props: Record<string, unknown>) => ReactNode;\n    /** Fired with the validated credential on success. */\n    onSuccess: (credential: OAuthCredential) => void | Promise<void>;\n    /** Fired with a normalised error on failure. */\n    onError?: (error: OAuthError) => void;\n    /** Optional locale override (e.g. `\"pt-BR\"`). Falls back to browser locale. */\n    locale?: string;\n    /** Visual theme — passed through to `<GoogleLogin>`. */\n    theme?: GoogleSignInTheme;\n    /** Button text variant. */\n    text?: GoogleSignInText;\n    /** Button shape. */\n    shape?: GoogleSignInShape;\n    /** Button size. */\n    size?: GoogleSignInSize;\n    /** Disable Google's \"One Tap\" auto-prompt. Default `false`. */\n    disableOneTap?: boolean;\n    /** Optional `width` override (px) — Google's button is fixed-width. */\n    width?: number;\n    /** Optional className applied to the wrapper. */\n    className?: string;\n    /** Optional inline style applied to the wrapper. */\n    style?: CSSProperties;\n}\n\n/**\n * Thin wrapper over `@react-oauth/google`'s `<GoogleLogin>` that:\n *\n * 1. Normalises the success payload into [[OAuthCredential]] (`idToken`,\n *    `provider: \"google\"`, `raw`).\n * 2. Normalises errors into [[OAuthError]].\n * 3. Lets you pass `GoogleLogin` via the `component` prop, so the SDK does\n *    not declare `@react-oauth/google` as a peer dep — apps that don't use\n *    Google never pay for it.\n *\n * @example\n * import { GoogleLogin, GoogleOAuthProvider } from \"@react-oauth/google\";\n * import { GoogleSignIn } from \"tempest-react-sdk\";\n *\n * <GoogleOAuthProvider clientId={import.meta.env.VITE_GOOGLE_CLIENT_ID}>\n *     <GoogleSignIn\n *         component={GoogleLogin}\n *         onSuccess={async ({ idToken }) => {\n *             await api.post(\"/auth/google\", { body: { id_token: idToken } });\n *         }}\n *         onError={(err) => toast.error(err.message)}\n *     />\n * </GoogleOAuthProvider>\n */\nexport function GoogleSignIn({\n    component: Component,\n    onSuccess,\n    onError,\n    locale,\n    theme,\n    text,\n    shape,\n    size,\n    disableOneTap,\n    width,\n    className,\n    style,\n}: GoogleSignInProps) {\n    return (\n        <div className={className} style={style}>\n            {Component({\n                onSuccess: (response: { credential?: string }) => {\n                    if (!response.credential) {\n                        onError?.({\n                            provider: \"google\",\n                            message: \"Google returned no credential\",\n                            raw: response,\n                        });\n                        return;\n                    }\n                    return onSuccess({\n                        idToken: response.credential,\n                        provider: \"google\",\n                        raw: response,\n                    });\n                },\n                onError: () => {\n                    onError?.({\n                        provider: \"google\",\n                        message: \"Google login failed\",\n                    });\n                },\n                locale,\n                theme,\n                text,\n                shape,\n                size,\n                useOneTap: !disableOneTap,\n                width,\n            })}\n        </div>\n    );\n}\n"],"mappings":"mCAqEA,SAAgB,EAAa,CACzB,UAAW,EACX,YACA,UACA,SACA,QACA,OACA,QACA,OACA,gBACA,QACA,YACA,SACkB,CAClB,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CAAgB,YAAkB,QAC7B,SAAA,EAAU,CACP,UAAY,GAAsC,CAC9C,GAAI,CAAC,EAAS,WAAY,CACtB,IAAU,CACN,SAAU,SACV,QAAS,gCACT,IAAK,CACT,CAAC,EACD,MACJ,CACA,OAAO,EAAU,CACb,QAAS,EAAS,WAClB,SAAU,SACV,IAAK,CACT,CAAC,CACL,EACA,YAAe,CACX,IAAU,CACN,SAAU,SACV,QAAS,qBACb,CAAC,CACL,EACA,SACA,QACA,OACA,QACA,OACA,UAAW,CAAC,EACZ,OACJ,CAAC,CACA,CAAA,CAEb"}