use std::time::Duration;
use anyhow::Result;
use async_trait::async_trait;
use tokio::sync::broadcast;
pub(crate) const RAW_INPUT_ENTER_DELAY: Duration = Duration::from_millis(200);
pub(crate) const ZELLIJ_PANE_DISCOVERY_RETRY_INTERVAL: Duration = Duration::from_millis(200);
pub(crate) const ZELLIJ_PANE_DISCOVERY_MAX_ATTEMPTS: usize = 15;
pub(crate) const ZELLIJ_SPAWN_TIMEOUT: Duration = Duration::from_secs(30);
pub(crate) const ZELLIJ_SPAWN_MAX_ATTEMPTS: usize = 2;
pub(crate) const ZELLIJ_SPAWN_RETRY_BACKOFF: Duration = Duration::from_millis(500);
pub(crate) const ZELLIJ_PANE_PROCESS_CHECK_INTERVAL: Duration = Duration::from_millis(300);
pub(crate) const ZELLIJ_PANE_PROCESS_CHECK_ATTEMPTS: usize = 3;
pub(crate) const ZELLIJ_ACTION_TIMEOUT: Duration = Duration::from_secs(8);
#[derive(Debug, Clone)]
pub struct SpawnOpts {
pub cwd: String,
#[allow(dead_code)]
pub cols: u16,
#[allow(dead_code)]
pub rows: u16,
pub env: Vec<(String, String)>,
}
#[allow(dead_code)]
#[async_trait]
pub trait SessionBackend: Send + Sync {
async fn spawn(&self, bin: &str, args: &[String], opts: SpawnOpts) -> Result<()>;
async fn send_text(&self, text: &str) -> Result<()>;
async fn send_enter(&self) -> Result<()>;
async fn send_special_keys(&self, keys: &[String]) -> Result<()>;
async fn paste_text(&self, text: &str) -> Result<()>;
async fn write_raw(&self, text: &str) -> Result<()>;
async fn raw_input(&self, text: &str) -> Result<()>;
async fn capture_viewport(&self) -> Result<String>;
async fn capture_current_screen(&self) -> Result<String>;
async fn is_alive(&self) -> Result<bool>;
async fn child_pid(&self) -> Result<Option<u32>>;
async fn kill(&self) -> Result<()>;
async fn destroy_session(&self) -> Result<()>;
async fn cursor_position(&self) -> Result<Option<(u16, u16)>>;
fn subscribe(&self) -> broadcast::Receiver<String>;
}
pub(crate) mod herdr;
mod observe;
pub(crate) mod select;
mod subscribe;
mod zellij;
pub use herdr::{HerdrBackend, HerdrObserveBackend};
pub use observe::ZellijObserveBackend;
pub use zellij::ZellijBackend;
#[cfg(test)]
#[path = "backend/tests.rs"]
mod tests;