import { routerActions } from './actions';

/** @type {VuexStoreModule} */
export const routerStore = {
  state() {
    return {
      current: {
        name: '',
        path: '',
        meta: '',
      },
      history: {
        name: '',
        path: '',
        meta: '',
      },
    };
  },
  mutations: {
    SET_ROUTER_CURRENT(state, data) {
      state.current = data;
    },
    SET_ROUTER_HISTORY(state, data) {
      state.history = data;
    },
  },
  getters: {
    getRouterCurrent(state) {
      return state.current;
    },
    getRouterHistory(state) {
      return state.history;
    },
    getRouterUrl() {
      return (uri) => {
        return `${window.location.origin}/popup.html#${uri}`;
      };
    },
  },
  actions: routerActions,
};
