const PROGRESS_DOM_EVENTS = {
  UPDATE: "om:progress:update",
  COMPLETE: "om:progress:complete",
  ERROR: "om:progress:error",
  CANCELLED: "om:progress:cancelled"
};
function emitProgressUpdate(detail) {
  if (typeof window === "undefined" || typeof CustomEvent === "undefined") return;
  window.dispatchEvent(new CustomEvent(PROGRESS_DOM_EVENTS.UPDATE, { detail }));
}
function emitProgressComplete(jobId, jobType) {
  if (typeof window === "undefined" || typeof CustomEvent === "undefined") return;
  window.dispatchEvent(new CustomEvent(PROGRESS_DOM_EVENTS.COMPLETE, { detail: { jobId, jobType } }));
}
function emitProgressError(jobId, errorMessage) {
  if (typeof window === "undefined" || typeof CustomEvent === "undefined") return;
  window.dispatchEvent(new CustomEvent(PROGRESS_DOM_EVENTS.ERROR, { detail: { jobId, errorMessage } }));
}
function subscribeProgressUpdate(handler) {
  if (typeof window === "undefined") return () => {
  };
  const listener = (event) => handler(event.detail);
  window.addEventListener(PROGRESS_DOM_EVENTS.UPDATE, listener);
  return () => window.removeEventListener(PROGRESS_DOM_EVENTS.UPDATE, listener);
}
function subscribeProgressComplete(handler) {
  if (typeof window === "undefined") return () => {
  };
  const listener = (event) => handler(event.detail);
  window.addEventListener(PROGRESS_DOM_EVENTS.COMPLETE, listener);
  return () => window.removeEventListener(PROGRESS_DOM_EVENTS.COMPLETE, listener);
}
export {
  PROGRESS_DOM_EVENTS,
  emitProgressComplete,
  emitProgressError,
  emitProgressUpdate,
  subscribeProgressComplete,
  subscribeProgressUpdate
};
//# sourceMappingURL=progressEvents.js.map
