const i18n=require("@wordpress/i18n"),{default:md5}=require("md5-es"),locationMap={plugin:"plugins/",theme:"themes/",core:""},hasOwn=(a,t)=>Object.prototype.hasOwnProperty.call(a,t);module.exports={state:{baseUrl:null,locale:null,domainMap:{},domainPaths:{}},async downloadI18n(a,t,e){if(!0!==STEC_VARIABLES?.i18n_loader)return;const n=this.state;if(!n||"string"!=typeof n.baseUrl)throw new Error("wp.jpI18nLoader.state is not set");if("en_US"===n.locale&&!0!==STEC_VARIABLES?.i18n_translate_all)return;if("undefined"==typeof fetch)throw new Error("Fetch API is not available.");const s=hasOwn(n.domainPaths,t)?n.domainPaths[t]:"";let o,l;const r=a.indexOf("?");r>=0?(o=md5.hash(s+a.substring(0,r)),l=a.substring(r)):(o=md5.hash(s+a),l="");const i=hasOwn(n.domainMap,t)?n.domainMap[t]:locationMap[e]+t,d=await fetch(`${n.baseUrl}${i}-${n.locale}-${o}.json${l}`);if(!d.ok)throw new Error(`HTTP request failed: ${d.status} ${d.statusText}`);const c=await d.json(),h=hasOwn(c.locale_data,t)?c.locale_data[t]:c.locale_data.messages;h[""].domain=t,i18n.setLocaleData(h,t)}};