<commit_before>const Cookies            = require('js-cookie');
const generateBirthDate  = require('./attach_dom/birth_date_picker');
const BinaryPjax         = require('../base/binary_pjax');
const Client             = require('../base/client');
const localize           = require('../base/localize').localize;
const State              = require('../base/storage').State;
const urlFor             = require('../base/url').urlFor;
const makeOption         = require('../common_functions/common_functions').makeOption;
const FormManager        = require('../common_functions/form_manager');
const BinarySocket       = require('../websocket_pages/socket');
const professionalClient = require('../websocket_pages/user/account/settings/professional_client');
require('select2');

const AccountOpening = (() => {
    const redirectAccount = (account_type_ico) => { // eslint-disable-line consistent-return
        const response_landing_company = State.getResponse('landing_company');
        const response_get_settings    = State.getResponse('get_settings');
        if (response_landing_company && response_get_settings) {
            return redirect(account_type_ico, response_landing_company);
        }
        BinarySocket.wait('landing_company', 'get_settings').then(() => redirect(account_type_ico));
    };

    const redirect = (account_type_ico, response_landing_company) => {
        const upgrade_info = Client.getUpgradeInfo(response_landing_company || State.getResponse('landing_company'), undefined, account_type_ico);

        if (!upgrade_info.can_upgrade) {
            BinaryPjax.loadPreviousUrl();
            return true;
        }

        if (!upgrade_info.is_current_path) {
            BinaryPjax.load(upgrade_info.upgrade_link);
            return true;
        }
        return false;
    };

    const populateForm = (form_id, getValidations, is_financial, is_ico_only) => {
        getResidence();
        BinarySocket.send({ states_list: Client.get('residence') }).then(data => handleState(data.states_list, form_id, getValidations));
        generateBirthDate();
        professionalClient.init(is_financial, false, is_ico_only);
    };

    const getResidence = () => {
        BinarySocket.send({ residence_list: 1 }).then(response => handleResidenceList(response.residence_list));
    };

    const handleResidenceList = (residence_list) => {
        if (residence_list.length > 0) {<commit_msg>show professional link only to supported list of countries<commit_after>const Cookies            = require('js-cookie');
const generateBirthDate  = require('./attach_dom/birth_date_picker');
const BinaryPjax         = require('../base/binary_pjax');
const Client             = require('../base/client');
const localize           = require('../base/localize').localize;
const State              = require('../base/storage').State;
const urlFor             = require('../base/url').urlFor;
const makeOption         = require('../common_functions/common_functions').makeOption;
const FormManager        = require('../common_functions/form_manager');
const BinarySocket       = require('../websocket_pages/socket');
const professionalClient = require('../websocket_pages/user/account/settings/professional_client');
require('select2');

const AccountOpening = (() => {
    const redirectAccount = (account_type_ico) => { // eslint-disable-line consistent-return
        const response_landing_company = State.getResponse('landing_company');
        const response_get_settings    = State.getResponse('get_settings');
        if (response_landing_company && response_get_settings) {
            return redirect(account_type_ico, response_landing_company);
        }
        BinarySocket.wait('landing_company', 'get_settings').then(() => redirect(account_type_ico));
    };

    const redirect = (account_type_ico, response_landing_company) => {
        const upgrade_info = Client.getUpgradeInfo(response_landing_company || State.getResponse('landing_company'), undefined, account_type_ico);

        if (!upgrade_info.can_upgrade) {
            BinaryPjax.loadPreviousUrl();
            return true;
        }

        if (!upgrade_info.is_current_path) {
            BinaryPjax.load(upgrade_info.upgrade_link);
            return true;
        }
        return false;
    };

    const residenceSupportsProfessional = (residence) => {
      /* Austria, Italy, Belgium, Latvia, Bulgaria,	Lithuania, Croatia, Luxembourg, Cyprus, Malta, Czech Republic,	Netherlands, Denmark, Poland, Estonia, Portugal, Finland, Romania, France, Slovakia, Germany, Slovenia, Greece, Spain, Hungary, Sweden, Ireland, United Kingdom, Australia, New Zealand, Singapore, Canada, Switzerland */
      const countries = [ "at", "it",  "be",  "lv",  "bg",  "lt",  "hr",  "lu",  "cy",  "mt",  "cf",  "nl",  "dk",  "pl",  "ee",  "pt",  "fi",  "ro",  "fr",  "sk",  "de",  "si",  "gr",  "es",  "hu",  "se",  "ie",  "gb",  "au",  "nz",  "sg",  "ca",  "ch" ];
      return countries.indexOf(residence.toLowerCase()) !== -1;

    };

    const populateForm = (form_id, getValidations, is_financial, is_ico_only) => {
        getResidence();
        BinarySocket.send({ states_list: Client.get('residence') }).then(data => handleState(data.states_list, form_id, getValidations));
        generateBirthDate();
        if (residenceSupportsProfessional(Client.get('residence'))) {
          professionalClient.init(is_financial, false, is_ico_only);
        }
    };

    const getResidence = () => {
        BinarySocket.send({ residence_list: 1 }).then(response => handleResidenceList(response.residence_list));
    };

    const handleResidenceList = (residence_list) => {
        if (residence_list.length > 0) {
{'fraction_non_alphanumeric': 0.1378463696948439, 'fraction_numerical': 0.001227639424763241, 'mean_word_length': 3.3634276970160673, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2272917', 'n_tokens_mistral': 1668, 'n_tokens_neox': 1596, 'n_words': 305}