import { serverDeviceManager } from '@/lib/auth/server-device'

interface DeviceIdProviderProps {
  children: React.ReactNode
}

export async function DeviceIdProvider({ children }: DeviceIdProviderProps) {
  // 获取设备ID（由中间件设置）
  const deviceIdFromCookie = await serverDeviceManager.getDeviceId()
  const deviceIdFromHeader = await serverDeviceManager.getDeviceIdFromHeaders()

  const deviceId = deviceIdFromCookie || deviceIdFromHeader || 'pending'

  console.log('🔧 服务端设备ID状态:', {
    fromCookie: deviceIdFromCookie,
    fromHeader: deviceIdFromHeader,
    final: deviceId,
  })

  return <>{children}</>
}
