import { createStore } from 'vuex';
import { app } from './modules/app';
import { user } from './modules/user';
import { global } from './modules/global';
import { workflow } from './modules/workflow';
import { simplyQuery } from './modules/simplyQuery';
// import { stepForm } from '@/views/form/step-form/model';
import createPersistedState from 'vuex-persistedstate';
import { ls } from '@remote/icpx-platform/utils';
/* import ls from '@/utils/local-storage'; */

// const debug = process.env.NODE_ENV !== 'production';
const debug = process.env.NODE_ENV;

const persistedPlugin = createPersistedState({
  paths: ['app'],
  storage: {
    getItem: (key: string) => ls.get(key),
    setItem: (key: string, value: any) => ls.set(key, value),
    removeItem: (key: string) => ls.remove(key),
  },
});

export default createStore({
  modules: {
    app,
    user,
    global,
    workflow,
    simplyQuery,
    // business
    // stepForm,
  },
  strict: debug,
  plugins: debug ? [persistedPlugin] : [],
});
