import 'features/auth/data/datasources/auth_remote_data_source.dart';
import 'features/auth/data/repositories/auth_repository_impl.dart';
import 'features/auth/domain/repositories/auth_repository.dart';
import 'features/auth/domain/usecases/send_otp.dart';
import 'features/auth/domain/usecases/verify_otp.dart';
import 'features/auth/presentation/bloc/auth_bloc.dart';

class ServiceLocator {
  static final ServiceLocator _instance = ServiceLocator._internal();
  factory ServiceLocator() => _instance;
  ServiceLocator._internal();

  late final AuthRemoteDataSource _authRemoteDataSource;
  late final AuthRepository _authRepository;
  late final SendOTP _sendOTPUseCase;
  late final VerifyOTP _verifyOTPUseCase;

  void init() {
    _authRemoteDataSource = AuthRemoteDataSourceImpl();

    _authRepository = AuthRepositoryImpl(
      remoteDataSource: _authRemoteDataSource,
    );

    _sendOTPUseCase = SendOTP(_authRepository);
    _verifyOTPUseCase = VerifyOTP(_authRepository);
  }

  AuthBloc get authBloc => AuthBloc(
    sendOTPUseCase: _sendOTPUseCase,
    verifyOTPUseCase: _verifyOTPUseCase,
  );
}

final sl = ServiceLocator();
