#[cfg(feature = "load_cty")]
pub mod load_cty;
#[cfg(feature = "load_cty")]
pub use load_cty::{CtyType, load_recent_cty};
pub mod error;
use csv::StringRecord;
use error::Error;
use regex::Regex;
use std::collections::HashMap;
use std::fmt::{Display, Formatter};
use std::fs;
use std::sync::LazyLock;
pub const NAME: &str = env!("CARGO_PKG_NAME");
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub type CountryCode = String;
#[derive(Debug, Clone, PartialEq)]
pub enum Continent {
NorthAmerica,
SouthAmerica,
Europe,
Africa,
Oceania,
Asia,
Antarctica,
Unknown(String),
}
impl From<&str> for Continent {
fn from(value: &str) -> Self {
match value.to_uppercase().as_str() {
"NA" => Continent::NorthAmerica,
"SA" => Continent::SouthAmerica,
"EU" => Continent::Europe,
"AF" => Continent::Africa,
"OC" => Continent::Oceania,
"AS" => Continent::Asia,
"AN" => Continent::Antarctica,
_ => Continent::Unknown(value.to_string()),
}
}
}
impl Display for Continent {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self {
Continent::NorthAmerica => "NA",
Continent::SouthAmerica => "SA",
Continent::Europe => "EU",
Continent::Africa => "AF",
Continent::Oceania => "OC",
Continent::Asia => "AS",
Continent::Antarctica => "AN",
Continent::Unknown(cont) => cont,
}
)
}
}
pub type DXCCEntity = u16;
pub type CQZone = u8;
pub type ITUZone = u8;
#[derive(Debug, Clone, PartialEq)]
pub struct Location {
pub lat: f32,
pub lon: f32,
}
impl TryFrom<&str> for Location {
type Error = Error;
fn try_from(value: &str) -> Result<Location, Self::Error> {
let mut loc = value.split("/");
if let (Some(Ok(lat)), Some(Ok(lon))) = (
loc.next().map(|v| v.parse::<f32>()),
loc.next().map(|v| v.parse::<f32>()),
) {
Ok(Location { lat, lon: -lon })
} else {
Err(Error::ParseError("unable to parse location".to_string()))
}
}
}
pub type TimeOffset = f32;
#[derive(Debug, Clone, PartialEq)]
pub struct Country {
pub code: CountryCode,
pub name: String,
pub dxcc: DXCCEntity,
pub continent: Continent,
pub cq: CQZone,
pub itu: ITUZone,
pub location: Location,
pub time_off: TimeOffset,
pub not_dxcc: bool,
}
impl Display for Country {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
pub type CountryMap = HashMap<CountryCode, Country>;
#[derive(Debug, Clone, PartialEq)]
struct OverrideData {
code: CountryCode,
cq: Option<CQZone>,
itu: Option<ITUZone>,
loc: Option<Location>,
cnt: Option<Continent>,
tz: Option<TimeOffset>,
}
static RE_OVERRIDES: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(concat!(
r"([A-Z0-9/=]+)", r"(?:\((\d+)\))?", r"(?:\[(\d+)\])?", r"(?:<(-?\d+.\d/-?\d+.\d)>)?", r"(?:\{(\w+)\})?", r"(?:~(-?\d+.\d)~)?", r".*"
))
.unwrap()
});
#[derive(Debug, PartialEq)]
pub struct CountryDatabase {
countries: CountryMap,
prefix_overrides: HashMap<String, OverrideData>,
prefixes: Vec<String>,
call_overrides: HashMap<String, OverrideData>,
version: String,
}
impl CountryDatabase {
pub fn new() -> Self {
Self::load(include_str!("../cty/cty.csv").as_bytes()).unwrap()
}
pub fn from_path(path: impl AsRef<str>) -> Result<Self, Error> {
Self::load(
fs::read(path.as_ref())
.map_err(|e| Error::CtyFileError(e.to_string()))?
.as_ref(),
)
}
fn load(data: &[u8]) -> Result<Self, Error> {
let mut countries = CountryMap::new();
let mut prefix_overrides: HashMap<String, OverrideData> = HashMap::new();
let mut call_overrides: HashMap<String, OverrideData> = HashMap::new();
let mut version = String::new();
let mut reader = csv::ReaderBuilder::new()
.delimiter(b',')
.has_headers(false)
.from_reader(data);
for res in reader.records() {
let record = res.map_err(|e| Error::CSVError(e.to_string()))?;
Self::parse_record(
&mut countries,
&mut prefix_overrides,
&mut call_overrides,
&mut version,
record,
)?;
}
if version.is_empty() {
return Err(Error::VersionNotFound);
}
let mut prefixes = prefix_overrides
.keys()
.map(|pfx| pfx.to_string())
.collect::<Vec<String>>();
prefixes.sort();
Ok(Self {
countries,
prefix_overrides,
prefixes,
call_overrides,
version,
})
}
fn parse_record(
countries: &mut HashMap<CountryCode, Country>,
prefix_overrides: &mut HashMap<String, OverrideData>,
call_overrides: &mut HashMap<String, OverrideData>,
version: &mut String,
record: StringRecord,
) -> Result<(), Error> {
let code = record.get(0).unwrap_or_default();
let not_dxcc = code.starts_with("*");
let code = code.replace("*", "");
countries.insert(
code.to_string(),
Country {
code: code.to_string(),
name: record.get(1).unwrap_or_default().to_string(),
dxcc: record
.get(2)
.unwrap_or_default()
.parse()
.map_err(|_| Error::ParseError(format!("DXCC for country code '{code}'")))?,
continent: record.get(3).unwrap_or_default().into(),
cq: record
.get(4)
.unwrap_or_default()
.parse()
.map_err(|_| Error::ParseError(format!("CQ zone for country code '{code}'")))?,
itu: record.get(5).unwrap_or_default().parse().map_err(|_| {
Error::ParseError(format!("ITU zone for country code '{code}'"))
})?,
location: Location {
lat: record.get(6).unwrap_or_default().parse().map_err(|_| {
Error::ParseError(format!("latitude for country code '{code}'"))
})?,
lon: record
.get(7)
.unwrap_or_default()
.parse::<f32>()
.map(|val| -val)
.map_err(|_| {
Error::ParseError(format!("longitude for country code '{code}'"))
})?,
},
time_off: record.get(8).unwrap_or_default().parse().map_err(|_| {
Error::ParseError(format!("time offset for country code '{code}'"))
})?,
not_dxcc,
},
);
record
.get(9)
.unwrap_or_default()
.replace(";", "")
.split(" ")
.for_each(|pfx| {
Self::parse_prefix_data(prefix_overrides, call_overrides, version, &code, pfx)
});
Ok(())
}
fn parse_prefix_data(
prefix_overrides: &mut HashMap<String, OverrideData>,
call_overrides: &mut HashMap<String, OverrideData>,
version: &mut String,
code: impl AsRef<str>,
pfx: impl AsRef<str>,
) {
let (pfx, cq, itu, loc, cnt, tz) =
if let Some(cap) = Regex::captures(&RE_OVERRIDES, pfx.as_ref()) {
(
cap.get(1).map(|v| v.as_str().to_string()),
cap.get(2).map(|v| v.as_str().parse::<CQZone>().unwrap()),
cap.get(3).map(|v| v.as_str().parse::<ITUZone>().unwrap()),
cap.get(4)
.map(|v| Location::try_from(v.as_str()).ok().unwrap()),
cap.get(5).map(|v| Continent::from(v.as_str())),
cap.get(6)
.map(|v| v.as_str().parse::<TimeOffset>().unwrap()),
)
} else {
(None, None, None, None, None, None)
};
let Some(pfx) = pfx else { return };
if let Some(pfx) = pfx.strip_prefix("=") {
if code.as_ref() == "VE" && pfx.starts_with("VER") {
version.push_str(pfx);
return;
}
if !call_overrides.contains_key(pfx) {
call_overrides.insert(
pfx.to_string(),
OverrideData {
code: code.as_ref().to_string(),
cq,
itu,
loc,
cnt,
tz,
},
);
}
} else {
prefix_overrides.insert(
pfx,
OverrideData {
code: code.as_ref().to_string(),
cq,
itu,
loc,
cnt,
tz,
},
);
}
}
pub fn version(&self) -> &String {
&self.version
}
pub fn version_entity(&self) -> Result<(CountryCode, String), Error> {
let cty = self
.country("VERSION")
.map_err(|_| Error::VersionEntityNotFound)?;
Ok((cty.code, cty.name))
}
pub fn prefix(&self, call: impl AsRef<str>) -> Result<String, Error> {
let mut pfx = String::new();
let call = call.as_ref().to_uppercase();
(1..call.chars().count() + 1).for_each(|i| {
if let Ok(_) = self.prefixes.binary_search(&call[..i].to_string()) {
pfx = call[..i].to_string()
}
});
if !pfx.is_empty() {
Ok(pfx)
} else {
Err(Error::PrefixNotFound)
}
}
fn country_code(&self, call: impl AsRef<str>) -> Result<&OverrideData, Error> {
if let Some(ord) = self.call_overrides.get(&call.as_ref().to_uppercase()) {
return Ok(ord);
}
self.prefix_overrides
.get(&self.prefix(call).map_err(|_| Error::CountryCodeNotFound)?)
.ok_or(Error::CountryCodeNotFound)
}
pub fn country(&self, call: impl AsRef<str>) -> Result<Country, Error> {
let data = self.country_code(&call)?.clone();
self.countries
.get(&data.code)
.ok_or(Error::CountryNotFound)
.map(|cty| Country {
cq: if let Some(cq) = data.cq { cq } else { cty.cq },
itu: if let Some(itu) = data.itu {
itu
} else {
cty.itu
},
location: if let Some(loc) = data.loc {
loc
} else {
cty.location.clone()
},
continent: if let Some(cnt) = data.cnt {
cnt
} else {
cty.continent.clone()
},
time_off: if let Some(tz) = data.tz {
tz
} else {
cty.time_off
},
..cty.clone()
})
}
}
impl Default for CountryDatabase {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::error::Error;
use std::collections::HashSet;
fn setup() -> CountryDatabase {
CountryDatabase::from_path("test_data/cty.csv").expect("error loading test data")
}
#[test]
fn test_100_version() {
let cdb = setup();
assert_eq!(cdb.version(), "VER20260603");
assert_eq!(
cdb.version_entity(),
Ok(("3DA".to_string(), "Kingdom of Eswatini".to_string()))
);
}
#[test]
fn test_101_cur_version() {
let cdb = CountryDatabase::default();
assert_eq!(cdb.version(), "VER20260915");
assert_eq!(
cdb.version_entity(),
Ok(("3D2/r".to_string(), "Rotuma Island".to_string()))
);
}
#[test]
fn test_105_prefixes_state() {
let cdb = setup();
assert_eq!(true, cdb.prefixes.is_sorted());
let mut helper_set = HashSet::new();
assert_eq!(
true,
cdb.prefixes
.clone()
.into_iter()
.all(|x| helper_set.insert(x))
);
}
#[test]
fn test_110_prefix() {
let cdb = setup();
assert_eq!(cdb.prefix("DF1ASC"), Ok("DF".to_string()));
assert_eq!(cdb.prefix("DK50K32MR"), Ok("DK".to_string()));
assert_eq!(cdb.prefix("XX1XX"), Err(Error::PrefixNotFound));
}
#[test]
fn test_120_search() {
let cdb = setup();
let cty = cdb.country("DF1ASC").unwrap();
assert_eq!(cty.code, "DL");
assert_eq!(cty.continent, Continent::Europe);
assert_eq!(
cty.location,
Location {
lat: 51.00,
lon: 10.00
}
);
assert_eq!(false, cty.not_dxcc);
let cty = cdb.country("N4ABC").unwrap();
assert_eq!(cty.code, "K");
assert_eq!(cty.continent, Continent::NorthAmerica);
assert_eq!(false, cty.not_dxcc);
let cty = cdb.country("IH9ABC").unwrap();
assert_eq!(true, cty.not_dxcc);
let calls = vec![
("LU1DD", "LU"), ("LU1ZB", "CE9"), ("LU1ZA", "VP8/o"), ("LU1ZAW", "CE9"), ];
for (call, cc) in calls {
let cty = cdb.country(call).unwrap();
assert_eq!(cty.code, cc);
}
assert_eq!(cdb.country("XX1XX"), Err(Error::CountryCodeNotFound));
}
#[test]
fn test_125_search_prefix() {
let cdb = setup();
let cty = cdb.country("PA/DF1ASC").unwrap();
assert_eq!(cty.code, "PA");
let cty = cdb.country("DO/K4ABC").unwrap();
assert_eq!(cty.code, "DL");
let cty = cdb.country("DK/ZS3ASD").unwrap();
assert_eq!(cty.code, "DL");
}
#[test]
fn test_130_search_w_override() {
let cdb = setup();
let cty = cdb.country("LU1ZA").unwrap();
assert_eq!(cty.code, "VP8/o");
assert_eq!(cty.continent, Continent::SouthAmerica);
let cty = cdb.country("4U1WB").unwrap();
assert_eq!(cty.code, "K");
assert_eq!(cty.continent, Continent::NorthAmerica);
assert_eq!(cty.cq, 5);
assert_eq!(cty.itu, 8);
let cty = cdb.country("PP6XX").unwrap();
assert_eq!(cty.code, "PY");
assert_eq!(cty.continent, Continent::SouthAmerica);
assert_eq!(cty.itu, 13);
assert_eq!(cty.cq, 11);
}
#[test]
fn test_135_search_w_override() {
let row = String::from(
"K,United States,291,NA,5,8,37.60,91.87,5.0,AA AB AC<2.0/3.5> AD{SA} AE~-3.0~ \
AF AG AI AJ AK(3)[24] K N W =4U1WB(5)[8] =AH0AB(13)[16] =AH0AJ(5) =AH0AM[8] \
=AH0AX(7)[6]<-12.0/23.5>{AF}~2.0~ =AH0BR(5)[8];\n\
3DA,Kingdom of Eswatini,468,AF,38,57,-26.65,-31.48,-2.0,3DA =VERSION;\n\
VE,Canada,1,NA,5,9,44.35,78.75,5.0,CF CG CJ CK =VER20260603 =VA2VVV(2)[4];",
);
let cdb = CountryDatabase::load(row.as_bytes()).unwrap();
let cty = cdb.country("AH0AX").unwrap();
assert_eq!("K", cty.code);
assert_eq!(7, cty.cq);
assert_eq!(6, cty.itu);
assert_eq!(
Location {
lat: -12.0,
lon: -23.5
},
cty.location
);
assert_eq!(Continent::Africa, cty.continent);
assert_eq!(2.0, cty.time_off)
}
#[test]
fn test_200_error() {
assert_eq!(Error::PrefixNotFound.to_string(), "PrefixNotFound");
}
#[test]
fn test_300_continent() {
assert_eq!(<&str as Into<Continent>>::into("AN"), Continent::Antarctica);
assert_eq!(
<&str as Into<Continent>>::into("BB"),
Continent::Unknown("BB".to_string())
);
}
#[test]
fn test_310_cont_disp() {
assert_eq!(Continent::Unknown("XX".to_string()).to_string(), "XX");
assert_eq!(Continent::NorthAmerica.to_string(), "NA");
assert_eq!(Continent::SouthAmerica.to_string(), "SA");
assert_eq!(Continent::Europe.to_string(), "EU");
assert_eq!(Continent::Africa.to_string(), "AF");
assert_eq!(Continent::Oceania.to_string(), "OC");
assert_eq!(Continent::Asia.to_string(), "AS");
assert_eq!(Continent::Antarctica.to_string(), "AN");
}
#[test]
fn test_320_country_disp() {
let country = Country {
code: "XY".to_string(),
name: "Xy".to_string(),
dxcc: 100,
continent: Continent::Antarctica,
cq: 101,
itu: 102,
location: Location {
lat: 10.1,
lon: 5.5,
},
time_off: -2.0,
not_dxcc: false,
};
assert_eq!(
country.to_string(),
"Country { \
code: \"XY\", \
name: \"Xy\", \
dxcc: 100, \
continent: Antarctica, \
cq: 101, \
itu: 102, \
location: Location { lat: 10.1, lon: 5.5 }, \
time_off: -2.0, \
not_dxcc: false \
}"
)
}
#[test]
fn test_400_parse_ok() {
let row = String::from(
"K,United States,29,NA,5,8,37.60,91.87,5.0,AA AB AC AD AE AF AG AI AJ AK K N W \
=4U1WB(5)[8] =AH0AB(3)[6] =AH0AJ(5)[8] =AH0AM(4)[8] =AH0AX(5)[8] =AH0BR(5)[8];\n\
3DA,Kingdom of Eswatini,468,AF,38,57,-26.65,-31.48,-2.0,3DA =VERSION;\n\
VE,Canada,1,NA,5,9,44.35,78.75,5.0,CF CG CJ CK =VER20260603 =VA2VVV(2)[4];",
);
let res = CountryDatabase::load(row.as_bytes());
assert_eq!(true, res.is_ok());
}
#[test]
fn test_410_parse_errors() {
let row = String::from(
"K,United States,291,NA,5,8,37.60,91.87,5.0,AA AB AC AD AE AF AG AI AJ AK K N W \
=4U1WB(5)[8] =AH0AB(3)[6] =AH0AJ(5)[8] =AH0AM(4)[8] =AH0AX(5)[8] =AH0BR(5)[8];",
);
let res = CountryDatabase::load(row.as_bytes());
assert_eq!(res, Err(Error::VersionNotFound));
let row = String::from(
"K,United States,29a,NA,5,8,37.60,91.87,5.0,AA AB AC AD AE AF AG AI AJ AK K N W \
=4U1WB(5)[8] =AH0AB(3)[6] =AH0AJ(5)[8] =AH0AM(4)[8] =AH0AX(5)[8] =AH0BR(5)[8];\n\
3DA,Kingdom of Eswatini,468,AF,38,57,-26.65,-31.48,-2.0,3DA =VERSION;",
);
let res = CountryDatabase::load(row.as_bytes());
assert_eq!(
res,
Err(Error::ParseError("DXCC for country code 'K'".to_string()))
);
let row = String::from(
"K,United States,291,NA,a,8,37.60,91.87,5.0,AA AB AC AD AE AF AG AI AJ AK K N W \
=4U1WB(5)[8] =AH0AB(3)[6] =AH0AJ(5)[8] =AH0AM(4)[8] =AH0AX(5)[8] =AH0BR(5)[8];\n\
3DA,Kingdom of Eswatini,468,AF,38,57,-26.65,-31.48,-2.0,3DA =VERSION;",
);
let res = CountryDatabase::load(row.as_bytes());
assert_eq!(
res,
Err(Error::ParseError(
"CQ zone for country code 'K'".to_string()
))
);
let row = String::from(
"K,United States,291,NA,5,a,37.60,91.87,5.0,AA AB AC AD AE AF AG AI AJ AK K N W \
=4U1WB(5)[8] =AH0AB(3)[6] =AH0AJ(5)[8] =AH0AM(4)[8] =AH0AX(5)[8] =AH0BR(5)[8];\n\
3DA,Kingdom of Eswatini,468,AF,38,57,-26.65,-31.48,-2.0,3DA =VERSION;",
);
let res = CountryDatabase::load(row.as_bytes());
assert_eq!(
res,
Err(Error::ParseError(
"ITU zone for country code 'K'".to_string()
))
);
let row = String::from(
"K,United States,291,NA,5,8,a.60,91.87,5.0,AA AB AC AD AE AF AG AI AJ AK K N W \
=4U1WB(5)[8] =AH0AB(3)[6] =AH0AJ(5)[8] =AH0AM(4)[8] =AH0AX(5)[8] =AH0BR(5)[8];\n\
3DA,Kingdom of Eswatini,468,AF,38,57,-26.65,-31.48,-2.0,3DA =VERSION;",
);
let res = CountryDatabase::load(row.as_bytes());
assert_eq!(
res,
Err(Error::ParseError(
"latitude for country code 'K'".to_string()
))
);
let row = String::from(
"K,United States,291,NA,5,8,37.60,a.87,5.0,AA AB AC AD AE AF AG AI AJ AK K N W \
=4U1WB(5)[8] =AH0AB(3)[6] =AH0AJ(5)[8] =AH0AM(4)[8] =AH0AX(5)[8] =AH0BR(5)[8];\n\
3DA,Kingdom of Eswatini,468,AF,38,57,-26.65,-31.48,-2.0,3DA =VERSION;",
);
let res = CountryDatabase::load(row.as_bytes());
assert_eq!(
res,
Err(Error::ParseError(
"longitude for country code 'K'".to_string()
))
);
let row = String::from(
"K,United States,291,NA,5,8,37.60,91.87,a.0,AA AB AC AD AE AF AG AI AJ AK K N W \
=4U1WB(5)[8] =AH0AB(3)[6] =AH0AJ(5)[8] =AH0AM(4)[8] =AH0AX(5)[8] =AH0BR(5)[8];\n\
3DA,Kingdom of Eswatini,468,AF,38,57,-26.65,-31.48,-2.0,3DA =VERSION;",
);
let res = CountryDatabase::load(row.as_bytes());
assert_eq!(
res,
Err(Error::ParseError(
"time offset for country code 'K'".to_string()
))
);
}
#[test]
fn test_420_parse_override() {
let row = String::from(
"K,United States,291,NA,5,8,37.60,91.87,5.0,AA AB AC<2.0/3.5> AD{SA} AE~-3.0~ \
AF AG AI AJ AK(3)[24] K N W =4U1WB(5)[8] =AH0AB(13)[16] =AH0AJ(5) =AH0AM[8] \
=AH0AX(7)[6]<-12.0/23.5>{AF}~2.0~ =AH0BR(5)[8];\n\
3DA,Kingdom of Eswatini,468,AF,38,57,-26.65,-31.48,-2.0,3DA =VERSION;\n\
VE,Canada,1,NA,5,9,44.35,78.75,5.0,CF CG CJ CK =VER20260603 =VA2VVV(2)[4];",
);
let cdb = CountryDatabase::load(row.as_bytes()).unwrap();
assert_eq!(None, cdb.prefix_overrides["AA"].cq);
assert_eq!(None, cdb.prefix_overrides["AA"].itu);
assert_eq!(None, cdb.prefix_overrides["AA"].loc);
assert_eq!(None, cdb.prefix_overrides["AA"].cnt);
assert_eq!(None, cdb.prefix_overrides["AA"].tz);
assert_eq!(None, cdb.prefix_overrides["AC"].cq);
assert_eq!(None, cdb.prefix_overrides["AC"].itu);
assert_eq!(
Some(Location {
lat: 2.0,
lon: -3.5
}),
cdb.prefix_overrides["AC"].loc
);
assert_eq!(None, cdb.prefix_overrides["AC"].cnt);
assert_eq!(None, cdb.prefix_overrides["AC"].tz);
assert_eq!(None, cdb.prefix_overrides["AD"].cq);
assert_eq!(None, cdb.prefix_overrides["AD"].itu);
assert_eq!(None, cdb.prefix_overrides["AD"].loc);
assert_eq!(
Some(Continent::SouthAmerica),
cdb.prefix_overrides["AD"].cnt
);
assert_eq!(None, cdb.prefix_overrides["AD"].tz);
assert_eq!(None, cdb.prefix_overrides["AE"].cq);
assert_eq!(None, cdb.prefix_overrides["AE"].itu);
assert_eq!(None, cdb.prefix_overrides["AE"].loc);
assert_eq!(None, cdb.prefix_overrides["AE"].cnt);
assert_eq!(Some(-3.0), cdb.prefix_overrides["AE"].tz);
assert_eq!(Some(3), cdb.prefix_overrides["AK"].cq);
assert_eq!(Some(24), cdb.prefix_overrides["AK"].itu);
assert_eq!(None, cdb.prefix_overrides["AK"].loc);
assert_eq!(None, cdb.prefix_overrides["AK"].cnt);
assert_eq!(None, cdb.prefix_overrides["AK"].tz);
assert_eq!(Some(7), cdb.call_overrides["AH0AX"].cq);
assert_eq!(Some(6), cdb.call_overrides["AH0AX"].itu);
assert_eq!(
Some(Location {
lat: -12.0,
lon: -23.5
}),
cdb.call_overrides["AH0AX"].loc
);
assert_eq!(Some(Continent::Africa), cdb.call_overrides["AH0AX"].cnt);
assert_eq!(Some(2.0), cdb.call_overrides["AH0AX"].tz);
}
}