use std::sync::Arc;

use dashmap::DashMap;
use tera::Tera;
use uuid::Uuid;

use common_contracts::observability::TaskProgress;

use crate::{config::AppConfig, templates::load_tera};

#[derive(Clone)]
pub struct AppState {
    pub tasks: Arc<DashMap<Uuid, TaskProgress>>,
    pub config: Arc<AppConfig>,
    pub tera: Arc<Tera>,
}

impl AppState {
    pub fn new(config: AppConfig) -> Self {
        Self {
            tasks: Arc::new(DashMap::new()),
            config: Arc::new(config),
            tera: Arc::new(load_tera()),
        }
    }
}
