"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@dialpad/i18n"),u=require("./en-US.cjs"),d=require("./zh-CN.cjs"),f=require("./nl-NL.cjs"),g=require("./fr-FR.cjs"),S=require("./de-DE.cjs"),h=require("./it-IT.cjs"),w=require("./ja-JP.cjs"),L=require("./pt-BR.cjs"),N=require("./ru-RU.cjs"),R=require("./es-LA.cjs"),t="dialtone",o={ENGLISH:"en-US",CHINESE:"zh-CN",DUTCH:"nl-NL",FRENCH:"fr-FR",GERMAN:"de-DE",ITALIAN:"it-IT",JAPANESE:"ja-JP",PORTUGUESE:"pt-BR",RUSSIAN:"ru-RU",SPANISH:"es-LA"},i="en-US",s="user-locale";class a{constructor(e=null){if(typeof a.instance=="object")return a.instance;this._locale=e||a.getPreferredLocale();const l=new n.RawBundleSource({resources:n.RawBundleSource.builtResources([["en-US",t,u.default],["zh-CN",t,d.default],["nl-NL",t,f.default],["fr-FR",t,g.default],["de-DE",t,S.default],["it-IT",t,h.default],["ja-JP",t,w.default],["pt-BR",t,L.default],["ru-RU",t,N.default],["es-LA",t,R.default]])}),r=new n.LocaleManager({bundleSource:l,allowedLocales:Object.values(o),fallbackLocale:i,preferredLocale:this._locale,namespaces:[t]});return a.instance=this,this.i18n=r.useI18N(t),typeof window<"u"&&(window.onstorage=c=>{c.key===s&&(this.currentLocale=c.newValue)}),this}static getPreferredLocale(){if(typeof window>"u"||!window.localStorage)return i;const e=window.localStorage.getItem(s),l=Object.values(o).find(r=>r.startsWith(navigator.language.slice(0,2)));return e||l||i}static getAllowedLocales(){return o}$t(...e){return this.i18n.$t(...e)}$ta(...e){return this.i18n.$ta(...e)}get currentLocale(){return this._locale}set currentLocale(e){if(e!==this._locale){if(!Object.values(o).includes(e))throw new Error(`Locale ${e} is not allowed, please use one of the following: ${Object.values(o).join(", ")}`);this._locale=e,this.i18n.setI18N({preferredLocale:e},t)}}}exports.DialtoneLocalization=a;
//# sourceMappingURL=index.cjs.map
