import 'package:krow_domain/krow_domain.dart';

// TODO: Implement StaffRepositoryInterface once defined in a feature package.
class StaffRepositoryMock {
  Future<Staff> createStaffProfile(Staff staff) async {
    await Future.delayed(const Duration(milliseconds: 500));
    return staff;
  }

  Future<List<Membership>> getMemberships(String userId) async {
    await Future.delayed(const Duration(milliseconds: 300));
    return <Membership>[
      Membership(
        id: 'mem_1',
        userId: userId,
        memberableId: 'biz_1',
        memberableType: 'business',
        role: 'staff',
      ),
    ];
  }

  Future<Staff?> getStaffProfile(String userId) async {
    await Future.delayed(const Duration(milliseconds: 400));
    return Staff(
      id: 'staff_1',
      authProviderId: userId,
      name: 'John Doe',
      email: 'john@krow.com',
      status: StaffStatus.active,
      avatar: 'https://i.pravatar.cc/300',
    );
  }

  Future<Staff> updateStaffProfile(Staff staff) async {
    await Future.delayed(const Duration(milliseconds: 500));
    return staff;
  }

  // Mock Availability Data Store
  final Map<String, dynamic> _mockAvailability = {};

  Future<Map<String, dynamic>> getAvailability(String userId, DateTime start, DateTime end) async {
    await Future.delayed(const Duration(milliseconds: 300));
    // Return mock structure: Date ISO String -> { isAvailable: bool, slots: { id: bool } }
    
    // Auto-generate some data if empty
    if (_mockAvailability.isEmpty) {
      // Just return empty, let the caller handle defaults
    }
    return _mockAvailability;
  }

  Future<void> updateAvailability(String userId, String dateIso, Map<String, dynamic> data) async {
    await Future.delayed(const Duration(milliseconds: 200));
    _mockAvailability[dateIso] = data;
  }
}