import Vue from 'vue';
import Vuex from 'vuex';
import VuexPersist from 'vuex-persist';
import locales from './locale/locales.json';

Vue.use(Vuex);

let locale: string = 'en';
let lang: string;

for (lang of navigator.languages) {
  if (lang in Object.keys(locales) ||
    lang.substr(0, 2) in Object.keys(locales)) {
    locale = lang;
    break;
  }
}

const vuexPersist = new VuexPersist({
  key: 'nervmag',
  storage: localStorage,
});

export default new Vuex.Store({
  actions: {

  },
  mutations: {

  },
  plugins: [vuexPersist.plugin],
  state: {
    backgroundColor: 'dark-strong-gray',
    brightness: 100,
    contrast: 100,
    fontSize: 14,
    hueRotation: 0,
    locale,
    mode: 'normal',
    textColor: 'light-blue',
    zoom: 1.0,
  },
});
