// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.12.0.

// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import

import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';

import '../frb_generated.dart';
import 'error.dart';
import 'metadata.dart';
import 'relays.dart';
import 'users.dart';

// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_fields_are_eq`, `assert_fields_are_eq`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`

Future<List<Account>> getAccounts() => RustLib.instance.api.crateApiAccountsGetAccounts();

Future<Account> getAccount({required String pubkey}) =>
    RustLib.instance.api.crateApiAccountsGetAccount(pubkey: pubkey);

Future<Account> createIdentity() => RustLib.instance.api.crateApiAccountsCreateIdentity();

Future<LoginResult> loginStart({required String nsecOrHexPrivkey}) =>
    RustLib.instance.api.crateApiAccountsLoginStart(nsecOrHexPrivkey: nsecOrHexPrivkey);

Future<LoginResult> loginPublishDefaultRelays({required String pubkey}) =>
    RustLib.instance.api.crateApiAccountsLoginPublishDefaultRelays(
      pubkey: pubkey,
    );

Future<LoginResult> loginWithCustomRelay({
  required String pubkey,
  required String relayUrl,
}) => RustLib.instance.api.crateApiAccountsLoginWithCustomRelay(
  pubkey: pubkey,
  relayUrl: relayUrl,
);

Future<void> loginCancel({required String pubkey}) =>
    RustLib.instance.api.crateApiAccountsLoginCancel(pubkey: pubkey);

Future<void> logout({required String pubkey}) =>
    RustLib.instance.api.crateApiAccountsLogout(pubkey: pubkey);

Future<String> exportAccountNsec({required String pubkey}) =>
    RustLib.instance.api.crateApiAccountsExportAccountNsec(pubkey: pubkey);

Future<void> updateAccountMetadata({
  required String pubkey,
  required FlutterMetadata metadata,
}) => RustLib.instance.api.crateApiAccountsUpdateAccountMetadata(
  pubkey: pubkey,
  metadata: metadata,
);

Future<String> uploadAccountProfilePicture({
  required String pubkey,
  required String serverUrl,
  required String filePath,
  required String imageType,
}) => RustLib.instance.api.crateApiAccountsUploadAccountProfilePicture(
  pubkey: pubkey,
  serverUrl: serverUrl,
  filePath: filePath,
  imageType: imageType,
);

Future<List<Relay>> accountRelays({
  required String pubkey,
  required RelayType relayType,
}) => RustLib.instance.api.crateApiAccountsAccountRelays(
  pubkey: pubkey,
  relayType: relayType,
);

Future<void> restoreDefaultRelays({required String pubkey}) =>
    RustLib.instance.api.crateApiAccountsRestoreDefaultRelays(pubkey: pubkey);

Future<void> addAccountRelay({
  required String pubkey,
  required String url,
  required RelayType relayType,
}) => RustLib.instance.api.crateApiAccountsAddAccountRelay(
  pubkey: pubkey,
  url: url,
  relayType: relayType,
);

Future<void> removeAccountRelay({
  required String pubkey,
  required String url,
  required RelayType relayType,
}) => RustLib.instance.api.crateApiAccountsRemoveAccountRelay(
  pubkey: pubkey,
  url: url,
  relayType: relayType,
);

Future<FlutterEvent?> accountKeyPackage({required String pubkey}) =>
    RustLib.instance.api.crateApiAccountsAccountKeyPackage(pubkey: pubkey);

Future<List<FlutterEvent>> accountKeyPackages({
  required String accountPubkey,
}) => RustLib.instance.api.crateApiAccountsAccountKeyPackages(
  accountPubkey: accountPubkey,
);

Future<void> publishAccountKeyPackage({required String accountPubkey}) =>
    RustLib.instance.api.crateApiAccountsPublishAccountKeyPackage(
      accountPubkey: accountPubkey,
    );

Future<bool> deleteAccountKeyPackage({
  required String accountPubkey,
  required String keyPackageId,
}) => RustLib.instance.api.crateApiAccountsDeleteAccountKeyPackage(
  accountPubkey: accountPubkey,
  keyPackageId: keyPackageId,
);

Future<BigInt> deleteAccountKeyPackages({required String accountPubkey}) =>
    RustLib.instance.api.crateApiAccountsDeleteAccountKeyPackages(
      accountPubkey: accountPubkey,
    );

