//! UltiAI native shell. Loads the shared static export at `/chat/`
//! and wires the suite's native capabilities through `ulti-core` + plugins.

use tauri::Emitter;

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_deep_link::init())
        .plugin(tauri_plugin_notification::init())
        .plugin(tauri_plugin_opener::init())
        .plugin(ulti_core::init())
        .setup(|app| {
            #[cfg(any(target_os = "android", target_os = "ios", desktop))]
            {
                use tauri_plugin_deep_link::DeepLinkExt;
                let handle = app.handle().clone();
                app.deep_link().on_open_url(move |event| {
                    let urls: Vec<String> =
                        event.urls().iter().map(|u| u.to_string()).collect();
                    let _ = handle.emit("ulti://deep-link", urls);
                });
            }
            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running UltiAI");
}
