import {
  bridgeLegacyGuard,
  runMutationGuards
} from "@open-mercato/shared/lib/crud/mutation-guard-registry";
function resolveUserFeatures(auth) {
  const features = auth?.features;
  if (!Array.isArray(features)) return [];
  return features.filter((value) => typeof value === "string");
}
async function runIntegrationMutationGuards(container, input, userFeatures) {
  const legacyGuard = bridgeLegacyGuard(container);
  if (!legacyGuard) {
    return { ok: true, afterSuccessCallbacks: [] };
  }
  return runMutationGuards([legacyGuard], input, { userFeatures });
}
async function runIntegrationMutationGuardAfterSuccess(callbacks, input) {
  for (const callback of callbacks) {
    if (!callback.guard.afterSuccess) continue;
    await callback.guard.afterSuccess({
      ...input,
      metadata: callback.metadata ?? null
    });
  }
}
export {
  resolveUserFeatures,
  runIntegrationMutationGuardAfterSuccess,
  runIntegrationMutationGuards
};
//# sourceMappingURL=guards.js.map
