import { AbilityContext } from "./ability.context.mjs";
import { OpenApiRouter } from "../config/router.context.mjs";
const createAclGuard = () => ({ canUse, redirectTo = "/", children }) => {
  const ability = AbilityContext.useAbility();
  const { replace } = OpenApiRouter.useRouter();
  if (!ability.can(canUse[0], canUse[1])) {
    replace(redirectTo);
    return null;
  }
  return children;
};
export {
  createAclGuard
};
