import '../../../core/i18n/locale_utils.dart';

bool isPublicAuthPath(String path, Uri uri) {
  return path == '/signin' ||
      path == '/signup' ||
      path == '/login' ||
      path == '/registration' ||
      path == '/verify' ||
      path == '/verification' ||
      path == '/verify-complete' ||
      path.startsWith('/verify/') ||
      path.startsWith('/l/') ||
      path == '/approve' ||
      path.startsWith('/ql/') ||
      path == '/forgot-password' ||
      path == '/recovery' ||
      path == '/reset-password' ||
      path == '/error' ||
      path == '/settings' ||
      path == '/consent' ||
      path.startsWith('/consent/') ||
      uri.path.contains('/consent');
}

String? extractLoginShortCode(Uri uri) {
  final normalizedPath = stripLocalePath(uri);
  final segments = normalizedPath
      .split('/')
      .where((segment) => segment.isNotEmpty)
      .toList();
  if (segments.length < 2 || segments.first != 'l') {
    return null;
  }
  return segments[1];
}
