import*as t from"path";import{chunk as e}from"lodash-es";const o="./fixtures/countries_states_cities.json.js";function r(e){return t.resolve(__dirname,e)}const a=t=>Array.isArray(t),n=async t=>{let n=0;try{const s=(await import(r(o))).default.countries;if(!a(s))throw new TypeError("Expected an array of countries");for(const o of s){if(!a(o.states))throw new TypeError("Expected an array of states");for(const r of o.states){if(!a(r.cities))throw new TypeError("Expected an array of cities");const o=r.cities.map((t=>{const e={_id:t.id,name:t.name,state:r.id,createdAt:new Date,updatedAt:new Date};return null!=t.latitude&&null!=t.longitude&&(e.location={type:"Point",coordinates:[parseFloat(t.longitude),parseFloat(t.latitude)]}),e}));await Promise.all(e(o,1e3).map((async e=>{await(t?.(e)),n+=e.length})))}}return n}catch(t){throw console.error("Failed to load or process cities:",t),t}},s=async t=>{let e=0;try{const n=(await import(r(o))).default.countries;if(!a(n))throw new TypeError("Expected an array of countries");for(const o of n){if(!a(o.states))throw new TypeError("Expected an array of states");const r=o.states.map((t=>{const e={_id:t.id,name:t.name,country:o.id,createdAt:new Date,updatedAt:new Date};return null!=t.latitude&&null!=t.longitude&&(e.location={type:"Point",coordinates:[parseFloat(t.longitude),parseFloat(t.latitude)]}),e}));await(t?.(r)),e+=r.length}return e}catch(t){throw console.error("Failed to load or process states:",t),t}},i=async t=>{let e=0;try{const n=(await import(r(o))).default.countries;if(!a(n))throw new TypeError("Expected an array of countries");const s=n.map((t=>({_id:t.id,name:t.name,phone_code:t.phone_code,currency:t.currency,currency_symbol:t.currency_symbol,emoji:t.emoji,location:{type:"Point",coordinates:[parseFloat(t.longitude),parseFloat(t.latitude)]},createdAt:new Date,updatedAt:new Date})));return await(t?.(s)),e=s.length,e}catch(t){throw console.error("Failed to load or process countries:",t),t}};export{r as getPathFromAmdModule,n as loadAllCities,i as loadAllCountries,s as loadAllStates};