import { readSelectedApi } from 'helpers/selectedApi'

import { ENV, isProduction } from './env'

export const APIS = {
  preproduction: {
    api: 'https://api.insports.tv',
    auth: 'https://auth.insports.tv',
  },
  production: {
    api: 'https://api.insports.tv',
    auth: 'https://auth.insports.tv',
  },
  staging: {
    api: 'https://api.test.insports.tv',
    auth: 'https://auth.test.insports.tv',
  },
}

const VIEWS_APIS = {
  preproduction: 'https://views.insports.tv',
  production: 'https://views.insports.tv',
  staging: 'https://views.test.insports.tv',
}

const STATS_APIS = {
  preproduction: 'https://statistic.insports.tv',
  production: 'https://statistic.insports.tv',
  staging: 'https://statistic-stage.insports.tv',
}

const env = isProduction ? ENV : readSelectedApi() ?? ENV

export const VIEWS_API = VIEWS_APIS[env]
export const AUTH_SERVICE = APIS[env].auth
export const API_ROOT = APIS[env].api
export const DATA_URL = `${API_ROOT}/data`
export const URL_AWS = 'https://cf-aws.insports.tv'
export const STATS_API_URL = STATS_APIS[env]
