'use client';

// src/contexts/EventBusContext.tsx
import { createContext, useContext, useMemo } from "react";
import { EventBus } from "@semiont/core";
import { jsx } from "react/jsx-runtime";
var EventBusContext = createContext(null);
var globalEventBus = new EventBus();
function resetEventBusForTesting() {
  globalEventBus.destroy();
  globalEventBus = new EventBus();
  return globalEventBus;
}
function EventBusProvider({ children }) {
  const eventBus = useMemo(() => globalEventBus, []);
  return /* @__PURE__ */ jsx(EventBusContext.Provider, { value: eventBus, children });
}
function useEventBus() {
  const eventBus = useContext(EventBusContext);
  if (!eventBus) {
    throw new Error("useEventBus must be used within EventBusProvider");
  }
  return eventBus;
}

export {
  resetEventBusForTesting,
  EventBusProvider,
  useEventBus
};
//# sourceMappingURL=chunk-2HGWOLVN.mjs.map