import 'package:pshared/models/payment/methods/card.dart';
import 'package:pshared/models/payment/methods/iban.dart';
import 'package:pshared/models/payment/methods/russian_bank.dart';
import 'package:pshared/models/payment/methods/wallet.dart';
import 'package:pshared/models/recipient/status.dart';
import 'package:pshared/models/recipient/type.dart';


class Recipient {
  final String? avatarUrl; // network URL / local asset
  final String name;
  final String email;
  final RecipientStatus status;
  final RecipientType type;
  final CardPaymentMethod? card;
  final IbanPaymentMethod? iban;
  final RussianBankAccountPaymentMethod? bank;
  final WalletPaymentMethod? wallet;

  const Recipient({
    this.avatarUrl,
    required this.name,
    required this.email,
    required this.status,
    required this.type,
    this.card,
    this.iban,
    this.bank,
    this.wallet,
  });

  /// Convenience factory for quickly creating mock recipients.
  factory Recipient.mock({
    required String name,
    required String email,
    required RecipientStatus status,
    required RecipientType type,
    CardPaymentMethod? card,
    IbanPaymentMethod? iban,
    RussianBankAccountPaymentMethod? bank,
    WalletPaymentMethod? wallet,
  }) =>
      Recipient(
        avatarUrl: null,
        name: name,
        email: email,
        status: status,
        type: type,
        card: card,
        iban: iban,
        bank: bank,
        wallet: wallet,
      );

  bool matchesQuery(String q) {
    final searchable = [
      name,
      email,
      card?.pan,
      card?.firstName,
      card?.lastName,
      iban?.iban,
      iban?.accountHolder,
      iban?.bic,
      iban?.bankName,
      bank?.accountNumber,
      bank?.recipientName,
      bank?.inn,
      bank?.kpp,
      bank?.bankName,
      bank?.bik,
      bank?.correspondentAccount,
      wallet?.walletId,
    ];

    return searchable.any((field) => field?.toLowerCase().contains(q) ?? false);
  }
}
