// https://nuxt.com/docs/api/configuration/nuxt-config
import vuePlugin from 'rollup-plugin-vue'
import fs from 'node:fs'
import path from 'node:path'

export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  modules: [
    '@nuxtjs/color-mode',
    'nuxt-security',
    '@nuxtjs/tailwindcss',
    '@vueuse/nuxt',
    'radix-vue/nuxt',
    '@nuxtjs/sitemap',
  ],
  tailwindcss: {
    viewer: false,
    config: {
      content: {
        files: [
          "./shared/**/*.{vue,js,jsx,mjs,ts,tsx}"
        ]
      },
      theme: {
        extend: {
          boxShadow: {
            raw: '0 0 0 2px var(--tw-shadow-color)'
          },
          keyframes: {
            slideDownAndFade: {
              from: { opacity: '0', transform: 'translateY(-2px)' },
              to: { opacity: '1', transform: 'translateY(0)' },
            },
            slideLeftAndFade: {
              from: { opacity: '0', transform: 'translateX(2px)' },
              to: { opacity: '1', transform: 'translateX(0)' },
            },
            slideUpAndFade: {
              from: { opacity: '0', transform: 'translateY(2px)' },
              to: { opacity: '1', transform: 'translateY(0)' },
            },
            slideRightAndFade: {
              from: { opacity: '0', transform: 'translateX(-2px)' },
              to: { opacity: '1', transform: 'translateX(0)' },
            },
            contentShow: {
              from: { opacity: '0', transform: 'translate(-50%, -48%) scale(0.96)' },
              to: { opacity: '1', transform: 'translate(-50%, -50%) scale(1)' },
            },
          },
          animation: {
            slideDownAndFade: 'slideDownAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)',
            slideLeftAndFade: 'slideLeftAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)',
            slideUpAndFade: 'slideUpAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)',
            slideRightAndFade: 'slideRightAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)',
            contentShow: 'contentShow 150ms cubic-bezier(0.16, 1, 0.3, 1)',
          },
        },
        colors: {
          transparent: 'transparent',
          current: 'currentColor',
          light: {
            red: '#e93147',
            redBack: '#F9C7CD',
            orange: '#ec7500',
            yellow: '#e0ac00',
            green: '#08b94e',
            greenBack: '#BCECCF',
            cyan: '#00bfbc',
            blue: '#086ddd',
            purple: '#7852ee',
            pink: '#d53984',
            0: "#ffffff",
            5: "#fcfcfc",
            10: "#fafafa",
            20: "#f7f7f7",
            25: "#e4e4e4",
            30: "#dfdfdf",
            35: "#d2d2d2",
            40: "#bdbdbd",
            50: "#ababab",
            60: "#707070",
            70: "#5c5c5c",
            100: "#202020",
          },
          dark: {
            red: '#fb464c',
            redBack: '#5A292B',
            orange: '#e9973f',
            yellow: '#e0de71',
            green: '#44cf6e',
            greenBack: '#284E34',
            cyan: '#53dfdd',
            blue: '#027aff',
            purple: '#a882ff',
            pink: '#fa99cd',
            0: '#1e1e1e',
            5: '#212121',
            10: '#242424',
            20: '#262626',
            25: '#2a2a2a',
            30: '#363636',
            35: '#3f3f3f',
            40: '#555555',
            50: '#666666',
            60: '#999999',
            70: '#b3b3b3',
            100: '#dadada',
          },
          accent: {
            purple: '#43A047',
            blue: '#26C6DA',
          },
        }
      }
    }
  },
  app: {
    pageTransition: false,
    layoutTransition: false
  },
  ssr: false,
  components: [
    {
      path: '~/components',
      pathPrefix: false,
    },
  ],
  nitro: {
    preset: 'bun',
    experimental: {
      tasks: true,
    },
    rollupConfig: {
      external: ['bun'],
      plugins: [
        vuePlugin({ include: /\.vue$/, target: 'node' })
      ]
    },
  },
  runtimeConfig: {
    session: {
      password: '699c46bd-9aaa-4364-ad01-510ee4fe7013',
      maxAge: 60 * 60 * 24 * 30,
    },
    database: 'db.sqlite',
    mail: {
      host: '',
      port: '',
      user: '',
      passwd: '',
      dkim: '',
    }
  },
  security: {
    rateLimiter: false,
    headers: {
      contentSecurityPolicy: {
        "img-src": "'self' data: blob:",
        "base-uri": "localhost:*"
      }
    },
    xssValidator: false,
  },
  sitemap: {
    exclude: ['/admin/**', '/explore/edit', '/user/mailvalidated', '/user/changing-password', '/user/reset-password'],
    sources: ['/api/__sitemap__/urls']
  },
  experimental: {
    componentIslands: {
      selectiveClient: true,
    },
    defaults: {
      nuxtLink: {
        prefetchOn: {
          interaction: false,
          visibility: false,
        }
      }
    }
  },
  devServer: {
    https: {
      key: fs.readFileSync(path.resolve(__dirname, 'localhost+1-key.pem')).toString('utf-8'),
      cert: fs.readFileSync(path.resolve(__dirname, 'localhost+1.pem')).toString('utf-8'),
    }
  },
  vue: {
    compilerOptions: {
      isCustomElement: (tag) => tag === 'iconify-icon',
    }
  }
})