// 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';

// 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`, `clone`, `clone`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`, `from`

Stream<NotificationUpdate> subscribeToNotifications() =>
    RustLib.instance.api.crateApiNotificationsSubscribeToNotifications();

Future<PushRegistration?> getPushRegistration({required String pubkey}) =>
    RustLib.instance.api.crateApiNotificationsGetPushRegistration(
      pubkey: pubkey,
    );

Future<GroupPushDebugInfo> getGroupPushDebugInfo({
  required String pubkey,
  required String groupId,
}) => RustLib.instance.api.crateApiNotificationsGetGroupPushDebugInfo(
  pubkey: pubkey,
  groupId: groupId,
);

Future<PushRegistration> upsertPushRegistration({
  required String pubkey,
  required PushPlatform platform,
  required String rawToken,
  required String serverPubkey,
  String? relayHint,
}) => RustLib.instance.api.crateApiNotificationsUpsertPushRegistration(
  pubkey: pubkey,
  platform: platform,
  rawToken: rawToken,
  serverPubkey: serverPubkey,
  relayHint: relayHint,
);

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

class GroupPushDebugInfo {
  final int totalTokenCount;
  final int activeTokenCount;
  final int staleTokenCount;
  final int missingRelayHintCount;
  final DateTime? lastTokenListUpdatedAt;
  final LocalPushRegistrationDebugInfo localRegistration;
  final List<GroupPushTokenDebugEntry> tokens;

  const GroupPushDebugInfo({
    required this.totalTokenCount,
    required this.activeTokenCount,
    required this.staleTokenCount,
    required this.missingRelayHintCount,
    this.lastTokenListUpdatedAt,
    required this.localRegistration,
    required this.tokens,
  });

  @override
  int get hashCode =>
      totalTokenCount.hashCode ^
      activeTokenCount.hashCode ^
      staleTokenCount.hashCode ^
      missingRelayHintCount.hashCode ^
      lastTokenListUpdatedAt.hashCode ^
      localRegistration.hashCode ^
      tokens.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is GroupPushDebugInfo &&
          runtimeType == other.runtimeType &&
          totalTokenCount == other.totalTokenCount &&
          activeTokenCount == other.activeTokenCount &&
          staleTokenCount == other.staleTokenCount &&
          missingRelayHintCount == other.missingRelayHintCount &&
          lastTokenListUpdatedAt == other.lastTokenListUpdatedAt &&
          localRegistration == other.localRegistration &&
          tokens == other.tokens;
}

class GroupPushTokenDebugEntry {
  final String memberPubkey;
  final int leafIndex;
  final String serverPubkey;
  final bool hasRelayHint;
  final bool activeLeaf;
  final bool memberMatchesActiveLeaf;
  final bool isLocalMember;
  final DateTime updatedAt;

  const GroupPushTokenDebugEntry({
    required this.memberPubkey,
    required this.leafIndex,
    required this.serverPubkey,
    required this.hasRelayHint,
    required this.activeLeaf,
    required this.memberMatchesActiveLeaf,
    required this.isLocalMember,
    required this.updatedAt,
  });

  @override
  int get hashCode =>
      memberPubkey.hashCode ^
      leafIndex.hashCode ^
      serverPubkey.hashCode ^
      hasRelayHint.hashCode ^
      activeLeaf.hashCode ^
      memberMatchesActiveLeaf.hashCode ^
      isLocalMember.hashCode ^
      updatedAt.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is GroupPushTokenDebugEntry &&
          runtimeType == other.runtimeType &&
          memberPubkey == other.memberPubkey &&
          leafIndex == other.leafIndex &&
          serverPubkey == other.serverPubkey &&
          hasRelayHint == other.hasRelayHint &&
          activeLeaf == other.activeLeaf &&
          memberMatchesActiveLeaf == other.memberMatchesActiveLeaf &&
          isLocalMember == other.isLocalMember &&
          updatedAt == other.updatedAt;
}

