import { computed, toValue, type MaybeRefOrGetter } from 'vue' export type DevModeEnvironmentKey = | 'localhost' | 'development' | 'development:feature-branch' | 'preprod' | 'demo' | 'production' export function useDevModeEnvironment(environment: MaybeRefOrGetter) { const environmentKey = computed(() => toValue(environment) ?? null) const isDevEnv = computed( () => environmentKey.value === 'localhost' || environmentKey.value === 'development' || environmentKey.value === 'development:feature-branch', ) const isPreprod = computed(() => environmentKey.value === 'preprod') const environmentText = computed(() => { switch (environmentKey.value) { case 'localhost': return 'Localhost' case 'development': return 'Development' case 'development:feature-branch': return 'Dev: Feature' case 'preprod': return 'Preprod' case 'demo': return 'Demo' case 'production': return 'Production' default: return 'Environment not found' } }) const isBannerEnvironment = computed(() => isDevEnv.value || isPreprod.value) const isLocalhost = computed(() => environmentKey.value === 'localhost') return { environmentKey, isDevEnv, isPreprod, isLocalhost, environmentText, isBannerEnvironment, } }