generaltranslation 4.0.0 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))}function n(e,t){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=t.call(e,i)}catch(e){c=[6,e],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="/v1/translate/batch",o="/v1/translate/react",i="/v1/translate/content",a="/v1/project/dictionary/update",c="/v1/project/locales";function u(e,o){return t(this,void 0,void 0,(function(){var t,i,a,c,u,s,l,f,p;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,i=t.signal,(null===(p=null===(f=null===(l=o[0])||void 0===l?void 0:l.data)||void 0===f?void 0:f.metadata)||void 0===p?void 0:p.timeout)&&setTimeout((function(){return t.abort()}),o[0].data.metadata.timeout),[4,fetch("".concat(e.baseURL).concat(r),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify(o),signal:i})];case 1:return(a=n.sent()).ok?[3,3]:(c=Error.bind,s=(u="".concat(a.status,": ")).concat,[4,a.text()]);case 2:throw new(c.apply(Error,[void 0,s.apply(u,[n.sent()])]));case 3:return[4,a.json()];case 4:return[2,n.sent()]}}))}))}function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{var n=e.flat().map((function(e){return new Intl.Locale(e).language}));return n.every((function(e){return e===n[0]}))}catch(e){return console.error(e),!1}}var l="en-US",f=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],p=function(e){try{var t=new Intl.Locale(e),n=t.language,r=t.region,o=t.script;if(new Intl.DisplayNames([l],{type:"language"}).of(n)===n)return!1;if(r)if(new Intl.DisplayNames([l],{type:"region"}).of(r)===r)return!1;if(o)if(new Intl.DisplayNames([l],{type:"script"}).of(o)===o&&!f.includes(o))return!1;return!0}catch(e){return!1}},v=function(e){return Intl.getCanonicalLocales(e)[0]};function d(){for(var e,t,n,r,o,i,a,c,u,s,l=[],f=0;f<arguments.length;f++)l[f]=arguments[f];try{for(var p=l.flat().map(v),d=0;d<p.length;d++)for(var m=d+1;m<p.length;m++)if(e=p[d],t=p[m],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(e),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(t),c=a.language,u=a.region,s=a.script,r!==c||o&&u&&o!==u||i&&s&&i!==s)return!1;return!0}catch(e){return console.error(e),!1}}function m(e,r,o,a){return t(this,void 0,void 0,(function(){var t,c,u,s,l,f;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,c=t.signal,a.timeout&&setTimeout((function(){return t.abort()}),a.timeout),[4,fetch("".concat(e.baseURL).concat(i),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({content:r,targetLocale:o,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function y(e,r,i,a){return t(this,void 0,void 0,(function(){var t,c,u,s,l,f;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,c=t.signal,a.timeout&&setTimeout((function(){return t.abort()}),a.timeout),[4,fetch("".concat(e.baseURL).concat(o),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({children:r,targetLocale:i,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function g(e,r,o,i){return t(this,void 0,void 0,(function(){var t,c,u,s,l;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(e.baseURL).concat(a),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({updates:r,locales:o,options:i})})];case 1:return(t=n.sent()).ok?[3,3]:(c=Error.bind,s=(u="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(c.apply(Error,[void 0,s.apply(u,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,null==(l=n.sent())?void 0:l.locales]}}))}))}function h(e,r){return t(this,void 0,void 0,(function(){var t,o,i,a;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(e.baseURL).concat(c,"?projectID=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey}})];case 1:return(t=n.sent()).ok?[3,3]:(o=Error.bind,a=(i="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(o.apply(Error,[void 0,a.apply(i,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,n.sent()]}}))}))}function b(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,i=t.options,a=void 0===i?{}:i;return new Intl.NumberFormat(o,e({numberingSystem:"latn"},a)).format(n)}function N(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,i=t.options,a=void 0===i?{}:i;return new Intl.DateTimeFormat(o,e({calendar:"gregory",numberingSystem:"latn"},a)).format(n)}function w(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,i=t.currency,a=void 0===i?"USD":i,c=t.options,u=void 0===c?{}:c;return new Intl.NumberFormat(o,e({style:"currency",currency:a,numberingSystem:"latn"},u)).format(n)}function L(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,i=t.options,a=void 0===i?{}:i;return new Intl.ListFormat(o,e({type:"conjunction",style:"long"},a)).format(n)}var S={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function C(t){if("string"!=typeof t)throw new Error("splitStringToContent: ".concat(t," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,i=0;null!==(n=o.exec(t));){var a=n[0],c=n[1],u=n.index;if("^"!==t[u-1]){u>i&&r.push(t.slice(i,u));var s=c.split(",").map((function(e){return e.trim()})),l=s[0],f=s[1]?S[s[1]]:void 0,p=e({key:l},f&&{variable:f});r.push(p),i=u+a.length}else u-1>i&&r.push(t.slice(i,u-1)),r.push(a),i=u+a.length}return i<t.length&&r.push(t.slice(i)),r}function T(e,t){if(void 0===t&&(t={}),!p(e))return x;if(t[e=v(e)])return t[e];var n=new Intl.Locale(e),r=n.region;if(r&&E[r])return E[r];var o=n.maximize(),i=o.region||"";return M[o.language]||E[i]||x}var I="🌍",x=I,M={ca:I,eu:I,ku:I,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},E={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 R=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},G=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,o=t.defaultLocale,i=void 0===o?l:o,a=t.projectID,c=void 0===a?"":a,u=t.baseURL,s=void 0===u?"https://prod.gtx.dev":u;this.apiKey=r||R("GT_API_KEY"),this.projectID=c||R("GT_PROJECT_ID"),this.defaultLocale=v(i)||l,this.baseURL=s}return r.prototype.translate=function(r,o,i){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,m(this,r,o,e({defaultLocale:this.defaultLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateReact=function(r,o,i){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,y(this,r,o,e({defaultLocale:this.defaultLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateBatch=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,u(this,e)]}))}))},r.prototype.updateProjectDictionary=function(e){return t(this,arguments,void 0,(function(e,t,r){return void 0===t&&(t=[]),void 0===r&&(r={}),n(this,(function(n){return[2,g(this,e,t,r)]}))}))},r.prototype.getProjectLocales=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,h(this,e||this.projectID)]}))}))},r}();function D(e){return v(e)}exports.default=G,exports.determineLocale=function(e,t){return function(e,t){if("string"==typeof e&&(e=[e]),!t)return e[0];for(var n=function(e){for(var n=v(e),r=[],o=0,i=t;o<i.length;o++){var a=i[o],c=v(a);if(n===c)return{value:c};s(n,c)&&r.push(c)}if(r.length)return{value:r.find((function(e){return d(n,e)}))||r[0]}},r=0,o=e;r<o.length;r++){var i=n(o[r]);if("object"==typeof i)return i.value}}(e,t)},exports.formatCurrency=function(e){return w(e)},exports.formatDateTime=function(e){return N(e)},exports.formatList=function(e){return L(e)},exports.formatNum=function(e){return b(e)},exports.formatRelativeTime=function(t){return r=(n=t).value,o=n.unit,i=n.locales,a=void 0===i?[l]:i,c=n.options,u=void 0===c?{}:c,new Intl.RelativeTimeFormat(a,e({style:"long",numeric:"auto"},u)).format(r,o);var n,r,o,i,a,c,u},exports.getLocaleDirection=function(e){return function(e){var t;try{var n=new Intl.Locale(e);return"rtl"===(null===(t=null==n?void 0:n.textInfo)||void 0===t?void 0:t.direction)?"rtl":"ltr"}catch(e){return"ltr"}}(e)},exports.getLocaleEmoji=function(e,t){return T(e,t)},exports.getLocaleName=function(e,t){return void 0===t&&(t=l),function(e,t){void 0===t&&(t=l);try{return new Intl.DisplayNames([t,l],{type:"language"}).of(e)||""}catch(e){return""}}(e,t)},exports.getLocaleProperties=function(e,t){return function(e,t){void 0===t&&(t=l);try{e=D(e);var n=new Intl.Locale(e),r=n.language,o=n.region,i=new Intl.Locale(e).maximize(),a=i.toString(),c=i.region||"",u=i.script||"",s=new Intl.Locale(e).minimize().toString(),f=new Intl.DisplayNames([t,e,l],{type:"language"}),p=new Intl.DisplayNames([e,t,l],{type:"language"}),v=f.of(e)||e,d=p.of(e)||e,m=f.of(a)||e,y=p.of(a)||e,g=f.of(s)||e,h=p.of(s)||e,b=f.of(r)||e,N=p.of(r)||e,w=o?"".concat(b," (").concat(o,")"):b,L=o?"".concat(N," (").concat(o,")"):N,S=new Intl.DisplayNames([t,e,l],{type:"region"}),C=new Intl.DisplayNames([e,t,l],{type:"region"}),I=S.of(c)||"",x=C.of(c)||"",M=new Intl.DisplayNames([t,e,l],{type:"script"}),E=new Intl.DisplayNames([e,t,l],{type:"script"});return{code:e,name:v,nativeName:d,maximizedCode:a,maximizedName:m,nativeMaximizedName:y,minimizedCode:s,minimizedName:g,nativeMinimizedName:h,languageCode:r,languageName:b,nativeLanguageName:N,nameWithRegionCode:w,nativeNameWithRegionCode:L,regionCode:c,regionName:I,nativeRegionName:x,scriptCode:u,scriptName:M.of(u)||"",nativeScriptName:E.of(u)||"",emoji:T(e)}}catch(t){var R=e||"",G=null==R?void 0:R.split("-");return{code:R,name:R,nativeName:R,maximizedCode:R,maximizedName:R,nativeMaximizedName:R,minimizedCode:R,minimizedName:R,nativeMinimizedName:R,languageCode:r=(null==G?void 0:G[0])||R||"",languageName:r,nativeLanguageName:r,regionCode:c=G.length>2?null==G?void 0:G[2]:(null==G?void 0:G[1])||"",regionName:c,nativeRegionName:c,scriptCode:u=(null==G?void 0:G[3])||"",scriptName:u,nativeScriptName:u,nameWithRegionCode:w=r?c?"".concat(r," (").concat(c,")"):r:"",nativeNameWithRegionCode:R,emoji:T(R)}}}(e,t)},exports.isSameDialect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d.apply(void 0,e)},exports.isSameLanguage=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.apply(void 0,e)},exports.isValidLocale=function(e){return p(e)},exports.renderContentToString=function(t,n,r,o){return function(t,n,r,o){if(void 0===n&&(n=l),void 0===r&&(r={}),void 0===o&&(o={}),"string"==typeof t&&(t=C(t)),"string"==typeof t)return t;if(!Array.isArray(t))throw new Error("renderContentToString: content ".concat(t," is invalid"));return t.map((function(t){var i;if("string"==typeof t)return t;if("object"==typeof t){var a=r[t.key];return t.variable?"number"===t.variable?b({value:a,locales:n,options:o[t.key]}):"currency"===t.variable?w(e(e({value:a,locales:n},o[t.key]&&{options:o[t.key]}),(null===(i=o[t.key])||void 0===i?void 0:i.currency)&&{currency:o[t.key].currency})):"datetime"===t.variable?N(e({value:a,locales:n},o[t.key]&&{options:o[t.key]})):"list"===t.variable?L(e({value:a,locales:n},o[t.key]&&{options:o[t.key]})):a:a}})).join("")}(t,n,r,o)},exports.requiresTranslation=function(e,t,n){return function(e,t,n){return!(!p(e)||!p(t)||n&&n.some((function(e){return!p(e)}))||d(e,t)||n&&!n.some((function(e){return s(t,e)})))}(e,t,n)},exports.splitStringToContent=function(e){return C(e)},exports.standardizeLocale=D;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}u((r=r.apply(e,t||[])).next())}))}function n(e,t){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=t.call(e,i)}catch(e){c=[6,e],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="/v1/translate/batch",o="/v1/translate/react",i="/v1/translate/content",a="/v1/project/dictionary/update",c="/v1/project/locales";function u(e,o){return t(this,void 0,void 0,(function(){var t,i,a,c,u,s,l,f,p;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,i=t.signal,(null===(p=null===(f=null===(l=o[0])||void 0===l?void 0:l.data)||void 0===f?void 0:f.metadata)||void 0===p?void 0:p.timeout)&&setTimeout((function(){return t.abort()}),o[0].data.metadata.timeout),[4,fetch("".concat(e.baseURL).concat(r),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify(o),signal:i})];case 1:return(a=n.sent()).ok?[3,3]:(c=Error.bind,s=(u="".concat(a.status,": ")).concat,[4,a.text()]);case 2:throw new(c.apply(Error,[void 0,s.apply(u,[n.sent()])]));case 3:return[4,a.json()];case 4:return[2,n.sent()]}}))}))}function s(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{var n=e.flat().map((function(e){return new Intl.Locale(e).language}));return n.every((function(e){return e===n[0]}))}catch(e){return console.error(e),!1}}var l="en-US",f=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],p=function(e){try{var t=new Intl.Locale(e),n=t.language,r=t.region,o=t.script;if(new Intl.DisplayNames([l],{type:"language"}).of(n)===n)return!1;if(r)if(new Intl.DisplayNames([l],{type:"region"}).of(r)===r)return!1;if(o)if(new Intl.DisplayNames([l],{type:"script"}).of(o)===o&&!f.includes(o))return!1;return!0}catch(e){return!1}},v=function(e){return Intl.getCanonicalLocales(e)[0]};function d(){for(var e,t,n,r,o,i,a,c,u,s,l=[],f=0;f<arguments.length;f++)l[f]=arguments[f];try{for(var p=l.flat().map(v),d=0;d<p.length;d++)for(var m=d+1;m<p.length;m++)if(e=p[d],t=p[m],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(e),r=n.language,o=n.region,i=n.script,a=new Intl.Locale(t),c=a.language,u=a.region,s=a.script,r!==c||o&&u&&o!==u||i&&s&&i!==s)return!1;return!0}catch(e){return console.error(e),!1}}function m(e,r,o,a){return t(this,void 0,void 0,(function(){var t,c,u,s,l,f;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,c=t.signal,a.timeout&&setTimeout((function(){return t.abort()}),a.timeout),[4,fetch("".concat(e.baseURL).concat(i),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({content:r,targetLocale:o,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function y(e,r,i,a){return t(this,void 0,void 0,(function(){var t,c,u,s,l,f;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,c=t.signal,a.timeout&&setTimeout((function(){return t.abort()}),a.timeout),[4,fetch("".concat(e.baseURL).concat(o),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({children:r,targetLocale:i,metadata:a}),signal:c})];case 1:return(u=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(u.status,": ")).concat,[4,u.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,u.json()];case 4:return[2,n.sent()]}}))}))}function g(e,r,o,i){return t(this,void 0,void 0,(function(){var t,c,u,s;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(e.baseURL).concat(a),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({updates:r,locales:o,options:i})})];case 1:return(t=n.sent()).ok?[3,3]:(c=Error.bind,s=(u="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(c.apply(Error,[void 0,s.apply(u,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,n.sent()]}}))}))}function h(e,r){return t(this,void 0,void 0,(function(){var t,o,i,a;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(e.baseURL).concat(c,"?projectID=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey}})];case 1:return(t=n.sent()).ok?[3,3]:(o=Error.bind,a=(i="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(o.apply(Error,[void 0,a.apply(i,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,n.sent()]}}))}))}function b(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,i=t.options,a=void 0===i?{}:i;return new Intl.NumberFormat(o,e({numberingSystem:"latn"},a)).format(n)}function N(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,i=t.options,a=void 0===i?{}:i;return new Intl.DateTimeFormat(o,e({calendar:"gregory",numberingSystem:"latn"},a)).format(n)}function w(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,i=t.currency,a=void 0===i?"USD":i,c=t.options,u=void 0===c?{}:c;return new Intl.NumberFormat(o,e({style:"currency",currency:a,numberingSystem:"latn"},u)).format(n)}function L(t){var n=t.value,r=t.locales,o=void 0===r?[l]:r,i=t.options,a=void 0===i?{}:i;return new Intl.ListFormat(o,e({type:"conjunction",style:"long"},a)).format(n)}var S={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function C(t){if("string"!=typeof t)throw new Error("splitStringToContent: ".concat(t," is not a string!"));for(var n,r=[],o=/{([^}]+)}/g,i=0;null!==(n=o.exec(t));){var a=n[0],c=n[1],u=n.index;if("^"!==t[u-1]){u>i&&r.push(t.slice(i,u));var s=c.split(",").map((function(e){return e.trim()})),l=s[0],f=s[1]?S[s[1]]:void 0,p=e({key:l},f&&{variable:f});r.push(p),i=u+a.length}else u-1>i&&r.push(t.slice(i,u-1)),r.push(a),i=u+a.length}return i<t.length&&r.push(t.slice(i)),r}function T(e,t){if(void 0===t&&(t={}),!p(e))return x;if(t[e=v(e)])return t[e];var n=new Intl.Locale(e),r=n.region;if(r&&E[r])return E[r];var o=n.maximize(),i=o.region||"";return M[o.language]||E[i]||x}var I="🌍",x=I,M={ca:I,eu:I,ku:I,bo:"🌏",ug:"🌏",gd:"🏴󠁧󠁢󠁳󠁣󠁴󠁿",cy:"🏴󠁧󠁢󠁷󠁬󠁳󠁿",gv:"🇮🇲",grc:"🏺"},E={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 R=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},G=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,o=t.defaultLocale,i=void 0===o?l:o,a=t.projectID,c=void 0===a?"":a,u=t.baseURL,s=void 0===u?"https://prod.gtx.dev":u;this.apiKey=r||R("GT_API_KEY"),this.projectID=c||R("GT_PROJECT_ID"),this.defaultLocale=v(i)||l,this.baseURL=s}return r.prototype.translate=function(r,o,i){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,m(this,r,o,e({defaultLocale:this.defaultLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateReact=function(r,o,i){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,y(this,r,o,e({defaultLocale:this.defaultLocale},i))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateBatch=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,u(this,e)]}))}))},r.prototype.updateProjectDictionary=function(e){return t(this,arguments,void 0,(function(e,t,r){return void 0===t&&(t=[]),void 0===r&&(r={}),n(this,(function(n){switch(n.label){case 0:return[4,g(this,e,t,r)];case 1:return[2,n.sent()]}}))}))},r.prototype.getProjectLocales=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,h(this,e||this.projectID)]}))}))},r}();function D(e){return v(e)}exports.default=G,exports.determineLocale=function(e,t){return function(e,t){if("string"==typeof e&&(e=[e]),!t)return e[0];for(var n=function(e){for(var n=v(e),r=[],o=0,i=t;o<i.length;o++){var a=i[o],c=v(a);if(n===c)return{value:c};s(n,c)&&r.push(c)}if(r.length)return{value:r.find((function(e){return d(n,e)}))||r[0]}},r=0,o=e;r<o.length;r++){var i=n(o[r]);if("object"==typeof i)return i.value}}(e,t)},exports.formatCurrency=function(e){return w(e)},exports.formatDateTime=function(e){return N(e)},exports.formatList=function(e){return L(e)},exports.formatNum=function(e){return b(e)},exports.formatRelativeTime=function(t){return r=(n=t).value,o=n.unit,i=n.locales,a=void 0===i?[l]:i,c=n.options,u=void 0===c?{}:c,new Intl.RelativeTimeFormat(a,e({style:"long",numeric:"auto"},u)).format(r,o);var n,r,o,i,a,c,u},exports.getLocaleDirection=function(e){return function(e){var t;try{var n=new Intl.Locale(e);return"rtl"===(null===(t=null==n?void 0:n.textInfo)||void 0===t?void 0:t.direction)?"rtl":"ltr"}catch(e){return"ltr"}}(e)},exports.getLocaleEmoji=function(e,t){return T(e,t)},exports.getLocaleName=function(e,t){return void 0===t&&(t=l),function(e,t){void 0===t&&(t=l);try{return new Intl.DisplayNames([t,l],{type:"language"}).of(e)||""}catch(e){return""}}(e,t)},exports.getLocaleProperties=function(e,t){return function(e,t){void 0===t&&(t=l);try{e=D(e);var n=new Intl.Locale(e),r=n.language,o=n.region,i=new Intl.Locale(e).maximize(),a=i.toString(),c=i.region||"",u=i.script||"",s=new Intl.Locale(e).minimize().toString(),f=new Intl.DisplayNames([t,e,l],{type:"language"}),p=new Intl.DisplayNames([e,t,l],{type:"language"}),v=f.of(e)||e,d=p.of(e)||e,m=f.of(a)||e,y=p.of(a)||e,g=f.of(s)||e,h=p.of(s)||e,b=f.of(r)||e,N=p.of(r)||e,w=o?"".concat(b," (").concat(o,")"):b,L=o?"".concat(N," (").concat(o,")"):N,S=new Intl.DisplayNames([t,e,l],{type:"region"}),C=new Intl.DisplayNames([e,t,l],{type:"region"}),I=S.of(c)||"",x=C.of(c)||"",M=new Intl.DisplayNames([t,e,l],{type:"script"}),E=new Intl.DisplayNames([e,t,l],{type:"script"});return{code:e,name:v,nativeName:d,maximizedCode:a,maximizedName:m,nativeMaximizedName:y,minimizedCode:s,minimizedName:g,nativeMinimizedName:h,languageCode:r,languageName:b,nativeLanguageName:N,nameWithRegionCode:w,nativeNameWithRegionCode:L,regionCode:c,regionName:I,nativeRegionName:x,scriptCode:u,scriptName:M.of(u)||"",nativeScriptName:E.of(u)||"",emoji:T(e)}}catch(t){var R=e||"",G=null==R?void 0:R.split("-");return{code:R,name:R,nativeName:R,maximizedCode:R,maximizedName:R,nativeMaximizedName:R,minimizedCode:R,minimizedName:R,nativeMinimizedName:R,languageCode:r=(null==G?void 0:G[0])||R||"",languageName:r,nativeLanguageName:r,regionCode:c=G.length>2?null==G?void 0:G[2]:(null==G?void 0:G[1])||"",regionName:c,nativeRegionName:c,scriptCode:u=(null==G?void 0:G[3])||"",scriptName:u,nativeScriptName:u,nameWithRegionCode:w=r?c?"".concat(r," (").concat(c,")"):r:"",nativeNameWithRegionCode:R,emoji:T(R)}}}(e,t)},exports.isSameDialect=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d.apply(void 0,e)},exports.isSameLanguage=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.apply(void 0,e)},exports.isValidLocale=function(e){return p(e)},exports.renderContentToString=function(t,n,r,o){return function(t,n,r,o){if(void 0===n&&(n=l),void 0===r&&(r={}),void 0===o&&(o={}),"string"==typeof t&&(t=C(t)),"string"==typeof t)return t;if(!Array.isArray(t))throw new Error("renderContentToString: content ".concat(t," is invalid"));return t.map((function(t){var i;if("string"==typeof t)return t;if("object"==typeof t){var a=r[t.key];return t.variable?"number"===t.variable?b({value:a,locales:n,options:o[t.key]}):"currency"===t.variable?w(e(e({value:a,locales:n},o[t.key]&&{options:o[t.key]}),(null===(i=o[t.key])||void 0===i?void 0:i.currency)&&{currency:o[t.key].currency})):"datetime"===t.variable?N(e({value:a,locales:n},o[t.key]&&{options:o[t.key]})):"list"===t.variable?L(e({value:a,locales:n},o[t.key]&&{options:o[t.key]})):a:a}})).join("")}(t,n,r,o)},exports.requiresTranslation=function(e,t,n){return function(e,t,n){return!(!p(e)||!p(t)||n&&n.some((function(e){return!p(e)}))||d(e,t)||n&&!n.some((function(e){return s(t,e)})))}(e,t,n)},exports.splitStringToContent=function(e){return C(e)},exports.standardizeLocale=D;
2
2
  //# sourceMappingURL=index.cjs.min.cjs.map