export default defineNuxtConfig({
  modules: ['@nuxtjs/tailwindcss'],
  css: [
    '~/assets/css/main.css',
    'leaflet/dist/leaflet.css',
    'leaflet.markercluster/dist/MarkerCluster.css',
    'leaflet.markercluster/dist/MarkerCluster.Default.css',
  ],

  runtimeConfig: {
    nocodbUrl: process.env.NOCODB_URL,
    nocodbToken: process.env.NOCODB_TOKEN,
    nocodbBase: process.env.NOCODB_BASE || process.env.NOCODB_BASE_ID || 'pipilvsi7dibo80',
    orgTableId: process.env.ORG_TABLE_ID || process.env.NOCODB_TABLE_ORGAS || 'm08t7g5v4wch6wb',
    avisTableId: process.env.AVIS_TABLE_ID,
    commentTableId: process.env.COMMENT_TABLE_ID || process.env.AVIS_TABLE_ID,
    statsTableId: process.env.STATS_TABLE_ID || 'mbbq7n47ixy19mc',
    mistralApiKey: process.env.MISTRAL_API_KEY,
    redisUrl: process.env.REDIS_URL || 'redis://127.0.0.1:6379',
    resendApiKey: process.env.RESEND_API_KEY,
    emailJules: process.env.EMAIL_JULES || 'jules@trans-former.fr',
    codevTableId: '',            // NUXT_CODEV_TABLE_ID
    codevPassword: 'merci',      // NUXT_CODEV_PASSWORD - défaut "merci", overridable
    codevBaseId: '',             // NUXT_CODEV_BASE_ID - base NocoDB (ex: pipilvsi7dibo80)
    codevAdminPassword: 'admin2026', // NUXT_CODEV_ADMIN_PASSWORD
    ragPeUrl: process.env.RAG_PE_URL || 'http://localhost:9621',
    referencesTableId: process.env.REFERENCES_TABLE_ID || process.env.NUXT_REFERENCES_TABLE_ID || '',
  },

  // Leaflet ne fonctionne pas en SSR — forcer le rendu côté client
  ssr: true,

  vite: {
    cacheDir: 'C:/Users/jules/AppData/Local/nav-carte-vite-cache',
    optimizeDeps: {
      include: ['leaflet', 'leaflet.markercluster', 'd3'],
    },
    ssr: {
      noExternal: [],
    },
  },

  compatibilityDate: '2024-11-01',
})
