import { inject, provide } from "vue";
const COMMIT_BUS_KEY = Symbol("shwfed-form-commit-bus");
export function provideCommitBus() {
  const commits = /* @__PURE__ */ new Set();
  const bus = {
    register(commit) {
      commits.add(commit);
      return () => {
        commits.delete(commit);
      };
    },
    flushAll() {
      for (const commit of [...commits]) commit();
    }
  };
  provide(COMMIT_BUS_KEY, bus);
  return bus;
}
const NOOP_BUS = {
  register: () => () => {
  },
  flushAll: () => {
  }
};
export function useCommitBus() {
  return inject(COMMIT_BUS_KEY, NOOP_BUS);
}
