
export default {
  name: 'config',
  
  getReducer(){
    const initialData = {
      default:{}
    }
    return (state = initialData, { type, payload }) => {
      return state;
    }
  },

  selectDefaultConfig: (state) => {
    return state.config.default;
  },

  selectBasemapList: (state) => {
    return state.config.default.basemaps.map((b) => {
      if(b.url.indexOf('{accessToken}') !== -1) b.url = b.url.replace(/{accessToken}/ig, b.accessToken || '');
      if(b.url.indexOf('{s}') !== -1) b.url = b.url.replace(/{s}/ig, b.accessToken || '{a-c}');
      return b;
    });
  },

  selectBasemapImages: (state) => {
    return state.config.default.basemapImageIDs;
  },
  
  selectDefaultLayers: (state) => {
    return state.config.default.datasets;
  },

  selectLimitMapExtent: (state) => {
    return state.config.default.limitMapExtent;
  }

}