export default defineNuxtConfig({
  ssr: false,
  compatibilityDate: "2024-11-01",
  devtools: { enabled: true },
  modules: ["nuxt-directus", "vuetify-nuxt-module", "@vite-pwa/nuxt"],
  app: {
    head: {
      titleTemplate: "%s • Port Nimara Portal",
      title: "Port Nimara Portal",
      meta: [
        { property: "og:title", content: "Port Nimara Portal" },
        { property: "og:image", content: "/og-image.png" },
        { name: "twitter:card", content: "summary_large_image" },
        { name: "viewport", content: "width=device-width, initial-scale=1" },
        { name: "apple-mobile-web-app-capable", content: "yes" },
        { name: "apple-mobile-web-app-status-bar-style", content: "default" },
        { name: "apple-mobile-web-app-title", content: "Port Nimara Portal" },
      ],
      htmlAttrs: {
        lang: "en",
      },
    },
  },
  pwa: {
    registerType: 'autoUpdate',
    manifest: {
      name: 'Port Nimara Portal',
      short_name: 'Port Nimara',
      description: 'Port Nimara Client Portal - Manage your berth interests and expressions of interest',
      theme_color: '#387bca',
      background_color: '#ffffff',
      display: 'standalone',
      orientation: 'portrait',
      start_url: '/',
      scope: '/',
      icons: [
        {
          src: '/icons/icon-72x72.png',
          sizes: '72x72',
          type: 'image/png'
        },
        {
          src: '/icons/icon-96x96.png',
          sizes: '96x96',
          type: 'image/png'
        },
        {
          src: '/icons/icon-128x128.png',
          sizes: '128x128',
          type: 'image/png'
        },
        {
          src: '/icons/icon-144x144.png',
          sizes: '144x144',
          type: 'image/png'
        },
        {
          src: '/icons/icon-152x152.png',
          sizes: '152x152',
          type: 'image/png'
        },
        {
          src: '/icons/icon-192x192.png',
          sizes: '192x192',
          type: 'image/png'
        },
        {
          src: '/icons/icon-384x384.png',
          sizes: '384x384',
          type: 'image/png'
        },
        {
          src: '/icons/icon-512x512.png',
          sizes: '512x512',
          type: 'image/png'
        }
      ]
    },
    workbox: {
      navigateFallback: '/',
      globPatterns: ['**/*.{js,css,html,png,jpg,jpeg,svg,ico}'],
      runtimeCaching: [
        {
          urlPattern: /^https:\/\/cms\.portnimara\.dev\/.*/i,
          handler: 'NetworkFirst',
          options: {
            cacheName: 'api-cache',
            expiration: {
              maxEntries: 10,
              maxAgeSeconds: 60 * 60 * 24 // 24 hours
            },
            cacheableResponse: {
              statuses: [0, 200]
            }
          }
        }
      ]
    },
    client: {
      installPrompt: true,
      periodicSyncForUpdates: 20
    },
    devOptions: {
      enabled: true,
      type: 'module'
    }
  },
  nitro: {
    // Trust proxy headers for proper HTTPS detection
    experimental: {
      wasm: true
    }
  },
  runtimeConfig: {
    nocodb: {
      url: "",
      token: "",
    },
    minio: {
      endPoint: "s3.portnimara.com",
      port: 443,
      useSSL: true,
      accessKey: "279QFJV96Ja9wNB0YYmU1W3Pv4Ofeh3pxojcz0pzeC5LjRurq",
      secretKey: "y8ze6nmA2VHJWDsIU1eNEBq4R4WlmJWp97UE0zUR7E4zWLS6O",
      bucketName: "client-portal",
    },
    public: {
      directus: {
        url: "https://cms.portnimara.dev",
      },
    },
  },
  vuetify: {
    vuetifyOptions: {
      theme: {
        defaultTheme: "portnimara",
        themes: {
          portnimara: {
            colors: {
              primary: "#387bca",
            },
          },
        },
      },
    },
  },
});
