@innovayse/geo-atlas 2.0.2 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,38 +1,17 @@
1
- import { Country } from '../types/country.interface';
2
- import { Currency } from '../types/currency.type';
3
- import { PhoneCode } from '../types/phone-code.interface';
1
+ import { CountriesData } from './CountriesData';
4
2
  import { State } from '../types/state.interface';
5
- import { Timezone } from '../types/timezone.type';
6
3
  /**
7
- * Main helper class for querying countries, states, cities, timezones,
8
- * calling codes and currencies from the offline geo-atlas dataset.
4
+ * Full offline geo-atlas helper.
5
+ *
6
+ * Extends {@link CountriesData} (country list / phone / currency / timezone —
7
+ * all from the small bundled `atlas.json`) and adds per-country state & city
8
+ * access. The state/city methods pull data through `countryLoaders`, which
9
+ * references every per-country JSON file (~171 MB total). Because that import
10
+ * lives here and NOT in `CountriesData`, consumers that only need the country
11
+ * list can import `CountriesData` (or the `/lite` entry) and avoid bundling the
12
+ * per-country dataset entirely.
9
13
  */
10
- export declare class CountriesAtlas {
11
- /** Internal countries array loaded from the bundled atlas.json. */
12
- private countries;
13
- /** Initializes the atlas by loading the bundled country data. */
14
- constructor();
15
- /**
16
- * Retrieve all countries with specified properties, or all countries if no properties are specified.
17
- *
18
- * @param {string[]} properties - Array of properties to retrieve.
19
- * @return {Country[]} - Array of country objects with specified properties or all countries.
20
- */
21
- getCountries(properties?: string[]): Country[];
22
- /**
23
- * Find a country by its ISO2 code.
24
- *
25
- * @param {string} iso2 - ISO2 code of the country to find.
26
- * @return {Country | undefined} - Country object or undefined if not found.
27
- */
28
- find(iso2: string): Country | undefined;
29
- /**
30
- * Find a country by its ISO3 code.
31
- *
32
- * @param {string} iso3 - ISO3 code of the country to find.
33
- * @return {Country | undefined} - Country object or undefined if not found.
34
- */
35
- findByIso3(iso3: string): Country | undefined;
14
+ export declare class CountriesAtlas extends CountriesData {
36
15
  /**
37
16
  * Retrieve all states of a country by its ISO2 code.
38
17
  *
@@ -41,7 +20,11 @@ export declare class CountriesAtlas {
41
20
  */
42
21
  getStates(iso2: string): State[] | undefined;
43
22
  /**
44
- * Retrieve all states of a country by its ISO2 code using dynamic import (browser-compatible).
23
+ * Retrieve all states of a country by its ISO2 code using a static loader registry.
24
+ *
25
+ * Uses explicit string-literal dynamic imports (via countryLoaders) so bundlers
26
+ * such as Vite, webpack, and rollup can statically analyze paths and code-split
27
+ * country data. Works in both Node.js (CJS/ESM) and browser environments.
45
28
  *
46
29
  * @param {string} iso2 - ISO2 code of the country.
47
30
  * @returns {Promise<State[]>} - Promise resolving to array of state objects.
@@ -55,45 +38,6 @@ export declare class CountriesAtlas {
55
38
  * @returns {State | undefined} - State object or undefined if not found.
56
39
  */
57
40
  state(iso2: string, stateCode: string): State | undefined;
58
- /**
59
- * Retrieve all timezones of all available countries.
60
- *
61
- * @returns {Timezone[]} - Array of timezone objects.
62
- */
63
- getTimezones(): Timezone[];
64
- /**
65
- * Retrieve all timezones of a country by its ISO2 code.
66
- *
67
- * @param {string} iso2 - ISO2 code of the country.
68
- * @returns {Timezone[] | undefined} - Array of timezone objects or undefined if not found.
69
- */
70
- timezone(iso2: string): Timezone[] | undefined;
71
- /**
72
- * Retrieve all calling codes of all available countries.
73
- *
74
- * @returns {PhoneCode[]} - Array of phone code objects.
75
- */
76
- getCallingCodes(): PhoneCode[];
77
- /**
78
- * Retrieve calling codes of a country by its ISO2 code.
79
- *
80
- * @param {string} iso2 - ISO2 code of the country.
81
- * @returns {PhoneCode | undefined} - Phone code object or undefined if not found.
82
- */
83
- callingCode(iso2: string): PhoneCode | undefined;
84
- /**
85
- * Retrieve all currencies of all available countries.
86
- *
87
- * @returns {Currency[]} - Array of currency objects.
88
- */
89
- getCurrencies(): Currency[];
90
- /**
91
- * Retrieve currency of a country by its ISO2 code.
92
- *
93
- * @param {string} iso2 - ISO2 code of the country.
94
- * @returns {Currency | undefined} - Currency object or undefined if not found.
95
- */
96
- currency(iso2: string): Currency | undefined;
97
41
  }
98
42
  declare const _default: CountriesAtlas;
99
43
  export default _default;
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -36,65 +13,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
13
  };
