//! WASM-specific helpers for Rhai bindings and session management
//! Provides global functions for Rhai integration in WASM builds.

#[cfg(target_arch = "wasm32")]
pub fn select_keypair_global(key_id: &str) -> Result<(), String> {
    use crate::session_singleton::SESSION_MANAGER;
    SESSION_MANAGER.with(|cell| {
        let mut opt = cell.borrow_mut();
        if let Some(session) = opt.as_mut() {
            session.select_keypair(key_id).map_err(|e| format!("select_keypair error: {e}"))
        } else {
            Err("Session not initialized".to_string())
        }
    })
}
