"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hashAndEncode = hashAndEncode;
exports.hashAndEncodeToInt = hashAndEncodeToInt;
exports.getUpsertURL = getUpsertURL;
exports.getCreateAudienceURL = getCreateAudienceURL;
exports.getDataCenter = getDataCenter;
exports.getSectionId = getSectionId;
const hashing_utils_1 = require("../../lib/hashing-utils");
function hashAndEncode(property) {
    return (0, hashing_utils_1.processHashing)(property, 'sha256', 'hex');
}
function hashAndEncodeToInt(property) {
    const hash = (0, hashing_utils_1.processHashing)(property, 'sha256', 'hex');
    const bigInt = BigInt('0x' + hash);
    let integerString = bigInt.toString();
    if (integerString.length > 16) {
        integerString = integerString.substring(0, 16);
    }
    return Number(integerString);
}
function getDomain(dataCenter) {
    let domain = 'dev-use1';
    switch (dataCenter) {
        case 'US':
            domain = 'use1';
            break;
        case 'EU':
            domain = 'euc1';
            break;
        case 'DEV':
            domain = 'dev-use1';
            break;
    }
    return domain;
}
function getUpsertURL(dataCenter) {
    return `https://cdp-extensions-api.${getDomain(dataCenter)}.dynamicyield.com/cdp/segment/audiences/membership-change`;
}
function getCreateAudienceURL(dataCenter) {
    return `https://cdp-extensions-api.${getDomain(dataCenter)}.dynamicyield.com/cdp/segment/audiences/subscription`;
}
function getDataCenter(sectionId) {
    return sectionId.toLocaleLowerCase().startsWith('9')
        ? 'EU'
        : sectionId.toLocaleLowerCase().startsWith('8')
            ? 'US'
            : 'DEV';
}
function getSectionId(sectionId) {
    return sectionId.toLocaleLowerCase().replace('dev', '');
}
//# sourceMappingURL=helpers.js.map