"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.isValidAction = exports.createSafeDispatch = exports.createAsyncAction = void 0;
const isValidAction = action => {
  if (typeof action !== 'object' || action === null) {
    console.error('Action is not a plain object:', action);
    return false;
  }
  if (!action.type) {
    console.error('Action missing type property:', action);
    return false;
  }
  return true;
};
exports.isValidAction = isValidAction;
const createSafeDispatch = dispatch => {
  return action => {
    if (!isValidAction(action)) {
      console.error('Invalid action being dispatched:', action);
      throw new Error('Invalid action: ' + JSON.stringify(action));
    }
    return dispatch(action);
  };
};
exports.createSafeDispatch = createSafeDispatch;
const createAsyncAction = asyncFunction => {
  return (...args) => async (dispatch, getState) => {
    try {
      const result = await asyncFunction(...args);
      return result;
    } catch (error) {
      console.error('Async action error:', error);
      throw error;
    }
  };
};
exports.createAsyncAction = createAsyncAction;
//# sourceMappingURL=actionHelpers.js.map