'use strict';

class EnvironmentConfigService {
  constructor() {
    // Private constructor, singleton
    this.init();
  }
  static getInstance() {
    if (!EnvironmentConfigService.instance) {
      EnvironmentConfigService.instance = new EnvironmentConfigService();
    }
    return EnvironmentConfigService.instance;
  }
  init() {
    if (!window) {
      return;
    }
    const win = window;
    const Sparkle = win.Sparkle;
    this.m = new Map(Object.entries(Sparkle.config));
  }
  get(key, fallback) {
    const value = this.m.get(key);
    return value !== undefined ? value : fallback;
  }
}

exports.EnvironmentConfigService = EnvironmentConfigService;
