/**
 * LoginWindow - login modal for KeepworkSDK.
 *
 * Features:
 * - Username/password login
 * - Registration (username/password)
 * - WeChat QR login on desktop
 * - WeChat OAuth redirect login inside WeChat browser
 * - Google OAuth login (opt-in via googleClientId option)
 * - English / Chinese i18n (auto-detected from system language)
 * - Mobile-responsive
 *
 * All UI, styles, and logic are self-contained in this file.
 */
type LoginStrings = Record<string, string>;
/**
 * 宽松的 DOM 元素类型：登录弹窗内的元素可能是 input/button/div，
 * 这里用交叉类型统一暴露用到的属性（value/disabled/style/focus 等），
 * 避免在每个 querySelector 处分别断言。运行时行为与原 JS 一致。
 */
type LWEl = HTMLInputElement & HTMLButtonElement & HTMLElement & HTMLIFrameElement;
/** LoginWindow 依赖的 SDK 表面 */
interface LWSdk {
    wxAuth?: unknown;
    login(...args: unknown[]): Promise<Record<string, unknown>>;
    register?(...args: unknown[]): Promise<unknown>;
    request?(...args: unknown[]): Promise<unknown>;
    post(path: string, body?: unknown): Promise<Record<string, unknown>>;
    get(path: string, query?: unknown): Promise<Record<string, unknown>>;
    setToken(token: unknown): void;
    [key: string]: unknown;
}
export default class LoginWindow {
    sdk: LWSdk;
    _wxAuthInstance: unknown;
    _overlay: HTMLElement | null;
    _styleEl: HTMLStyleElement | null;
    _wechatPollingTimer: ReturnType<typeof setInterval> | null;
    _resetTimer: ReturnType<typeof setTimeout> | null;
    _processedWechatCodes: Set<string>;
    _googlePopup: Window | null;
    _googlePollingTimer: ReturnType<typeof setInterval> | null;
    _googleCodeHandled: boolean;
    _googleMessageHandler: ((e: MessageEvent) => void) | null;
    _googleSentState: string | null;
    _viewportHandler: (() => void) | null;
    _oauthBindCtx: Record<string, unknown> | null;
    _lang?: string;
    _strings?: LoginStrings;
    _title?: string;
    _platform?: unknown;
    _machineCode?: unknown;
    _resolve?: (v: Record<string, unknown>) => void;
    _reject?: (e: Error) => void;
    _wechatOptions?: Record<string, string>;
    _googleOptions?: Record<string, unknown>;
    [key: string]: unknown;
    constructor(sdk: unknown);
    /**
     * Show the login window.
     * @param {Object} options
     * @param {string}  [options.title]          - Custom title
     * @param {string}  [options.lang]           - 'zhCN' | 'enUS' (auto-detected if omitted)
     * @param {boolean} [options.enableRegister=true] - Show register view
     * @param {boolean} [options.enableWechat=true]   - Show WeChat login
     * @param {string}  [options.wechatAppId]    - WeChat QR connect app id
     * @param {string}  [options.wechatRedirectUri] - Redirect URI for WeChat QR connect
     * @param {boolean} [options.enableGoogle]   - Show Google login button (requires googleClientId)
     * @param {string}  [options.googleClientId] - Google OAuth client id (web). Required to enable Google login.
     * @param {string}  [options.googleRedirectUri] - Redirect URI registered in Google Cloud Console
     * @param {string}  [options.googleScope]    - OAuth scope (default: 'openid email profile')
     * @param {string}  [options.googleState]    - OAuth state (default: 'login')
     * @param {string}  [options.platform]       - Platform tag forwarded to backend
     * @param {string}  [options.machineCode]    - Machine code forwarded to backend
     * @returns {Promise<Object>} Resolves with login/register response on success, rejects on cancel
     */
    show(options?: Record<string, unknown>): Promise<Record<string, unknown>>;
    /**
     * Close the login window if open.
     */
    close(): void;
    /**
     * 打开登录弹窗并直接进入「设置账号」视图，用于微信回调全局识别后、
     * 探测到未绑定账号（needBind）时完成绑定登录。
     *
     * show() 内部同步创建并挂载 overlay 后才返回 Promise，因此可在返回后立即
     * 切换到 oauth-setup 视图（用户只会看到设置账号界面，不会看到账号/密码登录界面）。
     *
     * @param data    - codeToProbe 返回的 { ticket, suggestedUsername, provider, bindPath? }
     * @param options - 透传给 show() 的选项（title / lang 等）
     * @returns 与 show() 一致：绑定成功 resolve 登录结果，取消 reject
     */
    showWechatBindSetup(data: Record<string, unknown>, options?: Record<string, unknown>): Promise<Record<string, unknown>>;
    _renderWechatQrPanel(t: (k: string) => string): string;
    _renderSocialPanel(t: (k: string) => string, { showGoogle, showWechatRedirect, showPasswordEntry }?: {
        showGoogle?: boolean;
        showWechatRedirect?: boolean;
        showPasswordEntry?: boolean;
    }): string;
    _switchView(overlay: HTMLElement, viewId: string): void;
    _normalizeWechatOptions(options: Record<string, unknown>): Record<string, string>;
    _getDefaultWechatRedirectUri(): string;
    _getWechatAuthUrl(): string;
    _startWechatPolling(overlay: HTMLElement): void;
    _stopWechatPolling(): void;
    _maybeHandleWechatCodeFromCurrentUrl(overlay: HTMLElement): void;
    _handleWechatCode(code: string, state: string | null, overlay: HTMLElement): Promise<void>;
    _isWechatCodeProcessed(code: string): boolean;
    _markWechatCodeProcessed(code: string): void;
    _clearWechatQueryFromCurrentUrl(): void;
    /**
     * Check if the current URL contains a WxAuth OAuth redirect code (wxauth=1).
     * If found, handle the code exchange via WxAuth.codeToToken.
     */
    _maybeHandleWxAuthRedirectCode(overlay: HTMLElement): void;
    /**
     * Exchange a WxAuth OAuth code for a token using WxAuth.codeToToken.
     */
    _handleWxAuthRedirectCode(code: string, overlay: HTMLElement): Promise<void>;
    _setWechatLoading(overlay: HTMLElement, isLoading: boolean): void;
    _normalizeGoogleOptions(options: Record<string, unknown>): Record<string, unknown>;
    _getGoogleAuthUrl(): string;
    _buildGoogleState(): string;
    _getGoogleReturnUrl(): string;
    _decodeGoogleState(state: string | null): Record<string, unknown> | null;
    _b64urlEncode(str: string): string;
    _b64urlDecode(b64url: string): string;
    _startGoogleLogin(overlay: HTMLElement): void;
    _startGoogleMessageListener(overlay: HTMLElement): void;
    _stopGoogleMessageListener(): void;
    _openGooglePopup(url: string): Window | null;
    _startGooglePolling(overlay: HTMLElement): void;
    _stopGooglePolling(): void;
    _closeGooglePopup(): void;
    _maybeHandleGoogleCodeFromCurrentUrl(overlay: HTMLElement): void;
    _handleGoogleCode(code: string, state: string | null, overlay: HTMLElement): Promise<void>;
    _clearGoogleQueryFromCurrentUrl(): void;
    _setGoogleError(overlay: HTMLElement, keyOrMessage: string): void;
    _setWechatError(overlay: HTMLElement, keyOrMessage: string): void;
    _bindPasswordReset(overlay: HTMLElement): void;
    _startResetCountdown(btn: LWEl, seconds: number): void;
    _clearResetTimer(): void;
    _validatePhoneOrEmail(value: string): boolean;
    _validateResetPassword(password: string): boolean;
    _extractApiMessage(err: unknown): string;
    _isCaptchaError(err: unknown, message: string): boolean;
    _validateUsername(name: string): boolean;
    /**
     * 第三方登录探测发现未绑定账号时，进入「设置账号」视图：用户名预填后端建议，
     * 密码本地生成一串明文显示，二者均可修改。
     * @param {HTMLElement} overlay
     * @param {Object} data - 探测返回 { ticket, suggestedUsername, provider, ... }
     * @param {string} bindPath - 绑定接口路径
     */
    _showOauthSetup(overlay: HTMLElement, data: Record<string, unknown>, bindPath: string): void;
    _doOauthBind(overlay: HTMLElement): Promise<void>;
    _generatePassword(len?: number): string;
    /**
     * 登录/注册成功统一收尾：写 token + cookie，然后关窗口并 resolve。
     * 所有「直接持有 token 的路径」都走此方法，避免各处重复写 setToken + setCookie。
     * 若 response 不含 token（如账号登录走 sdk.login() 内部处理），退化为普通 _finish。
     */
    _finishWithAuth(response: Record<string, unknown>): void;
    /**
     * 整页跳转式 OAuth 登录（微信浏览器 / 小程序）成功后刷新页面，
     * 使宿主页面以登录态重新初始化。SSR 等无 window 环境下静默跳过。
     */
    _reloadAfterOAuthLogin(): void;
    _finish(response: Record<string, unknown>): void;
    /**
     * Constrain the overlay to the visual viewport so the on-screen keyboard
     * never hides the lower part of the form (e.g. the third-party login
     * buttons). When the soft keyboard opens, the layout viewport stays the
     * same size but the visual viewport shrinks; by pinning the overlay to the
     * visual viewport the modal stays fully above the keyboard and its content
     * (which has overflow-y: auto) can be scrolled to reach every button.
     */
    _setupViewportHandling(overlay: HTMLElement): void;
    _teardownViewportHandling(): void;
    _injectStyles(): void;
    _destroy(): void;
    _esc(str: unknown): string;
    _escapeHTML(str: unknown): string;
}
export {};
//# sourceMappingURL=LoginWindow.d.ts.map