/// Frappe Auth Provider
///
/// Riverpod provider for FrappeAuthService.
library;

import 'package:dio/dio.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:worker/core/services/frappe_auth_service.dart';

part 'frappe_auth_provider.g.dart';

/// Frappe Auth Service Provider
///
/// Provides singleton instance of FrappeAuthService.
@riverpod
FrappeAuthService frappeAuthService(Ref ref) {
  // Create a separate Dio instance for Frappe auth
  // (not using the main dio client to avoid circular dependencies)
  final dio = Dio();

  const secureStorage = FlutterSecureStorage(
    aOptions: AndroidOptions(encryptedSharedPreferences: true),
    iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock),
  );

  return FrappeAuthService(dio, secureStorage);
}
