// Next Imports
import localFont from 'next/font/local'

// MUI Imports
import type { Theme } from '@mui/material/styles'

// Type Imports
import type { Settings } from '@core/contexts/settingsContext'
import type { SystemMode, Skin } from '@core/types'

// Theme Options Imports
import overrides from './overrides'
import colorSchemes from './colorSchemes'
import spacing from './spacing'
import shadows from './shadows'
import customShadows from './customShadows'
import typography from './typography'

export const iran_sans = localFont({
  src: [
    {
      path: '../../../public/fonts/iranSans/woff2/IRANSansWeb(FaNum)_Light.woff2',
      weight: '300',
      style: 'normal'
    },
    {
      path: '../../../public/fonts/iranSans/woff2/IRANSansWeb(FaNum).woff2',
      weight: '400',
      style: 'normal'
    },
    {
      path: '../../../public/fonts/iranSans/woff2/IRANSansWeb(FaNum)_Medium.woff2',
      weight: '500',
      style: 'normal'
    },
    {
      path: '../../../public/fonts/iranSans/woff2/IRANSansWeb(FaNum)_Bold.woff2',
      weight: '700',
      style: 'normal'
    }
  ],
  variable: '--font-iran-sans',
  display: 'swap'
})

const theme = (settings: Settings, mode: SystemMode, direction: Theme['direction']): Theme => {
  return {
    direction,
    components: overrides(settings.skin as Skin),
    colorSchemes: colorSchemes(settings.skin as Skin),
    ...spacing,
    shape: {
      borderRadius: 6,
      customBorderRadius: {
        xs: 2,
        sm: 4,
        md: 6,
        lg: 8,
        xl: 10
      }
    },
    shadows: shadows(mode),
    typography: typography(iran_sans.style.fontFamily),
    customShadows: customShadows(mode),
    mainColorChannels: {
      light: '47 43 61',
      dark: '225 222 245',
      lightShadow: '47 43 61',
      darkShadow: '19 17 32'
    }
  } as Theme
}

export default theme
