import { NextResponse } from "next/server";
const DEVTOOLS_ALLOWED_ROLES = ["superadmin", "developer"];
function canAccessDevtoolsApi(authResult) {
  if (!authResult.success || !authResult.user) {
    return false;
  }
  return DEVTOOLS_ALLOWED_ROLES.includes(
    authResult.user.role
  );
}
function createDevtoolsAccessDeniedResponse() {
  return NextResponse.json(
    {
      success: false,
      error: {
        message: "Access denied: DevTools APIs require superadmin or developer role",
        code: "DEVTOOLS_ACCESS_DENIED",
        details: {
          requiredRoles: DEVTOOLS_ALLOWED_ROLES,
          hint: 'User role "member" cannot access DevTools APIs regardless of team role'
        }
      }
    },
    { status: 403 }
  );
}
function createDevtoolsUnauthorizedResponse() {
  return NextResponse.json(
    {
      success: false,
      error: {
        message: "Authentication required",
        code: "AUTHENTICATION_REQUIRED",
        details: {
          hint: "Provide a valid API key via Authorization header or x-api-key header"
        }
      }
    },
    { status: 401 }
  );
}
export {
  canAccessDevtoolsApi,
  createDevtoolsAccessDeniedResponse,
  createDevtoolsUnauthorizedResponse
};
