"use strict";const addQueryArgs=require("./add-query-args-49dcb630.js");var _a;const lang=(null===(_a=window.scData)||void 0===_a?void 0:_a.locale)||navigator.language||(null===navigator||void 0===navigator?void 0:navigator.browserLanguage)||(navigator.languages||["en"])[0];let cachedCountryChoices=null;const countryDetailsCache=new Map,countryChoices=async()=>{var a,e,t,o;if(cachedCountryChoices)return cachedCountryChoices;const n=addQueryArgs.addQueryArgs("https://api.surecart.com/v1/public/atlas",{locale:lang}),r=await fetch(n),s=await r.json(),i=null===(a=(null==s?void 0:s.data)||[])||void 0===a?void 0:a.map((({code:a,name:e})=>({value:a,label:e})));return cachedCountryChoices=(null===(o=null===(t=null===(e=null===window||void 0===window?void 0:window.wp)||void 0===e?void 0:e.hooks)||void 0===t?void 0:t.applyFilters)||void 0===o?void 0:o.call(t,"surecart_address_countries",i))||i,cachedCountryChoices},getCountryDetails=async a=>{if(countryDetailsCache.has(a))return countryDetailsCache.get(a);const e=addQueryArgs.addQueryArgs(`https://api.surecart.com/v1/public/atlas/${a}`,{locale:lang}),t=await fetch(e),o=await t.json();return countryDetailsCache.set(a,o),o},getCountryRegions=async a=>{if(!a)return[];const e=await getCountryDetails(a);return((null==e?void 0:e.states)||[]).map((a=>({value:a.code,label:a.name})))};exports.countryChoices=countryChoices,exports.getCountryDetails=getCountryDetails,exports.getCountryRegions=getCountryRegions;