/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2015 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by all applicable intellectual property laws,
* including trade secret and or copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/
import{dcLocalStorage as e}from"../../common/local-storage.js";import{util as a}from"../util.js";import{floodgate as r}from"../floodgate.js";import{removeExperimentCodeForAnalytics as o,setExperimentCodeForAnalytics as s}from"../../common/experimentUtils.js";const t={"whatsapp-preview":{featureFlag:"dc-cv-express-whatsapp-preview",enabledPropertyName:"enableWhatsappPreviewExpressMenu"},"whatsapp-hover":{featureFlag:"dc-cv-express-whatsapp-hover",enabledPropertyName:"enableWhatsappHoverExpressMenu",enabledLocales:["en-US","en-GB"]},"gmail-native-viewer":{featureFlag:"dc-cv-express-gmail-native-viewer",enabledPropertyName:"enableGmailNVExpressMenu"},"gmail-message-view":{featureFlag:"dc-cv-express-gmail-message-view",controlFlag:"dc-cv-express-gmail-message-view-control",enabledPropertyName:"enableGmailMessageViewCTA",enabledLocales:["en-US","en-GB"]},"google-image-preview":{featureFlag:"dc-cv-express-google-image-preview",enabledPropertyName:"enableGoogleImagePreviewExpressMenu"},"gdrive-native-viewer":{featureFlag:"dc-cv-express-gdrive-native-viewer",enabledPropertyName:"enableGdriveNativeViewerExpressMenu"},"facebook-preview":{featureFlag:"dc-cv-express-facebook-preview",enabledPropertyName:"enableFacebookPreviewExpressMenu"},"chatgpt-preview":{featureFlag:"dc-cv-express-chatgpt-preview",enabledPropertyName:"enableChatGPTPreviewExpressMenu"},"outlook-native-viewer":{featureFlag:"dc-cv-express-outlook-native-viewer",controlFlag:"dc-cv-express-outlook-native-viewer-control",enabledPropertyName:"enableOutlookNVExpressMenu"}};function n(){const a="true"===e.getItem("adobeInternal"),r=e.getItem("installSource");return a||"admin"!==r}async function c(){const a={"dc-cv-express-standalone":"EL","dc-cv-express-standalone-control":"ELC","dc-cv-express-gmail-message-view":"EGM","dc-cv-express-gmail-message-view-control":"EGMC","dc-cv-express-outlook-native-viewer":"EON","dc-cv-express-outlook-native-viewer-control":"EONC","dc-cv-express-precaching":"EPC","dc-cv-express-precaching-control":"EPCC"},t=n();for(const e of Object.keys(a)){const n=a[e];t&&await r.hasFlag(e)&&l(e)?s(n):o(n)}o("Exp_Mod"),o("Exp_Loe"),o("EC"),o("EWP"),o("EWPC"),o("EGN"),o("EGNC"),o("ECS"),o("ECSC"),o("EI2"),o("EI2C"),o("EGI"),o("EGIC"),o("EWSC"),o("EWS"),o("EWF"),o("EWFC"),o("EGF"),o("EGFC"),o("EGD"),o("EGDC"),o("EFB"),o("EFBC"),o("EIF"),o("EIFC"),o("EDF"),o("EDFC"),o("ECP"),o("ECPC"),o("EWH"),o("EWHC"),e.removeItem("dc-cv-express-whatsapp-hover-menu-fg-enabled"),e.removeItem("dc-cv-express-whatsapp-hover-menu-fg-control-enabled"),e.removeItem("dc-cv-express-gmail-message-view-fg-enabled"),e.removeItem("dc-cv-express-gmail-message-view-fg-control-enabled"),e.removeItem("dc-cv-express-chatgpt-preview-fg-enabled"),e.removeItem("dc-cv-express-chatgpt-preview-fg-control-enabled"),e.removeItem("dc-cv-express-outlook-native-viewer-fg-enabled"),e.removeItem("dc-cv-express-outlook-native-viewer-fg-control-enabled")}function l(e){const r=a.getFrictionlessLocale(chrome.i18n.getMessage("@@ui_locale")),o={};for(const[e,a]of Object.entries(t))a.featureFlag&&(o[a.featureFlag]=e),a.controlFlag&&(o[a.controlFlag]=e);const s=o[e];return!s||!t[s]?.enabledLocales||t[s].enabledLocales.includes(r)}async function i(o){const s=t[o];if(!s)throw new Error(`Unknown surface: ${o}`);const{featureFlag:l,enabledPropertyName:i,enabledLocales:p}=s,v={[i]:!1,enableExpressOptionsPagePreference:!1};if(p){const e=a.getFrictionlessLocale(chrome.i18n.getMessage("@@ui_locale"));if(!p.includes(e))return v}const g=await r.hasFlag(l);let m=e.getItem("express-touch-points");return m=""===m||m,await c(),g&&n()&&(v.enableExpressOptionsPagePreference=!0,m&&"false"!==m&&(v[i]=!0)),v}export{i as isExpressMenuEnabled,n as isExpressEnabledForInstallType,c as setFeatureVariantForAnalytics};