import {
  createSelector,
  createFeatureSelector,
  ActionReducerMap,
} from '@ngrx/store';

import { StateSelector } from '@overflow/core/ngrx/store';

import { MODULE } from '../probe.constant';

import * as ProbeEntityStore from './entity/probe';
import * as ProbeListContainerStore from './container/probe-list';
import * as ProbeDetailContainerStore from './container/probe-detail';
import * as ProbeSelectorContainerStore from './container/probe-selector';

export interface State {
  probe_list_container: ProbeListContainerStore.State;
  probe_detail_container: ProbeDetailContainerStore.State;
  probe_selector_container: ProbeSelectorContainerStore.State;
}

export const REDUCERS = {
  probe_list_container: ProbeListContainerStore.reducer,
  probe_detail_container: ProbeDetailContainerStore.reducer,
  probe_selector_container: ProbeSelectorContainerStore.reducer
};

export const EFFECTS = [
  ProbeEntityStore.Effects,
];

export const selectState = createFeatureSelector<State>(MODULE.name);

export const ProbeListContainerSelector = ProbeListContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.probe_list_container
));

export const ProbeDetailContainerSelector = ProbeDetailContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.probe_detail_container
));

export const ProbeSelectorContainerSelector = ProbeSelectorContainerStore.getSelectors(createSelector(
  selectState,
  (state: State) => state.probe_selector_container
));
