use fancy_regex::Regex;
use std::collections::{HashMap, HashSet};
use std::sync::LazyLock;
pub static CONSTRAINT_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r#"(?:constraint|contrainte\s+unique)\s+(?:["«])?([a-zA-Z0-9_]+)(?:["»])?"#).unwrap()
});
pub static KEY_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"Key\s+\(([^)]+)\)").unwrap());
pub static FAILED_REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"failed:\s+[a-zA-Z0-9_]+\.([a-zA-Z0-9_]+)").unwrap());
pub static FOR_KEY_REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"for\s+key\s+'[^.]+\.([^']+)'").unwrap());
pub static RICH_CONTENT_FIELDS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
HashSet::from([
"content",
"description",
"bio",
"comment",
"message",
"body",
"post",
"article",
])
});
pub static ALLOWED_TAGS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
HashSet::from([
"p",
"br",
"hr",
"strong",
"em",
"b",
"i",
"u",
"del",
"s",
"sub",
"sup",
"code",
"a",
"img",
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"ul",
"ol",
"li",
"blockquote",
"pre",
"table",
"thead",
"tbody",
"tr",
"th",
"td",
])
});
pub static ALLOWED_ATTRS: LazyLock<HashMap<&'static str, HashSet<&'static str>>> =
LazyLock::new(|| {
let mut map = HashMap::new();
map.insert("a", HashSet::from(["href", "title", "target"]));
map.insert("img", HashSet::from(["src", "alt", "title"]));
map.insert("code", HashSet::from(["class"]));
map
});