generaltranslation 5.0.2 → 5.0.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 e=function(){return e=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},e.apply(this,arguments)};function n(e,n,t,r){return new(t||(t=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,u)}c((r=r.apply(e,n||[])).next())}))}function t(e,n){var t,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=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(t=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=n.call(e,i)}catch(e){u=[6,e],r=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function r(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{var t=e.flat().map((function(e){return new Intl.Locale(e).language}));return t.every((function(e){return e===t[0]}))}catch(e){return console.error(e),!1}}"function"==typeof SuppressedError&&SuppressedError;var o="en-US",i=6e4,a=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],u=function(e){try{var n=new Intl.Locale(e),t=n.language,r=n.region,i=n.script;if(e.split("-").length!==(u=1,r&&(u+=1),i&&(u+=1),u))return!1;if(new Intl.DisplayNames([o],{type:"language"}).of(t)===t)return!1;if(r)if(new Intl.DisplayNames([o],{type:"region"}).of(r)===r)return!1;if(i)if(new Intl.DisplayNames([o],{type:"script"}).of(i)===i&&!a.includes(i))return!1;return!0}catch(e){return!1}var u},c=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(n){return e}};function l(){for(var e,n,t,r,o,i,a,u,l,s,f=[],v=0;v<arguments.length;v++)f[v]=arguments[v];try{for(var p=f.flat().map(c),d=0;d<p.length;d++)for(var y=d+1;y<p.length;y++)if(e=p[d],n=p[y],t=void 0,r=void 0,o=void 0,i=void 0,a=void 0,u=void 0,l=void 0,s=void 0,t=new Intl.Locale(e),r=t.language,o=t.region,i=t.script,a=new Intl.Locale(n),u=a.language,l=a.region,s=a.script,r!==u||o&&l&&o!==l||i&&s&&i!==s)return!1;return!0}catch(e){return console.error(e),!1}}function s(r,o,a,u){return n(this,void 0,void 0,(function(){var n,c,l,s,f,v,p,d;return t(this,(function(t){switch(t.label){case 0:n=new AbortController,c=n.signal,(l=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return n.abort()}),l),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/content"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:o,targetLocale:a,metadata:u}),signal:c})];case 2:return s=t.sent(),[3,4];case 3:if("AbortError"===(null==(f=t.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(v=Error.bind,d=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(v.apply(Error,[void 0,d.apply(p,[t.sent()])]));case 6:return[4,s.json()];case 7:return[2,t.sent()]}}))}))}function f(r,o,a,u){return n(this,void 0,void 0,(function(){var n,c,l,s,f,v,p,d;return t(this,(function(t){switch(t.label){case 0:n=new AbortController,c=n.signal,(l=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return n.abort()}),l),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/react"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:o,targetLocale:a,metadata:u}),signal:c})];case 2:return s=t.sent(),[3,4];case 3:if("AbortError"===(null==(f=t.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(v=Error.bind,d=(p="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(v.apply(Error,[void 0,d.apply(p,[t.sent()])]));case 6:return[4,s.json()];case 7:return[2,t.sent()]}}))}))}function v(n){var t=n.value,r=n.locales,i=void 0===r?[o]:r,a=n.options,u=void 0===a?{}:a;return new Intl.NumberFormat(i,e({numberingSystem:"latn"},u)).format(t)}function p(n){var t=n.value,r=n.locales,i=void 0===r?[o]:r,a=n.options,u=void 0===a?{}:a;return new Intl.DateTimeFormat(i,e({calendar:"gregory",numberingSystem:"latn"},u)).format(t)}function d(n){var t=n.value,r=n.locales,i=void 0===r?[o]:r,a=n.currency,u=void 0===a?"USD":a,c=n.options,l=void 0===c?{}:c;return new Intl.NumberFormat(i,e({style:"currency",currency:u,numberingSystem:"latn"},l)).format(t)}function y(n){var t=n.value,r=n.locales,i=void 0===r?[o]:r,a=n.options,u=void 0===a?{}:a;return new Intl.ListFormat(i,e({type:"conjunction",style:"long"},u)).format(t)}var m={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function g(n){if("string"!=typeof n)throw new Error("splitStringToContent: ".concat(n," is not a string!"));for(var t,r=[],o=/{([^}]+)}/g,i=0;null!==(t=o.exec(n));){var a=t[0],u=t[1],c=t.index;if("^"!==n[c-1]){c>i&&r.push(n.slice(i,c));var l=u.split(",").map((function(e){return e.trim()})),s=l[0],f=l[1]?m[l[1]]:void 0,v=e({key:s},f&&{variable:f});r.push(v),i=c+a.length}else c-1>i&&r.push(n.slice(i,c-1)),r.push(a),i=c+a.length}return i<n.length&&r.push(n.slice(i)),r}function h(e,n){if(void 0===n&&(n={}),!u(e))return w;if(n[e=c(e)])return n[e];var t=new Intl.Locale(e),r=t.region;if(r&&I[r])return I[r];var o=t.maximize(),i=o.region||"";return b[o.language]||I[i]||w}var N="🌍",w=N,b={ca:N,eu:N,ku:N,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 S=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},C=function(){function r(e){var n=void 0===e?{}:e,t=n.apiKey,r=void 0===t?"":t,o=n.devApiKey,i=void 0===o?"":o,a=n.sourceLocale,u=void 0===a?"":a,l=n.projectId,s=void 0===l?"":l,f=n.baseUrl,v=void 0===f?"https://api.gtx.dev":f;this.apiKey=r||S("GT_API_KEY"),this.devApiKey=i||S("GT_DEV_API_KEY"),this.projectId=s||S("GT_PROJECT_ID"),this.sourceLocale=c(u)||"",this.baseUrl=v}return r.prototype.translate=function(r,o,i){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,s(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,n.sent()]}}))}))},r.prototype.translateJsx=function(r,o,i){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,f(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,n.sent()]}}))}))},r}();function T(e){return function(e){var n;try{var t=new Intl.Locale(e);return"rtl"===(null===(n=null==t?void 0:t.textInfo)||void 0===n?void 0:n.direction)?"rtl":"ltr"}catch(e){return"ltr"}}(e)}function M(e,n){return void 0===n&&(n=o),function(e,n){void 0===n&&(n=o);try{return new Intl.DisplayNames([n,o],{type:"language"}).of(e)||""}catch(e){return""}}(e,n)}function A(e,n){return function(e,n){void 0===n&&(n=o);try{e=c(e);var t=new Intl.Locale(e),r=t.language,i=t.region,a=new Intl.Locale(e).maximize(),u=a.toString(),l=a.region||"",s=a.script||"",f=new Intl.Locale(e).minimize().toString(),v=new Intl.DisplayNames([n,e,o],{type:"language"}),p=new Intl.DisplayNames([e,n,o],{type:"language"}),d=v.of(e)||e,y=p.of(e)||e,m=v.of(u)||e,g=p.of(u)||e,N=v.of(f)||e,w=p.of(f)||e,b=v.of(r)||e,I=p.of(r)||e,S=i?"".concat(b," (").concat(i,")"):b,C=i?"".concat(I," (").concat(i,")"):I,T=new Intl.DisplayNames([n,e,o],{type:"region"}),M=new Intl.DisplayNames([e,n,o],{type:"region"}),A=T.of(l)||"",L=M.of(l)||"",E=new Intl.DisplayNames([n,e,o],{type:"script"}),G=new Intl.DisplayNames([e,n,o],{type:"script"});return{code:e,name:d,nativeName:y,maximizedCode:u,maximizedName:m,nativeMaximizedName:g,minimizedCode:f,minimizedName:N,nativeMinimizedName:w,languageCode:r,languageName:b,nativeLanguageName:I,nameWithRegionCode:S,nativeNameWithRegionCode:C,regionCode:l,regionName:A,nativeRegionName:L,scriptCode:s,scriptName:E.of(s)||"",nativeScriptName:G.of(s)||"",emoji:h(e)}}catch(n){var K=e||"",D=null==K?void 0:K.split("-");return{code:K,name:K,nativeName:K,maximizedCode:K,maximizedName:K,nativeMaximizedName:K,minimizedCode:K,minimizedName:K,nativeMinimizedName:K,languageCode:r=(null==D?void 0:D[0])||K||"",languageName:r,nativeLanguageName:r,regionCode:l=D.length>2?null==D?void 0:D[2]:(null==D?void 0:D[1])||"",regionName:l,nativeRegionName:l,scriptCode:s=(null==D?void 0:D[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:S=r?l?"".concat(r," (").concat(l,")"):r:"",nativeNameWithRegionCode:K,emoji:h(K)}}}(e,n)}function L(e,n){return h(e,n)}function E(e){return u(e)}function G(e){return c(e)}function K(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return l.apply(void 0,e)}function D(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return r.apply(void 0,e)}function P(e){return v(e)}function R(e){return p(e)}function x(e){return d(e)}function B(e){return y(e)}function O(n){return r=(t=n).value,i=t.unit,a=t.locales,u=void 0===a?[o]:a,c=t.options,l=void 0===c?{}:c,new Intl.RelativeTimeFormat(u,e({style:"long",numeric:"auto"},l)).format(r,i);var t,r,i,a,u,c,l}function k(e){return g(e)}function U(n,t,r,i){return function(n,t,r,i){if(void 0===t&&(t=o),void 0===r&&(r={}),void 0===i&&(i={}),"string"==typeof n&&(n=g(n)),"string"==typeof n)return n;if(!Array.isArray(n))throw new Error("renderContentToString: content ".concat(n," is invalid"));return n.map((function(n){var o;if("string"==typeof n)return n;if("object"==typeof n){var a=r[n.key];return n.variable?"number"===n.variable?v({value:a,locales:t,options:i[n.key]}):"currency"===n.variable?d(e(e({value:a,locales:t},i[n.key]&&{options:i[n.key]}),(null===(o=i[n.key])||void 0===o?void 0:o.currency)&&{currency:i[n.key].currency})):"datetime"===n.variable?p(e({value:a,locales:t},i[n.key]&&{options:i[n.key]})):"list"===n.variable?y(e({value:a,locales:t},i[n.key]&&{options:i[n.key]})):a:a}})).join("")}(n,t,r,i)}function F(e,n){return function(e,n){if("string"==typeof e&&(e=[e]),e=e.filter(u),!(n=n.filter(u)))return e[0];for(var t=function(e){if(!u(e))return"continue";for(var t=c(e),o=[],i=0,a=n;i<a.length;i++){var s=a[i],f=c(s);if(t===f)return{value:f};r(t,f)&&o.push(f)}return o.length?{value:o.find((function(e){return l(t,e)}))||o[0]}:void 0},o=0,i=e;o<i.length;o++){var a=t(i[o]);if("object"==typeof a)return a.value}}(e,n)}function j(e,n,t){return function(e,n,t){return!(!u(e)||!u(n)||t&&t.some((function(e){return!u(e)}))||l(e,n)||t&&!t.some((function(e){return r(n,e)})))}(e,n,t)}export{C as default,F as determineLocale,x as formatCurrency,R as formatDateTime,B as formatList,P as formatNum,O as formatRelativeTime,T as getLocaleDirection,L as getLocaleEmoji,M as getLocaleName,A as getLocaleProperties,K as isSameDialect,D as isSameLanguage,E as isValidLocale,U as renderContentToString,j as requiresTranslation,k as splitStringToContent,G as standardizeLocale};
1
+ var e=function(){return e=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},e.apply(this,arguments)};function n(e,n,t,r){return new(t||(t=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function u(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,u)}l((r=r.apply(e,n||[])).next())}))}function t(e,n){var t,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=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(l){return function(u){if(t)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(t=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=n.call(e,i)}catch(e){u=[6,e],r=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,l])}}}function r(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{var t=e.flat().map((function(e){return new Intl.Locale(e).language}));return t.every((function(e){return e===t[0]}))}catch(e){return console.error(e),!1}}"function"==typeof SuppressedError&&SuppressedError;var o="en-US",i=6e4,a=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],u=function(e){try{var n=new Intl.Locale(e),t=n.language,r=n.region,i=n.script;if(e.split("-").length!==(u=1,r&&(u+=1),i&&(u+=1),u))return!1;if(new Intl.DisplayNames([o],{type:"language"}).of(t)===t)return!1;if(r)if(new Intl.DisplayNames([o],{type:"region"}).of(r)===r)return!1;if(i)if(new Intl.DisplayNames([o],{type:"script"}).of(i)===i&&!a.includes(i))return!1;return!0}catch(e){return!1}var u},l=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(n){return e}};function c(){for(var e,n,t,r,o,i,a,u,c,s,f=[],d=0;d<arguments.length;d++)f[d]=arguments[d];try{for(var v=f.flat().map(l),p=0;p<v.length;p++)for(var y=p+1;y<v.length;y++)if(e=v[p],n=v[y],t=void 0,r=void 0,o=void 0,i=void 0,a=void 0,u=void 0,c=void 0,s=void 0,t=new Intl.Locale(e),r=t.language,o=t.region,i=t.script,a=new Intl.Locale(n),u=a.language,c=a.region,s=a.script,r!==u||o&&c&&o!==c||i&&s&&i!==s)return!1;return!0}catch(e){return console.error(e),!1}}function s(r,o,a,u){return n(this,void 0,void 0,(function(){var n,l,c,s,f,d,v,p;return t(this,(function(t){switch(t.label){case 0:n=new AbortController,l=n.signal,(c=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return n.abort()}),c),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/content"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:o,targetLocale:a,metadata:u}),signal:l})];case 2:return s=t.sent(),[3,4];case 3:if("AbortError"===(null==(f=t.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(d=Error.bind,p=(v="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(d.apply(Error,[void 0,p.apply(v,[t.sent()])]));case 6:return[4,s.json()];case 7:return[2,t.sent()]}}))}))}function f(r,o,a,u){return n(this,void 0,void 0,(function(){var n,l,c,s,f,d,v,p;return t(this,(function(t){switch(t.label){case 0:n=new AbortController,l=n.signal,(c=Math.min((null==u?void 0:u.timeout)||i,i))&&setTimeout((function(){return n.abort()}),c),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,fetch("".concat(r.baseUrl).concat("/v1/translate/react"),{method:"POST",headers:e(e({"Content-Type":"application/json"},r.apiKey&&{"x-gt-api-key":r.apiKey}),r.devApiKey&&{"x-gt-dev-api-key":r.devApiKey}),body:JSON.stringify({source:o,targetLocale:a,metadata:u}),signal:l})];case 2:return s=t.sent(),[3,4];case 3:if("AbortError"===(null==(f=t.sent())?void 0:f.name))throw new Error("Translation request timed out. This has either occured due to the translation of an unusually large request or a translation failure in the API.");throw f;case 4:return s.ok?[3,6]:(d=Error.bind,p=(v="".concat(s.status,": ")).concat,[4,s.text()]);case 5:throw new(d.apply(Error,[void 0,p.apply(v,[t.sent()])]));case 6:return[4,s.json()];case 7:return[2,t.sent()]}}))}))}function d(n){var t=n.value,r=n.locales,i=void 0===r?[o]:r,a=n.options,u=void 0===a?{}:a;return new Intl.NumberFormat(i,e({numberingSystem:"latn"},u)).format(t)}function v(n){var t=n.value,r=n.locales,i=void 0===r?[o]:r,a=n.options,u=void 0===a?{}:a;return new Intl.DateTimeFormat(i,e({calendar:"gregory",numberingSystem:"latn"},u)).format(t)}function p(n){var t=n.value,r=n.locales,i=void 0===r?[o]:r,a=n.currency,u=void 0===a?"USD":a,l=n.options,c=void 0===l?{}:l;return new Intl.NumberFormat(i,e({style:"currency",currency:u,numberingSystem:"latn"},c)).format(t)}function y(n){var t=n.value,r=n.locales,i=void 0===r?[o]:r,a=n.options,u=void 0===a?{}:a;return new Intl.ListFormat(i,e({type:"conjunction",style:"long"},u)).format(t)}var m={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function g(n){if("string"!=typeof n)throw new Error("splitStringToContent: ".concat(n," is not a string!"));for(var t,r=[],o=/{([^}]+)}/g,i=0;null!==(t=o.exec(n));){var a=t[0],u=t[1],l=t.index;if("^"!==n[l-1]){l>i&&r.push(n.slice(i,l));var c=u.split(",").map((function(e){return e.trim()})),s=c[0],f=c[1]?m[c[1]]:void 0,d=e({key:s},f&&{variable:f});r.push(d),i=l+a.length}else l-1>i&&r.push(n.slice(i,l-1)),r.push(a),i=l+a.length}return i<n.length&&r.push(n.slice(i)),r}function h(e,n){if(void 0===n&&(n={}),!u(e))return N;if(n[e=l(e)])return n[e];var t=new Intl.Locale(e),r=t.region;if(r&&I[r])return I[r];var o=t.maximize(),i=o.region||"";return b[o.language]||I[i]||N}var w="🌍",N=w,b={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 S=["singular","plural","dual","zero","one","two","few","many","other"];var C=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},T=function(){function r(e){var n=void 0===e?{}:e,t=n.apiKey,r=void 0===t?"":t,o=n.devApiKey,i=void 0===o?"":o,a=n.sourceLocale,u=void 0===a?"":a,c=n.projectId,s=void 0===c?"":c,f=n.baseUrl,d=void 0===f?"https://api.gtx.dev":f;this.apiKey=r||C("GT_API_KEY"),this.devApiKey=i||C("GT_DEV_API_KEY"),this.projectId=s||C("GT_PROJECT_ID"),this.sourceLocale=l(u)||"",this.baseUrl=d}return r.prototype.translate=function(r,o,i){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,s(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,n.sent()]}}))}))},r.prototype.translateJsx=function(r,o,i){return n(this,void 0,void 0,(function(){return t(this,(function(n){switch(n.label){case 0:return[4,f(this,r,o,e({sourceLocale:this.sourceLocale},i))];case 1:return[2,n.sent()]}}))}))},r}();function M(e){return function(e){var n;try{var t=new Intl.Locale(e);return"rtl"===(null===(n=null==t?void 0:t.textInfo)||void 0===n?void 0:n.direction)?"rtl":"ltr"}catch(e){return"ltr"}}(e)}function A(e,n){return void 0===n&&(n=o),function(e,n){void 0===n&&(n=o);try{return new Intl.DisplayNames([n,o],{type:"language"}).of(e)||""}catch(e){return""}}(e,n)}function L(e,n){return function(e,n){void 0===n&&(n=o);try{e=l(e);var t=new Intl.Locale(e),r=t.language,i=t.region,a=new Intl.Locale(e).maximize(),u=a.toString(),c=a.region||"",s=a.script||"",f=new Intl.Locale(e).minimize().toString(),d=new Intl.DisplayNames([n,e,o],{type:"language"}),v=new Intl.DisplayNames([e,n,o],{type:"language"}),p=d.of(e)||e,y=v.of(e)||e,m=d.of(u)||e,g=v.of(u)||e,w=d.of(f)||e,N=v.of(f)||e,b=d.of(r)||e,I=v.of(r)||e,S=i?"".concat(b," (").concat(i,")"):b,C=i?"".concat(I," (").concat(i,")"):I,T=new Intl.DisplayNames([n,e,o],{type:"region"}),M=new Intl.DisplayNames([e,n,o],{type:"region"}),A=T.of(c)||"",L=M.of(c)||"",E=new Intl.DisplayNames([n,e,o],{type:"script"}),G=new Intl.DisplayNames([e,n,o],{type:"script"});return{code:e,name:p,nativeName:y,maximizedCode:u,maximizedName:m,nativeMaximizedName:g,minimizedCode:f,minimizedName:w,nativeMinimizedName:N,languageCode:r,languageName:b,nativeLanguageName:I,nameWithRegionCode:S,nativeNameWithRegionCode:C,regionCode:c,regionName:A,nativeRegionName:L,scriptCode:s,scriptName:E.of(s)||"",nativeScriptName:G.of(s)||"",emoji:h(e)}}catch(n){var K=e||"",P=null==K?void 0:K.split("-");return{code:K,name:K,nativeName:K,maximizedCode:K,maximizedName:K,nativeMaximizedName:K,minimizedCode:K,minimizedName:K,nativeMinimizedName:K,languageCode:r=(null==P?void 0:P[0])||K||"",languageName:r,nativeLanguageName:r,regionCode:c=P.length>2?null==P?void 0:P[2]:(null==P?void 0:P[1])||"",regionName:c,nativeRegionName:c,scriptCode:s=(null==P?void 0:P[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:S=r?c?"".concat(r," (").concat(c,")"):r:"",nativeNameWithRegionCode:K,emoji:h(K)}}}(e,n)}function E(e,n){return h(e,n)}function G(e){return u(e)}function K(e){return l(e)}function P(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return c.apply(void 0,e)}function R(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return r.apply(void 0,e)}function D(e){return d(e)}function x(e){return v(e)}function B(e){return p(e)}function O(e){return y(e)}function k(n){return r=(t=n).value,i=t.unit,a=t.locales,u=void 0===a?[o]:a,l=t.options,c=void 0===l?{}:l,new Intl.RelativeTimeFormat(u,e({style:"long",numeric:"auto"},c)).format(r,i);var t,r,i,a,u,l,c}function U(e){return g(e)}function F(n,t,r,i){return function(n,t,r,i){if(void 0===t&&(t=o),void 0===r&&(r={}),void 0===i&&(i={}),"string"==typeof n&&(n=g(n)),"string"==typeof n)return n;if(!Array.isArray(n))throw new Error("renderContentToString: content ".concat(n," is invalid"));return n.map((function(n){var o;if("string"==typeof n)return n;if("object"==typeof n){var a=r[n.key];return n.variable?"number"===n.variable?d({value:a,locales:t,options:i[n.key]}):"currency"===n.variable?p(e(e({value:a,locales:t},i[n.key]&&{options:i[n.key]}),(null===(o=i[n.key])||void 0===o?void 0:o.currency)&&{currency:i[n.key].currency})):"datetime"===n.variable?v(e({value:a,locales:t},i[n.key]&&{options:i[n.key]})):"list"===n.variable?y(e({value:a,locales:t},i[n.key]&&{options:i[n.key]})):a:a}})).join("")}(n,t,r,i)}function z(e,n){return function(e,n){if("string"==typeof e&&(e=[e]),e=e.filter(u),!(n=n.filter(u)))return e[0];for(var t=function(e){if(!u(e))return"continue";for(var t=l(e),o=[],i=0,a=n;i<a.length;i++){var s=a[i],f=l(s);if(t===f)return{value:f};r(t,f)&&o.push(f)}return o.length?{value:o.find((function(e){return c(t,e)}))||o[0]}:void 0},o=0,i=e;o<i.length;o++){var a=t(i[o]);if("object"==typeof a)return a.value}}(e,n)}function j(e,n,t){return function(e,n,t){return!(!u(e)||!u(n)||t&&t.some((function(e){return!u(e)}))||c(e,n)||t&&!t.some((function(e){return r(n,e)})))}(e,n,t)}function W(e,n,t){return function(e,n,t){void 0===n&&(n=S),void 0===t&&(t=[o]);var r=new Intl.PluralRules(t).select(e),i=Math.abs(e);if(0===i&&n.includes("zero"))return"zero";if(1===i){if(n.includes("singular"))return"singular";if(n.includes("one"))return"one"}if("one"===r&&n.includes("singular"))return"singular";if(2===i){if(n.includes("dual"))return"dual";if(n.includes("two"))return"two"}return"two"===r&&n.includes("dual")?"dual":n.includes(r)?r:"two"===r&&n.includes("dual")?"dual":"two"===r&&n.includes("plural")?"plural":"two"===r&&n.includes("other")?"other":"few"===r&&n.includes("plural")?"plural":"few"===r&&n.includes("other")?"other":"many"===r&&n.includes("plural")?"plural":"many"===r&&n.includes("other")?"other":"other"===r&&n.includes("plural")?"plural":""}(e,n,t)}export{T as default,z as determineLocale,B as formatCurrency,x as formatDateTime,O as formatList,D as formatNum,k as formatRelativeTime,M as getLocaleDirection,E as getLocaleEmoji,A as getLocaleName,L as getLocaleProperties,W as getPluralForm,P as isSameDialect,R as isSameLanguage,G as isValidLocale,F as renderContentToString,j as requiresTranslation,U as splitStringToContent,K as standardizeLocale};
2
2
  //# sourceMappingURL=index.esm.min.mjs.map