Future<BigInt> deleteAllAccountKeyPackages({required String accountPubkey}) =>
    RustLib.instance.api.crateApiAccountsDeleteAllAccountKeyPackages(
      accountPubkey: accountPubkey,
    );

Future<List<User>> accountFollows({required String pubkey}) =>
    RustLib.instance.api.crateApiAccountsAccountFollows(pubkey: pubkey);

Future<void> followUser({
  required String accountPubkey,
  required String userToFollowPubkey,
}) => RustLib.instance.api.crateApiAccountsFollowUser(
  accountPubkey: accountPubkey,
  userToFollowPubkey: userToFollowPubkey,
);

Future<void> unfollowUser({
  required String accountPubkey,
  required String userToUnfollowPubkey,
}) => RustLib.instance.api.crateApiAccountsUnfollowUser(
  accountPubkey: accountPubkey,
  userToUnfollowPubkey: userToUnfollowPubkey,
);

Future<bool> isFollowingUser({
  required String accountPubkey,
  required String userPubkey,
}) => RustLib.instance.api.crateApiAccountsIsFollowingUser(
  accountPubkey: accountPubkey,
  userPubkey: userPubkey,
);

Future<AccountSettings> accountSettings({required String pubkey}) =>
    RustLib.instance.api.crateApiAccountsAccountSettings(pubkey: pubkey);

Future<AccountSettings> updateNotificationsEnabled({
  required String pubkey,
  required bool enabled,
}) => RustLib.instance.api.crateApiAccountsUpdateNotificationsEnabled(
  pubkey: pubkey,
  enabled: enabled,
);

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<RelayType>>
abstract class RelayType implements RustOpaqueInterface {}

class Account {
  final String pubkey;

  /// The type of account (local key or external signer).
  final AccountType accountType;
  final DateTime? lastSyncedAt;
  final DateTime createdAt;
  final DateTime updatedAt;

  const Account({
    required this.pubkey,
    required this.accountType,
    this.lastSyncedAt,
    required this.createdAt,
    required this.updatedAt,
  });

  @override
  int get hashCode =>
      pubkey.hashCode ^
      accountType.hashCode ^
      lastSyncedAt.hashCode ^
      createdAt.hashCode ^
      updatedAt.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is Account &&
          runtimeType == other.runtimeType &&
          pubkey == other.pubkey &&
          accountType == other.accountType &&
          lastSyncedAt == other.lastSyncedAt &&
          createdAt == other.createdAt &&
          updatedAt == other.updatedAt;
}

class AccountSettings {
  final bool notificationsEnabled;

  const AccountSettings({
    required this.notificationsEnabled,
  });

  @override
  int get hashCode => notificationsEnabled.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is AccountSettings &&
          runtimeType == other.runtimeType &&
          notificationsEnabled == other.notificationsEnabled;
}

/// The type of account authentication.
enum AccountType {
  /// Account with locally stored private key.
  local,

  /// Account using external signer (e.g., Amber via NIP-55).
  external_,
}

class FlutterEvent {
  final String id;
  final String pubkey;
  final DateTime createdAt;
  final int kind;
  final List<List<String>> tags;
  final String content;

  const FlutterEvent({
    required this.id,
    required this.pubkey,
    required this.createdAt,
    required this.kind,
    required this.tags,
    required this.content,
  });

  @override
  int get hashCode =>
      id.hashCode ^
      pubkey.hashCode ^
      createdAt.hashCode ^
      kind.hashCode ^
      tags.hashCode ^
      content.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is FlutterEvent &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          pubkey == other.pubkey &&
          createdAt == other.createdAt &&
          kind == other.kind &&
          tags == other.tags &&
          content == other.content;
}

/// The result of a login attempt.
class LoginResult {
  final Account account;
  final LoginStatus status;

  const LoginResult({
    required this.account,
    required this.status,
  });

  @override
  int get hashCode => account.hashCode ^ status.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is LoginResult &&
          runtimeType == other.runtimeType &&
          account == other.account &&
          status == other.status;
}

/// The status of a login attempt.
enum LoginStatus {
  /// Login completed successfully.
  complete,

  /// Relay lists were not found. The caller must resolve relay lists before
  /// login can complete.
  needsRelayLists,
}
