import { UIKitStore, rootReducer } from '../../store/index.js';
import React__default, { createContext, useRef, useCallback } from 'react';
import { Provider, createDispatchHook, createSelectorHook } from 'react-redux';
import { createStore } from 'redux';
import { ModalActions } from '../../store/modal.js';

const ctx = createContext({
  store: UIKitStore,
  storeState: UIKitStore.getState()
});
const KitStoreProvider = (props) => {
  const { children } = props;
  const storeRef = useRef(createStore(rootReducer));
  return /* @__PURE__ */ React__default.createElement(Provider, { context: ctx, store: storeRef.current }, children);
};
var KitStoreProvider$1 = KitStoreProvider;
const useKitDispatch = createDispatchHook(ctx);
const useKitSelector = createSelectorHook(ctx);
const usePushModal = () => {
  const dispatch = useKitDispatch();
  const pushModal = useCallback(
    (modal) => {
      dispatch({
        type: ModalActions.PUSH_MODAL,
        payload: modal
      });
    },
    [dispatch]
  );
  return pushModal;
};
const useCloseModal = () => {
  const dispatch = useKitDispatch();
  const closeModal = useCallback(
    (id) => {
      dispatch({
        type: ModalActions.CLOSE_MODAL,
        id
      });
    },
    [dispatch]
  );
  return closeModal;
};
const usePopModal = () => {
  const dispatch = useKitDispatch();
  const popModal = useCallback(() => {
    dispatch({
      type: ModalActions.POP_MODAL
    });
  }, [dispatch]);
  return popModal;
};
const useResetModal = () => {
  const dispatch = useKitDispatch();
  const resetModal = useCallback(() => {
    dispatch({
      type: ModalActions.RESET_MODAL
    });
  }, [dispatch]);
  return resetModal;
};

export { KitStoreProvider$1 as default, useCloseModal, useKitDispatch, useKitSelector, usePopModal, usePushModal, useResetModal };
