import axios from 'axios';

const DISP: IDisp = {
    cn: ['cn-pconnect1.coolkit.cc', 'cn-pconnect2.coolkit.cc', 'cn-pconnect3.coolkit.cc'],
    us: ['us-pconnect1.coolkit.cc', 'us-pconnect2.coolkit.cc', 'us-pconnect3.coolkit.cc', 'us-pconnect4.coolkit.cc'],
    eu: [
        'eu-pconnect1.coolkit.cc',
        'eu-pconnect2.coolkit.cc',
        'eu-pconnect3.coolkit.cc',
        'eu-pconnect4.coolkit.cc',
        'eu-pconnect5.coolkit.cc',
        'eu-pconnect6.coolkit.cc',
        'eu-pconnect7.coolkit.cc',
    ],
    as: ['as-pconnect1.coolkit.cc', 'as-pconnect2.coolkit.cc', 'as-pconnect3.coolkit.cc'],
    test: ['test-pconnect1.coolkit.cn'],
};

interface IDisp {
    cn: string[];
    us: string[];
    eu: string[];
    as: string[];
    test: string[];
}

export default function getWsIpServices(region: keyof IDisp, useTestEnv: boolean) {
    const disps = useTestEnv ? DISP.test : DISP[region];
    const randomIndex = parseInt(`${Math.random() * (disps.length - 1 - 0 + 1) + 0}`, 10);
    const dist = disps[randomIndex];
    return dist;
}
