bd-geo-location 1.0.2 → 1.1.1
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.
- package/README.md +331 -64
- package/dist/chunk-745FSI7K.mjs +1 -0
- package/dist/chunk-7AXGEKLM.js +1 -0
- package/dist/chunk-A22T5G6E.mjs +1 -0
- package/dist/chunk-FWH6G3LI.js +1 -0
- package/dist/{index-SvmbRelJ.d.ts → index-UgYYjMwe.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -29156
- package/dist/index.mjs +1 -29113
- package/dist/react-native.d.ts +2 -0
- package/dist/react-native.js +1 -0
- package/dist/react-native.mjs +1 -0
- package/dist/react.d.ts +3 -3
- package/dist/react.js +1 -29132
- package/dist/react.mjs +1 -29100
- package/dist/vue.d.ts +3 -3
- package/dist/vue.js +1 -29175
- package/dist/vue.mjs +1 -29143
- package/package.json +25 -4
package/README.md
CHANGED
|
@@ -1,20 +1,116 @@
|
|
|
1
1
|
# BD Geo Location
|
|
2
2
|
|
|
3
|
+
> 🇧🇩 Complete geographical location data for Bangladesh with multi-platform support
|
|
4
|
+
|
|
3
5
|
A comprehensive TypeScript package for Bangladesh's geographical administrative divisions. This package provides complete hierarchical data for Divisions, Districts, Upazilas/Thanas, City Corporations, Unions, Pourosovas, and Villages.
|
|
4
6
|
|
|
7
|
+
## ✅ Production Ready
|
|
8
|
+
|
|
9
|
+
**Status**: All platforms tested and verified production-ready
|
|
10
|
+
|
|
11
|
+
- ✅ React (Web)
|
|
12
|
+
- ✅ Vue (Web)
|
|
13
|
+
- ✅ Angular (Web)
|
|
14
|
+
- ✅ React Native (Mobile)
|
|
15
|
+
- ✅ Flutter (Mobile)
|
|
16
|
+
- ✅ iOS/macOS (Native)
|
|
17
|
+
|
|
18
|
+
[📖 View Production Readiness Report](./generated/FINAL_PRODUCTION_READINESS.md)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 🚀 Quick Start
|
|
23
|
+
|
|
24
|
+
### React
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install bd-geo-location
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { useDivisions, useDistricts } from 'bd-geo-location/react';
|
|
32
|
+
|
|
33
|
+
function App() {
|
|
34
|
+
const divisions = useDivisions();
|
|
35
|
+
const [divisionId, setDivisionId] = useState(null);
|
|
36
|
+
const districts = useDistricts(divisionId);
|
|
37
|
+
|
|
38
|
+
return <YourLocationSelector divisions={divisions} districts={districts} />;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Vue
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npm install bd-geo-location
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```vue
|
|
49
|
+
<script setup>
|
|
50
|
+
import { useDivisions, useDistricts } from 'bd-geo-location/vue';
|
|
51
|
+
|
|
52
|
+
const { divisions } = useDivisions();
|
|
53
|
+
const divisionId = ref(null);
|
|
54
|
+
const { districts } = useDistricts(divisionId);
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Flutter
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Generate Dart code
|
|
62
|
+
npm run generate:dart
|
|
63
|
+
|
|
64
|
+
# Copy to your Flutter project
|
|
65
|
+
cp -r generated/flutter/lib/models/* your_flutter_project/lib/models/
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```dart
|
|
69
|
+
import 'package:bd_geo_location/models/models.dart';
|
|
70
|
+
|
|
71
|
+
final geoData = BangladeshGeoData.fromJson(jsonData);
|
|
72
|
+
final districts = geoData.getDistrictsByDivision('30');
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### iOS/macOS (Swift)
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Generate Swift code
|
|
79
|
+
npm run generate:swift
|
|
80
|
+
|
|
81
|
+
# Add to Xcode project
|
|
82
|
+
cp -r generated/ios/Sources your_project/
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
```swift
|
|
86
|
+
import BdGeoLocation
|
|
87
|
+
|
|
88
|
+
let geoData = try BangladeshGeoData.load(from: jsonData)
|
|
89
|
+
let districts = geoData.getDistricts(divisionId: "30")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
[📖 Full Installation Guide](./docs/INSTALLATION.md) | [⚡ Quick Start Guide](./docs/QUICK_START.md)
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
5
96
|
## Features
|
|
6
97
|
|
|
7
98
|
- **Complete data for Bangladesh**: 8 Divisions, 68 Districts, 531 Upazilas, 4,916 Unions
|
|
8
99
|
- **JSON-based data format** - Easy to edit and extend without recompiling
|
|
9
100
|
- **JSON Schema validation** - Ensures data integrity
|
|
10
|
-
- TypeScript support with full type definitions
|
|
11
|
-
- Framework-specific integrations
|
|
101
|
+
- **TypeScript support** with full type definitions
|
|
102
|
+
- **Framework-specific integrations**:
|
|
12
103
|
- React Hooks
|
|
13
104
|
- Vue 3 Composables
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
105
|
+
- React Native components
|
|
106
|
+
- Angular compatible
|
|
107
|
+
- **Platform-specific code generators**:
|
|
108
|
+
- Flutter (Dart models)
|
|
109
|
+
- iOS/macOS (Swift models)
|
|
110
|
+
- **Support for both English and Bengali names**
|
|
111
|
+
- **Tree-shakeable and optimized bundle size**
|
|
112
|
+
- **ES Modules and CommonJS support**
|
|
113
|
+
- **Production-ready with security best practices**
|
|
18
114
|
|
|
19
115
|
## Data Coverage
|
|
20
116
|
|
|
@@ -93,7 +189,20 @@ npm run data:validate
|
|
|
93
189
|
npm run data:test
|
|
94
190
|
```
|
|
95
191
|
|
|
96
|
-
##
|
|
192
|
+
## 📚 Documentation
|
|
193
|
+
|
|
194
|
+
| Document | Description |
|
|
195
|
+
|----------|-------------|
|
|
196
|
+
| [Installation Guide](./docs/INSTALLATION.md) | Complete setup instructions for all platforms |
|
|
197
|
+
| [Usage Guide](./docs/USAGE_GUIDE.md) | Comprehensive usage examples and patterns |
|
|
198
|
+
| [Quick Start Guide](./docs/QUICK_START.md) | Get started in 5 minutes |
|
|
199
|
+
| [Production Readiness](./generated/FINAL_PRODUCTION_READINESS.md) | Full verification and security report |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 📦 Installation
|
|
204
|
+
|
|
205
|
+
### npm Package (JavaScript/TypeScript Frameworks)
|
|
97
206
|
|
|
98
207
|
```bash
|
|
99
208
|
npm install bd-geo-location
|
|
@@ -103,6 +212,42 @@ yarn add bd-geo-location
|
|
|
103
212
|
pnpm add bd-geo-location
|
|
104
213
|
```
|
|
105
214
|
|
|
215
|
+
**Framework-specific imports**:
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
// React
|
|
219
|
+
import { useDivisions } from 'bd-geo-location/react';
|
|
220
|
+
|
|
221
|
+
// Vue
|
|
222
|
+
import { useDivisions } from 'bd-geo-location/vue';
|
|
223
|
+
|
|
224
|
+
// Angular/Vanilla TypeScript
|
|
225
|
+
import { getAllDivisions } from 'bd-geo-location';
|
|
226
|
+
|
|
227
|
+
// React Native
|
|
228
|
+
import { LocationSelector } from 'bd-geo-location/react-native';
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Platform Code Generators
|
|
232
|
+
|
|
233
|
+
Generate platform-specific code:
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# Flutter (Dart)
|
|
237
|
+
npm run generate:dart
|
|
238
|
+
|
|
239
|
+
# iOS/macOS (Swift)
|
|
240
|
+
npm run generate:swift
|
|
241
|
+
|
|
242
|
+
# React Native components
|
|
243
|
+
npm run generate:react-native
|
|
244
|
+
|
|
245
|
+
# All platforms
|
|
246
|
+
npm run generate:all
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
[📖 Detailed Installation Guide](./docs/INSTALLATION.md)
|
|
250
|
+
|
|
106
251
|
## Data Hierarchy
|
|
107
252
|
|
|
108
253
|
```
|
|
@@ -117,41 +262,109 @@ Division (বিভাগ)
|
|
|
117
262
|
└── Village (গ্রাম)
|
|
118
263
|
```
|
|
119
264
|
|
|
120
|
-
## Basic Usage
|
|
265
|
+
## 💻 Basic Usage
|
|
121
266
|
|
|
122
|
-
### TypeScript/JavaScript (Vanilla)
|
|
267
|
+
### TypeScript/JavaScript (Vanilla, Angular)
|
|
123
268
|
|
|
124
269
|
```typescript
|
|
125
270
|
import {
|
|
126
271
|
getAllDivisions,
|
|
127
|
-
getDivisionById,
|
|
128
272
|
getDistrictsByDivision,
|
|
129
|
-
getUpazilasByDistrict,
|
|
130
|
-
getUnionsByUpazila,
|
|
131
|
-
getPourosovasByUpazila,
|
|
132
|
-
getCityCorporationsByDistrict,
|
|
133
273
|
searchByName
|
|
134
274
|
} from 'bd-geo-location';
|
|
135
275
|
|
|
136
276
|
// Get all divisions
|
|
137
277
|
const divisions = getAllDivisions();
|
|
138
|
-
console.log(divisions);
|
|
139
278
|
|
|
140
279
|
// Get districts by division ID
|
|
141
280
|
const dhakaDistricts = getDistrictsByDivision('30');
|
|
142
|
-
console.log(dhakaDistricts);
|
|
143
|
-
|
|
144
|
-
// Get upazilas by district ID
|
|
145
|
-
const dhakaUpazilas = getUpazilasByDistrict('26');
|
|
146
|
-
console.log(dhakaUpazilas);
|
|
147
281
|
|
|
148
282
|
// Search locations
|
|
149
283
|
const results = searchByName('Dhaka');
|
|
150
|
-
console.log(results);
|
|
151
284
|
```
|
|
152
285
|
|
|
153
286
|
### React
|
|
154
287
|
|
|
288
|
+
```tsx
|
|
289
|
+
import { useDivisions, useDistricts } from 'bd-geo-location/react';
|
|
290
|
+
|
|
291
|
+
function LocationSelector() {
|
|
292
|
+
const divisions = useDivisions();
|
|
293
|
+
const [divisionId, setDivisionId] = useState(null);
|
|
294
|
+
const districts = useDistricts(divisionId);
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<div>
|
|
298
|
+
<select onChange={(e) => setDivisionId(e.target.value)}>
|
|
299
|
+
{divisions.map(d => (
|
|
300
|
+
<option key={d.id} value={d.id}>{d.name}</option>
|
|
301
|
+
))}
|
|
302
|
+
</select>
|
|
303
|
+
<select>
|
|
304
|
+
{districts.map(d => (
|
|
305
|
+
<option key={d.id} value={d.id}>{d.name}</option>
|
|
306
|
+
))}
|
|
307
|
+
</select>
|
|
308
|
+
</div>
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Vue 3
|
|
314
|
+
|
|
315
|
+
```vue
|
|
316
|
+
<script setup>
|
|
317
|
+
import { useDivisions, useDistricts } from 'bd-geo-location/vue';
|
|
318
|
+
|
|
319
|
+
const { divisions } = useDivisions();
|
|
320
|
+
const divisionId = ref(null);
|
|
321
|
+
const { districts } = useDistricts(divisionId);
|
|
322
|
+
</script>
|
|
323
|
+
|
|
324
|
+
<template>
|
|
325
|
+
<select v-model="divisionId">
|
|
326
|
+
<option v-for="d in divisions" :key="d.id" :value="d.id">
|
|
327
|
+
{{ d.name }}
|
|
328
|
+
</option>
|
|
329
|
+
</select>
|
|
330
|
+
</template>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
### React Native
|
|
334
|
+
|
|
335
|
+
```tsx
|
|
336
|
+
import { LocationSelector } from 'bd-geo-location/react-native';
|
|
337
|
+
|
|
338
|
+
<LocationSelector
|
|
339
|
+
onLocationChange={(location) => console.log(location)}
|
|
340
|
+
showUnion={true}
|
|
341
|
+
/>
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### Flutter
|
|
345
|
+
|
|
346
|
+
```dart
|
|
347
|
+
import 'package:bd_geo_location/models/models.dart';
|
|
348
|
+
|
|
349
|
+
final geoData = BangladeshGeoData.fromJson(jsonData);
|
|
350
|
+
final divisions = geoData.getAllDivisions();
|
|
351
|
+
final dhakaDistricts = geoData.getDistrictsByDivision('30');
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### iOS/macOS (Swift)
|
|
355
|
+
|
|
356
|
+
```swift
|
|
357
|
+
import BdGeoLocation
|
|
358
|
+
|
|
359
|
+
let geoData = try BangladeshGeoData.load(from: jsonData)
|
|
360
|
+
let divisions = geoData.getAllDivisions()
|
|
361
|
+
let dhakaDistricts = geoData.getDistricts(divisionId: "30")
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
[📖 Full Usage Guide](./docs/USAGE_GUIDE.md)
|
|
365
|
+
|
|
366
|
+
### React
|
|
367
|
+
|
|
155
368
|
```tsx
|
|
156
369
|
import {
|
|
157
370
|
useDivisions,
|
|
@@ -348,42 +561,66 @@ function LocationScreen() {
|
|
|
348
561
|
}
|
|
349
562
|
```
|
|
350
563
|
|
|
351
|
-
##
|
|
564
|
+
## 🔧 Platform-Specific Code Generators
|
|
352
565
|
|
|
353
|
-
|
|
566
|
+
This package includes code generators for creating platform-specific models and components:
|
|
354
567
|
|
|
355
|
-
|
|
356
|
-
Returns all divisions in Bangladesh.
|
|
568
|
+
### Flutter (Dart)
|
|
357
569
|
|
|
358
|
-
|
|
359
|
-
|
|
570
|
+
```bash
|
|
571
|
+
npm run generate:dart
|
|
572
|
+
```
|
|
360
573
|
|
|
361
|
-
|
|
362
|
-
|
|
574
|
+
Creates:
|
|
575
|
+
- Dart model classes for all geo data types
|
|
576
|
+
- Helper methods for querying data
|
|
577
|
+
- Files in `generated/flutter/lib/models/`
|
|
363
578
|
|
|
364
|
-
|
|
365
|
-
Get all districts in a division.
|
|
579
|
+
### iOS/macOS (Swift)
|
|
366
580
|
|
|
367
|
-
|
|
368
|
-
|
|
581
|
+
```bash
|
|
582
|
+
npm run generate:swift
|
|
583
|
+
```
|
|
369
584
|
|
|
370
|
-
|
|
371
|
-
|
|
585
|
+
Creates:
|
|
586
|
+
- Swift structs with Codable support
|
|
587
|
+
- Helper methods for querying data
|
|
588
|
+
- Swift Package Manager setup
|
|
589
|
+
- Files in `generated/ios/Sources/BdGeoLocation/`
|
|
372
590
|
|
|
373
|
-
|
|
374
|
-
Get all unions in an upazila.
|
|
591
|
+
### React Native
|
|
375
592
|
|
|
376
|
-
|
|
377
|
-
|
|
593
|
+
```bash
|
|
594
|
+
npm run generate:react-native
|
|
595
|
+
```
|
|
378
596
|
|
|
379
|
-
|
|
380
|
-
|
|
597
|
+
Creates:
|
|
598
|
+
- Ready-to-use React Native components
|
|
599
|
+
- AsyncStorage utilities for caching
|
|
600
|
+
- Location selector component
|
|
601
|
+
- Files in `generated/react-native/`
|
|
381
602
|
|
|
382
|
-
|
|
383
|
-
Search for locations by name. Returns an object with divisions, districts, upazilas, unions, pourosovas, and city corporations.
|
|
603
|
+
### All Platforms
|
|
384
604
|
|
|
385
|
-
|
|
386
|
-
|
|
605
|
+
```bash
|
|
606
|
+
npm run generate:all
|
|
607
|
+
```
|
|
608
|
+
|
|
609
|
+
[📖 Full Usage Guide](./docs/USAGE_GUIDE.md)
|
|
610
|
+
|
|
611
|
+
## 📖 API Reference
|
|
612
|
+
|
|
613
|
+
### Core Functions
|
|
614
|
+
|
|
615
|
+
- `getAllDivisions()` - Returns all divisions
|
|
616
|
+
- `getDivisionById(id: string)` - Get division by ID
|
|
617
|
+
- `getDistrictsByDivision(divisionId: string)` - Get districts by division
|
|
618
|
+
- `getUpazilasByDistrict(districtId: string)` - Get upazilas by district
|
|
619
|
+
- `getUnionsByUpazila(upazilaId: string, districtId: string)` - Get unions by upazila
|
|
620
|
+
- `getPourosovasByUpazila(upazilaId: string, districtId: string)` - Get pourosovas by upazila
|
|
621
|
+
- `getCityCorporationsByDistrict(districtId: string)` - Get city corporations by district
|
|
622
|
+
- `searchByName(searchTerm: string)` - Search locations by name
|
|
623
|
+
- `getGeoHierarchy(locationId: string, level: string)` - Get complete hierarchy
|
|
387
624
|
|
|
388
625
|
### React Hooks
|
|
389
626
|
|
|
@@ -398,14 +635,12 @@ Get the complete geographical hierarchy for a location.
|
|
|
398
635
|
|
|
399
636
|
### Vue Composables
|
|
400
637
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
- `useSearch(searchTerm)` - Search locations by name
|
|
408
|
-
- `useLocationById(id, type)` - Get location by ID and type
|
|
638
|
+
Same as React hooks but return reactive objects:
|
|
639
|
+
|
|
640
|
+
```typescript
|
|
641
|
+
const { divisions } = useDivisions();
|
|
642
|
+
const { districts } = useDistricts(divisionId);
|
|
643
|
+
```
|
|
409
644
|
|
|
410
645
|
## Types
|
|
411
646
|
|
|
@@ -461,25 +696,57 @@ interface Division {
|
|
|
461
696
|
}
|
|
462
697
|
```
|
|
463
698
|
|
|
464
|
-
##
|
|
699
|
+
## 🔒 Security
|
|
465
700
|
|
|
466
|
-
|
|
701
|
+
All platforms include security best practices:
|
|
467
702
|
|
|
468
|
-
|
|
703
|
+
- ✅ Input validation and sanitization
|
|
704
|
+
- ✅ DoS protection (search terms limited to 100 characters)
|
|
705
|
+
- ✅ Type-safe operations
|
|
706
|
+
- ✅ Safe error handling
|
|
707
|
+
- ✅ No unsafe type casting
|
|
469
708
|
|
|
470
|
-
|
|
709
|
+
[📖 Security Analysis Report](./generated/SECURITY_ANALYSIS.md)
|
|
471
710
|
|
|
472
|
-
|
|
711
|
+
---
|
|
712
|
+
|
|
713
|
+
## 📊 Platform Support Matrix
|
|
714
|
+
|
|
715
|
+
| Platform | Status | Documentation |
|
|
716
|
+
|----------|--------|---------------|
|
|
717
|
+
| **React** | ✅ Production Ready | [React Guide](./docs/USAGE_GUIDE.md#react-hooks) |
|
|
718
|
+
| **Vue** | ✅ Production Ready | [Vue Guide](./docs/USAGE_GUIDE.md#vue-composables) |
|
|
719
|
+
| **Angular** | ✅ Production Ready | [Angular Guide](./docs/USAGE_GUIDE.md#angular-services) |
|
|
720
|
+
| **React Native** | ✅ Production Ready | [React Native Guide](./docs/USAGE_GUIDE.md#react-native-components) |
|
|
721
|
+
| **Flutter** | ✅ Production Ready | [Flutter Guide](./docs/USAGE_GUIDE.md#flutter-dart) |
|
|
722
|
+
| **iOS** | ✅ Production Ready | [iOS Guide](./docs/USAGE_GUIDE.md#iosmacos-swift) |
|
|
723
|
+
| **macOS** | ✅ Production Ready | [iOS Guide](./docs/USAGE_GUIDE.md#iosmacos-swift) |
|
|
724
|
+
|
|
725
|
+
---
|
|
726
|
+
|
|
727
|
+
## 🤝 Contributing
|
|
728
|
+
|
|
729
|
+
Contributions are welcome! Please:
|
|
473
730
|
|
|
474
731
|
1. Fork the repository
|
|
475
|
-
2.
|
|
476
|
-
3.
|
|
732
|
+
2. Create a feature branch
|
|
733
|
+
3. Make your changes
|
|
477
734
|
4. Submit a pull request
|
|
478
735
|
|
|
479
|
-
|
|
736
|
+
---
|
|
737
|
+
|
|
738
|
+
## 📄 License
|
|
739
|
+
|
|
740
|
+
MIT © [Mazharul Islam](https://github.com/mazharvai007)
|
|
741
|
+
|
|
742
|
+
---
|
|
743
|
+
|
|
744
|
+
## 📞 Support
|
|
480
745
|
|
|
481
|
-
|
|
746
|
+
- 📖 [Documentation](./docs/)
|
|
747
|
+
- 🐛 [Issues](https://github.com/mazharvai007/bd-geo-location/issues)
|
|
748
|
+
- 💬 [Discussions](https://github.com/mazharvai007/bd-geo-location/discussions)
|
|
482
749
|
|
|
483
|
-
|
|
750
|
+
---
|
|
484
751
|
|
|
485
|
-
|
|
752
|
+
**Made with ❤️ for Bangladesh 🇧🇩**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as f}from"./chunk-A22T5G6E.mjs";import{useMemo as c}from"react";var a=f;function p(){return a.divisions}function v(i){return c(()=>i?a.divisions.find(o=>o.id===i)?.districts||[]:[],[i])}function C(i,n){return c(()=>!i||!n?[]:a.divisions.find(s=>s.id===n)?.districts?.find(s=>s.id===i)?.upazilas||[],[i,n])}function g(i,n,o){return c(()=>!i||!n||!o?[]:a.divisions.find(t=>t.id===o)?.districts?.find(t=>t.id===n)?.upazilas?.find(t=>t.id===i)?.unions||[],[i,n,o])}function z(i,n,o){return c(()=>!i||!n||!o?[]:a.divisions.find(t=>t.id===o)?.districts?.find(t=>t.id===n)?.upazilas?.find(t=>t.id===i)?.pourosovas||[],[i,n,o])}function m(i,n){return c(()=>!i||!n?[]:a.divisions.find(s=>s.id===n)?.districts?.find(s=>s.id===i)?.cityCorporations||[],[i,n])}function y(i){return c(()=>{let n=i.length>100?i.substring(0,100):i;if(!n)return{divisions:[],districts:[],upazilas:[],unions:[],pourosovas:[],cityCorporations:[]};let o=n.toLowerCase(),r={divisions:[],districts:[],upazilas:[],unions:[],pourosovas:[],cityCorporations:[]};for(let s of a.divisions)if((s.name.toLowerCase().includes(o)||s.nameBn.includes(n))&&r.divisions.push(s),s.districts)for(let u of s.districts){if((u.name.toLowerCase().includes(o)||u.nameBn.includes(n))&&r.districts.push(u),u.upazilas)for(let t of u.upazilas){if((t.name.toLowerCase().includes(o)||t.nameBn.includes(n))&&r.upazilas.push(t),t.unions)for(let e of t.unions)(e.name.toLowerCase().includes(o)||e.nameBn.includes(n))&&r.unions.push(e);if(t.pourosovas)for(let e of t.pourosovas)(e.name.toLowerCase().includes(o)||e.nameBn.includes(n))&&r.pourosovas.push(e)}if(u.cityCorporations)for(let t of u.cityCorporations)(t.name.toLowerCase().includes(o)||t.nameBn.includes(n))&&r.cityCorporations.push(t)}return r},[i])}function D(i,n){return c(()=>{if(!i)return null;switch(n){case"division":return a.divisions.find(o=>o.id===i)||null;case"district":for(let o of a.divisions){let r=o.districts?.find(s=>s.id===i);if(r)return r}return null;case"upazila":for(let o of a.divisions)for(let r of o.districts||[]){let s=r.upazilas?.find(u=>u.id===i);if(s)return s}return null;case"union":for(let o of a.divisions)for(let r of o.districts||[])for(let s of r.upazilas||[]){let u=s.unions?.find(t=>t.id===i);if(u)return u}return null;case"pourosova":for(let o of a.divisions)for(let r of o.districts||[])for(let s of r.upazilas||[]){let u=s.pourosovas?.find(t=>t.id===i);if(u)return u}return null;case"cityCorporation":for(let o of a.divisions)for(let r of o.districts||[]){let s=r.cityCorporations?.find(u=>u.id===i);if(s)return s}return null;default:return null}},[i,n])}export{p as a,v as b,C as c,g as d,z as e,m as f,y as g,D as h};
|