// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
// ignore_for_file: unused_local_variable

import 'package:test/test.dart';
import 'dart:typed_data';
import 'package:kreuzberg/kreuzberg.dart';
import 'package:kreuzberg/kreuzberg.dart' show DocumentExtractor;
import 'package:kreuzberg/kreuzberg.dart' show OcrBackend;
import 'package:kreuzberg/kreuzberg.dart' show PostProcessor;
import 'package:kreuzberg/kreuzberg.dart' show Renderer;
import 'package:kreuzberg/kreuzberg.dart' show Validator;
import 'package:kreuzberg/kreuzberg.dart' show EmbeddingBackend;
import 'package:kreuzberg/src/kreuzberg_bridge_generated/frb_generated.dart' show RustLib;

// E2e tests for category: plugin_api

String _alefE2eText(Object? value) {
  if (value == null) return '';
  // Check if it's an enum by examining its toString representation.
  final str = value.toString();
  if (str.contains('.')) {
    // Enum.toString() returns 'EnumName.variantName'. Extract the variant name.
    final parts = str.split('.');
    if (parts.length == 2) {
      final variantName = parts[1];
      // Convert camelCase variant names to snake_case for serde compatibility.
      // E.g. 'toolCalls' -> 'tool_calls', 'stop' -> 'stop'.
      return _camelToSnake(variantName);
    }
  }
  return str;
}

String _camelToSnake(String camel) {
  final buffer = StringBuffer();
  for (int i = 0; i < camel.length; i++) {
    final char = camel[i];
    if (char.contains(RegExp(r'[A-Z]'))) {
      if (i > 0) buffer.write('_');
      buffer.write(char.toLowerCase());
    } else {
      buffer.write(char);
    }
  }
  return buffer.toString();
}

class TestStubRegisterDocumentExtractorTraitBridge extends DocumentExtractor {
  String get name => 'register_document_extractor_trait_bridge';
  Future<InternalDocumentBridge> extractBytes(Uint8List content, String mimeType, ExtractionConfig config) async => throw UnimplementedError();
  Future<InternalDocumentBridge> extractFile(String path, String mimeType, ExtractionConfig config) async => throw UnimplementedError();
  Future<List<String>> supportedMimeTypes() async => [];
  Future<int> priority() async => 1;
  Future<bool> canHandle(String path, String mimeType) async => false;
}
final _TestStubRegisterDocumentExtractorTraitBridge_instance = TestStubRegisterDocumentExtractorTraitBridge();
Future<DocumentExtractorDartImpl> _createTestStubRegisterDocumentExtractorTraitBridgeWrapper() async => await createDocumentExtractorDartImpl(
  pluginName: 'register_document_extractor_trait_bridge',
  pluginVersion: '0.0.1',
  extractBytes: (Uint8List content, String mimeType, ExtractionConfig config) => _TestStubRegisterDocumentExtractorTraitBridge_instance.extractBytes(content, mimeType, config),
  extractFile: (String path, String mimeType, ExtractionConfig config) => _TestStubRegisterDocumentExtractorTraitBridge_instance.extractFile(path, mimeType, config),
  supportedMimeTypes: () => _TestStubRegisterDocumentExtractorTraitBridge_instance.supportedMimeTypes(),
  priority: () => _TestStubRegisterDocumentExtractorTraitBridge_instance.priority(),
  canHandle: (String path, String mimeType) => _TestStubRegisterDocumentExtractorTraitBridge_instance.canHandle(path, mimeType)
);


