// https://nuxt.com/docs/api/configuration/nuxt-config

const rybbitUrl = process.env.NUXT_PUBLIC_RYBBIT_URL
const rybbitSiteId = process.env.NUXT_PUBLIC_RYBBIT_SITE_ID

export default defineNuxtConfig({

  modules: [
    '@nuxt/eslint',
    '@nuxt/ui',
    '@nuxt/image',
    '@nuxtjs/i18n',
    '@pinia/nuxt',
    '@nuxt/test-utils/module'
  ],

  ssr: false,

  devtools: {
    enabled: true
  },
  app: {
    head: {
      script: [
        ...(rybbitUrl && rybbitSiteId
          ? [{
              'src': rybbitUrl + '/api/script.js',
              'defer': true,
              'data-site-id': rybbitSiteId
            }]
          : [])
      ]
    }
  },

  css: ['~/assets/css/main.css'],

  runtimeConfig: {
    pbAdminEmail: process.env.PB_ADMIN_EMAIL || '',
    pbAdminPassword: process.env.PB_ADMIN_PASSWORD || '',
    anthropicApiKey: process.env.ANTHROPIC_API_KEY || '',
    stripeSecretKey: process.env.STRIPE_SECRET_KEY || '',
    stripeWebhookSecret: process.env.STRIPE_WEBHOOK_SECRET || '',
    public: {
      appUrl: 'http://localhost:3000',
      pocketbaseUrl: process.env.NUXT_PUBLIC_PB_URL || 'http://127.0.0.1:8090',
      stripePublishableKey: process.env.STRIPE_PUBLISHABLE_KEY || '',
      rybbitScriptUrl: '',
      rybbitSiteId: ''
    }
  },

  dir: {
    public: 'app/public' // moved to app dir to clean up root
  },

  experimental: {
    asyncContext: false,
    payloadExtraction: true
  },

  compatibilityDate: '2025-01-15',

  eslint: {
    config: {
      stylistic: {
        commaDangle: 'never',
        braceStyle: '1tbs'
      }
    }
  },

  i18n: {
    langDir: '../app/i18n/locales', // moved to app dir to clean up root
    defaultLocale: 'en',
    strategy: 'no_prefix',
    locales: [
      { code: 'en', name: 'English', file: 'en.json' },
      { code: 'de', name: 'Deutsch', file: 'de.json' }
    ],
    detectBrowserLanguage: {
      useCookie: true,
      cookieKey: 'app_language'
    }
  }
})