37
14
  Object.defineProperty(exports, "__esModule", { value: true });
38
15
  exports.CountriesAtlas = void 0;
39
- const atlas_json_1 = __importDefault(require("../data/atlas.json"));
16
+ const CountriesData_1 = require("./CountriesData");
17
+ const countryLoaders_1 = __importDefault(require("./countryLoaders"));
40
18
  /**
41
- * Main helper class for querying countries, states, cities, timezones,
42
- * calling codes and currencies from the offline geo-atlas dataset.
19
+ * Full offline geo-atlas helper.
20
+ *
21
+ * Extends {@link CountriesData} (country list / phone / currency / timezone —
22
+ * all from the small bundled `atlas.json`) and adds per-country state & city
23
+ * access. The state/city methods pull data through `countryLoaders`, which
24
+ * references every per-country JSON file (~171 MB total). Because that import
25
+ * lives here and NOT in `CountriesData`, consumers that only need the country
26
+ * list can import `CountriesData` (or the `/lite` entry) and avoid bundling the
27
+ * per-country dataset entirely.
43
28
  */
44
- class CountriesAtlas {
45
- /** Initializes the atlas by loading the bundled country data. */
46
- constructor() {
47
- this.countries = atlas_json_1.default;
48
- }
49
- /**
50
- * Retrieve all countries with specified properties, or all countries if no properties are specified.
51
- *
52
- * @param {string[]} properties - Array of properties to retrieve.
53
- * @return {Country[]} - Array of country objects with specified properties or all countries.
54
- */
55
- getCountries(properties) {
56
- if (properties) {
57
- return this.countries.map(country => {
58
- const newCountry = {};
59
- properties.forEach(property => {
60
- newCountry[property] = country[property];
61
- });
62
- return newCountry;
63
- });
64
- }
65
- return this.countries;
66
- }
67
- /**
68
- * Find a country by its ISO2 code.
69
- *
70
- * @param {string} iso2 - ISO2 code of the country to find.
71
- * @return {Country | undefined} - Country object or undefined if not found.
72
- */
73
- find(iso2) {
74
- return this.countries.find(country => { var _a; return ((_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === iso2.toUpperCase(); });
75
- }
76
- /**
77
- * Find a country by its ISO3 code.
78
- *
79
- * @param {string} iso3 - ISO3 code of the country to find.
80
- * @return {Country | undefined} - Country object or undefined if not found.
81
- */
82
- findByIso3(iso3) {
83
- return this.countries.find(country => { var _a; return ((_a = country.iso3) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === iso3.toUpperCase(); });
84
- }
85
- // getStates(iso2: string): Promise<State[]> | undefined {
86
- // const country = this.find(iso2)
87
- // if (country) {
88
- // return import(`../data/countries/${country.iso2?.toLowerCase()}.json`)
89
- // .then(statesData => {
90
- // return statesData.states
91
- // })
92
- // .catch(() => {
93
- // return undefined
94
- // })
95
- // }
96
- // return undefined
97
- // }
29
+ class CountriesAtlas extends CountriesData_1.CountriesData {
98
30
  /**
99
31
  * Retrieve all states of a country by its ISO2 code.
100
32
  *
@@ -116,7 +48,11 @@ class CountriesAtlas {
116
48
  return undefined;
117
49
  }
118
50
  /**
119
- * Retrieve all states of a country by its ISO2 code using dynamic import (browser-compatible).
51
+ * Retrieve all states of a country by its ISO2 code using a static loader registry.
52
+ *
53
+ * Uses explicit string-literal dynamic imports (via countryLoaders) so bundlers
54
+ * such as Vite, webpack, and rollup can statically analyze paths and code-split
55
+ * country data. Works in both Node.js (CJS/ESM) and browser environments.
120
56
  *
121
57
  * @param {string} iso2 - ISO2 code of the country.
122
58
  * @returns {Promise<State[]>} - Promise resolving to array of state objects.
@@ -124,32 +60,22 @@ class CountriesAtlas {
124
60
  getStatesAsync(iso2) {
125
61
  var _a, _b;
126
62
  return __awaiter(this, void 0, void 0, function* () {
127
- var _c;
128
63
  const country = this.find(iso2);
129
- if (!country || !country.iso2)
64
+ if (!(country === null || country === void 0 ? void 0 : country.iso2))
65
+ return [];
66
+ const loader = countryLoaders_1.default[country.iso2.toLowerCase()];
67
+ if (!loader)
130
68
  return [];
131
69
  try {
132
- const mod = yield (_c = `../data/countries/${country.iso2.toLowerCase()}.json`, Promise.resolve().then(() => __importStar(require(_c))));
70
+ const mod = yield loader();
133
71
  const data = (_a = mod.default) !== null && _a !== void 0 ? _a : mod;
134
72
  return (_b = data.states) !== null && _b !== void 0 ? _b : [];
135
73
  }
136
- catch (_d) {
74
+ catch (_c) {
137
75
  return [];
138
76
  }
139
77
  });
140
78
  }
141
- // state(iso2: string, stateCode: string): Promise<State | undefined> | undefined {
142
- // const country = this.find(iso2);
143
- // if (country) {
144
- // return import(`../data/countries/${country.iso2?.toLowerCase()}.json`)
145
- // .then((statesData: StateData) => {
146
- // const state = statesData.states.find((s: State) => s.state_code?.toUpperCase() === stateCode);
147
- // return state ? state : undefined;
148
- // })
149
- // .catch(() => undefined);
150
- // }
151
- // return undefined;
152
- // }
153
79
  /**
154
80
  * Find a state by its state code and country ISO2 code.
155
81
  *
@@ -172,97 +98,6 @@ class CountriesAtlas {
172
98
  }
173
99
  return undefined;
174
100
  }
175
- /**
176
- * Retrieve all timezones of all available countries.
177
- *
178
- * @returns {Timezone[]} - Array of timezone objects.
179
- */
180
- getTimezones() {
181
- const timezoneSet = new Set();
182
- this.countries.forEach(country => {
183
- var _a;
184
- (_a = country.timezones) === null || _a === void 0 ? void 0 : _a.forEach(timezone => {
185
- timezoneSet.add(timezone);
186
- });
187
- });
188
- return Array.from(timezoneSet);
189
- }
190
- /**
191
- * Retrieve all timezones of a country by its ISO2 code.
192
- *
193
- * @param {string} iso2 - ISO2 code of the country.
194
- * @returns {Timezone[] | undefined} - Array of timezone objects or undefined if not found.
195
- */
196
- timezone(iso2) {
197
- const country = this.find(iso2);
198
- if (country) {
199
- return country.timezones;
200
- }
201
- return undefined;
202
- }
203
- /**
204
- * Retrieve all calling codes of all available countries.
205
- *
206
- * @returns {PhoneCode[]} - Array of phone code objects.
207
- */
208
- getCallingCodes() {
209
- return this.getCountries(['name', 'phone', 'iso2']).map(country => {
210
- var _a;
211
- return Object.assign(Object.assign({}, country), { phone_code: `+${country.phone}`, flag: `flag flag-${(_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toLowerCase()}` });
212
- });
213
- }
214
- /**
215
- * Retrieve calling codes of a country by its ISO2 code.
216
- *
217
- * @param {string} iso2 - ISO2 code of the country.
218
- * @returns {PhoneCode | undefined} - Phone code object or undefined if not found.
219
- */
220
- callingCode(iso2) {
221
- var _a;
222
- const country = this.find(iso2);
223
- if (country) {
224
- return {
225
- name: country.name,
226
- phone: country.phone,
227
- iso2: country.iso2,
228
- phone_code: `+${country.phone}`,
229
- flag: `flag flag-${(_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toLowerCase()}`
230
- };
231
- }
232
- return undefined;
233
- }
234
- /**
235
- * Retrieve all currencies of all available countries.
236
- *
237
- * @returns {Currency[]} - Array of currency objects.
238
- */
239
- getCurrencies() {
240
- return this.getCountries(['name', 'iso2', 'currency', 'currency_symbol', 'currency_name']).map(country => {
241
- var _a;
242
- return Object.assign(Object.assign({}, country), { flag: `flag flag-${(_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toLowerCase()}` });
243
- });
244
- }
245
- /**
246
- * Retrieve currency of a country by its ISO2 code.
247
- *
248
- * @param {string} iso2 - ISO2 code of the country.
249
- * @returns {Currency | undefined} - Currency object or undefined if not found.
250
- */
251
- currency(iso2) {
252
- var _a;
253
- const country = this.find(iso2);
254
- if (country) {
255
- return {
256
- name: country.name,
257
- iso2: country.iso2,
258
- currency: country.currency,
259
- currency_symbol: country.currency_symbol,
260
- currency_name: country.currency_name,
261
- flag: `flag flag-${(_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toLowerCase()}`
262
- };
263
- }
264
- return undefined;
265
- }
266
101
  }
267
102
  exports.CountriesAtlas = CountriesAtlas;
268
103
  exports.default = new CountriesAtlas();
@@ -0,0 +1,86 @@
1
+ import { Country } from '../types/country.interface';
2
+ import { Currency } from '../types/currency.type';
3
+ import { PhoneCode } from '../types/phone-code.interface';
4
+ import { Timezone } from '../types/timezone.type';
5
+ /**
6
+ * Lightweight country-list helper.
7
+ *
8
+ * Loads ONLY the bundled `atlas.json` (the country list plus per-country
9
+ * metadata: names, translations, phone, currency, timezones). It deliberately
10
+ * does NOT import the per-country state/city loaders (`countryLoaders`), so
11
+ * importing this class never drags the ~171 MB of per-country state/city JSON
12
+ * into a consumer's bundle.
13
+ *
14
+ * Use this when you only need countries, phone codes, currencies or timezones
15
+ * — e.g. on a server-rendered path. When you need states/cities, use
16
+ * `CountriesAtlas` (which extends this) or the `@touchestate/geo-atlas/cities`
17
+ * entry point.
18
+ */
19
+ export declare class CountriesData {
20
+ /** Internal countries array loaded from the bundled atlas.json. */
21
+ protected countries: Country[];
22
+ /** Initializes the atlas by loading the bundled country data. */
23
+ constructor();
24
+ /**
25
+ * Retrieve all countries with specified properties, or all countries if no properties are specified.
26
+ *
27
+ * @param {string[]} properties - Array of properties to retrieve.
28
+ * @return {Country[]} - Array of country objects with specified properties or all countries.
29
+ */
30
+ getCountries(properties?: string[]): Country[];
31
+ /**
32
+ * Find a country by its ISO2 code.
33
+ *
34
+ * @param {string} iso2 - ISO2 code of the country to find.
35
+ * @return {Country | undefined} - Country object or undefined if not found.
36
+ */
37
+ find(iso2: string): Country | undefined;
38
+ /**
39
+ * Find a country by its ISO3 code.
40
+ *
41
+ * @param {string} iso3 - ISO3 code of the country to find.
42
+ * @return {Country | undefined} - Country object or undefined if not found.
43
+ */
44
+ findByIso3(iso3: string): Country | undefined;
45
+ /**
46
+ * Retrieve all timezones of all available countries.
47
+ *
48
+ * @returns {Timezone[]} - Array of timezone objects.
49
+ */
50
+ getTimezones(): Timezone[];
51
+ /**
52
+ * Retrieve all timezones of a country by its ISO2 code.
53
+ *
54
+ * @param {string} iso2 - ISO2 code of the country.
55
+ * @returns {Timezone[] | undefined} - Array of timezone objects or undefined if not found.
56
+ */
57
+ timezone(iso2: string): Timezone[] | undefined;
58
+ /**
59
+ * Retrieve all calling codes of all available countries.
60
+ *
61
+ * @returns {PhoneCode[]} - Array of phone code objects.
62
+ */
63
+ getCallingCodes(): PhoneCode[];
64
+ /**
65
+ * Retrieve calling codes of a country by its ISO2 code.
66
+ *
67
+ * @param {string} iso2 - ISO2 code of the country.
68
+ * @returns {PhoneCode | undefined} - Phone code object or undefined if not found.
69
+ */
70
+ callingCode(iso2: string): PhoneCode | undefined;
71
+ /**
72
+ * Retrieve all currencies of all available countries.
73
+ *
74
+ * @returns {Currency[]} - Array of currency objects.
75
+ */
76
+ getCurrencies(): Currency[];
77
+ /**
78
+ * Retrieve currency of a country by its ISO2 code.
79
+ *
80
+ * @param {string} iso2 - ISO2 code of the country.
81
+ * @returns {Currency | undefined} - Currency object or undefined if not found.
82
+ */
83
+ currency(iso2: string): Currency | undefined;
84
+ }
85
+ declare const _default: CountriesData;
86
+ export default _default;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CountriesData = void 0;
7
+ const atlas_json_1 = __importDefault(require("../data/atlas.json"));
8
+ /**
9
+ * Lightweight country-list helper.
10
+ *
11
+ * Loads ONLY the bundled `atlas.json` (the country list plus per-country
12
+ * metadata: names, translations, phone, currency, timezones). It deliberately
13
+ * does NOT import the per-country state/city loaders (`countryLoaders`), so
14
+ * importing this class never drags the ~171 MB of per-country state/city JSON
15
+ * into a consumer's bundle.
16
+ *
17
+ * Use this when you only need countries, phone codes, currencies or timezones
18
+ * — e.g. on a server-rendered path. When you need states/cities, use
19
+ * `CountriesAtlas` (which extends this) or the `@touchestate/geo-atlas/cities`
20
+ * entry point.
21
+ */
22
+ class CountriesData {
23
+ /** Initializes the atlas by loading the bundled country data. */
24
+ constructor() {
25
+ this.countries = atlas_json_1.default;
26
+ }
27
+ /**
28
+ * Retrieve all countries with specified properties, or all countries if no properties are specified.
29
+ *
30
+ * @param {string[]} properties - Array of properties to retrieve.
31
+ * @return {Country[]} - Array of country objects with specified properties or all countries.
32
+ */
33
+ getCountries(properties) {
34
+ if (properties) {
35
+ return this.countries.map(country => {
36
+ const newCountry = {};
37
+ properties.forEach(property => {
38
+ newCountry[property] = country[property];
39
+ });
40
+ return newCountry;
41
+ });
42
+ }
43
+ return this.countries;
44
+ }
45
+ /**
46
+ * Find a country by its ISO2 code.
47
+ *
48
+ * @param {string} iso2 - ISO2 code of the country to find.
49
+ * @return {Country | undefined} - Country object or undefined if not found.
50
+ */
51
+ find(iso2) {
52
+ return this.countries.find(country => { var _a; return ((_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === iso2.toUpperCase(); });
53
+ }
54
+ /**
55
+ * Find a country by its ISO3 code.
56
+ *
57
+ * @param {string} iso3 - ISO3 code of the country to find.
58
+ * @return {Country | undefined} - Country object or undefined if not found.
59
+ */
60
+ findByIso3(iso3) {
61
+ return this.countries.find(country => { var _a; return ((_a = country.iso3) === null || _a === void 0 ? void 0 : _a.toUpperCase()) === iso3.toUpperCase(); });
62
+ }
63
+ /**
64
+ * Retrieve all timezones of all available countries.
65
+ *
66
+ * @returns {Timezone[]} - Array of timezone objects.
67
+ */
68
+ getTimezones() {
69
+ const timezoneSet = new Set();
70
+ this.countries.forEach(country => {
71
+ var _a;
72
+ (_a = country.timezones) === null || _a === void 0 ? void 0 : _a.forEach(timezone => {
73
+ timezoneSet.add(timezone);
74
+ });
75
+ });
76
+ return Array.from(timezoneSet);
77
+ }
78
+ /**
79
+ * Retrieve all timezones of a country by its ISO2 code.
80
+ *
81
+ * @param {string} iso2 - ISO2 code of the country.
82
+ * @returns {Timezone[] | undefined} - Array of timezone objects or undefined if not found.
83
+ */
84
+ timezone(iso2) {
85
+ const country = this.find(iso2);
86
+ if (country) {
87
+ return country.timezones;
88
+ }
89
+ return undefined;
90
+ }
91
+ /**
92
+ * Retrieve all calling codes of all available countries.
93
+ *
94
+ * @returns {PhoneCode[]} - Array of phone code objects.
95
+ */
96
+ getCallingCodes() {
97
+ return this.getCountries(['name', 'phone', 'iso2', 'phone_format']).map(country => {
98
+ var _a;
99
+ return Object.assign(Object.assign({}, country), { phone_code: `+${country.phone}`, flag: `flag flag-${(_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toLowerCase()}` });
100
+ });
101
+ }
102
+ /**
103
+ * Retrieve calling codes of a country by its ISO2 code.
104
+ *
105
+ * @param {string} iso2 - ISO2 code of the country.
106
+ * @returns {PhoneCode | undefined} - Phone code object or undefined if not found.
107
+ */
108
+ callingCode(iso2) {
109
+ var _a;
110
+ const country = this.find(iso2);
111
+ if (country) {
112
+ return {
113
+ name: country.name,
114
+ phone: country.phone,
115
+ iso2: country.iso2,
116
+ phone_code: `+${country.phone}`,
117
+ flag: `flag flag-${(_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toLowerCase()}`,
118
+ phone_format: country.phone_format
119
+ };
120
+ }
121
+ return undefined;
122
+ }
123
+ /**
124
+ * Retrieve all currencies of all available countries.
125
+ *
126
+ * @returns {Currency[]} - Array of currency objects.
127
+ */
128
+ getCurrencies() {
129
+ return this.getCountries(['name', 'iso2', 'currency', 'currency_symbol', 'currency_name']).map(country => {
130
+ var _a;
131
+ return Object.assign(Object.assign({}, country), { flag: `flag flag-${(_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toLowerCase()}` });
132
+ });
133
+ }
134
+ /**
135
+ * Retrieve currency of a country by its ISO2 code.
136
+ *
137
+ * @param {string} iso2 - ISO2 code of the country.
138
+ * @returns {Currency | undefined} - Currency object or undefined if not found.
139
+ */
140
+ currency(iso2) {
141
+ var _a;
142
+ const country = this.find(iso2);
143
+ if (country) {
144
+ return {
145
+ name: country.name,
146
+ iso2: country.iso2,
147
+ currency: country.currency,
148
+ currency_symbol: country.currency_symbol,
149
+ currency_name: country.currency_name,
150
+ flag: `flag flag-${(_a = country.iso2) === null || _a === void 0 ? void 0 : _a.toLowerCase()}`
151
+ };
152
+ }
153
+ return undefined;
154
+ }
155
+ }
156
+ exports.CountriesData = CountriesData;
157
+ exports.default = new CountriesData();
@@ -0,0 +1,17 @@
1
+ import type { State } from '../types/state.interface';
2
+ /**
3
+ * Auto-generated static loader registry for per-country state/city data.
4
+ *
5
+ * Each entry uses an explicit string-literal dynamic import path, allowing
6
+ * bundlers (Vite, webpack, rollup) to statically analyze, bundle, and
7
+ * code-split country data. DO NOT EDIT MANUALLY.
8
+ *
9
+ * Regenerate with: npm run generate:loaders
10
+ */
11
+ declare const countryLoaders: Record<string, () => Promise<{
12
+ default?: {
13
+ states: State[];
14
+ };
15
+ states?: State[];
16
+ }>>;
17
+ export default countryLoaders;