import { b as HEALTH_TOOL_NAME_TRACKING } from './healthTools-304323dc.js';
import { l as locale } from './index-9ddd1558.js';
import { u as useSSOV2Store } from './store-b88d97b9.js';
import { h as SubotType } from './index-91c6a49c.js';
import { L as LOCALE } from './Locale-87b46912.js';

const isFeatureWhatsAppEnabled = [
    LOCALE.Indonesia,
    LOCALE.Malaysia,
].includes(locale);
const isFeatureSMSEnabled = [LOCALE.Vietnam].includes(locale);
const isFeatureZaloEnabled = [LOCALE.Vietnam].includes(locale);
const isFeaturePolicyUpdateEnabled = [LOCALE.Malaysia].includes(locale);
const isSupportProduct = (featureFlagsProduct) => {
    const setupSource = useSSOV2Store.getState().setupSource || 'discover';
    const isSupportDiscover = (featureFlagsProduct === null || featureFlagsProduct === void 0 ? void 0 : featureFlagsProduct.find((p) => p.name === 'discover')) &&
        setupSource === 'discover';
    const isSupportTogether = (featureFlagsProduct === null || featureFlagsProduct === void 0 ? void 0 : featureFlagsProduct.find((p) => p.name === 'together')) &&
        setupSource === 'community';
    const isSupportCare = (featureFlagsProduct === null || featureFlagsProduct === void 0 ? void 0 : featureFlagsProduct.find((p) => p.name === 'care')) &&
        setupSource === 'care';
    return isSupportDiscover || isSupportTogether || isSupportCare;
};
const getURLwithSSOTracking = (url, { source, botItem }) => {
    var _a;
    if (!source && !botItem)
        return null;
    try {
        const urlObj = new URL(url.startsWith('localhost') ? `http://${url}` : url);
        const mapHealthToolName = {
            bmi: HEALTH_TOOL_NAME_TRACKING.BMI,
            bmr: HEALTH_TOOL_NAME_TRACKING.BMR,
            'due-date': HEALTH_TOOL_NAME_TRACKING.DUE_DATE,
            ovulation: HEALTH_TOOL_NAME_TRACKING.OVULATION,
            'baby-growth': HEALTH_TOOL_NAME_TRACKING.BABY_GROWTH,
            'baby-vaccine': HEALTH_TOOL_NAME_TRACKING.BABY_VACCINE,
            'pregnancy-weight-gain': HEALTH_TOOL_NAME_TRACKING.PWG,
            'target-heart-rate': HEALTH_TOOL_NAME_TRACKING.THR,
            'baby-poop-checking': HEALTH_TOOL_NAME_TRACKING.BABY_POOP,
        };
        const healthToolName = mapHealthToolName[source];
        const isHealthToolPage = window.location.href.includes('/health-tools');
        // Only accept the health tools are embedded in other pages
        if (healthToolName && !isHealthToolPage) {
            urlObj.searchParams.set('embeddedType', 'healthTool');
            urlObj.searchParams.set('toolName', healthToolName);
        }
        else if (((_a = botItem === null || botItem === void 0 ? void 0 : botItem.extra_settings) === null || _a === void 0 ? void 0 : _a.subot_type) === SubotType.ristScreener) {
            urlObj.searchParams.set('embeddedType', 'riskScreener');
            urlObj.searchParams.set('toolName', String(botItem.id));
        }
        return urlObj;
    }
    catch (err) {
        return null;
    }
};

export { isFeatureWhatsAppEnabled as a, isFeatureZaloEnabled as b, isFeatureSMSEnabled as c, isSupportProduct as d, getURLwithSSOTracking as g, isFeaturePolicyUpdateEnabled as i };
