1use std::collections::{HashMap, HashSet};
2
3fn country_method_map() -> HashMap<&'static str, i64> {
4 HashMap::from([
5 ("United States", 2),
6 ("USA", 2),
7 ("US", 2),
8 ("Canada", 2),
9 ("Mexico", 2),
10 ("Pakistan", 1),
11 ("Bangladesh", 1),
12 ("India", 1),
13 ("Afghanistan", 1),
14 ("United Kingdom", 3),
15 ("UK", 3),
16 ("Germany", 3),
17 ("Netherlands", 3),
18 ("Belgium", 3),
19 ("Sweden", 3),
20 ("Norway", 3),
21 ("Denmark", 3),
22 ("Finland", 3),
23 ("Austria", 3),
24 ("Switzerland", 3),
25 ("Poland", 3),
26 ("Italy", 3),
27 ("Spain", 3),
28 ("Greece", 3),
29 ("Japan", 3),
30 ("China", 3),
31 ("South Korea", 3),
32 ("Australia", 3),
33 ("New Zealand", 3),
34 ("South Africa", 3),
35 ("Saudi Arabia", 4),
36 ("Yemen", 4),
37 ("Oman", 4),
38 ("Bahrain", 4),
39 ("Egypt", 5),
40 ("Syria", 5),
41 ("Lebanon", 5),
42 ("Palestine", 5),
43 ("Jordan", 5),
44 ("Iraq", 5),
45 ("Libya", 5),
46 ("Sudan", 5),
47 ("Iran", 7),
48 ("Kuwait", 9),
49 ("Qatar", 10),
50 ("Singapore", 11),
51 ("France", 12),
52 ("Turkey", 13),
53 ("Türkiye", 13),
54 ("Russia", 14),
55 ("United Arab Emirates", 16),
56 ("UAE", 16),
57 ("Malaysia", 17),
58 ("Brunei", 17),
59 ("Tunisia", 18),
60 ("Algeria", 19),
61 ("Indonesia", 20),
62 ("Morocco", 21),
63 ("Portugal", 22),
64 ])
65}
66
67fn hanafi_countries() -> HashSet<&'static str> {
68 HashSet::from([
69 "Pakistan",
70 "Bangladesh",
71 "India",
72 "Afghanistan",
73 "Turkey",
74 "Türkiye",
75 "Iraq",
76 "Syria",
77 "Jordan",
78 "Palestine",
79 "Kazakhstan",
80 "Uzbekistan",
81 "Tajikistan",
82 "Turkmenistan",
83 "Kyrgyzstan",
84 ])
85}
86
87pub fn get_recommended_method(country: &str) -> Option<i64> {
88 let map = country_method_map();
89
90 if let Some(method) = map.get(country) {
91 return Some(*method);
92 }
93
94 let normalized = country.to_ascii_lowercase();
95 map.into_iter()
96 .find(|(key, _)| key.to_ascii_lowercase() == normalized)
97 .map(|(_, value)| value)
98}
99
100pub fn get_recommended_school(country: &str) -> i64 {
101 let direct = hanafi_countries();
102 if direct.contains(country) {
103 return 1;
104 }
105
106 let normalized = country.to_ascii_lowercase();
107 if direct
108 .iter()
109 .any(|entry| entry.to_ascii_lowercase() == normalized)
110 {
111 return 1;
112 }
113
114 0
115}
116
117#[cfg(test)]
118mod tests {
119 use super::{get_recommended_method, get_recommended_school};
120
121 #[test]
122 fn method_lookup_is_case_insensitive() {
123 assert_eq!(get_recommended_method("Pakistan"), Some(1));
124 assert_eq!(get_recommended_method("pakistan"), Some(1));
125 }
126
127 #[test]
128 fn school_recommendation_matches_expected_defaults() {
129 assert_eq!(get_recommended_school("Pakistan"), 1);
130 assert_eq!(get_recommended_school("Canada"), 0);
131 }
132}