export default defineEventHandler(async (event) => {
  try {
    // Get cookies to check session state
    const cookies = parseCookies(event) || {}
    
    // Check for OIDC-related cookies
    const oidcCookies = Object.keys(cookies).filter(name => 
      name.includes('nuxt') || name.includes('oidc') || name.includes('session')
    )
    
    return {
      success: true,
      timestamp: new Date().toISOString(),
      cookies: {
        count: oidcCookies.length,
        names: oidcCookies,
        hasSession: oidcCookies.some(name => name.includes('session'))
      },
      headers: {
        host: getHeader(event, 'host'),
        userAgent: getHeader(event, 'user-agent'),
        referer: getHeader(event, 'referer')
      }
    }
  } catch (error) {
    return {
      success: false,
      error: error instanceof Error ? error.message : 'Unknown error',
      timestamp: new Date().toISOString()
    }
  }
})
