generaltranslation 6.1.9 → 6.1.10

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"==typeof SuppressedError&&SuppressedError;var r="en-US",o=6e4,i=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],a=function(e){try{var n=new Intl.Locale(e),t=n.language,o=n.region,a=n.script;if(e.split("-").length!==(u=1,o&&(u+=1),a&&(u+=1),u))return!1;if(new Intl.DisplayNames([r],{type:"language"}).of(t)===t)return!1;if(o)if(new Intl.DisplayNames([r],{type:"region"}).of(o)===o)return!1;if(a)if(new Intl.DisplayNames([r],{type:"script"}).of(a)===a&&!i.includes(a))return!1;return!0}catch(e){return!1}var u},u=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(n){return e}};function c(){for(var e,n,t,r,o,i,a,c,l,s,f=[],v=0;v<arguments.length;v++)f[v]=arguments[v];try{for(var p=f.flat().map(u),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,c=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),c=a.language,l=a.region,s=a.script,r!==c||o&&l&&o!==l||i&&s&&i!==s)return!1;return!0}catch(e){return console.error(e),!1}}function l(){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 s(r,i,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)||o,o))&&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:i,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,i,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)||o,o))&&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:i,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(e,n){if(void 0===n&&(n={}),!a(e))return d;if(n[e=u(e)])return n[e];var t=new Intl.Locale(e),r=t.region;if(r&&m[r])return m[r];var o=t.maximize(),i=o.region||"";return y[o.language]||m[i]||d}var p="🌍",d=p,y={ca:p,eu:p,ku:p,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},m={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:"🇪🇺"};function g(e,n){void 0===n&&(n=r);try{e=u(e);var t=new Intl.Locale(e),o=t.language,i=t.region,a=new Intl.Locale(e).maximize(),c=a.toString(),l=a.region||"",s=a.script||"",f=new Intl.Locale(e).minimize().toString(),p=new Intl.DisplayNames([n,e,r],{type:"language"}),d=new Intl.DisplayNames([e,n,r],{type:"language"}),y=p.of(e)||e,m=d.of(e)||e,g=p.of(c)||e,h=d.of(c)||e,b=p.of(f)||e,N=d.of(f)||e,w=p.of(o)||e,C=d.of(o)||e,I=i?"".concat(w," (").concat(i,")"):w,S=i?"".concat(C," (").concat(i,")"):C,T=new Intl.DisplayNames([n,e,r],{type:"region"}),M=new Intl.DisplayNames([e,n,r],{type:"region"}),A=T.of(l)||"",L=M.of(l)||"",E=new Intl.DisplayNames([n,e,r],{type:"script"}),G=new Intl.DisplayNames([e,n,r],{type:"script"});return{code:e,name:y,nativeName:m,maximizedCode:c,maximizedName:g,nativeMaximizedName:h,minimizedCode:f,minimizedName:b,nativeMinimizedName:N,languageCode:o,languageName:w,nativeLanguageName:C,nameWithRegionCode:I,nativeNameWithRegionCode:S,regionCode:l,regionName:A,nativeRegionName:L,scriptCode:s,scriptName:E.of(s)||"",nativeScriptName:G.of(s)||"",emoji:v(e)}}catch(n){var K=e||"",O=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:o=(null==O?void 0:O[0])||K||"",languageName:o,nativeLanguageName:o,regionCode:l=O.length>2?null==O?void 0:O[2]:(null==O?void 0:O[1])||"",regionName:l,nativeRegionName:l,scriptCode:s=(null==O?void 0:O[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:I=o?l?"".concat(o," (").concat(l,")"):o:"",nativeNameWithRegionCode:K,emoji:v(K)}}}function h(n,t){"string"==typeof n&&(n=[n]),n=n.filter(a),t=t.filter(a);for(var r=function(n){var r=t.filter((function(e){return l(e)})),o=function(e){for(var n=e.locale,t=e.languageCode,o=e.minimizedCode,i=e.regionCode,a=e.scriptCode,u=0,c=[n,"".concat(t,"-").concat(i),"".concat(t,"-").concat(a),o];u<c.length;u++){var l=c[u];if(r.includes(l))return l}return null},i=g(n),a=i.languageCode,u=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}(i,["languageCode"]),c=o(e({locale:n,languageCode:a},u))||o(e({locale:a},g(a)));if(c)return{value:c}},o=0,i=n;o<i.length;o++){var u=r(i[o]);if("object"==typeof u)return u.value}}function b(n){var t=n.value,o=n.locales,i=void 0===o?[r]:o,a=n.options,u=void 0===a?{}:a;return new Intl.NumberFormat(i,e({numberingSystem:"latn"},u)).format(t)}function N(n){var t=n.value,o=n.locales,i=void 0===o?[r]:o,a=n.options,u=void 0===a?{}:a;return new Intl.DateTimeFormat(i,e({calendar:"gregory",numberingSystem:"latn"},u)).format(t)}function w(n){var t=n.value,o=n.locales,i=void 0===o?[r]:o,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 C(n){var t=n.value,o=n.locales,i=void 0===o?[r]:o,a=n.options,u=void 0===a?{}:a;return new Intl.ListFormat(i,e({type:"conjunction",style:"long"},u)).format(t)}var I={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function S(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]?I[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}var T=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},M=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,c=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||T("GT_API_KEY"),this.devApiKey=i||T("GT_DEV_API_KEY"),this.projectId=s||T("GT_PROJECT_ID"),this.sourceLocale=u(c)||"",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 A(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 L(e,n){return void 0===n&&(n=r),function(e,n){void 0===n&&(n=r);try{return new Intl.DisplayNames([n,r],{type:"language"}).of(e)||""}catch(e){return""}}(e,n)}function E(e,n){return g(e,n)}function G(e,n){return v(e,n)}function K(e){return a(e)}function O(e){return u(e)}function P(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return c.apply(void 0,e)}function D(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return l.apply(void 0,e)}function R(e){return b(e)}function x(e){return N(e)}function B(e){return w(e)}function k(e){return C(e)}function U(n){return o=(t=n).value,i=t.unit,a=t.locales,u=void 0===a?[r]:a,c=t.options,l=void 0===c?{}:c,new Intl.RelativeTimeFormat(u,e({style:"long",numeric:"auto"},l)).format(o,i);var t,o,i,a,u,c,l}function j(e){return S(e)}function F(n,t,o,i){return function(n,t,o,i){if(void 0===t&&(t=r),void 0===o&&(o={}),void 0===i&&(i={}),"string"==typeof n&&(n=S(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 r;if("string"==typeof n)return n;if("object"==typeof n){var a=o[n.key];return n.variable?"number"===n.variable?b({value:a,locales:t,options:i[n.key]}):"currency"===n.variable?w(e(e({value:a,locales:t},i[n.key]&&{options:i[n.key]}),(null===(r=i[n.key])||void 0===r?void 0:r.currency)&&{currency:i[n.key].currency})):"datetime"===n.variable?N(e({value:a,locales:t},i[n.key]&&{options:i[n.key]})):"list"===n.variable?C(e({value:a,locales:t},i[n.key]&&{options:i[n.key]})):a:a}})).join("")}(n,t,o,i)}function z(e,n){return h(e,n)}function W(e,n,t){return function(e,n,t){return!(!a(e)||!a(n)||t&&t.some((function(e){return!a(e)}))||c(e,n)||t&&!t.some((function(e){return l(n,e)})))}(e,n,t)}export{M as default,z as determineLocale,B as formatCurrency,x as formatDateTime,k as formatList,R as formatNum,U as formatRelativeTime,A as getLocaleDirection,G as getLocaleEmoji,L as getLocaleName,E as getLocaleProperties,P as isSameDialect,D as isSameLanguage,K as isValidLocale,F as renderContentToString,W as requiresTranslation,j as splitStringToContent,O 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{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"==typeof SuppressedError&&SuppressedError;var r="en-US",o=6e4,i=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],a=function(e){try{var n=new Intl.Locale(e),t=n.language,o=n.region,a=n.script;if(e.split("-").length!==(u=1,o&&(u+=1),a&&(u+=1),u))return!1;if(new Intl.DisplayNames([r],{type:"language"}).of(t)===t)return!1;if(o)if(new Intl.DisplayNames([r],{type:"region"}).of(o)===o)return!1;if(a)if(new Intl.DisplayNames([r],{type:"script"}).of(a)===a&&!i.includes(a))return!1;return!0}catch(e){return!1}var u},u=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(n){return e}};function c(){for(var e,n,t,r,o,i,a,c,l,s,f=[],v=0;v<arguments.length;v++)f[v]=arguments[v];try{for(var p=f.flat().map(u),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,c=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),c=a.language,l=a.region,s=a.script,r!==c||o&&l&&o!==l||i&&s&&i!==s)return!1;return!0}catch(e){return console.error(e),!1}}function l(){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 s(r,i,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)||o,o))&&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:i,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,i,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)||o,o))&&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:i,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(e,n){if(void 0===n&&(n={}),!a(e))return d;if(n[e=u(e)])return n[e];var t=new Intl.Locale(e),r=t.region;if(r&&m[r])return m[r];var o=t.maximize(),i=o.region||"";return y[o.language]||m[i]||d}var p="🌍",d=p,y={ca:p,eu:p,ku:p,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},m={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:"🇪🇺"};function g(e,n){void 0===n&&(n=r);try{e=u(e);var t=new Intl.Locale(e),o=t.language,i=t.region,a=new Intl.Locale(e).maximize(),c=a.toString(),l=a.region||"",s=a.script||"",f=new Intl.Locale(e).minimize().toString(),p=new Intl.DisplayNames([n,e,r],{type:"language"}),d=new Intl.DisplayNames([e,n,r],{type:"language"}),y=p.of(e)||e,m=d.of(e)||e,g=p.of(c)||e,h=d.of(c)||e,b=p.of(f)||e,N=d.of(f)||e,w=p.of(o)||e,C=d.of(o)||e,I=i?"".concat(w," (").concat(i,")"):w,S=i?"".concat(C," (").concat(i,")"):C,T=new Intl.DisplayNames([n,e,r],{type:"region"}),M=new Intl.DisplayNames([e,n,r],{type:"region"}),A=T.of(l)||"",L=M.of(l)||"",E=new Intl.DisplayNames([n,e,r],{type:"script"}),G=new Intl.DisplayNames([e,n,r],{type:"script"});return{code:e,name:y,nativeName:m,maximizedCode:c,maximizedName:g,nativeMaximizedName:h,minimizedCode:f,minimizedName:b,nativeMinimizedName:N,languageCode:o,languageName:w,nativeLanguageName:C,nameWithRegionCode:I,nativeNameWithRegionCode:S,regionCode:l,regionName:A,nativeRegionName:L,scriptCode:s,scriptName:E.of(s)||"",nativeScriptName:G.of(s)||"",emoji:v(e)}}catch(n){var K=e||"",O=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:o=(null==O?void 0:O[0])||K||"",languageName:o,nativeLanguageName:o,regionCode:l=O.length>2?null==O?void 0:O[2]:(null==O?void 0:O[1])||"",regionName:l,nativeRegionName:l,scriptCode:s=(null==O?void 0:O[3])||"",scriptName:s,nativeScriptName:s,nameWithRegionCode:I=o?l?"".concat(o," (").concat(l,")"):o:"",nativeNameWithRegionCode:K,emoji:v(K)}}}function h(n,t){"string"==typeof n&&(n=[n]),n=n.filter(a),t=t.filter(a);for(var r=function(n){var r=t.filter((function(e){return l(n,e)})),o=function(e){for(var n=e.locale,t=e.languageCode,o=e.minimizedCode,i=e.regionCode,a=e.scriptCode,u=0,c=[n,"".concat(t,"-").concat(i),"".concat(t,"-").concat(a),o];u<c.length;u++){var l=c[u];if(r.includes(l))return l}return null},i=g(n),a=i.languageCode,u=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(t[r[o]]=e[r[o]])}return t}(i,["languageCode"]),c=o(e({locale:n,languageCode:a},u))||o(e({locale:a},g(a)));if(c)return{value:c}},o=0,i=n;o<i.length;o++){var u=r(i[o]);if("object"==typeof u)return u.value}}function b(n){var t=n.value,o=n.locales,i=void 0===o?[r]:o,a=n.options,u=void 0===a?{}:a;return new Intl.NumberFormat(i,e({numberingSystem:"latn"},u)).format(t)}function N(n){var t=n.value,o=n.locales,i=void 0===o?[r]:o,a=n.options,u=void 0===a?{}:a;return new Intl.DateTimeFormat(i,e({calendar:"gregory",numberingSystem:"latn"},u)).format(t)}function w(n){var t=n.value,o=n.locales,i=void 0===o?[r]:o,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 C(n){var t=n.value,o=n.locales,i=void 0===o?[r]:o,a=n.options,u=void 0===a?{}:a;return new Intl.ListFormat(i,e({type:"conjunction",style:"long"},u)).format(t)}var I={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function S(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]?I[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}var T=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},M=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,c=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||T("GT_API_KEY"),this.devApiKey=i||T("GT_DEV_API_KEY"),this.projectId=s||T("GT_PROJECT_ID"),this.sourceLocale=u(c)||"",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 A(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 L(e,n){return void 0===n&&(n=r),function(e,n){void 0===n&&(n=r);try{return new Intl.DisplayNames([n,r],{type:"language"}).of(e)||""}catch(e){return""}}(e,n)}function E(e,n){return g(e,n)}function G(e,n){return v(e,n)}function K(e){return a(e)}function O(e){return u(e)}function P(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return c.apply(void 0,e)}function D(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return l.apply(void 0,e)}function R(e){return b(e)}function x(e){return N(e)}function B(e){return w(e)}function k(e){return C(e)}function U(n){return o=(t=n).value,i=t.unit,a=t.locales,u=void 0===a?[r]:a,c=t.options,l=void 0===c?{}:c,new Intl.RelativeTimeFormat(u,e({style:"long",numeric:"auto"},l)).format(o,i);var t,o,i,a,u,c,l}function j(e){return S(e)}function F(n,t,o,i){return function(n,t,o,i){if(void 0===t&&(t=r),void 0===o&&(o={}),void 0===i&&(i={}),"string"==typeof n&&(n=S(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 r;if("string"==typeof n)return n;if("object"==typeof n){var a=o[n.key];return n.variable?"number"===n.variable?b({value:a,locales:t,options:i[n.key]}):"currency"===n.variable?w(e(e({value:a,locales:t},i[n.key]&&{options:i[n.key]}),(null===(r=i[n.key])||void 0===r?void 0:r.currency)&&{currency:i[n.key].currency})):"datetime"===n.variable?N(e({value:a,locales:t},i[n.key]&&{options:i[n.key]})):"list"===n.variable?C(e({value:a,locales:t},i[n.key]&&{options:i[n.key]})):a:a}})).join("")}(n,t,o,i)}function z(e,n){return h(e,n)}function W(e,n,t){return function(e,n,t){return!(!a(e)||!a(n)||t&&t.some((function(e){return!a(e)}))||c(e,n)||t&&!t.some((function(e){return l(n,e)})))}(e,n,t)}export{M as default,z as determineLocale,B as formatCurrency,x as formatDateTime,k as formatList,R as formatNum,U as formatRelativeTime,A as getLocaleDirection,G as getLocaleEmoji,L as getLocaleName,E as getLocaleProperties,P as isSameDialect,D as isSameLanguage,K as isValidLocale,F as renderContentToString,W as requiresTranslation,j as splitStringToContent,O as standardizeLocale};
2
2
  //# sourceMappingURL=index.esm.min.mjs.map