generaltranslation 4.1.2 → 4.1.3

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.
@@ -1,2 +1,2 @@
1
- var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var r="en-US";function o(t,r){return e(this,void 0,void 0,(function(){var e,o,i,a,c,u,l;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,o=e.signal,i=Math.min.apply(Math,r.map((function(t){var e,n;return(null===(n=null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.metadata)||void 0===n?void 0:n.timeout)||60}))),i&&setTimeout((function(){return e.abort()}),i),[4,fetch("".concat(t.baseURL).concat("/v1/translate/batch"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify(r),signal:o})];case 1:return(a=n.sent()).ok?[3,3]:(c=Error.bind,l=(u="".concat(a.status,": ")).concat,[4,a.text()]);case 2:throw new(c.apply(Error,[void 0,l.apply(u,[n.sent()])]));case 3:return[4,a.json()];case 4:return[2,n.sent()]}}))}))}function i(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{var n=t.flat().map((function(t){return new Intl.Locale(t).language}));return n.every((function(t){return t===n[0]}))}catch(t){return console.error(t),!1}}var a=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],c=function(t){try{var e=new Intl.Locale(t),n=e.language,o=e.region,i=e.script;if(t.split("-").length!==(c=1,o&&(c+=1),i&&(c+=1),c))return!1;if(new Intl.DisplayNames([r],{type:"language"}).of(n)===n)return!1;if(o)if(new Intl.DisplayNames([r],{type:"region"}).of(o)===o)return!1;if(i)if(new Intl.DisplayNames([r],{type:"script"}).of(i)===i&&!a.includes(i))return!1;return!0}catch(t){return!1}var c},u=function(t){return Intl.getCanonicalLocales(t)[0]};function l(){for(var t,e,n,r,o,i,a,c,l,s,f=[],p=0;p<arguments.length;p++)f[p]=arguments[p];try{for(var v=f.flat().map(u),d=0;d<v.length;d++)for(var y=d+1;y<v.length;y++)if(t=v[d],e=v[y],n=void 0,r=void 0,o=void 0,i=void 0,a=void 0,c=void 0,l=void 0,s=void 0,n=new Intl.Locale(t),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(e),c=a.language,l=a.region,s=a.script,r!==c||o&&l&&o!==l||i&&s&&i!==s)return!1;return!0}catch(t){return console.error(t),!1}}function s(t,r,o,i){return e(this,void 0,void 0,(function(){var e,a,c,u,l,s,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,a=e.signal,(c=(null==i?void 0:i.timeout)||60)&&setTimeout((function(){return e.abort()}),c),[4,fetch("".concat(t.baseURL).concat("/v1/translate/content"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({content:r,targetLocale:o,metadata:i}),signal:a})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,f=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,f.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function f(t,r,o,i){return e(this,void 0,void 0,(function(){var e,a,c,u,l,s,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,a=e.signal,(c=(null==i?void 0:i.timeout)||60)&&setTimeout((function(){return e.abort()}),c),[4,fetch("".concat(t.baseURL).concat("/v1/translate/react"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({children:r,targetLocale:o,metadata:i}),signal:a})];case 1:return(u=n.sent()).ok?[3,3]:(l=Error.bind,f=(s="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(l.apply(Error,[void 0,f.apply(s,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function p(t,r,o,i){return e(this,void 0,void 0,(function(){var e,a,c,u;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat("/v1/project/translations/update"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({updates:r,locales:o,options:i})})];case 1:return(e=n.sent()).ok?[3,3]:(a=Error.bind,u=(c="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(a.apply(Error,[void 0,u.apply(c,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function v(t,r){return e(this,void 0,void 0,(function(){var e,o,i,a;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat("/v1/project/locales","?projectId=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey}})];case 1:return(e=n.sent()).ok?[3,3]:(o=Error.bind,a=(i="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(o.apply(Error,[void 0,a.apply(i,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function d(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.options,c=void 0===a?{}:a;return new Intl.NumberFormat(i,t({numberingSystem:"latn"},c)).format(n)}function y(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.options,c=void 0===a?{}:a;return new Intl.DateTimeFormat(i,t({calendar:"gregory",numberingSystem:"latn"},c)).format(n)}function m(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.currency,c=void 0===a?"USD":a,u=e.options,l=void 0===u?{}:u;return new Intl.NumberFormat(i,t({style:"currency",currency:c,numberingSystem:"latn"},l)).format(n)}function h(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.options,c=void 0===a?{}:a;return new Intl.ListFormat(i,t({type:"conjunction",style:"long"},c)).format(n)}var g={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function b(e){if("string"!=typeof e)throw new Error("splitStringToContent: ".concat(e," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,i=0;null!==(n=o.exec(e));){var a=n[0],c=n[1],u=n.index;if("^"!==e[u-1]){u>i&&r.push(e.slice(i,u));var l=c.split(",").map((function(t){return t.trim()})),s=l[0],f=l[1]?g[l[1]]:void 0,p=t({key:s},f&&{variable:f});r.push(p),i=u+a.length}else u-1>i&&r.push(e.slice(i,u-1)),r.push(a),i=u+a.length}return i<e.length&&r.push(e.slice(i)),r}function N(t,e){if(void 0===e&&(e={}),!c(t))return S;if(e[t=u(t)])return e[t];var n=new Intl.Locale(t),r=n.region;if(r&&I[r])return I[r];var o=n.maximize(),i=o.region||"";return C[o.language]||I[i]||S}var w="🌍",S=w,C={ca:w,eu:w,ku:w,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},I={AF:"🇦🇫",AX:"🇦🇽",AL:"🇦🇱",DZ:"🇩🇿",AS:"🇦🇸",AD:"🇦🇩",AO:"🇦🇴",AI:"🇦🇮",AQ:"🇦🇶",AG:"🇦🇬",AR:"🇦🇷",AM:"🇦🇲",AW:"🇦🇼",AU:"🇦🇺",AT:"🇦🇹",AZ:"🇦🇿",BS:"🇧🇸",BH:"🇧🇭",BD:"🇧🇩",BB:"🇧🇧",BY:"🇧🇾",BE:"🇧🇪",BZ:"🇧🇿",BJ:"🇧🇯",BM:"🇧🇲",BT:"🇧🇹",BO:"🇧🇴",BQ:"🇧🇶",BA:"🇧🇦",BW:"🇧🇼",BV:"🇧🇻",BR:"🇧🇷",IO:"🇮🇴",BN:"🇧🇳",BG:"🇧🇬",BF:"🇧🇫",BI:"🇧🇮",CV:"🇨🇻",KH:"🇰🇭",CM:"🇨🇲",CA:"🇨🇦",KY:"🇰🇾",CF:"🇨🇫",TD:"🇹🇩",CL:"🇨🇱",CN:"🇨🇳",CX:"🇨🇽",CC:"🇨🇨",CO:"🇨🇴",KM:"🇰🇲",CD:"🇨🇩",CG:"🇨🇬",CK:"🇨🇰",CR:"🇨🇷",CI:"🇨🇮",HR:"🇭🇷",CU:"🇨🇺",CW:"🇨🇼",CY:"🇨🇾",CZ:"🇨🇿",DK:"🇩🇰",DJ:"🇩🇯",DM:"🇩🇲",DO:"🇩🇴",EC:"🇪🇨",EG:"🇪🇬",SV:"🇸🇻",GQ:"🇬🇶",ER:"🇪🇷",EE:"🇪🇪",SZ:"🇸🇿",ET:"🇪🇹",FK:"🇫🇰",FO:"🇫🇴",FJ:"🇫🇯",FI:"🇫🇮",FR:"🇫🇷",GF:"🇬🇫",PF:"🇵🇫",TF:"🇹🇫",GA:"🇬🇦",GM:"🇬🇲",GE:"🇬🇪",DE:"🇩🇪",GH:"🇬🇭",GI:"🇬🇮",GR:"🇬🇷",GL:"🇬🇱",GD:"🇬🇩",GP:"🇬🇵",GU:"🇬🇺",GT:"🇬🇹",GG:"🇬🇬",GN:"🇬🇳",GW:"🇬🇼",GY:"🇬🇾",HT:"🇭🇹",HM:"🇭🇲",VA:"🇻🇦",HN:"🇭🇳",HK:"🇭🇰",HU:"🇭🇺",IS:"🇮🇸",IN:"🇮🇳",ID:"🇮🇩",IR:"🇮🇷",IQ:"🇮🇶",IE:"🇮🇪",IM:"🇮🇲",IL:"🇮🇱",IT:"🇮🇹",JM:"🇯🇲",JP:"🇯🇵",JE:"🇯🇪",JO:"🇯🇴",KZ:"🇰🇿",KE:"🇰🇪",KI:"🇰🇮",KP:"🇰🇵",KR:"🇰🇷",KW:"🇰🇼",KG:"🇰🇬",LA:"🇱🇦",LV:"🇱🇻",LB:"🇱🇧",LS:"🇱🇸",LR:"🇱🇷",LY:"🇱🇾",LI:"🇱🇮",LT:"🇱🇹",LU:"🇱🇺",MO:"🇲🇴",MG:"🇲🇬",MW:"🇲🇼",MY:"🇲🇾",MV:"🇲🇻",ML:"🇲🇱",MT:"🇲🇹",MH:"🇲🇭",MQ:"🇲🇶",MR:"🇲🇷",MU:"🇲🇺",YT:"🇾🇹",MX:"🇲🇽",FM:"🇫🇲",MD:"🇲🇩",MC:"🇲🇨",MN:"🇲🇳",ME:"🇲🇪",MS:"🇲🇸",MA:"🇲🇦",MZ:"🇲🇿",MM:"🇲🇲",NA:"🇳🇦",NR:"🇳🇷",NP:"🇳🇵",NL:"🇳🇱",NC:"🇳🇨",NZ:"🇳🇿",NI:"🇳🇮",NE:"🇳🇪",NG:"🇳🇬",NU:"🇳🇺",NF:"🇳🇫",MK:"🇲🇰",MP:"🇲🇵",NO:"🇳🇴",OM:"🇴🇲",PK:"🇵🇰",PW:"🇵🇼",PS:"🇵🇸",PA:"🇵🇦",PG:"🇵🇬",PY:"🇵🇾",PE:"🇵🇪",PH:"🇵🇭",PN:"🇵🇳",PL:"🇵🇱",PT:"🇵🇹",PR:"🇵🇷",QA:"🇶🇦",RE:"🇷🇪",RO:"🇷🇴",RU:"🇷🇺",RW:"🇷🇼",BL:"🇧🇱",SH:"🇸🇭",KN:"🇰🇳",LC:"🇱🇨",MF:"🇲🇫",PM:"🇵🇲",VC:"🇻🇨",WS:"🇼🇸",SM:"🇸🇲",ST:"🇸🇹",SA:"🇸🇦",SN:"🇸🇳",RS:"🇷🇸",SC:"🇸🇨",SL:"🇸🇱",SG:"🇸🇬",SX:"🇸🇽",SK:"🇸🇰",SI:"🇸🇮",SB:"🇸🇧",SO:"🇸🇴",ZA:"🇿🇦",GS:"🇬🇸",SS:"🇸🇸",ES:"🇪🇸",LK:"🇱🇰",SD:"🇸🇩",SR:"🇸🇷",SJ:"🇸🇯",SE:"🇸🇪",CH:"🇨🇭",SY:"🇸🇾",TW:"🇹🇼",TJ:"🇹🇯",TZ:"🇹🇿",TH:"🇹🇭",TL:"🇹🇱",TG:"🇹🇬",TK:"🇹🇰",TO:"🇹🇴",TT:"🇹🇹",TN:"🇹🇳",TR:"🇹🇷",TM:"🇹🇲",TC:"🇹🇨",TV:"🇹🇻",UG:"🇺🇬",UA:"🇺🇦",AE:"🇦🇪",GB:"🇬🇧",US:"🇺🇸",UM:"🇺🇲",UY:"🇺🇾",UZ:"🇺🇿",VU:"🇻🇺",VE:"🇻🇪",VN:"🇻🇳",VG:"🇻🇬",VI:"🇻🇮",WF:"🇼🇫",EH:"🇪🇭",YE:"🇾🇪",ZM:"🇿🇲",ZW:"🇿🇼",EU:"🇪🇺"};var T=function(t){return"undefined"!=typeof process&&process.env&&process.env[t]||""},L=function(){function i(t){var e=void 0===t?{}:t,n=e.apiKey,o=void 0===n?"":n,i=e.defaultLocale,a=void 0===i?r:i,c=e.projectId,l=void 0===c?"":c,s=e.baseURL,f=void 0===s?"https://prod.gtx.dev":s;this.apiKey=o||T("GT_API_KEY"),this.projectId=l||T("GT_PROJECT_ID"),this.defaultLocale=u(a)||r,this.baseURL=f}return i.prototype.translate=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,s(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},i.prototype.translateReact=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,f(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},i.prototype.translateBatch=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,o(this,t)]}))}))},i.prototype.updateProjectTranslations=function(t){return e(this,arguments,void 0,(function(t,e,r){return void 0===e&&(e=[]),void 0===r&&(r={}),n(this,(function(n){switch(n.label){case 0:return[4,p(this,t,e,r)];case 1:return[2,n.sent()]}}))}))},i.prototype.getProjectLocales=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,v(this,t||this.projectId)]}))}))},i}();function M(t){return function(t){var e;try{var n=new Intl.Locale(t);return"rtl"===(null===(e=null==n?void 0:n.textInfo)||void 0===e?void 0:e.direction)?"rtl":"ltr"}catch(t){return"ltr"}}(t)}function E(t,e){return void 0===e&&(e=r),function(t,e){void 0===e&&(e=r);try{return new Intl.DisplayNames([e,r],{type:"language"}).of(t)||""}catch(t){return""}}(t,e)}function G(t,e){return function(t,e){void 0===e&&(e=r);try{t=u(t);var n=new Intl.Locale(t),o=n.language,i=n.region,a=new Intl.Locale(t).maximize(),c=a.toString(),l=a.region||"",s=a.script||"",f=new Intl.Locale(t).minimize().toString(),p=new Intl.DisplayNames([e,t,r],{type:"language"}),v=new Intl.DisplayNames([t,e,r],{type:"language"}),d=p.of(t)||t,y=v.of(t)||t,m=p.of(c)||t,h=v.of(c)||t,g=p.of(f)||t,b=v.of(f)||t,w=p.of(o)||t,S=v.of(o)||t,C=i?"".concat(w," (").concat(i,")"):w,I=i?"".concat(S," (").concat(i,")"):S,T=new Intl.DisplayNames([e,t,r],{type:"region"}),L=new Intl.DisplayNames([t,e,r],{type:"region"}),M=T.of(l)||"",E=L.of(l)||"",G=new Intl.DisplayNames([e,t,r],{type:"script"}),R=new Intl.DisplayNames([t,e,r],{type:"script"});return{code:t,name:d,nativeName:y,maximizedCode:c,maximizedName:m,nativeMaximizedName:h,minimizedCode:f,minimizedName:g,nativeMinimizedName:b,languageCode:o,languageName:w,nativeLanguageName:S,nameWithRegionCode:C,nativeNameWithRegionCode:I,regionCode:l,regionName:M,nativeRegionName:E,scriptCode:s,scriptName:G.of(s)||"",nativeScriptName:R.of(s)||"",emoji:N(t)}}catch(e){var A=t||"",K=null==A?void 0:A.split("-");return{code:A,name:A,nativeName:A,maximizedCode:A,maximizedName:A,nativeMaximizedName:A,minimizedCode:A,minimizedName:A,nativeMinimizedName:A,languageCode:o=(null==K?void 0:K[0])||A||"",languageName:o,nativeLanguageName:o,regionCode:l=K.length>2?null==K?void 0:K[2]:(null==K?void 0:K[1])||"",regionName:l,nativeRegionName:l,scriptCode:s=(null==K?void 0:K[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:C=o?l?"".concat(o," (").concat(l,")"):o:"",nativeNameWithRegionCode:A,emoji:N(A)}}}(t,e)}function R(t,e){return N(t,e)}function A(t){return c(t)}function K(t){return u(t)}function P(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return l.apply(void 0,t)}function j(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return i.apply(void 0,t)}function x(t){return d(t)}function D(t){return y(t)}function O(t){return m(t)}function k(t){return h(t)}function B(e){return o=(n=e).value,i=n.unit,a=n.locales,c=void 0===a?[r]:a,u=n.options,l=void 0===u?{}:u,new Intl.RelativeTimeFormat(c,t({style:"long",numeric:"auto"},l)).format(o,i);var n,o,i,a,c,u,l}function U(t){return b(t)}function F(e,n,o,i){return function(e,n,o,i){if(void 0===n&&(n=r),void 0===o&&(o={}),void 0===i&&(i={}),"string"==typeof e&&(e=b(e)),"string"==typeof e)return e;if(!Array.isArray(e))throw new Error("renderContentToString: content ".concat(e," is invalid"));return e.map((function(e){var r;if("string"==typeof e)return e;if("object"==typeof e){var a=o[e.key];return e.variable?"number"===e.variable?d({value:a,locales:n,options:i[e.key]}):"currency"===e.variable?m(t(t({value:a,locales:n},i[e.key]&&{options:i[e.key]}),(null===(r=i[e.key])||void 0===r?void 0:r.currency)&&{currency:i[e.key].currency})):"datetime"===e.variable?y(t({value:a,locales:n},i[e.key]&&{options:i[e.key]})):"list"===e.variable?h(t({value:a,locales:n},i[e.key]&&{options:i[e.key]})):a:a}})).join("")}(e,n,o,i)}function W(t,e){return function(t,e){if("string"==typeof t&&(t=[t]),!e)return t[0];for(var n=function(t){for(var n=u(t),r=[],o=0,a=e;o<a.length;o++){var c=a[o],s=u(c);if(n===s)return{value:s};i(n,s)&&r.push(s)}if(r.length)return{value:r.find((function(t){return l(n,t)}))||r[0]}},r=0,o=t;r<o.length;r++){var a=n(o[r]);if("object"==typeof a)return a.value}}(t,e)}function z(t,e,n){return function(t,e,n){return!(!c(t)||!c(e)||n&&n.some((function(t){return!c(t)}))||l(t,e)||n&&!n.some((function(t){return i(e,t)})))}(t,e,n)}export{L as default,W as determineLocale,O as formatCurrency,D as formatDateTime,k as formatList,x as formatNum,B as formatRelativeTime,M as getLocaleDirection,R as getLocaleEmoji,E as getLocaleName,G as getLocaleProperties,P as isSameDialect,j as isSameLanguage,A as isValidLocale,F as renderContentToString,z as requiresTranslation,U as splitStringToContent,K as standardizeLocale};
1
+ var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{u(r.next(t))}catch(t){i(t)}}function c(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}u((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,r=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}"function"==typeof SuppressedError&&SuppressedError;var r="en-US",o=6e4;function i(t,r){return e(this,void 0,void 0,(function(){var e,i,a,c,u,l,s;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,i=e.signal,a=Math.min.apply(Math,r.map((function(t){var e,n;return(null===(n=null===(e=null==t?void 0:t.data)||void 0===e?void 0:e.metadata)||void 0===n?void 0:n.timeout)||o}))),a&&setTimeout((function(){return e.abort()}),a),[4,fetch("".concat(t.baseURL).concat("/v1/translate/batch"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify(r),signal:i})];case 1:return(c=n.sent()).ok?[3,3]:(u=Error.bind,s=(l="".concat(c.status,": ")).concat,[4,c.text()]);case 2:throw new(u.apply(Error,[void 0,s.apply(l,[n.sent()])]));case 3:return[4,c.json()];case 4:return[2,n.sent()]}}))}))}function a(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{var n=t.flat().map((function(t){return new Intl.Locale(t).language}));return n.every((function(t){return t===n[0]}))}catch(t){return console.error(t),!1}}var c=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],u=function(t){try{var e=new Intl.Locale(t),n=e.language,o=e.region,i=e.script;if(t.split("-").length!==(a=1,o&&(a+=1),i&&(a+=1),a))return!1;if(new Intl.DisplayNames([r],{type:"language"}).of(n)===n)return!1;if(o)if(new Intl.DisplayNames([r],{type:"region"}).of(o)===o)return!1;if(i)if(new Intl.DisplayNames([r],{type:"script"}).of(i)===i&&!c.includes(i))return!1;return!0}catch(t){return!1}var a},l=function(t){return Intl.getCanonicalLocales(t)[0]};function s(){for(var t,e,n,r,o,i,a,c,u,s,f=[],p=0;p<arguments.length;p++)f[p]=arguments[p];try{for(var v=f.flat().map(l),d=0;d<v.length;d++)for(var y=d+1;y<v.length;y++)if(t=v[d],e=v[y],n=void 0,r=void 0,o=void 0,i=void 0,a=void 0,c=void 0,u=void 0,s=void 0,n=new Intl.Locale(t),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(e),c=a.language,u=a.region,s=a.script,r!==c||o&&u&&o!==u||i&&s&&i!==s)return!1;return!0}catch(t){return console.error(t),!1}}function f(t,r,i,a){return e(this,void 0,void 0,(function(){var e,c,u,l,s,f,p;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,c=e.signal,(u=(null==a?void 0:a.timeout)||o)&&setTimeout((function(){return e.abort()}),u),[4,fetch("".concat(t.baseURL).concat("/v1/translate/content"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({content:r,targetLocale:i,metadata:a}),signal:c})];case 1:return(l=n.sent()).ok?[3,3]:(s=Error.bind,p=(f="".concat(l.status,": ")).concat,[4,l.text()]);case 2:throw new(s.apply(Error,[void 0,p.apply(f,[n.sent()])]));case 3:return[4,l.json()];case 4:return[2,n.sent()]}}))}))}function p(t,r,i,a){return e(this,void 0,void 0,(function(){var e,c,u,l,s,f,p;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,c=e.signal,(u=(null==a?void 0:a.timeout)||o)&&setTimeout((function(){return e.abort()}),u),[4,fetch("".concat(t.baseURL).concat("/v1/translate/react"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({children:r,targetLocale:i,metadata:a}),signal:c})];case 1:return(l=n.sent()).ok?[3,3]:(s=Error.bind,p=(f="".concat(l.status,": ")).concat,[4,l.text()]);case 2:throw new(s.apply(Error,[void 0,p.apply(f,[n.sent()])]));case 3:return[4,l.json()];case 4:return[2,n.sent()]}}))}))}function v(t,r,o,i){return e(this,void 0,void 0,(function(){var e,a,c,u;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat("/v1/project/translations/update"),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({updates:r,locales:o,options:i})})];case 1:return(e=n.sent()).ok?[3,3]:(a=Error.bind,u=(c="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(a.apply(Error,[void 0,u.apply(c,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function d(t,r){return e(this,void 0,void 0,(function(){var e,o,i,a;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat("/v1/project/locales","?projectId=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey}})];case 1:return(e=n.sent()).ok?[3,3]:(o=Error.bind,a=(i="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(o.apply(Error,[void 0,a.apply(i,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,n.sent()]}}))}))}function y(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.options,c=void 0===a?{}:a;return new Intl.NumberFormat(i,t({numberingSystem:"latn"},c)).format(n)}function m(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.options,c=void 0===a?{}:a;return new Intl.DateTimeFormat(i,t({calendar:"gregory",numberingSystem:"latn"},c)).format(n)}function h(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.currency,c=void 0===a?"USD":a,u=e.options,l=void 0===u?{}:u;return new Intl.NumberFormat(i,t({style:"currency",currency:c,numberingSystem:"latn"},l)).format(n)}function g(e){var n=e.value,o=e.locales,i=void 0===o?[r]:o,a=e.options,c=void 0===a?{}:a;return new Intl.ListFormat(i,t({type:"conjunction",style:"long"},c)).format(n)}var b={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function N(e){if("string"!=typeof e)throw new Error("splitStringToContent: ".concat(e," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,i=0;null!==(n=o.exec(e));){var a=n[0],c=n[1],u=n.index;if("^"!==e[u-1]){u>i&&r.push(e.slice(i,u));var l=c.split(",").map((function(t){return t.trim()})),s=l[0],f=l[1]?b[l[1]]:void 0,p=t({key:s},f&&{variable:f});r.push(p),i=u+a.length}else u-1>i&&r.push(e.slice(i,u-1)),r.push(a),i=u+a.length}return i<e.length&&r.push(e.slice(i)),r}function w(t,e){if(void 0===e&&(e={}),!u(t))return C;if(e[t=l(t)])return e[t];var n=new Intl.Locale(t),r=n.region;if(r&&T[r])return T[r];var o=n.maximize(),i=o.region||"";return I[o.language]||T[i]||C}var S="🌍",C=S,I={ca:S,eu:S,ku:S,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},T={AF:"🇦🇫",AX:"🇦🇽",AL:"🇦🇱",DZ:"🇩🇿",AS:"🇦🇸",AD:"🇦🇩",AO:"🇦🇴",AI:"🇦🇮",AQ:"🇦🇶",AG:"🇦🇬",AR:"🇦🇷",AM:"🇦🇲",AW:"🇦🇼",AU:"🇦🇺",AT:"🇦🇹",AZ:"🇦🇿",BS:"🇧🇸",BH:"🇧🇭",BD:"🇧🇩",BB:"🇧🇧",BY:"🇧🇾",BE:"🇧🇪",BZ:"🇧🇿",BJ:"🇧🇯",BM:"🇧🇲",BT:"🇧🇹",BO:"🇧🇴",BQ:"🇧🇶",BA:"🇧🇦",BW:"🇧🇼",BV:"🇧🇻",BR:"🇧🇷",IO:"🇮🇴",BN:"🇧🇳",BG:"🇧🇬",BF:"🇧🇫",BI:"🇧🇮",CV:"🇨🇻",KH:"🇰🇭",CM:"🇨🇲",CA:"🇨🇦",KY:"🇰🇾",CF:"🇨🇫",TD:"🇹🇩",CL:"🇨🇱",CN:"🇨🇳",CX:"🇨🇽",CC:"🇨🇨",CO:"🇨🇴",KM:"🇰🇲",CD:"🇨🇩",CG:"🇨🇬",CK:"🇨🇰",CR:"🇨🇷",CI:"🇨🇮",HR:"🇭🇷",CU:"🇨🇺",CW:"🇨🇼",CY:"🇨🇾",CZ:"🇨🇿",DK:"🇩🇰",DJ:"🇩🇯",DM:"🇩🇲",DO:"🇩🇴",EC:"🇪🇨",EG:"🇪🇬",SV:"🇸🇻",GQ:"🇬🇶",ER:"🇪🇷",EE:"🇪🇪",SZ:"🇸🇿",ET:"🇪🇹",FK:"🇫🇰",FO:"🇫🇴",FJ:"🇫🇯",FI:"🇫🇮",FR:"🇫🇷",GF:"🇬🇫",PF:"🇵🇫",TF:"🇹🇫",GA:"🇬🇦",GM:"🇬🇲",GE:"🇬🇪",DE:"🇩🇪",GH:"🇬🇭",GI:"🇬🇮",GR:"🇬🇷",GL:"🇬🇱",GD:"🇬🇩",GP:"🇬🇵",GU:"🇬🇺",GT:"🇬🇹",GG:"🇬🇬",GN:"🇬🇳",GW:"🇬🇼",GY:"🇬🇾",HT:"🇭🇹",HM:"🇭🇲",VA:"🇻🇦",HN:"🇭🇳",HK:"🇭🇰",HU:"🇭🇺",IS:"🇮🇸",IN:"🇮🇳",ID:"🇮🇩",IR:"🇮🇷",IQ:"🇮🇶",IE:"🇮🇪",IM:"🇮🇲",IL:"🇮🇱",IT:"🇮🇹",JM:"🇯🇲",JP:"🇯🇵",JE:"🇯🇪",JO:"🇯🇴",KZ:"🇰🇿",KE:"🇰🇪",KI:"🇰🇮",KP:"🇰🇵",KR:"🇰🇷",KW:"🇰🇼",KG:"🇰🇬",LA:"🇱🇦",LV:"🇱🇻",LB:"🇱🇧",LS:"🇱🇸",LR:"🇱🇷",LY:"🇱🇾",LI:"🇱🇮",LT:"🇱🇹",LU:"🇱🇺",MO:"🇲🇴",MG:"🇲🇬",MW:"🇲🇼",MY:"🇲🇾",MV:"🇲🇻",ML:"🇲🇱",MT:"🇲🇹",MH:"🇲🇭",MQ:"🇲🇶",MR:"🇲🇷",MU:"🇲🇺",YT:"🇾🇹",MX:"🇲🇽",FM:"🇫🇲",MD:"🇲🇩",MC:"🇲🇨",MN:"🇲🇳",ME:"🇲🇪",MS:"🇲🇸",MA:"🇲🇦",MZ:"🇲🇿",MM:"🇲🇲",NA:"🇳🇦",NR:"🇳🇷",NP:"🇳🇵",NL:"🇳🇱",NC:"🇳🇨",NZ:"🇳🇿",NI:"🇳🇮",NE:"🇳🇪",NG:"🇳🇬",NU:"🇳🇺",NF:"🇳🇫",MK:"🇲🇰",MP:"🇲🇵",NO:"🇳🇴",OM:"🇴🇲",PK:"🇵🇰",PW:"🇵🇼",PS:"🇵🇸",PA:"🇵🇦",PG:"🇵🇬",PY:"🇵🇾",PE:"🇵🇪",PH:"🇵🇭",PN:"🇵🇳",PL:"🇵🇱",PT:"🇵🇹",PR:"🇵🇷",QA:"🇶🇦",RE:"🇷🇪",RO:"🇷🇴",RU:"🇷🇺",RW:"🇷🇼",BL:"🇧🇱",SH:"🇸🇭",KN:"🇰🇳",LC:"🇱🇨",MF:"🇲🇫",PM:"🇵🇲",VC:"🇻🇨",WS:"🇼🇸",SM:"🇸🇲",ST:"🇸🇹",SA:"🇸🇦",SN:"🇸🇳",RS:"🇷🇸",SC:"🇸🇨",SL:"🇸🇱",SG:"🇸🇬",SX:"🇸🇽",SK:"🇸🇰",SI:"🇸🇮",SB:"🇸🇧",SO:"🇸🇴",ZA:"🇿🇦",GS:"🇬🇸",SS:"🇸🇸",ES:"🇪🇸",LK:"🇱🇰",SD:"🇸🇩",SR:"🇸🇷",SJ:"🇸🇯",SE:"🇸🇪",CH:"🇨🇭",SY:"🇸🇾",TW:"🇹🇼",TJ:"🇹🇯",TZ:"🇹🇿",TH:"🇹🇭",TL:"🇹🇱",TG:"🇹🇬",TK:"🇹🇰",TO:"🇹🇴",TT:"🇹🇹",TN:"🇹🇳",TR:"🇹🇷",TM:"🇹🇲",TC:"🇹🇨",TV:"🇹🇻",UG:"🇺🇬",UA:"🇺🇦",AE:"🇦🇪",GB:"🇬🇧",US:"🇺🇸",UM:"🇺🇲",UY:"🇺🇾",UZ:"🇺🇿",VU:"🇻🇺",VE:"🇻🇪",VN:"🇻🇳",VG:"🇻🇬",VI:"🇻🇮",WF:"🇼🇫",EH:"🇪🇭",YE:"🇾🇪",ZM:"🇿🇲",ZW:"🇿🇼",EU:"🇪🇺"};var L=function(t){return"undefined"!=typeof process&&process.env&&process.env[t]||""},M=function(){function o(t){var e=void 0===t?{}:t,n=e.apiKey,o=void 0===n?"":n,i=e.defaultLocale,a=void 0===i?r:i,c=e.projectId,u=void 0===c?"":c,s=e.baseURL,f=void 0===s?"https://prod.gtx.dev":s;this.apiKey=o||L("GT_API_KEY"),this.projectId=u||L("GT_PROJECT_ID"),this.defaultLocale=l(a)||r,this.baseURL=f}return o.prototype.translate=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,f(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},o.prototype.translateReact=function(r,o,i){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,p(this,r,o,t({defaultLocale:this.defaultLocale},i))];case 1:return[2,e.sent()]}}))}))},o.prototype.translateBatch=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,i(this,t)]}))}))},o.prototype.updateProjectTranslations=function(t){return e(this,arguments,void 0,(function(t,e,r){return void 0===e&&(e=[]),void 0===r&&(r={}),n(this,(function(n){switch(n.label){case 0:return[4,v(this,t,e,r)];case 1:return[2,n.sent()]}}))}))},o.prototype.getProjectLocales=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,d(this,t||this.projectId)]}))}))},o}();function E(t){return function(t){var e;try{var n=new Intl.Locale(t);return"rtl"===(null===(e=null==n?void 0:n.textInfo)||void 0===e?void 0:e.direction)?"rtl":"ltr"}catch(t){return"ltr"}}(t)}function G(t,e){return void 0===e&&(e=r),function(t,e){void 0===e&&(e=r);try{return new Intl.DisplayNames([e,r],{type:"language"}).of(t)||""}catch(t){return""}}(t,e)}function R(t,e){return function(t,e){void 0===e&&(e=r);try{t=l(t);var n=new Intl.Locale(t),o=n.language,i=n.region,a=new Intl.Locale(t).maximize(),c=a.toString(),u=a.region||"",s=a.script||"",f=new Intl.Locale(t).minimize().toString(),p=new Intl.DisplayNames([e,t,r],{type:"language"}),v=new Intl.DisplayNames([t,e,r],{type:"language"}),d=p.of(t)||t,y=v.of(t)||t,m=p.of(c)||t,h=v.of(c)||t,g=p.of(f)||t,b=v.of(f)||t,N=p.of(o)||t,S=v.of(o)||t,C=i?"".concat(N," (").concat(i,")"):N,I=i?"".concat(S," (").concat(i,")"):S,T=new Intl.DisplayNames([e,t,r],{type:"region"}),L=new Intl.DisplayNames([t,e,r],{type:"region"}),M=T.of(u)||"",E=L.of(u)||"",G=new Intl.DisplayNames([e,t,r],{type:"script"}),R=new Intl.DisplayNames([t,e,r],{type:"script"});return{code:t,name:d,nativeName:y,maximizedCode:c,maximizedName:m,nativeMaximizedName:h,minimizedCode:f,minimizedName:g,nativeMinimizedName:b,languageCode:o,languageName:N,nativeLanguageName:S,nameWithRegionCode:C,nativeNameWithRegionCode:I,regionCode:u,regionName:M,nativeRegionName:E,scriptCode:s,scriptName:G.of(s)||"",nativeScriptName:R.of(s)||"",emoji:w(t)}}catch(e){var A=t||"",K=null==A?void 0:A.split("-");return{code:A,name:A,nativeName:A,maximizedCode:A,maximizedName:A,nativeMaximizedName:A,minimizedCode:A,minimizedName:A,nativeMinimizedName:A,languageCode:o=(null==K?void 0:K[0])||A||"",languageName:o,nativeLanguageName:o,regionCode:u=K.length>2?null==K?void 0:K[2]:(null==K?void 0:K[1])||"",regionName:u,nativeRegionName:u,scriptCode:s=(null==K?void 0:K[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:C=o?u?"".concat(o," (").concat(u,")"):o:"",nativeNameWithRegionCode:A,emoji:w(A)}}}(t,e)}function A(t,e){return w(t,e)}function K(t){return u(t)}function P(t){return l(t)}function j(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return s.apply(void 0,t)}function x(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a.apply(void 0,t)}function D(t){return y(t)}function O(t){return m(t)}function k(t){return h(t)}function B(t){return g(t)}function U(e){return o=(n=e).value,i=n.unit,a=n.locales,c=void 0===a?[r]:a,u=n.options,l=void 0===u?{}:u,new Intl.RelativeTimeFormat(c,t({style:"long",numeric:"auto"},l)).format(o,i);var n,o,i,a,c,u,l}function F(t){return N(t)}function W(e,n,o,i){return function(e,n,o,i){if(void 0===n&&(n=r),void 0===o&&(o={}),void 0===i&&(i={}),"string"==typeof e&&(e=N(e)),"string"==typeof e)return e;if(!Array.isArray(e))throw new Error("renderContentToString: content ".concat(e," is invalid"));return e.map((function(e){var r;if("string"==typeof e)return e;if("object"==typeof e){var a=o[e.key];return e.variable?"number"===e.variable?y({value:a,locales:n,options:i[e.key]}):"currency"===e.variable?h(t(t({value:a,locales:n},i[e.key]&&{options:i[e.key]}),(null===(r=i[e.key])||void 0===r?void 0:r.currency)&&{currency:i[e.key].currency})):"datetime"===e.variable?m(t({value:a,locales:n},i[e.key]&&{options:i[e.key]})):"list"===e.variable?g(t({value:a,locales:n},i[e.key]&&{options:i[e.key]})):a:a}})).join("")}(e,n,o,i)}function z(t,e){return function(t,e){if("string"==typeof t&&(t=[t]),!e)return t[0];for(var n=function(t){for(var n=l(t),r=[],o=0,i=e;o<i.length;o++){var c=i[o],u=l(c);if(n===u)return{value:u};a(n,u)&&r.push(u)}if(r.length)return{value:r.find((function(t){return s(n,t)}))||r[0]}},r=0,o=t;r<o.length;r++){var i=n(o[r]);if("object"==typeof i)return i.value}}(t,e)}function H(t,e,n){return function(t,e,n){return!(!u(t)||!u(e)||n&&n.some((function(t){return!u(t)}))||s(t,e)||n&&!n.some((function(t){return a(e,t)})))}(t,e,n)}export{M as default,z as determineLocale,k as formatCurrency,O as formatDateTime,B as formatList,D as formatNum,U as formatRelativeTime,E as getLocaleDirection,A as getLocaleEmoji,G as getLocaleName,R as getLocaleProperties,j as isSameDialect,x as isSameLanguage,K as isValidLocale,W as renderContentToString,H as requiresTranslation,F as splitStringToContent,P as standardizeLocale};
2
2
  //# sourceMappingURL=index.esm.min.mjs.map