class LocalPushRegistrationDebugInfo {
  final bool registered;
  final bool shareable;
  final bool notificationsEnabled;
  final int? localLeafIndex;
  final bool localTokenCached;

  const LocalPushRegistrationDebugInfo({
    required this.registered,
    required this.shareable,
    required this.notificationsEnabled,
    this.localLeafIndex,
    required this.localTokenCached,
  });

  @override
  int get hashCode =>
      registered.hashCode ^
      shareable.hashCode ^
      notificationsEnabled.hashCode ^
      localLeafIndex.hashCode ^
      localTokenCached.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is LocalPushRegistrationDebugInfo &&
          runtimeType == other.runtimeType &&
          registered == other.registered &&
          shareable == other.shareable &&
          notificationsEnabled == other.notificationsEnabled &&
          localLeafIndex == other.localLeafIndex &&
          localTokenCached == other.localTokenCached;
}

enum NotificationTrigger {
  newMessage,
  groupInvite,
}

class NotificationUpdate {
  final NotificationTrigger trigger;
  final String mlsGroupId;
  final String? groupName;
  final bool isDm;
  final NotificationUser receiver;
  final NotificationUser sender;
  final String content;
  final DateTime timestamp;

  const NotificationUpdate({
    required this.trigger,
    required this.mlsGroupId,
    this.groupName,
    required this.isDm,
    required this.receiver,
    required this.sender,
    required this.content,
    required this.timestamp,
  });

  @override
  int get hashCode =>
      trigger.hashCode ^
      mlsGroupId.hashCode ^
      groupName.hashCode ^
      isDm.hashCode ^
      receiver.hashCode ^
      sender.hashCode ^
      content.hashCode ^
      timestamp.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is NotificationUpdate &&
          runtimeType == other.runtimeType &&
          trigger == other.trigger &&
          mlsGroupId == other.mlsGroupId &&
          groupName == other.groupName &&
          isDm == other.isDm &&
          receiver == other.receiver &&
          sender == other.sender &&
          content == other.content &&
          timestamp == other.timestamp;
}

class NotificationUser {
  final String pubkey;
  final String? displayName;
  final String? pictureUrl;

  const NotificationUser({
    required this.pubkey,
    this.displayName,
    this.pictureUrl,
  });

  @override
  int get hashCode => pubkey.hashCode ^ displayName.hashCode ^ pictureUrl.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is NotificationUser &&
          runtimeType == other.runtimeType &&
          pubkey == other.pubkey &&
          displayName == other.displayName &&
          pictureUrl == other.pictureUrl;
}

enum PushPlatform {
  apns,
  fcm,
}

class PushRegistration {
  final String accountPubkey;
  final PushPlatform platform;
  final String rawToken;
  final String serverPubkey;
  final String? relayHint;
  final DateTime createdAt;
  final DateTime updatedAt;
  final DateTime? lastSharedAt;

  const PushRegistration({
    required this.accountPubkey,
    required this.platform,
    required this.rawToken,
    required this.serverPubkey,
    this.relayHint,
    required this.createdAt,
    required this.updatedAt,
    this.lastSharedAt,
  });

  @override
  int get hashCode =>
      accountPubkey.hashCode ^
      platform.hashCode ^
      rawToken.hashCode ^
      serverPubkey.hashCode ^
      relayHint.hashCode ^
      createdAt.hashCode ^
      updatedAt.hashCode ^
      lastSharedAt.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is PushRegistration &&
          runtimeType == other.runtimeType &&
          accountPubkey == other.accountPubkey &&
          platform == other.platform &&
          rawToken == other.rawToken &&
          serverPubkey == other.serverPubkey &&
          relayHint == other.relayHint &&
          createdAt == other.createdAt &&
          updatedAt == other.updatedAt &&
          lastSharedAt == other.lastSharedAt;
}
