"use client";
'use strict';

var tslib_es6 = require('../node_modules/.pnpm/@rollup_plugin-typescript@12.1.4_rollup@4.46.2_tslib@2.8.1_typescript@5.9.3/node_modules/tslib/tslib.es6.js');
var jsxRuntime = require('react/jsx-runtime');
var nextjs = require('@clerk/nextjs');
var React = require('react');
var fingerprintProvider = require('./fingerprint/fingerprint-provider.js');

/**
 * SignUp component with fingerprint awareness
 * 如果没有FingerprintProvider，会优雅降级为普通SignUp组件
 * 如果有FingerprintProvider，会处理fingerprint相关逻辑
 */
function SignUpWithFingerprint() {
    const fingerprintContext = fingerprintProvider.useFingerprintContextSafe();
    // 如果没有fingerprint context，使用默认值
    const { fingerprintId = null, xUser = null, isInitialized = false, initializeAnonymousUser = () => tslib_es6.__awaiter(this, void 0, void 0, function* () { }) } = fingerprintContext || {};
    // 准备传递给Clerk的metadata，包含匿名用户信息
    const unsafeMetadata = {
        user_id: (xUser === null || xUser === void 0 ? void 0 : xUser.userId) || null,
        fingerprint_id: fingerprintId || null,
    };
    // 确保匿名用户已初始化
    React.useEffect(() => {
        if (!isInitialized && fingerprintId) {
            initializeAnonymousUser();
        }
    }, [fingerprintId, isInitialized, initializeAnonymousUser]);
    // 调试日志和处理注册逻辑
    React.useEffect(() => {
        console.log('SignUpWithFingerprint on [redirect] DEBUG:', {
            fingerprintProvider: fingerprintContext ? 'Available' : 'Not found',
            fingerprintId: fingerprintId || 'Not generated',
            xUser: xUser ? 'Initialized' : 'Not initialized',
            clerkMetadata: unsafeMetadata
        });
    }, [xUser, fingerprintId, fingerprintContext, unsafeMetadata]);
    return jsxRuntime.jsx(nextjs.SignUp, { unsafeMetadata: unsafeMetadata });
}

exports.SignUpWithFingerprint = SignUpWithFingerprint;
