// 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 'frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
part 'api.freezed.dart';

// These functions are ignored because they are not marked as `pub`: `drive_upload`, `error_fields`, `wire_event`

CallParams? decodeVcp({required String vcp, required String conversationId}) =>
    RustLib.instance.api
        .crateApiDecodeVcp(vcp: vcp, conversationId: conversationId);

Future<CallSignaling> connectCallSignaling(
        {required String url, String? userAgent, String? proxy}) =>
    RustLib.instance.api.crateApiConnectCallSignaling(
        url: url, userAgent: userAgent, proxy: proxy);

void setTrustMincifryCa({required bool enabled}) =>
    RustLib.instance.api.crateApiSetTrustMincifryCa(enabled: enabled);

bool trustMincifryCa() => RustLib.instance.api.crateApiTrustMincifryCa();

Uint8List authMode(
        {required List<int> signature,
        required List<int> dex,
        required List<int> so,
        required PlatformInt64 callsSeed,
        required String deviceId}) =>
    RustLib.instance.api.crateApiAuthMode(
        signature: signature,
        dex: dex,
        so: so,
        callsSeed: callsSeed,
        deviceId: deviceId);

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<CallSignaling>>
abstract class CallSignaling implements RustOpaqueInterface {
  void close();

  bool isConnected();

  Stream<String> notifications();

  Future<String> sendCommand(
      {required String command, required String extraJson});
}

// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<KusoftSession>>
abstract class KusoftSession implements RustOpaqueInterface {
  Future<HandshakeInfo> connect();

  void disconnect();

  factory KusoftSession(
          {required SessionOptions options,
          RustStreamSink<WireLogEvent>? wireLog}) =>
      RustLib.instance.api
          .crateApiKusoftSessionNew(options: options, wireLog: wireLog);

  bool pingInteractive();

  Stream<PushEvent> pushes();

  Future<Uint8List> request({required int opcode, required List<int> payload});

  Future<RequestOutcome> requestFull(
      {required int opcode, required String jsonIn});

  Future<String> requestJson({required int opcode, required String jsonIn});

  int send({required int opcode, required List<int> payload});

  void setPingInteractive({required bool interactive});

  String state();

  Stream<UploadEvent> uploadFile(
      {required String url,
      required List<int> data,
      required String filename,
      String? userAgent});

  Stream<UploadEvent> uploadFilePath(
      {required String url,
      required String path,
      required String filename,
      String? contentType,
      String? connection,
      String? userAgent});

  Stream<UploadEvent> uploadPhoto(
      {required String url,
      required List<int> data,
      required String filename,
      String? userAgent});

  Stream<UploadEvent> uploadPhotoPath(
      {required String url,
      required String path,
      required String filename,
      String? userAgent});

  Stream<UploadEvent> uploadVideoPath(
      {required String url,
      required String path,
      required int chunkSize,
      required int concurrency});

  String userAgent();
}

class CallParams {
  final String token;
  final String wsEndpoint;
  final String? stun;
  final List<String> turn;
  final String? turnUser;
  final String? turnPassword;
  final bool isVideo;

  const CallParams({
    required this.token,
    required this.wsEndpoint,
    this.stun,
    required this.turn,
    this.turnUser,
    this.turnPassword,
    required this.isVideo,
  });

  @override
  int get hashCode =>
      token.hashCode ^
      wsEndpoint.hashCode ^
      stun.hashCode ^
      turn.hashCode ^
      turnUser.hashCode ^
      turnPassword.hashCode ^
      isVideo.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is CallParams &&
          runtimeType == other.runtimeType &&
          token == other.token &&
          wsEndpoint == other.wsEndpoint &&
          stun == other.stun &&
          turn == other.turn &&
          turnUser == other.turnUser &&
          turnPassword == other.turnPassword &&
          isVideo == other.isVideo;
}

class HandshakeInfo {
  final PlatformInt64? callsSeed;
  final String? deviceName;
  final Uint8List payload;
  final String payloadJson;

  const HandshakeInfo({
    this.callsSeed,
    this.deviceName,
    required this.payload,
    required this.payloadJson,
  });

  @override
  int get hashCode =>
      callsSeed.hashCode ^
      deviceName.hashCode ^
      payload.hashCode ^
      payloadJson.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is HandshakeInfo &&
          runtimeType == other.runtimeType &&
          callsSeed == other.callsSeed &&
          deviceName == other.deviceName &&
          payload == other.payload &&
          payloadJson == other.payloadJson;
}

class PushEvent {
  final int opcode;
  final Uint8List payload;
  final String payloadJson;

  const PushEvent({
    required this.opcode,
    required this.payload,
    required this.payloadJson,
  });

  @override
  int get hashCode => opcode.hashCode ^ payload.hashCode ^ payloadJson.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is PushEvent &&
          runtimeType == other.runtimeType &&
          opcode == other.opcode &&
          payload == other.payload &&
          payloadJson == other.payloadJson;
}

