generaltranslation 3.3.2 → 3.3.3

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 t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},t.apply(this,arguments)};function e(t,e,n,r){return new(n||(n=Promise))((function(a,o){function i(t){try{c(r.next(t))}catch(t){o(t)}}function u(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(i,u)}c((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=u(0),i.throw=u(1),i.return=u(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){o.label=u[1];break}if(6===u[0]&&o.label<a[1]){o.label=a[1],a=u;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(u);break}a[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],r=0}finally{n=a=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="/v1/translate/batch",a="/v1/translate/react",o="/v1/translate/content",i="/v1/project/dictionary/update",u="/v1/project/languages";function c(t,a){return e(this,void 0,void 0,(function(){var e,o,i,u,c,s,l,f,p;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,o=e.signal,(null===(p=null===(f=null===(l=a[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 e.abort()}),a[0].data.metadata.timeout),[4,fetch("".concat(t.baseURL).concat(r),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify(a),signal:o})];case 1:return(i=n.sent()).ok?[3,3]:(u=Error.bind,s=(c="".concat(i.status,": ")).concat,[4,i.text()]);case 2:throw new(u.apply(Error,[void 0,s.apply(c,[n.sent()])]));case 3:return[4,i.json()];case 4:return[2,n.sent()]}}))}))}var s="en",l=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],f=function(t){try{var e=new Intl.Locale(t),n=e.language,r=e.region,a=e.script;if(new Intl.DisplayNames([s],{type:"language"}).of(n)===n)return!1;if(r)if(new Intl.DisplayNames([s],{type:"region"}).of(r)===r)return!1;if(a)if(new Intl.DisplayNames([s],{type:"script"}).of(a)===a&&!l.includes(a))return!1;return!0}catch(t){return!1}},p=function(t){try{return Intl.getCanonicalLocales(t)[0]}catch(t){return""}};function g(){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}}function d(t,r,a,i){return e(this,void 0,void 0,(function(){var e,u,c,s,l,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,u=e.signal,i.timeout&&setTimeout((function(){return e.abort()}),i.timeout),[4,fetch("".concat(t.baseURL).concat(o),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({content:r,targetLanguage:a,metadata:i}),signal:u})];case 1:return(c=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(c.status,": ")).concat,[4,c.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,c.json()];case 4:return[2,n.sent()]}}))}))}function v(t,r,o,i){return e(this,void 0,void 0,(function(){var e,u,c,s,l,f;return n(this,(function(n){switch(n.label){case 0:return e=new AbortController,u=e.signal,i.timeout&&setTimeout((function(){return e.abort()}),i.timeout),[4,fetch("".concat(t.baseURL).concat(a),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({children:r,targetLanguage:o,metadata:i}),signal:u})];case 1:return(c=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(c.status,": ")).concat,[4,c.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,c.json()];case 4:return[2,n.sent()]}}))}))}function y(t,r,a,o){return e(this,void 0,void 0,(function(){var e,u,c,s,l;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat(i),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey},body:JSON.stringify({updates:r,languages:a,options:o})})];case 1:return(e=n.sent()).ok?[3,3]:(u=Error.bind,s=(c="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(u.apply(Error,[void 0,s.apply(c,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,null==(l=n.sent())?void 0:l.languages]}}))}))}function m(t,r){return e(this,void 0,void 0,(function(){var e,a,o,i,c;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(t.baseURL).concat(u,"?projectID=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":t.apiKey}})];case 1:return(e=n.sent()).ok?[3,3]:(a=Error.bind,i=(o="".concat(e.status,": ")).concat,[4,e.text()]);case 2:throw new(a.apply(Error,[void 0,i.apply(o,[n.sent()])]));case 3:return[4,e.json()];case 4:return[2,null==(c=n.sent())?void 0:c.languages]}}))}))}function h(e){var n=e.value,r=e.languages,a=void 0===r?[s]:r,o=e.options,i=void 0===o?{}:o;return new Intl.NumberFormat(a,t({numberingSystem:"latn"},i)).format(n)}function b(e){var n=e.value,r=e.languages,a=void 0===r?[s]:r,o=e.options,i=void 0===o?{}:o;return new Intl.DateTimeFormat(a,t({calendar:"gregory",numberingSystem:"latn"},i)).format(n)}function N(e){var n=e.value,r=e.languages,a=void 0===r?[s]:r,o=e.currency,i=void 0===o?"USD":o,u=e.options,c=void 0===u?{}:u;return new Intl.NumberFormat(a,t({style:"currency",currency:i,numberingSystem:"latn"},c)).format(n)}function w(e){var n=e.value,r=e.languages,a=void 0===r?[s]:r,o=e.options,i=void 0===o?{}:o;return new Intl.ListFormat(a,t({type:"conjunction",style:"long"},i)).format(n)}var L={var:"variable",num:"number",datetime:"datetime",currency:"currency"};function C(e){if("string"!=typeof e)throw new Error("splitStringToContent: ".concat(e," is not a string!"));for(var n,r=[],a=/{([^}]+)}/g,o=0;null!==(n=a.exec(e));){var i=n[0],u=n[1],c=n.index;if("^"!==e[c-1]){c>o&&r.push(e.slice(o,c));var s=u.split(",").map((function(t){return t.trim()})),l=s[0],f=s[1]?L[s[1]]:void 0,p=t({key:l},f&&{variable:f});r.push(p),o=c+i.length}else c-1>o&&r.push(e.slice(o,c-1)),r.push(i),o=c+i.length}return o<e.length&&r.push(e.slice(o)),r}function S(t,e){if(void 0===e&&(e={}),!f(t))return I;var n=new Intl.Locale(t);if(e[t=n.toString()])return e[t];var r=n.region;if(r&&M[r])return M[r];var a=n.maximize(),o=a.region||"";return x[a.language]||M[o]||I}var T="🌍",I=T,x={ca:T,eu:T,ku:T,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:"🇪🇺"};var E=function(t){return"undefined"!=typeof process&&process.env&&process.env[t]||""},A=function(){function r(t){var e=void 0===t?{}:t,n=e.apiKey,r=void 0===n?"":n,a=e.defaultLanguage,o=void 0===a?s:a,i=e.projectID,u=void 0===i?"":i,c=e.baseURL,l=void 0===c?"https://prod.gtx.dev":c;this.apiKey=r||E("GT_API_KEY"),this.projectID=u||E("GT_PROJECT_ID"),this.defaultLanguage=o.toLowerCase(),this.baseURL=l}return r.prototype.translate=function(r,a,o){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,d(this,r,a,t({defaultLanguage:this.defaultLanguage},o))];case 1:return[2,e.sent()]}}))}))},r.prototype.translateReact=function(r,a,o){return e(this,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,v(this,r,a,t({defaultLanguage:this.defaultLanguage},o))];case 1:return[2,e.sent()]}}))}))},r.prototype.translateBatch=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,c(this,t)]}))}))},r.prototype.updateProjectDictionary=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){return[2,y(this,t,e,r)]}))}))},r.prototype.getProjectLanguages=function(t){return e(this,void 0,void 0,(function(){return n(this,(function(e){return[2,m(this,t||this.projectID)]}))}))},r}();exports.default=A,exports.determineLanguage=function(t,e){return function(t,e){if("string"==typeof t&&(t=[t]),!e)return t[0];for(var n=function(t){var n=e.find((function(e){return e===t}));if(n)return{value:n};var r=e.find((function(e){return g(e,t)}));return r?{value:r}:void 0},r=0,a=t;r<a.length;r++){var o=n(a[r]);if("object"==typeof o)return o.value}}(t,e)},exports.formatCurrency=function(t){return N(t)},exports.formatDateTime=function(t){return b(t)},exports.formatList=function(t){return w(t)},exports.formatNum=function(t){return h(t)},exports.formatRelativeTime=function(e){return r=(n=e).value,a=n.unit,o=n.languages,i=void 0===o?[s]:o,u=n.options,c=void 0===u?{}:u,new Intl.RelativeTimeFormat(i,t({style:"long",numeric:"auto"},c)).format(r,a);var n,r,a,o,i,u,c},exports.getLanguageDirection=function(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)},exports.getLanguageEmoji=function(t,e){return S(t,e)},exports.getLanguageName=function(t,e){return function(t,e){void 0===e&&(e=s);try{var n=new Intl.DisplayNames([e,s],{type:"language"});return"string"==typeof t?n.of(t)||"":Array.isArray(t)?t.map((function(t){return n.of(t)||""})):""}catch(e){return"string"==typeof t?"":Array.isArray(t)?t.map((function(){return""})):""}}(t,e)},exports.getLanguageNames=function(t,e){return function(t,e){void 0===e&&(e=s);try{var n=new Intl.Locale(t);t=n.toString();var r=n.language,a=n.region,o=new Intl.Locale(t).maximize(),i=o.toString(),u=o.region||"",c=o.script||"",l=new Intl.Locale(t).minimize().toString(),f=new Intl.DisplayNames([e,t,s],{type:"language"}),p=new Intl.DisplayNames([t,e,s],{type:"language"}),g=f.of(t)||t,d=p.of(t)||t,v=f.of(i)||t,y=p.of(i)||t,m=f.of(l)||t,h=p.of(l)||t,b=f.of(r)||t,N=p.of(r)||t,w=a?"".concat(b," (").concat(a,")"):b,L=a?"".concat(N," (").concat(a,")"):N,C=new Intl.DisplayNames([e,t,s],{type:"region"}),T=new Intl.DisplayNames([t,e,s],{type:"region"}),I=C.of(u)||"",x=T.of(u)||"",M=new Intl.DisplayNames([e,t,s],{type:"script"}),E=new Intl.DisplayNames([t,e,s],{type:"script"});return{code:t,name:g,nativeName:d,maximizedCode:i,maximizedName:v,nativeMaximizedName:y,minimizedCode:l,minimizedName:m,nativeMinimizedName:h,languageCode:r,languageName:b,nativeLanguageName:N,nameWithRegionCode:w,nativeNameWithRegionCode:L,regionCode:u,regionName:I,nativeRegionName:x,scriptCode:c,scriptName:M.of(c)||"",nativeScriptName:E.of(c)||"",emoji:S(t)}}catch(e){t||(t="");var A=null==t?void 0:t.split("-");return{code:t,name:t,nativeName:t,maximizedCode:t,maximizedName:t,nativeMaximizedName:t,minimizedCode:t,minimizedName:t,nativeMinimizedName:t,languageCode:r=(null==A?void 0:A[0])||t||"",languageName:r,nativeLanguageName:r,regionCode:u=A.length>2?null==A?void 0:A[2]:(null==A?void 0:A[1])||"",regionName:u,nativeRegionName:u,scriptCode:c=(null==A?void 0:A[3])||"",scriptName:c,nativeScriptName:c,nameWithRegionCode:w=r?u?"".concat(r," (").concat(u,")"):r:"",nativeNameWithRegionCode:t,emoji:S(t)}}}(t,e)},exports.isSameLanguage=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return g.apply(void 0,t)},exports.isValidLanguageCode=function(t){return f(t)},exports.renderContentToString=function(e,n,r,a){return function(e,n,r,a){if(void 0===n&&(n=s),void 0===r&&(r={}),void 0===a&&(a={}),"string"==typeof e&&(e=C(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 o;if("string"==typeof e)return e;if("object"==typeof e){var i=r[e.key];return e.variable?"number"===e.variable?h({value:i,languages:n,options:a[e.key]}):"currency"===e.variable?N(t(t({value:i,languages:n},a[e.key]&&{options:a[e.key]}),(null===(o=a[e.key])||void 0===o?void 0:o.currency)&&{currency:a[e.key].currency})):"datetime"===e.variable?b(t({value:i,languages:n},a[e.key]&&{options:a[e.key]})):"list"===e.variable?w(t({value:i,languages:n},a[e.key]&&{options:a[e.key]})):i:i}})).join("")}(e,n,r,a)},exports.requiresTranslation=function(t,e,n){return function(t,e,n){if(!e)return!1;if(p(e)===p(t))return!1;var r=new Intl.Locale(t),a=r.language,o=r.region,i=new Intl.Locale(e),u=i.language,c=i.region;return!(!(o&&c||!g(a,u))||n&&!n.some((function(t){return g(e,t)})))}(t,e,n)},exports.splitStringToContent=function(t){return C(t)},exports.standardizeLanguageCode=function(t){return p(t)};
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 a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},e.apply(this,arguments)};function t(e,t,n,r){return new(n||(n=Promise))((function(a,o){function i(e){try{c(r.next(e))}catch(e){o(e)}}function u(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))}function n(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=u(0),i.throw=u(1),i.return=u(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&u[0]?r.return:u[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,u[1])).done)return a;switch(r=0,a&&(u=[2&u[0],a.value]),u[0]){case 0:case 1:a=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(a=o.trys,(a=a.length>0&&a[a.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!a||u[1]>a[0]&&u[1]<a[3])){o.label=u[1];break}if(6===u[0]&&o.label<a[1]){o.label=a[1],a=u;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(u);break}a[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=a=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="/v1/translate/batch",a="/v1/translate/react",o="/v1/translate/content",i="/v1/project/dictionary/update",u="/v1/project/languages";function c(e,a){return t(this,void 0,void 0,(function(){var t,o,i,u,c,s,l,f,p;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,o=t.signal,(null===(p=null===(f=null===(l=a[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()}),a[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(a),signal:o})];case 1:return(i=n.sent()).ok?[3,3]:(u=Error.bind,s=(c="".concat(i.status,": ")).concat,[4,i.text()]);case 2:throw new(u.apply(Error,[void 0,s.apply(c,[n.sent()])]));case 3:return[4,i.json()];case 4:return[2,n.sent()]}}))}))}var s="en",l=["Cham","Jamo","Kawi","Lisu","Toto","Thai"],f=function(e){try{var t=new Intl.Locale(e),n=t.language,r=t.region,a=t.script;if(new Intl.DisplayNames([s],{type:"language"}).of(n)===n)return!1;if(r)if(new Intl.DisplayNames([s],{type:"region"}).of(r)===r)return!1;if(a)if(new Intl.DisplayNames([s],{type:"script"}).of(a)===a&&!l.includes(a))return!1;return!0}catch(e){return!1}},p=function(e){try{return Intl.getCanonicalLocales(e)[0]}catch(e){return""}};function g(){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}}function d(e,r,a,i){return t(this,void 0,void 0,(function(){var t,u,c,s,l,f;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,u=t.signal,i.timeout&&setTimeout((function(){return t.abort()}),i.timeout),[4,fetch("".concat(e.baseURL).concat(o),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({content:r,targetLanguage:a,metadata:i}),signal:u})];case 1:return(c=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(c.status,": ")).concat,[4,c.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,c.json()];case 4:return[2,n.sent()]}}))}))}function v(e,r,o,i){return t(this,void 0,void 0,(function(){var t,u,c,s,l,f;return n(this,(function(n){switch(n.label){case 0:return t=new AbortController,u=t.signal,i.timeout&&setTimeout((function(){return t.abort()}),i.timeout),[4,fetch("".concat(e.baseURL).concat(a),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({children:r,targetLanguage:o,metadata:i}),signal:u})];case 1:return(c=n.sent()).ok?[3,3]:(s=Error.bind,f=(l="".concat(c.status,": ")).concat,[4,c.text()]);case 2:throw new(s.apply(Error,[void 0,f.apply(l,[n.sent()])]));case 3:return[4,c.json()];case 4:return[2,n.sent()]}}))}))}function m(e,r,a,o){return t(this,void 0,void 0,(function(){var t,u,c,s,l;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(e.baseURL).concat(i),{method:"POST",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey},body:JSON.stringify({updates:r,languages:a,options:o})})];case 1:return(t=n.sent()).ok?[3,3]:(u=Error.bind,s=(c="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(u.apply(Error,[void 0,s.apply(c,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,null==(l=n.sent())?void 0:l.languages]}}))}))}function y(e,r){return t(this,void 0,void 0,(function(){var t,a,o,i,c;return n(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat(e.baseURL).concat(u,"?projectID=").concat(r),{method:"GET",headers:{"Content-Type":"application/json","gtx-api-key":e.apiKey}})];case 1:return(t=n.sent()).ok?[3,3]:(a=Error.bind,i=(o="".concat(t.status,": ")).concat,[4,t.text()]);case 2:throw new(a.apply(Error,[void 0,i.apply(o,[n.sent()])]));case 3:return[4,t.json()];case 4:return[2,null==(c=n.sent())?void 0:c.languages]}}))}))}function h(t){var n=t.value,r=t.languages,a=void 0===r?[s]:r,o=t.options,i=void 0===o?{}:o;return new Intl.NumberFormat(a,e({numberingSystem:"latn"},i)).format(n)}function b(t){var n=t.value,r=t.languages,a=void 0===r?[s]:r,o=t.options,i=void 0===o?{}:o;return new Intl.DateTimeFormat(a,e({calendar:"gregory",numberingSystem:"latn"},i)).format(n)}function N(t){var n=t.value,r=t.languages,a=void 0===r?[s]:r,o=t.currency,i=void 0===o?"USD":o,u=t.options,c=void 0===u?{}:u;return new Intl.NumberFormat(a,e({style:"currency",currency:i,numberingSystem:"latn"},c)).format(n)}function w(t){var n=t.value,r=t.languages,a=void 0===r?[s]:r,o=t.options,i=void 0===o?{}:o;return new Intl.ListFormat(a,e({type:"conjunction",style:"long"},i)).format(n)}var L={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=[],a=/{([^}]+)}/g,o=0;null!==(n=a.exec(t));){var i=n[0],u=n[1],c=n.index;if("^"!==t[c-1]){c>o&&r.push(t.slice(o,c));var s=u.split(",").map((function(e){return e.trim()})),l=s[0],f=s[1]?L[s[1]]:void 0,p=e({key:l},f&&{variable:f});r.push(p),o=c+i.length}else c-1>o&&r.push(t.slice(o,c-1)),r.push(i),o=c+i.length}return o<t.length&&r.push(t.slice(o)),r}function S(e,t){if(void 0===t&&(t={}),!f(e))return I;var n=new Intl.Locale(e);if(t[e=n.toString()])return t[e];var r=n.region;if(r&&M[r])return M[r];var a=n.maximize(),o=a.region||"";return x[a.language]||M[o]||I}var T="🌍",I=T,x={ca:T,eu:T,ku:T,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:"🇪🇺"};var E=function(e){return"undefined"!=typeof process&&process.env&&process.env[e]||""},R=function(){function r(e){var t=void 0===e?{}:e,n=t.apiKey,r=void 0===n?"":n,a=t.defaultLanguage,o=void 0===a?s:a,i=t.projectID,u=void 0===i?"":i,c=t.baseURL,l=void 0===c?"https://prod.gtx.dev":c;this.apiKey=r||E("GT_API_KEY"),this.projectID=u||E("GT_PROJECT_ID"),this.defaultLanguage=o.toLowerCase(),this.baseURL=l}return r.prototype.translate=function(r,a,o){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,d(this,r,a,e({defaultLanguage:this.defaultLanguage},o))];case 1:return[2,t.sent()]}}))}))},r.prototype.translateReact=function(r,a,o){return t(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,v(this,r,a,e({defaultLanguage:this.defaultLanguage},o))];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,c(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,m(this,e,t,r)]}))}))},r.prototype.getProjectLanguages=function(e){return t(this,void 0,void 0,(function(){return n(this,(function(t){return[2,y(this,e||this.projectID)]}))}))},r}();exports.default=R,exports.determineLanguage=function(e,t){return function(e,t){if("string"==typeof e&&(e=[e]),!t)return e[0];for(var n=function(e){var n=t.find((function(t){return t===e}));if(n)return{value:n};var r=t.find((function(t){return g(t,e)}));return r?{value:r}:void 0},r=0,a=e;r<a.length;r++){var o=n(a[r]);if("object"==typeof o)return o.value}}(e,t)},exports.formatCurrency=function(e){return N(e)},exports.formatDateTime=function(e){return b(e)},exports.formatList=function(e){return w(e)},exports.formatNum=function(e){return h(e)},exports.formatRelativeTime=function(t){return r=(n=t).value,a=n.unit,o=n.languages,i=void 0===o?[s]:o,u=n.options,c=void 0===u?{}:u,new Intl.RelativeTimeFormat(i,e({style:"long",numeric:"auto"},c)).format(r,a);var n,r,a,o,i,u,c},exports.getLanguageDirection=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.getLanguageEmoji=function(e,t){return S(e,t)},exports.getLanguageName=function(e,t){return void 0===t&&(t=s),function(e,t){void 0===t&&(t=s);try{return new Intl.DisplayNames([t,s],{type:"language"}).of(e)||""}catch(e){return""}}(e,t)},exports.getLanguageNames=function(e,t){return function(e,t){void 0===t&&(t=s);try{var n=new Intl.Locale(e);e=n.toString();var r=n.language,a=n.region,o=new Intl.Locale(e).maximize(),i=o.toString(),u=o.region||"",c=o.script||"",l=new Intl.Locale(e).minimize().toString(),f=new Intl.DisplayNames([t,e,s],{type:"language"}),p=new Intl.DisplayNames([e,t,s],{type:"language"}),g=f.of(e)||e,d=p.of(e)||e,v=f.of(i)||e,m=p.of(i)||e,y=f.of(l)||e,h=p.of(l)||e,b=f.of(r)||e,N=p.of(r)||e,w=a?"".concat(b," (").concat(a,")"):b,L=a?"".concat(N," (").concat(a,")"):N,C=new Intl.DisplayNames([t,e,s],{type:"region"}),T=new Intl.DisplayNames([e,t,s],{type:"region"}),I=C.of(u)||"",x=T.of(u)||"",M=new Intl.DisplayNames([t,e,s],{type:"script"}),E=new Intl.DisplayNames([e,t,s],{type:"script"});return{code:e,name:g,nativeName:d,maximizedCode:i,maximizedName:v,nativeMaximizedName:m,minimizedCode:l,minimizedName:y,nativeMinimizedName:h,languageCode:r,languageName:b,nativeLanguageName:N,nameWithRegionCode:w,nativeNameWithRegionCode:L,regionCode:u,regionName:I,nativeRegionName:x,scriptCode:c,scriptName:M.of(c)||"",nativeScriptName:E.of(c)||"",emoji:S(e)}}catch(t){e||(e="");var R=null==e?void 0:e.split("-");return{code:e,name:e,nativeName:e,maximizedCode:e,maximizedName:e,nativeMaximizedName:e,minimizedCode:e,minimizedName:e,nativeMinimizedName:e,languageCode:r=(null==R?void 0:R[0])||e||"",languageName:r,nativeLanguageName:r,regionCode:u=R.length>2?null==R?void 0:R[2]:(null==R?void 0:R[1])||"",regionName:u,nativeRegionName:u,scriptCode:c=(null==R?void 0:R[3])||"",scriptName:c,nativeScriptName:c,nameWithRegionCode:w=r?u?"".concat(r," (").concat(u,")"):r:"",nativeNameWithRegionCode:e,emoji:S(e)}}}(e,t)},exports.isSameLanguage=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return g.apply(void 0,e)},exports.isValidLanguageCode=function(e){return f(e)},exports.renderContentToString=function(t,n,r,a){return function(t,n,r,a){if(void 0===n&&(n=s),void 0===r&&(r={}),void 0===a&&(a={}),"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 o;if("string"==typeof t)return t;if("object"==typeof t){var i=r[t.key];return t.variable?"number"===t.variable?h({value:i,languages:n,options:a[t.key]}):"currency"===t.variable?N(e(e({value:i,languages:n},a[t.key]&&{options:a[t.key]}),(null===(o=a[t.key])||void 0===o?void 0:o.currency)&&{currency:a[t.key].currency})):"datetime"===t.variable?b(e({value:i,languages:n},a[t.key]&&{options:a[t.key]})):"list"===t.variable?w(e({value:i,languages:n},a[t.key]&&{options:a[t.key]})):i:i}})).join("")}(t,n,r,a)},exports.requiresTranslation=function(e,t,n){return function(e,t,n){if(!t)return!1;if(p(t)===p(e))return!1;var r=new Intl.Locale(e),a=r.language,o=r.region,i=new Intl.Locale(t),u=i.language,c=i.region;return!(!(o&&c||!g(a,u))||n&&!n.some((function(e){return g(t,e)})))}(e,t,n)},exports.splitStringToContent=function(e){return C(e)},exports.standardizeLanguageCode=function(e){return p(e)};
2
2
  //# sourceMappingURL=index.cjs.min.cjs.map