import { Env } from './types';
import { RELEASE_VERSION } from '@/shared/constants/environment';
import { PRODUCTION_CONFIG_MAP } from './config.production';
import { DEVELOPMENT_CONFIG_MAP } from './config.development';


// env와 bankKey에따라  mockup, 개발계(development), 검증계(production)의 은행 설정 가져오기
function getConfig(env: Env) {
  function getCurrEnvConfigMap() {
    if (env === 'development') return DEVELOPMENT_CONFIG_MAP;
    if (env === 'production') return PRODUCTION_CONFIG_MAP;
    return DEVELOPMENT_CONFIG_MAP;
  }
  return getCurrEnvConfigMap();
}

/**
 * 환경변수에서 전달받은 환경값 ( mockup | development | production )
 * 이 값으로 api 호출 URL 세팅
 */
const ENV: Env = (import.meta.env.VITE_APP_ENV ?? 'development') as Env;

const WEB_VERSION = RELEASE_VERSION ?? '1';

export const config = getConfig(ENV);
console.log(`%cENV: %c${ENV}`, 'font-weight:bold;', 'color:red;font-weight:bold;');
console.log(`%cWEB_VERSION: %c${WEB_VERSION}`, 'font-weight:bold;', 'color:red;font-weight:bold;');
console.log('config', config);
