import { __name } from '../chunk-PAWJFY3S.mjs';
import { useCallback, useSyncExternalStore } from 'react';

var active = null;
var listeners = /* @__PURE__ */ new Set();
function registerComposer(handle) {
  active = handle;
  for (const fn of listeners) fn(active);
}
__name(registerComposer, "registerComposer");
function attachComposer(handle) {
  registerComposer(handle);
  return () => {
    if (active === handle) registerComposer(null);
  };
}
__name(attachComposer, "attachComposer");
function getActiveComposer() {
  return active;
}
__name(getActiveComposer, "getActiveComposer");
function subscribeComposer(listener) {
  listeners.add(listener);
  return () => {
    listeners.delete(listener);
  };
}
__name(subscribeComposer, "subscribeComposer");
function useActiveComposer() {
  const subscribe = useCallback((onChange) => {
    return subscribeComposer(onChange);
  }, []);
  return useSyncExternalStore(subscribe, getActiveComposer, () => null);
}
__name(useActiveComposer, "useActiveComposer");

export { attachComposer, getActiveComposer, registerComposer, subscribeComposer, useActiveComposer };
//# sourceMappingURL=index.mjs.map
//# sourceMappingURL=index.mjs.map