class RequestOutcome {
  final int cmd;
  final int opcode;
  final String payloadJson;
  final String? errorMessage;
  final String? errorKey;

  const RequestOutcome({
    required this.cmd,
    required this.opcode,
    required this.payloadJson,
    this.errorMessage,
    this.errorKey,
  });

  @override
  int get hashCode =>
      cmd.hashCode ^
      opcode.hashCode ^
      payloadJson.hashCode ^
      errorMessage.hashCode ^
      errorKey.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is RequestOutcome &&
          runtimeType == other.runtimeType &&
          cmd == other.cmd &&
          opcode == other.opcode &&
          payloadJson == other.payloadJson &&
          errorMessage == other.errorMessage &&
          errorKey == other.errorKey;
}

class SessionOptions {
  final String host;
  final int port;
  final String deviceId;
  final String instanceId;
  final String appVersion;
  final PlatformInt64 buildNumber;
  final String deviceType;
  final String osVersion;
  final String timezone;
  final String screen;
  final String pushDeviceType;
  final String arch;
  final String locale;
  final String deviceName;
  final String deviceLocale;
  final PlatformInt64 clientSessionId;
  final BigInt pingIntervalSecs;
  final bool pingInteractive;
  final bool autoReconnect;
  final bool insecureTls;
  final String? proxy;
  final bool? isPwa;
  final String? headerUserAgent;

  const SessionOptions({
    required this.host,
    required this.port,
    required this.deviceId,
    required this.instanceId,
    required this.appVersion,
    required this.buildNumber,
    required this.deviceType,
    required this.osVersion,
    required this.timezone,
    required this.screen,
    required this.pushDeviceType,
    required this.arch,
    required this.locale,
    required this.deviceName,
    required this.deviceLocale,
    required this.clientSessionId,
    required this.pingIntervalSecs,
    required this.pingInteractive,
    required this.autoReconnect,
    required this.insecureTls,
    this.proxy,
    this.isPwa,
    this.headerUserAgent,
  });

  @override
  int get hashCode =>
      host.hashCode ^
      port.hashCode ^
      deviceId.hashCode ^
      instanceId.hashCode ^
      appVersion.hashCode ^
      buildNumber.hashCode ^
      deviceType.hashCode ^
      osVersion.hashCode ^
      timezone.hashCode ^
      screen.hashCode ^
      pushDeviceType.hashCode ^
      arch.hashCode ^
      locale.hashCode ^
      deviceName.hashCode ^
      deviceLocale.hashCode ^
      clientSessionId.hashCode ^
      pingIntervalSecs.hashCode ^
      pingInteractive.hashCode ^
      autoReconnect.hashCode ^
      insecureTls.hashCode ^
      proxy.hashCode ^
      isPwa.hashCode ^
      headerUserAgent.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is SessionOptions &&
          runtimeType == other.runtimeType &&
          host == other.host &&
          port == other.port &&
          deviceId == other.deviceId &&
          instanceId == other.instanceId &&
          appVersion == other.appVersion &&
          buildNumber == other.buildNumber &&
          deviceType == other.deviceType &&
          osVersion == other.osVersion &&
          timezone == other.timezone &&
          screen == other.screen &&
          pushDeviceType == other.pushDeviceType &&
          arch == other.arch &&
          locale == other.locale &&
          deviceName == other.deviceName &&
          deviceLocale == other.deviceLocale &&
          clientSessionId == other.clientSessionId &&
          pingIntervalSecs == other.pingIntervalSecs &&
          pingInteractive == other.pingInteractive &&
          autoReconnect == other.autoReconnect &&
          insecureTls == other.insecureTls &&
          proxy == other.proxy &&
          isPwa == other.isPwa &&
          headerUserAgent == other.headerUserAgent;
}

@freezed
sealed class UploadEvent with _$UploadEvent {
  const UploadEvent._();

  const factory UploadEvent.progress({
    required BigInt sent,
    required BigInt total,
  }) = UploadEvent_Progress;
  const factory UploadEvent.done({
    required int status,
    required Uint8List body,
  }) = UploadEvent_Done;
  const factory UploadEvent.error({
    required String message,
  }) = UploadEvent_Error;
}

class WireLogEvent {
  final String direction;
  final String cmd;
  final int opcode;
  final int seq;
  final String json;

  const WireLogEvent({
    required this.direction,
    required this.cmd,
    required this.opcode,
    required this.seq,
    required this.json,
  });

  @override
  int get hashCode =>
      direction.hashCode ^
      cmd.hashCode ^
      opcode.hashCode ^
      seq.hashCode ^
      json.hashCode;

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is WireLogEvent &&
          runtimeType == other.runtimeType &&
          direction == other.direction &&
          cmd == other.cmd &&
          opcode == other.opcode &&
          seq == other.seq &&
          json == other.json;
}
