import { SharedActionTypes } from "../shared-api";
const BuilderActionTypes = {
  ...SharedActionTypes,
  MAKESWIFT_CONNECTION_CHECK: "MAKESWIFT_CONNECTION_CHECK",
  CHANGE_ELEMENT_BOX_MODELS: "CHANGE_ELEMENT_BOX_MODELS",
  MOUNT_COMPONENT: "MOUNT_COMPONENT",
  UNMOUNT_COMPONENT: "UNMOUNT_COMPONENT",
  CHANGE_DOCUMENT_ELEMENT_SIZE: "CHANGE_DOCUMENT_ELEMENT_SIZE",
  MESSAGE_BUILDER_PROP_CONTROLLER: "MESSAGE_BUILDER_PROP_CONTROLLER",
  HANDLE_WHEEL: "HANDLE_WHEEL",
  HANDLE_POINTER_MOVE: "HANDLE_POINTER_MOVE",
  ELEMENT_FROM_POINT_CHANGE: "ELEMENT_FROM_POINT_CHANGE",
  REGISTER_BUILDER_DOCUMENT: "REGISTER_BUILDER_DOCUMENT",
  UNREGISTER_BUILDER_DOCUMENT: "UNREGISTER_BUILDER_DOCUMENT",
  REGISTER_BUILDER_COMPONENT: "REGISTER_BUILDER_COMPONENT",
  UNREGISTER_BUILDER_COMPONENT: "UNREGISTER_BUILDER_COMPONENT",
  HANDLE_HOST_NAVIGATE: "HANDLE_HOST_NAVIGATE"
};
function makeswiftConnectionCheck(payload) {
  return { type: BuilderActionTypes.MAKESWIFT_CONNECTION_CHECK, payload };
}
function changeElementBoxModels(changedElementBoxModels) {
  return {
    type: BuilderActionTypes.CHANGE_ELEMENT_BOX_MODELS,
    payload: { changedElementBoxModels }
  };
}
function mountComponent(documentKey, elementKey) {
  return { type: BuilderActionTypes.MOUNT_COMPONENT, payload: { documentKey, elementKey } };
}
function unmountComponent(documentKey, elementKey) {
  return { type: BuilderActionTypes.UNMOUNT_COMPONENT, payload: { documentKey, elementKey } };
}
function mountComponentEffect(documentKey, elementKey) {
  return (dispatch) => {
    dispatch(mountComponent(documentKey, elementKey));
    return () => {
      dispatch(unmountComponent(documentKey, elementKey));
    };
  };
}
function changeDocumentElementSize(size) {
  return { type: BuilderActionTypes.CHANGE_DOCUMENT_ELEMENT_SIZE, payload: { size } };
}
function messageBuilderPropController(documentKey, elementKey, propName, message) {
  return {
    type: BuilderActionTypes.MESSAGE_BUILDER_PROP_CONTROLLER,
    payload: { documentKey, elementKey, propName, message }
  };
}
function handleWheel(payload) {
  return { type: BuilderActionTypes.HANDLE_WHEEL, payload };
}
function handlePointerMove(payload) {
  return { type: BuilderActionTypes.HANDLE_POINTER_MOVE, payload };
}
function elementFromPointChange(keys) {
  return { type: BuilderActionTypes.ELEMENT_FROM_POINT_CHANGE, payload: { keys } };
}
function registerBuilderDocument(document) {
  return {
    type: BuilderActionTypes.REGISTER_BUILDER_DOCUMENT,
    payload: { documentKey: document.key, document }
  };
}
function unregisterBuilderDocument(documentKey) {
  return { type: BuilderActionTypes.UNREGISTER_BUILDER_DOCUMENT, payload: { documentKey } };
}
function registerBuilderDocumentsEffect(documents) {
  return (dispatch) => {
    documents.forEach((document) => dispatch(registerBuilderDocument(document)));
    return () => {
      documents.forEach((document) => dispatch(unregisterBuilderDocument(document.key)));
    };
  };
}
function registerBuilderComponent(payload, transferables) {
  return {
    type: BuilderActionTypes.REGISTER_BUILDER_COMPONENT,
    payload,
    transferables
  };
}
function unregisterBuilderComponent(payload) {
  return { type: BuilderActionTypes.UNREGISTER_BUILDER_COMPONENT, payload };
}
function hasTransferables(action) {
  return "transferables" in action && Array.isArray(action.transferables);
}
export {
  BuilderActionTypes,
  changeDocumentElementSize,
  changeElementBoxModels,
  elementFromPointChange,
  handlePointerMove,
  handleWheel,
  hasTransferables,
  makeswiftConnectionCheck,
  messageBuilderPropController,
  mountComponent,
  mountComponentEffect,
  registerBuilderComponent,
  registerBuilderDocument,
  registerBuilderDocumentsEffect,
  unmountComponent,
  unregisterBuilderComponent,
  unregisterBuilderDocument
};
//# sourceMappingURL=actions.js.map