const GLOBAL_KEY = "__openMercatoMutationGuards__";
let _guardEntries = null;
function readGlobal() {
  try {
    const value = globalThis[GLOBAL_KEY];
    return Array.isArray(value) ? value : null;
  } catch {
    return null;
  }
}
function writeGlobal(entries) {
  try {
    ;
    globalThis[GLOBAL_KEY] = entries;
  } catch {
  }
}
function registerMutationGuards(entries) {
  const flat = [];
  for (const entry of entries) {
    for (const guard of entry.guards) {
      flat.push({ moduleId: entry.moduleId, guard });
    }
  }
  _guardEntries = flat;
  writeGlobal(flat);
}
function getAllMutationGuards() {
  const globalEntries = readGlobal();
  if (globalEntries) return globalEntries;
  if (!_guardEntries) return [];
  return _guardEntries;
}
function getAllMutationGuardInstances() {
  return getAllMutationGuards().map((entry) => entry.guard);
}
export {
  getAllMutationGuardInstances,
  getAllMutationGuards,
  registerMutationGuards
};
//# sourceMappingURL=mutation-guard-store.js.map
