// @flow

import getenv from 'getenv'
import {featureFlagsOverride} from '../local-debug.desktop'
import type {FeatureFlags} from './feature-flags'

// To enable a feature, include it in the environment variable KEYBASE_FEATURES.
// For example, KEYBASE_FEATURES=tracker2,login,awesomefeature

let features =
  (featureFlagsOverride && featureFlagsOverride.split(',')) || getenv.array('KEYBASE_FEATURES', 'string', '')

const featureOn = (key: $Keys<FeatureFlags>) => features.includes(key)

const ff: FeatureFlags = {
  admin: false,
  avatarUploadsEnabled: false,
  explodingMessagesEnabled: true,
  fsEnabled: true,
  fsWritesEnabled: true,
  plansEnabled: false,
  walletsEnabled: false,
}

const inAdmin: {[key: $Keys<FeatureFlags>]: boolean} = {
  avatarUploadsEnabled: true,
  walletsEnabled: true,
}

// load overrides
Object.keys(ff).forEach(k => {
  ff[k] = featureOn(k) || ff[k] || (featureOn('admin') && inAdmin[k])
})

if (__DEV__) {
  console.log('Features', ff)
}

export default ff

@@ -548,28 +548,27 @@
 adsEnabled: 
-fals
+tru
 e,%0A  explodi
@@ -748,38 +748,8 @@
 = %7B%0A
-  avatarUploadsEnabled: true,%0A
   wa

Enable avatar uploads on desktop. (#12918)