// Include the generated resource tables from build.rs
include!(concat!(env!("OUT_DIR"), "/public_resources.rs"));

use std::collections::HashMap;
use std::sync::OnceLock;

static FORWARD_MAP: OnceLock<HashMap<&'static str, u32>> = OnceLock::new();
static INVERSE_MAP: OnceLock<HashMap<u32, &'static str>> = OnceLock::new();

pub fn attr_forward(name: &str) -> Option<u32> {
    let map = FORWARD_MAP.get_or_init(|| ATTR_FORWARD.iter().map(|&(k, v)| (k, v)).collect());
    map.get(name).copied()
}

pub fn attr_inverse(id: u32) -> Option<&'static str> {
    let map = INVERSE_MAP.get_or_init(|| ATTR_INVERSE.iter().map(|&(k, v)| (k, v)).collect());
    map.get(&id).copied()
}