class TestStubRegisterEmbeddingBackendTraitBridge extends EmbeddingBackend {
  String get name => 'register_embedding_backend_trait_bridge';
  Future<int> dimensions() async => 1;
  Future<List<Float64List>> embed(List<String> texts) async => [];
}
final _TestStubRegisterEmbeddingBackendTraitBridge_instance = TestStubRegisterEmbeddingBackendTraitBridge();
Future<EmbeddingBackendDartImpl> _createTestStubRegisterEmbeddingBackendTraitBridgeWrapper() async => await createEmbeddingBackendDartImpl(
  pluginName: 'register_embedding_backend_trait_bridge',
  pluginVersion: '0.0.1',
  dimensions: () => _TestStubRegisterEmbeddingBackendTraitBridge_instance.dimensions(),
  embed: (List<String> texts) => _TestStubRegisterEmbeddingBackendTraitBridge_instance.embed(texts)
);


class TestStubRegisterOcrBackendTraitBridge extends OcrBackend {
  String get name => 'register_ocr_backend_trait_bridge';
  Future<ExtractionResult> processImage(Uint8List imageBytes, OcrConfig config) async => throw UnimplementedError();
  Future<ExtractionResult> processImageFile(String path, OcrConfig config) async => throw UnimplementedError();
  Future<bool> supportsLanguage(String lang) async => false;
  Future<OcrBackendType> backendType() async => OcrBackendType.tesseract;
  Future<List<String>> supportedLanguages() async => [];
  Future<bool> supportsTableDetection() async => false;
  Future<bool> supportsDocumentProcessing() async => false;
  Future<ExtractionResult> processDocument(String path, OcrConfig config) async => throw UnimplementedError();
}
final _TestStubRegisterOcrBackendTraitBridge_instance = TestStubRegisterOcrBackendTraitBridge();
Future<OcrBackendDartImpl> _createTestStubRegisterOcrBackendTraitBridgeWrapper() async => await createOcrBackendDartImpl(
  pluginName: 'register_ocr_backend_trait_bridge',
  pluginVersion: '0.0.1',
  processImage: (Uint8List imageBytes, OcrConfig config) => _TestStubRegisterOcrBackendTraitBridge_instance.processImage(imageBytes, config),
  processImageFile: (String path, OcrConfig config) => _TestStubRegisterOcrBackendTraitBridge_instance.processImageFile(path, config),
  supportsLanguage: (String lang) => _TestStubRegisterOcrBackendTraitBridge_instance.supportsLanguage(lang),
  backendType: () => _TestStubRegisterOcrBackendTraitBridge_instance.backendType(),
  supportedLanguages: () => _TestStubRegisterOcrBackendTraitBridge_instance.supportedLanguages(),
  supportsTableDetection: () => _TestStubRegisterOcrBackendTraitBridge_instance.supportsTableDetection(),
  supportsDocumentProcessing: () => _TestStubRegisterOcrBackendTraitBridge_instance.supportsDocumentProcessing(),
  processDocument: (String path, OcrConfig config) => _TestStubRegisterOcrBackendTraitBridge_instance.processDocument(path, config)
);


class TestStubRegisterPostProcessorTraitBridge extends PostProcessor {
  String get name => 'register_post_processor_trait_bridge';
  Future<void> process(ExtractionResult result, ExtractionConfig config) async => null;
  Future<ProcessingStage> processingStage() async => ProcessingStage.early;
  Future<bool> shouldProcess(ExtractionResult result, ExtractionConfig config) async => false;
  Future<int> estimatedDurationMs(ExtractionResult result) async => 1;
  Future<int> priority() async => 1;
}
final _TestStubRegisterPostProcessorTraitBridge_instance = TestStubRegisterPostProcessorTraitBridge();
Future<PostProcessorDartImpl> _createTestStubRegisterPostProcessorTraitBridgeWrapper() async => await createPostProcessorDartImpl(
  pluginName: 'register_post_processor_trait_bridge',
  pluginVersion: '0.0.1',
  process: (ExtractionResult result, ExtractionConfig config) => _TestStubRegisterPostProcessorTraitBridge_instance.process(result, config),
  processingStage: () => _TestStubRegisterPostProcessorTraitBridge_instance.processingStage(),
  shouldProcess: (ExtractionResult result, ExtractionConfig config) => _TestStubRegisterPostProcessorTraitBridge_instance.shouldProcess(result, config),
  estimatedDurationMs: (ExtractionResult result) => _TestStubRegisterPostProcessorTraitBridge_instance.estimatedDurationMs(result),
  priority: () => _TestStubRegisterPostProcessorTraitBridge_instance.priority()
);


