//! Disputed - Your knowledge graph, always listening.

mod commands;
mod llm;
mod types;

use commands::{
    check_claims, extract_claims, get_claim_count, get_settings, save_claims, test_llm_connection,
    update_settings, SettingsState,
};
use std::sync::Mutex;
use types::Settings;

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .manage(SettingsState(Mutex::new(Settings::default())))
        .plugin(
            tauri_plugin_log::Builder::new()
                .target(tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::LogDir {
                    file_name: None,
                }))
                .build(),
        )
        .plugin(tauri_plugin_shell::init())
        .plugin(tauri_plugin_os::init())
        .plugin(tauri_plugin_notification::init())
        .plugin(tauri_plugin_clipboard_manager::init())
        .plugin(tauri_plugin_global_shortcut::Builder::new().build())
        .invoke_handler(tauri::generate_handler![
            extract_claims,
            check_claims,
            save_claims,
            get_claim_count,
            get_settings,
            update_settings,
            test_llm_connection,
        ])
        .run(tauri::generate_context!())
        .unwrap_or_else(|e| {
            eprintln!("Failed to start Tauri application: {e}");
            std::process::exit(1);
        });
}
