import tailwindcss from '@tailwindcss/vite'

// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2025-07-15',
  devtools: { enabled: true },
  modules: [
    '@nuxtjs/i18n',
    '@pinia/nuxt',
    '@nuxtjs/leaflet',
    '@sentry/nuxt/module',
    '@nuxt/eslint',
    'nuxt-mapbox',
    '@nuxt/icon',
    '@formkit/nuxt',
    '@nuxtjs/apollo'
  ],
  css: ['~/assets/css/tailwind.css'],
  i18n: {
    strategy: 'prefix_and_default',
    defaultLocale: 'ru',
    lazy: true,
    langDir: 'locales',
    locales: [
      {
        code: 'ru',
        files: [
          'ru/about.json',
          'ru/aiAssistants.json',
          'ru/auth.json',
          'ru/billing.json',
          'ru/breadcrumbs.json',
          'ru/cabinetNav.json',
          'ru/catalogAddress.json',
          'ru/catalogHub.json',
          'ru/catalogHubsSection.json',
          'ru/catalogLanding.json',
          'ru/catalogMap.json',
          'ru/catalogOffer.json',
          'ru/catalogOfferCard.json',
          'ru/catalogOffersSection.json',
          'ru/catalogProduct.json',
          'ru/catalogSupplier.json',
          'ru/catalogSuppliersSection.json',
          'ru/clientOfferForm.json',
          'ru/clientOffersList.json',
          'ru/clientProfile.json',
          'ru/clientRedirect.json',
          'ru/clientTeam.json',
          'ru/clientTeamSwitch.json',
          'ru/common.json',
          'ru/cta.json',
          'ru/dashboard.json',
          'ru/footer.json',
          'ru/ganttTimeline.json',
          'ru/goods.json',
          'ru/howto.json',
          'ru/kyc.json',
          'ru/kycOverview.json',
          'ru/kycRussia.json',
          'ru/locations.json',
          'ru/nav.json',
          'ru/offersNew.json',
          'ru/orderCalendar.json',
          'ru/orderMap.json',
          'ru/orders.json',
          'ru/ordersDetail.json',
          'ru/ordersList.json',
          'ru/profile.json',
          'ru/profileAddresses.json',
          'ru/roles.json',
          'ru/routeMap.json',
          'ru/search.json',
          'ru/searchPage.json',
          'ru/sidebar.json',
          'ru/stats.json',
          'ru/supplier.json',
          'ru/supplierFlow.json',
          'ru/teams.json',
          'ru/testMap.json',
          'ru/testimonials.json',
          'ru/timelineStages.json',
        ],
        name: 'Russian'
      },
      {
        code: 'en',
        files: [
          'en/about.json',
          'en/aiAssistants.json',
          'en/auth.json',
          'en/billing.json',
          'en/breadcrumbs.json',
          'en/cabinetNav.json',
          'en/catalogAddress.json',
          'en/catalogHub.json',
          'en/catalogHubsSection.json',
          'en/catalogLanding.json',
          'en/catalogMap.json',
          'en/catalogOffer.json',
          'en/catalogOfferCard.json',
          'en/catalogOffersSection.json',
          'en/catalogProduct.json',
          'en/catalogSupplier.json',
          'en/catalogSuppliersSection.json',
          'en/clientOfferForm.json',
          'en/clientOffersList.json',
          'en/clientProfile.json',
          'en/clientRedirect.json',
          'en/clientTeam.json',
          'en/clientTeamSwitch.json',
          'en/common.json',
          'en/cta.json',
          'en/dashboard.json',
          'en/footer.json',
          'en/ganttTimeline.json',
          'en/goods.json',
          'en/howto.json',
          'en/kyc.json',
          'en/kycOverview.json',
          'en/kycRussia.json',
          'en/locations.json',
          'en/nav.json',
          'en/offersNew.json',
          'en/orderCalendar.json',
          'en/orderMap.json',
          'en/orders.json',
          'en/ordersDetail.json',
          'en/ordersList.json',
          'en/profile.json',
          'en/profileAddresses.json',
          'en/roles.json',
          'en/routeMap.json',
          'en/search.json',
          'en/searchPage.json',
          'en/sidebar.json',
          'en/stats.json',
          'en/supplier.json',
          'en/supplierFlow.json',
          'en/teams.json',
          'en/testMap.json',
          'en/testimonials.json',
          'en/timelineStages.json',
        ],
        name: 'English'
      },
    ]
  },
  imports: {
    dirs: ['stores/**']
  },
  components: [
    { path: '~/components', pathPrefix: false },
    { path: '~/components/ui', pathPrefix: false }
  ],
  ssr: true,
  app: {
    baseURL: '/',
    layoutTransition: { name: 'layout', mode: 'out-in' }
  },
  nitro: {
    preset: 'node-server',
    storage: {
      logto: {
        driver: 'fs',
        base: './.data/logto'
      }
    }
  },
  devServer: {
    host: '0.0.0.0',
    port: 3000
  },
  vite: {
    plugins: [tailwindcss()],
    server: {
      fs: {
        strict: false
      }
    }
  },
  runtimeConfig: {
    public: {
      odooApiUrl: process.env.NUXT_PUBLIC_ODOO_API_URL || 'https://odoo.optovia.ru',
      terminusGraphql: process.env.NUXT_PUBLIC_TERMINUS_GRAPHQL || 'https://terminus.optovia.ru/graphql',
      siteUrl: process.env.NUXT_PUBLIC_SITE_URL || 'http://localhost:3000',
      novuAppId: process.env.NUXT_PUBLIC_NOVU_APP_ID,
      novuBackendUrl: process.env.NUXT_PUBLIC_NOVU_BACKEND_URL,
      novuSocketUrl: process.env.NUXT_PUBLIC_NOVU_SOCKET_URL,
      sentryDsn: process.env.NUXT_PUBLIC_SENTRY_DSN,
      mapboxAccessToken: process.env.NUXT_PUBLIC_MAPBOX_ACCESS_TOKEN || ''
    }
  },
  sentry: {
    dsn: process.env.NUXT_PUBLIC_SENTRY_DSN,
    environment: process.env.NODE_ENV || 'production',
    tracesSampleRate: 0.1
  },
  mapbox: {
    accessToken: process.env.NUXT_PUBLIC_MAPBOX_ACCESS_TOKEN || ''
  },
  apollo: {
    clients: {
      default: {
        httpEndpoint: process.env.NUXT_PUBLIC_EXCHANGE_GRAPHQL_PUBLIC || 'https://exchange.optovia.ru/graphql/public/',
        devtools: { enabled: process.dev }
      },
      publicGeo: {
        httpEndpoint: process.env.NUXT_PUBLIC_GEO_GRAPHQL_PUBLIC || 'https://geo.optovia.ru/graphql/public/',
        devtools: { enabled: process.dev }
      },
      teamsUser: {
        httpEndpoint: process.env.NUXT_PUBLIC_TEAMS_GRAPHQL_USER || 'https://teams.optovia.ru/graphql/user/',
        devtools: { enabled: process.dev }
      },
      teamsTeam: {
        httpEndpoint: process.env.NUXT_PUBLIC_TEAMS_GRAPHQL_TEAM || 'https://teams.optovia.ru/graphql/team/',
        devtools: { enabled: process.dev }
      },
      exchangeTeam: {
        httpEndpoint: process.env.NUXT_PUBLIC_EXCHANGE_GRAPHQL_TEAM || 'https://exchange.optovia.ru/graphql/team/',
        devtools: { enabled: process.dev }
      },
      kycUser: {
        httpEndpoint: process.env.NUXT_PUBLIC_KYC_GRAPHQL_USER || 'https://kyc.optovia.ru/graphql/user/',
        devtools: { enabled: process.dev }
      },
      ordersTeam: {
        httpEndpoint: process.env.NUXT_PUBLIC_ORDERS_GRAPHQL_TEAM || 'https://orders.optovia.ru/graphql/team/',
        devtools: { enabled: process.dev }
      },
      billingTeam: {
        httpEndpoint: process.env.NUXT_PUBLIC_BILLING_GRAPHQL_TEAM || 'https://billing.optovia.ru/graphql/team/',
        devtools: { enabled: process.dev }
      }
    }
  }
})
