import { localeStringSchema } from "../locale";
const SharedActionTypes = {
  MAKESWIFT_CONNECTION_INIT: "MAKESWIFT_CONNECTION_INIT",
  REGISTER_DOCUMENT: "REGISTER_DOCUMENT",
  UNREGISTER_DOCUMENT: "UNREGISTER_DOCUMENT",
  SET_BREAKPOINTS: "SET_BREAKPOINTS",
  SET_LOCALE: "SET_LOCALE"
};
function makeswiftConnectionInit() {
  return {
    type: SharedActionTypes.MAKESWIFT_CONNECTION_INIT
  };
}
function registerDocument(document) {
  return {
    type: SharedActionTypes.REGISTER_DOCUMENT,
    payload: { documentKey: document.key, document }
  };
}
function unregisterDocument(documentKey) {
  return { type: SharedActionTypes.UNREGISTER_DOCUMENT, payload: { documentKey } };
}
function registerDocumentsEffect(documents) {
  return (dispatch) => {
    documents.forEach((document) => dispatch(registerDocument(document)));
    return () => {
      documents.forEach((document) => dispatch(unregisterDocument(document.key)));
    };
  };
}
function setBreakpoints(breakpoints) {
  return { type: SharedActionTypes.SET_BREAKPOINTS, payload: { breakpoints } };
}
function setLocale(locale, pathname) {
  return {
    type: SharedActionTypes.SET_LOCALE,
    payload: { locale: localeStringSchema.parse(locale.toString()), pathname }
  };
}
export {
  SharedActionTypes,
  makeswiftConnectionInit,
  registerDocument,
  registerDocumentsEffect,
  setBreakpoints,
  setLocale,
  unregisterDocument
};
//# sourceMappingURL=shared-api.js.map