class TestStubRegisterRendererTraitBridge extends Renderer {
  String get name => 'register_renderer_trait_bridge';
  Future<String> render(InternalDocumentBridge doc) async => '';
}
final _TestStubRegisterRendererTraitBridge_instance = TestStubRegisterRendererTraitBridge();
Future<RendererDartImpl> _createTestStubRegisterRendererTraitBridgeWrapper() async => await createRendererDartImpl(
  pluginName: 'register_renderer_trait_bridge',
  pluginVersion: '0.0.1',
  render: (InternalDocumentBridge doc) => _TestStubRegisterRendererTraitBridge_instance.render(doc)
);


class TestStubRegisterValidatorTraitBridge extends Validator {
  String get name => 'register_validator_trait_bridge';
  Future<void> validate(ExtractionResult result, ExtractionConfig config) async => null;
  Future<bool> shouldValidate(ExtractionResult result, ExtractionConfig config) async => false;
  Future<int> priority() async => 1;
}
final _TestStubRegisterValidatorTraitBridge_instance = TestStubRegisterValidatorTraitBridge();
Future<ValidatorDartImpl> _createTestStubRegisterValidatorTraitBridgeWrapper() async => await createValidatorDartImpl(
  pluginName: 'register_validator_trait_bridge',
  pluginVersion: '0.0.1',
  validate: (ExtractionResult result, ExtractionConfig config) => _TestStubRegisterValidatorTraitBridge_instance.validate(result, config),
  shouldValidate: (ExtractionResult result, ExtractionConfig config) => _TestStubRegisterValidatorTraitBridge_instance.shouldValidate(result, config),
  priority: () => _TestStubRegisterValidatorTraitBridge_instance.priority()
);


void main() {
  setUpAll(() async {
    await RustLib.init();
  });

  test('register_document_extractor: trait bridge', () async {
    final result = await KreuzbergBridge.registerDocumentExtractor(await _createTestStubRegisterDocumentExtractorTraitBridgeWrapper());
  });

  test('register_embedding_backend: trait bridge', () async {
    final result = await KreuzbergBridge.registerEmbeddingBackend(await _createTestStubRegisterEmbeddingBackendTraitBridgeWrapper());
  });

  test('register_ocr_backend: trait bridge', () async {
    final result = await KreuzbergBridge.registerOcrBackend(await _createTestStubRegisterOcrBackendTraitBridgeWrapper());
  });

  test('register_post_processor: trait bridge', () async {
    final result = await KreuzbergBridge.registerPostProcessor(await _createTestStubRegisterPostProcessorTraitBridgeWrapper());
  });

  test('register_renderer: trait bridge', () async {
    final result = await KreuzbergBridge.registerRenderer(await _createTestStubRegisterRendererTraitBridgeWrapper());
  });

  test('register_validator: trait bridge', () async {
    final result = await KreuzbergBridge.registerValidator(await _createTestStubRegisterValidatorTraitBridgeWrapper());
  });

  test('unregister_document_extractor', () async {
    final result = await KreuzbergBridge.unregisterDocumentExtractor('test-extractor');
  });

  test('unregister_embedding_backend', () async {
    final result = await KreuzbergBridge.unregisterEmbeddingBackend('test-embedding-backend');
  });

  test('unregister_post_processor', () async {
    final result = await KreuzbergBridge.unregisterPostProcessor('test-processor');
  });

  test('unregister_renderer', () async {
    final result = await KreuzbergBridge.unregisterRenderer('test-renderer');
  });

  test('unregister_validator', () async {
    final result = await KreuzbergBridge.unregisterValidator('test-validator');
  });

}
