import { ActionTypes, isKnownAction } from "../actions";
function getInitialState({
  reactComponents = /* @__PURE__ */ new Map()
} = {}) {
  return reactComponents;
}
function getReactComponents(state) {
  return state;
}
function getReactComponent(state, type) {
  return getReactComponents(state).get(type) ?? null;
}
function reducer(state = getInitialState(), action) {
  if (!isKnownAction(action))
    return state;
  switch (action.type) {
    case ActionTypes.REGISTER_REACT_COMPONENT:
      return new Map(state).set(action.payload.type, action.payload.component);
    case ActionTypes.UNREGISTER_REACT_COMPONENT: {
      const nextState = new Map(state);
      const deleted = nextState.delete(action.payload.type);
      return deleted ? nextState : state;
    }
    default:
      return state;
  }
}
export {
  getInitialState,
  getReactComponent,
  reducer
};
//# sourceMappingURL=react-components.js.map