'use strict';

var chunkPK6SKIKE_cjs = require('../chunk-PK6SKIKE.cjs');
var react = require('react');

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

exports.attachComposer = attachComposer;
exports.getActiveComposer = getActiveComposer;
exports.registerComposer = registerComposer;
exports.subscribeComposer = subscribeComposer;
exports.useActiveComposer = useActiveComposer;
//# sourceMappingURL=index.cjs.map
//# sourceMappingURL=index.cjs.map