@tolgee/core 1.4.0 → 1.6.1
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.
- package/dist/tolgee.cjs.js +253 -171
- package/dist/tolgee.cjs.js.map +1 -1
- package/dist/tolgee.cjs.min.js +1 -1
- package/dist/tolgee.cjs.min.js.map +1 -1
- package/dist/tolgee.umd.js +253 -171
- package/dist/tolgee.umd.js.map +1 -1
- package/dist/tolgee.umd.min.js +16 -0
- package/dist/tolgee.umd.min.js.map +1 -0
- package/lib/Tolgee.d.ts +5 -3
- package/lib/Tolgee.js +51 -28
- package/lib/Tolgee.js.map +1 -1
- package/lib/TolgeeConfig.d.ts +2 -2
- package/lib/services/TextService.d.ts +3 -3
- package/lib/services/TextService.js +106 -24
- package/lib/services/TextService.js.map +1 -1
- package/lib/services/TranslationService.d.ts +3 -2
- package/lib/services/TranslationService.js +53 -77
- package/lib/services/TranslationService.js.map +1 -1
- package/lib/types.d.ts +18 -2
- package/package.json +2 -2
package/dist/tolgee.cjs.min.js
CHANGED
|
@@ -13,5 +13,5 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};function t(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return(r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function n(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))}function i(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function o(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function a(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var u,c=function(){function e(){}return e.evaluateGenerator=function(e,t){var r,n;return i(this,(function(i){switch(i.label){case 0:n=document.evaluate(e,t,void 0,XPathResult.ANY_TYPE),i.label=1;case 1:return null===(r=n.iterateNext())?[3,3]:[4,r];case 2:return i.sent(),[3,1];case 3:return[2]}}))},e.evaluate=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Array.from(this.evaluateGenerator.apply(this,a([],s(e))))},e.evaluateToSingle=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this.evaluate.apply(this,a([],s(e)));if(1===r.length)return r[0];if(r.length<1)throw new Error("No element found");throw new Error("Multiple elements found")},e.closestElement=function(e){return e instanceof Text?e.parentElement:e},e.getParentElement=function(e){return e.parentElement?e.parentElement:e.ownerElement?e.ownerElement:void 0},e.isElementTargetElement=function(e){return e.hasAttribute("_tolgee-target")},e.markElementAsTargetElement=function(e){e.setAttribute("_tolgee-target","")},e.unmarkElementAsTargetElement=function(e){e.removeAttribute("_tolgee-target")},e.nodeContains=function(e,t){if(e.contains(t))return!0;if(t instanceof Attr){var r=Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&r)return!0}return!1},e}();exports.ModifierKey=void 0,(u=exports.ModifierKey||(exports.ModifierKey={}))[u.Alt=0]="Alt",u[u.Control=1]="Control",u[u.Shift=2]="Shift",u[u.Meta=3]="Meta";var l,h,p,f=function(){if("undefined"!=typeof document)return document.body},g=function(e){this.apiUrl="https://app.tolgee.io",this.inputPrefix="%-%tolgee:",this.inputSuffix="%-%",this.defaultLanguage="en",this.filesUrlPrefix="i18n/",this.tagAttributes={textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},this.highlightKeys=[exports.ModifierKey.Alt],this.passToParent=["option","optgroup"],this.restrictedElements=["script","style"],this.highlightColor="rgb(224 240 255)",this.preloadFallback=!1,Object.defineProperty(this,"targetElement",{set:function(e){if(void 0!==this.targetElement)throw new Error("Target element is already defined!");if(void 0===e&&(this._targetElement=f()),c.isElementTargetElement(e))throw console.error("Target element: ",this._targetElement),new Error("An tolgee instance is inited with provided target element");this._targetElement=e,c.markElementAsTargetElement(this._targetElement)},get:function(){return this._targetElement}}),Object.assign(this,e||{}),void 0===this._targetElement&&(this._targetElement=f()),this.mode=this.mode||(this.apiKey?"development":"production"),this.fallbackLanguage=this.fallbackLanguage||this.defaultLanguage,void 0===this.watch&&(this.watch="development"===this.mode)},d=function(){function e(){}return Object.defineProperty(e.prototype,"currentLanguage",{get:function(){var e;if(this.config.forceLanguage)return this.config.forceLanguage;"undefined"!=typeof localStorage?(e=localStorage.getItem("__tolgee_currentLanguage"),this.config.availableLanguages&&(this.config.availableLanguages.indexOf(e)>-1||(e=void 0))):e=this._currentLanguage;return e||(e=this.getLanguageByNavigator(),this.currentLanguage=e),e},set:function(e){"undefined"!=typeof localStorage?localStorage.setItem("__tolgee_currentLanguage",e):this._currentLanguage=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"preferredLanguages",{get:function(){return new Set(JSON.parse(localStorage.getItem("__tolgee_preferredLanguages")))},set:function(e){localStorage.setItem("__tolgee_preferredLanguages",JSON.stringify(Array.from(e)))},enumerable:!1,configurable:!0}),e.prototype.getLanguageByNavigator=function(){if("undefined"!=typeof window&&this.config.availableLanguages){var e=window.navigator.language,t=this.config.availableLanguages.find((function(t){return t===e}));if(t)return t;var r=function(e){return e.replace(/^(.+?)(-.*)?$/,"$1")},n=r(window.navigator.language),i=this.config.availableLanguages.find((function(e){return r(e)===n}));if(i)return i}return this.config.defaultLanguage},e}(),v=function(){function e(e){this.onUnsubscribe=e}return e.prototype.unsubscribe=function(){this.onUnsubscribe()},e}(),y=function(){function e(){this.idCounter=0,this._subscriptions=new Map}return Object.defineProperty(e.prototype,"subscriptions",{get:function(){return this._subscriptions},enumerable:!1,configurable:!0}),e.prototype.emit=function(e){var t,r,n=[];try{for(var i=o(this.subscriptions.values()),s=i.next();!s.done;s=i.next()){var a=(0,s.value)(e);"function"==typeof(null==a?void 0:a.then)&&n.push(a)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}if(0!==n.length)return new Promise((function(e){return Promise.all(n).then((function(){return e()}))}))},e.prototype.subscribe=function(e){var t=this,r=this.idCounter++,n=new v((function(){return t.unsubscribe(r)}));return this.subscriptions.set(r,e),n},e.prototype.unsubscribe=function(e){this._subscriptions.delete(e)||console.warn("Event to unsubscribe was not found")},e}(),m=function(){this.TRANSLATION_CHANGED=new y,this.LANGUAGE_CHANGED=new y,this.LANGUAGE_LOADED=new y,this.ELEMENT_REGISTERED=new y},E=function(e){function r(t,n){var i=e.call(this,"Api http error")||this;return i.response=t,i.code=n,Object.setPrototypeOf(i,r.prototype),i}return t(r,e),r}(Error),b=function(){function e(e){this.properties=e}return e.handleErrors=function(e){return n(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:if(!(e.status>=400))return[3,5];t=new E(e),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,e.json()];case 2:return r=n.sent(),t.code=r.code,[3,4];case 3:return n.sent(),console.warn("Tolgee server responded with invalid status code."),[3,4];case 4:throw t;case 5:return[2,e]}}))}))},e.prototype.fetch=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return n(this,void 0,void 0,(function(){var n,o,u;return i(this,(function(i){switch(i.label){case 0:return"object"!=typeof t[0]?[3,2]:[4,fetch(r(r({},t[0]),{url:this.getUrl(t[0].url)})).then((function(t){return e.handleErrors(t)}))];case 1:return[2,i.sent()];case 2:return n=s(t),o=n[0],u=n.slice(1),[4,fetch.apply(void 0,a([this.getUrl(o)],s(u))).then((function(t){return e.handleErrors(t)}))];case 3:return[2,i.sent()]}}))}))},e.prototype.fetchJson=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.fetch.apply(this,a([],s(e))).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},e.prototype.post=function(e,t,o){void 0===o&&(o={});for(var u=[],c=3;c<arguments.length;c++)u[c-3]=arguments[c];return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.fetch.apply(this,a([e,r({body:JSON.stringify(t),method:"POST",headers:{"Content-Type":"application/json"}},o)],s(u)))];case 1:return[2,n.sent()]}}))}))},e.prototype.postJson=function(e,t,r){void 0===r&&(r={});for(var o=[],u=3;u<arguments.length;u++)o[u-3]=arguments[u];return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.post.apply(this,a([e,t,r],s(o))).then((function(e){return e.json()}))];case 1:return[2,n.sent()]}}))}))},e.prototype.getUrl=function(e){var t=e.indexOf("?")<0?"?":"&";return this.properties.config.apiUrl+"/"+e+t+"ak="+this.properties.config.apiKey},e}(),_=function(e,t,r){this.key=e,this.translations=t,this.id=r},T=function(){function e(){}return e.splitOnNonEscapedDelimiter=function(e,t){for(var r=[],n="",i=!1,o=0;o<e.length;o++){var s=e[o];"\\"!==s||i?i?(i=!1,n+=s):s!==t?n+=s:(r.push(n),n=""):i=!0}return r.push(n),r},e.isCharEscaped=function(e,t){for(var r=0;e>-1&&"\\"===t[e-1];)r++,e--;return r%2==1},e.removeEscapes=function(e){for(var t="",r=!1,n=0;n<e.length;n++){var i=e[n];"\\"!==i||r?r?(r=!1,t+=i):t+=i:r=!0}return t},e}(),w=function(){function e(e,t,o,u){var c=this;this.properties=e,this.coreService=t,this.apiHttpService=o,this.eventService=u,this.translationsCache=new Map,this.fetchPromises={},this.getTranslationsOfKey=function(e,t){return void 0===t&&(t=new Set([c.properties.currentLanguage])),n(c,void 0,void 0,(function(){var n,o,u,c,l,h,p,f,g,d,v,y;return i(this,(function(i){switch(i.label){case 0:this.coreService.checkScope("translations.view"),i.label=1;case 1:return i.trys.push([1,3,,7]),n=a([],s(t)),o=n.map((function(e){return"languages="+e})).join("&"),[4,this.apiHttpService.fetchJson("v2/projects/translations?"+o+"&filterKeyName="+encodeURIComponent(e))];case 2:return u=i.sent(),c=n.reduce((function(e,t){var n;return r(r({},e),((n={})[t]="",n))}),{}),l=null===(g=null===(f=u._embedded)||void 0===f?void 0:f.keys)||void 0===g?void 0:g[0],(null==l?void 0:l.translations)&&Object.entries(null===(y=null===(v=null===(d=u._embedded)||void 0===d?void 0:d.keys)||void 0===v?void 0:v[0])||void 0===y?void 0:y.translations).forEach((function(e){var t=s(e,2),r=t[0],n=t[1];return c[r]=n.text})),[2,new _(e,c,null==l?void 0:l.keyId)];case 3:return(h=i.sent())instanceof E&&404===h.response.status&&"language_not_found"===h.code?(p=this.properties,[4,this.coreService.getLanguages()]):[3,5];case 4:return p.preferredLanguages=i.sent(),console.error("Requested language not found, refreshing the page!"),location.reload(),[3,6];case 5:throw h;case 6:return[3,7];case 7:return[2]}}))}))}}return e.translationByValue=function(e,t,r){if(e)return e;if(r)return"";var n=T.splitOnNonEscapedDelimiter(t,".");return n[n.length-1]},e.prototype.initStatic=function(){var e,t=this;"production"===this.properties.config.mode&&"object"==typeof(null===(e=this.properties.config)||void 0===e?void 0:e.staticData)&&Object.entries(this.properties.config.staticData).forEach((function(e){var r=s(e,2),n=r[0],i=r[1];"function"!=typeof i&&t.translationsCache.set(n,i)}))},e.prototype.loadTranslations=function(e){return void 0===e&&(e=this.properties.currentLanguage),n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return null!=this.translationsCache.get(e)?[3,2]:(this.fetchPromises[e]instanceof Promise||(this.fetchPromises[e]=this.fetchTranslations(e)),[4,this.fetchPromises[e]]);case 1:t.sent(),this.eventService.LANGUAGE_LOADED.emit(e),t.label=2;case 2:return this.fetchPromises[e]=void 0,[2]}}))}))},e.prototype.getTranslation=function(t,r,o){return void 0===r&&(r=this.properties.currentLanguage),void 0===o&&(o=!1),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return(n=this.getFromCache(t,r))?[3,3]:[4,this.loadTranslations(r)];case 1:return i.sent(),(n=this.getFromCache(t,r))?[3,3]:(n=this.getFromCache(t,this.properties.config.fallbackLanguage))?[3,3]:[4,this.loadTranslations(this.properties.config.fallbackLanguage)];case 2:i.sent(),n=this.getFromCache(t,this.properties.config.fallbackLanguage),i.label=3;case 3:return[2,e.translationByValue(n,t,o)]}}))}))},e.prototype.setTranslations=function(e){return n(this,void 0,void 0,(function(){var t,r=this;return i(this,(function(n){switch(n.label){case 0:return this.coreService.checkScope("translations.edit"),[4,this.apiHttpService.postJson("v2/projects/translations",{key:e.key,translations:e.translations})];case 1:return t=n.sent(),Object.keys(e.translations).forEach((function(t){if(r.translationsCache.get(t))for(var n=T.splitOnNonEscapedDelimiter(e.key,"."),i=r.translationsCache.get(t),o=0;o<n.length;o++){var s=n[o];if(void 0===i[s]&&(i[s]={}),o===n.length-1)return void(i[s]=e.translations[t]);i=i[s]}})),[2,t]}}))}))},e.prototype.uploadScreenshot=function(e,t){return n(this,void 0,void 0,(function(){var r,n;return i(this,(function(i){switch(i.label){case 0:return this.coreService.checkScope("translations.edit"),r=new FormData,[4,fetch(t).then((function(e){return e.blob()}))];case 1:return n=i.sent(),r.append("screenshot",n),[2,this.apiHttpService.post("v2/projects/keys/"+e+"/screenshots",void 0,{headers:{},body:r})]}}))}))},e.prototype.getFromCacheOrFallback=function(t,r,n){void 0===r&&(r=this.properties.currentLanguage),void 0===n&&(n=!1);var i=this.getFromCache(t,r)||this.getFromCache(t,this.properties.config.fallbackLanguage);return e.translationByValue(i,t,n)},e.prototype.fetchTranslations=function(e){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"development"!==this.properties.config.mode?[3,2]:[4,this.fetchTranslationsDevelopment(e)];case 1:return[2,t.sent()];case 2:return[4,this.fetchTranslationsProduction(e)];case 3:return[2,t.sent()]}}))}))},e.prototype.fetchTranslationsProduction=function(e){var t,r;return n(this,void 0,void 0,(function(){var n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return"function"!=typeof(n=null===(r=null===(t=this.properties.config)||void 0===t?void 0:t.staticData)||void 0===r?void 0:r[e])?[3,2]:[4,n()];case 1:return a=i.sent(),this.translationsCache.set(e,a),[2];case 2:if(void 0!==n)return this.translationsCache.set(e,n),[2];i.label=3;case 3:o=""+(this.properties.config.filesUrlPrefix||"/")+e+".json",i.label=4;case 4:return i.trys.push([4,10,,11]),[4,fetch(o)];case 5:if((s=i.sent()).status>=400)return console.error("Server responded with error status while loading localization data."),this.translationsCache.set(e,{}),[2];i.label=6;case 6:return i.trys.push([6,8,,9]),[4,s.json()];case 7:return a=i.sent(),this.translationsCache.set(e,a),[3,9];case 8:return i.sent(),console.error("Error parsing json retrieved from "+o+"."),this.setEmptyLanguageData(e),[3,9];case 9:return[3,11];case 10:return i.sent(),console.error("Error fetching localization data from "+o+"."),this.setEmptyLanguageData(e),[3,11];case 11:return[2]}}))}))},e.prototype.fetchTranslationsDevelopment=function(e){return n(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:this.coreService.checkScope("translations.view"),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.apiHttpService.fetchJson("v2/projects/translations/"+e)];case 2:return t=n.sent(),this.translationsCache.set(e,t[e]||{}),[3,4];case 3:return r=n.sent(),console.error("Error while fetching localization data from API.",r),this.setEmptyLanguageData(e),[2];case 4:return[2]}}))}))},e.prototype.setEmptyLanguageData=function(e){this.translationsCache.set(e,{})},e.prototype.getFromCache=function(e,t){var r,n;void 0===t&&(t=this.properties.currentLanguage);var i=T.splitOnNonEscapedDelimiter(e,"."),s=this.translationsCache.get(t);if(void 0!==s){if("string"==typeof s[e])return s[e];try{for(var a=o(i),u=a.next();!u.done;u=a.next()){var c=u.value;if(void 0===s[c])return;s=s[c]}}catch(e){r={error:e}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return s}},e}();function S(e){return e.type===h.literal}function L(e){return e.type===h.argument}function A(e){return e.type===h.number}function P(e){return e.type===h.date}function O(e){return e.type===h.time}function N(e){return e.type===h.select}function C(e){return e.type===h.plural}function R(e){return e.type===h.pound}function I(e){return e.type===h.tag}function k(e){return!(!e||"object"!=typeof e||e.type!==p.number)}function U(e){return!(!e||"object"!=typeof e||e.type!==p.dateTime)}!function(e){e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG"}(l||(l={})),function(e){e[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural",e[e.pound=7]="pound",e[e.tag=8]="tag"}(h||(h={})),function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"}(p||(p={}));var D=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,M=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function x(e){var t={};return e.replace(M,(function(e){var r=e.length;switch(e[0]){case"G":t.era=4===r?"long":5===r?"narrow":"short";break;case"y":t.year=2===r?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":t.month=["numeric","2-digit","short","long","narrow"][r-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":t.day=["numeric","2-digit"][r-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":t.weekday=4===r?"short":5===r?"narrow":"short";break;case"e":if(r<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"c":if(r<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"a":t.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":t.hourCycle="h12",t.hour=["numeric","2-digit"][r-1];break;case"H":t.hourCycle="h23",t.hour=["numeric","2-digit"][r-1];break;case"K":t.hourCycle="h11",t.hour=["numeric","2-digit"][r-1];break;case"k":t.hourCycle="h24",t.hour=["numeric","2-digit"][r-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":t.minute=["numeric","2-digit"][r-1];break;case"s":t.second=["numeric","2-digit"][r-1];break;case"S":case"A":throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");case"z":t.timeZoneName=r<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return""})),t}var G=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;var F,H=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,j=/^(@+)?(\+|#+)?$/g,K=/(\*)(0+)|(#+)(0+)|(0+)/g,V=/^(0+)$/;function X(e){var t={};return e.replace(j,(function(e,r,n){return"string"!=typeof n?(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length):"+"===n?t.minimumSignificantDigits=r.length:"#"===r[0]?t.maximumSignificantDigits=r.length:(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length+("string"==typeof n?n.length:0)),""})),t}function B(e){switch(e){case"sign-auto":return{signDisplay:"auto"};case"sign-accounting":case"()":return{currencySign:"accounting"};case"sign-always":case"+!":return{signDisplay:"always"};case"sign-accounting-always":case"()!":return{signDisplay:"always",currencySign:"accounting"};case"sign-except-zero":case"+?":return{signDisplay:"exceptZero"};case"sign-accounting-except-zero":case"()?":return{signDisplay:"exceptZero",currencySign:"accounting"};case"sign-never":case"+_":return{signDisplay:"never"}}}function Y(e){var t;if("E"===e[0]&&"E"===e[1]?(t={notation:"engineering"},e=e.slice(2)):"E"===e[0]&&(t={notation:"scientific"},e=e.slice(1)),t){var r=e.slice(0,2);if("+!"===r?(t.signDisplay="always",e=e.slice(2)):"+?"===r&&(t.signDisplay="exceptZero",e=e.slice(2)),!V.test(e))throw new Error("Malformed concise eng/scientific notation");t.minimumIntegerDigits=e.length}return t}function z(e){var t=B(e);return t||{}}function W(e){for(var t={},n=0,i=e;n<i.length;n++){var o=i[n];switch(o.stem){case"percent":case"%":t.style="percent";continue;case"%x100":t.style="percent",t.scale=100;continue;case"currency":t.style="currency",t.currency=o.options[0];continue;case"group-off":case",_":t.useGrouping=!1;continue;case"precision-integer":case".":t.maximumFractionDigits=0;continue;case"measure-unit":case"unit":t.style="unit",t.unit=o.options[0].replace(/^(.*?)-/,"");continue;case"compact-short":case"K":t.notation="compact",t.compactDisplay="short";continue;case"compact-long":case"KK":t.notation="compact",t.compactDisplay="long";continue;case"scientific":t=r(r(r({},t),{notation:"scientific"}),o.options.reduce((function(e,t){return r(r({},e),z(t))}),{}));continue;case"engineering":t=r(r(r({},t),{notation:"engineering"}),o.options.reduce((function(e,t){return r(r({},e),z(t))}),{}));continue;case"notation-simple":t.notation="standard";continue;case"unit-width-narrow":t.currencyDisplay="narrowSymbol",t.unitDisplay="narrow";continue;case"unit-width-short":t.currencyDisplay="code",t.unitDisplay="short";continue;case"unit-width-full-name":t.currencyDisplay="name",t.unitDisplay="long";continue;case"unit-width-iso-code":t.currencyDisplay="symbol";continue;case"scale":t.scale=parseFloat(o.options[0]);continue;case"integer-width":if(o.options.length>1)throw new RangeError("integer-width stems only accept a single optional option");o.options[0].replace(K,(function(e,r,n,i,o,s){if(r)t.minimumIntegerDigits=n.length;else{if(i&&o)throw new Error("We currently do not support maximum integer digits");if(s)throw new Error("We currently do not support exact integer digits")}return""}));continue}if(V.test(o.stem))t.minimumIntegerDigits=o.stem.length;else if(H.test(o.stem)){if(o.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");o.stem.replace(H,(function(e,r,n,i,o,s){return"*"===n?t.minimumFractionDigits=r.length:i&&"#"===i[0]?t.maximumFractionDigits=i.length:o&&s?(t.minimumFractionDigits=o.length,t.maximumFractionDigits=o.length+s.length):(t.minimumFractionDigits=r.length,t.maximumFractionDigits=r.length),""})),o.options.length&&(t=r(r({},t),X(o.options[0])))}else if(j.test(o.stem))t=r(r({},t),X(o.stem));else{var s=B(o.stem);s&&(t=r(r({},t),s));var a=Y(o.stem);a&&(t=r(r({},t),a))}}return t}var J=new RegExp("^"+D.source+"*"),q=new RegExp(D.source+"*$");function Z(e,t){return{start:e,end:t}}var $=!!String.prototype.startsWith,Q=!!String.fromCodePoint,ee=!!Object.fromEntries,te=!!String.prototype.codePointAt,re=!!String.prototype.trimStart,ne=!!String.prototype.trimEnd,ie=!!Number.isSafeInteger?Number.isSafeInteger:function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991},oe=!0;try{oe="a"===(null===(F=fe("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu").exec("a"))||void 0===F?void 0:F[0])}catch(e){oe=!1}var se,ae=$?function(e,t,r){return e.startsWith(t,r)}:function(e,t,r){return e.slice(r,r+t.length)===t},ue=Q?String.fromCodePoint:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r,n="",i=e.length,o=0;i>o;){if((r=e[o++])>1114111)throw RangeError(r+" is not a valid code point");n+=r<65536?String.fromCharCode(r):String.fromCharCode(55296+((r-=65536)>>10),r%1024+56320)}return n},ce=ee?Object.fromEntries:function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r],o=i[0],s=i[1];t[o]=s}return t},le=te?function(e,t){return e.codePointAt(t)}:function(e,t){var r=e.length;if(!(t<0||t>=r)){var n,i=e.charCodeAt(t);return i<55296||i>56319||t+1===r||(n=e.charCodeAt(t+1))<56320||n>57343?i:n-56320+(i-55296<<10)+65536}},he=re?function(e){return e.trimStart()}:function(e){return e.replace(J,"")},pe=ne?function(e){return e.trimEnd()}:function(e){return e.replace(q,"")};function fe(e,t){return new RegExp(e,t)}if(oe){var ge=fe("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");se=function(e,t){var r;return ge.lastIndex=t,null!==(r=ge.exec(e)[1])&&void 0!==r?r:""}}else se=function(e,t){for(var r=[];;){var n=le(e,t);if(void 0===n||ye(n)||me(n))break;r.push(n),t+=n>=65536?2:1}return ue.apply(void 0,r)};var de=function(){function e(e,t){void 0===t&&(t={}),this.message=e,this.position={offset:0,line:1,column:1},this.ignoreTag=!!t.ignoreTag,this.requiresOtherClause=!!t.requiresOtherClause,this.shouldParseSkeletons=!!t.shouldParseSkeletons}return e.prototype.parse=function(){if(0!==this.offset())throw Error("parser can only be used once");return this.parseMessage(0,"",!1)},e.prototype.parseMessage=function(e,t,r){for(var n=[];!this.isEOF();){var i=this.char();if(123===i){if((o=this.parseArgument(e,r)).err)return o;n.push(o.val)}else{if(125===i&&e>0)break;if(35!==i||"plural"!==t&&"selectordinal"!==t){if(60===i&&!this.ignoreTag&&47===this.peek()){if(r)break;return this.error(l.UNMATCHED_CLOSING_TAG,Z(this.clonePosition(),this.clonePosition()))}if(60===i&&!this.ignoreTag&&ve(this.peek()||0)){if((o=this.parseTag(e,t)).err)return o;n.push(o.val)}else{var o;if((o=this.parseLiteral(e,t)).err)return o;n.push(o.val)}}else{var s=this.clonePosition();this.bump(),n.push({type:h.pound,location:Z(s,this.clonePosition())})}}}return{val:n,err:null}},e.prototype.parseTag=function(e,t){var r=this.clonePosition();this.bump();var n=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:h.literal,value:"<"+n+"/>",location:Z(r,this.clonePosition())},err:null};if(this.bumpIf(">")){var i=this.parseMessage(e+1,t,!0);if(i.err)return i;var o=i.val,s=this.clonePosition();if(this.bumpIf("</")){if(this.isEOF()||!ve(this.char()))return this.error(l.INVALID_TAG,Z(s,this.clonePosition()));var a=this.clonePosition();return n!==this.parseTagName()?this.error(l.UNMATCHED_CLOSING_TAG,Z(a,this.clonePosition())):(this.bumpSpace(),this.bumpIf(">")?{val:{type:h.tag,value:n,children:o,location:Z(r,this.clonePosition())},err:null}:this.error(l.INVALID_TAG,Z(s,this.clonePosition())))}return this.error(l.UNCLOSED_TAG,Z(r,this.clonePosition()))}return this.error(l.INVALID_TAG,Z(r,this.clonePosition()))},e.prototype.parseTagName=function(){var e,t=this.offset();for(this.bump();!this.isEOF()&&(45===(e=this.char())||46===e||e>=48&&e<=57||95===e||e>=97&&e<=122||e>=65&&e<=90||183==e||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039);)this.bump();return this.message.slice(t,this.offset())},e.prototype.parseLiteral=function(e,t){for(var r=this.clonePosition(),n="";;){var i=this.tryParseQuote(t);if(i)n+=i;else{var o=this.tryParseUnquoted(e,t);if(o)n+=o;else{var s=this.tryParseLeftAngleBracket();if(!s)break;n+=s}}}var a=Z(r,this.clonePosition());return{val:{type:h.literal,value:n,location:a},err:null}},e.prototype.tryParseLeftAngleBracket=function(){return this.isEOF()||60!==this.char()||!this.ignoreTag&&(ve(e=this.peek()||0)||47===e)?null:(this.bump(),"<");var e},e.prototype.tryParseQuote=function(e){if(this.isEOF()||39!==this.char())return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if("plural"===e||"selectordinal"===e)break;return null;default:return null}this.bump();var t=[this.char()];for(this.bump();!this.isEOF();){var r=this.char();if(39===r){if(39!==this.peek()){this.bump();break}t.push(39),this.bump()}else t.push(r);this.bump()}return ue.apply(void 0,t)},e.prototype.tryParseUnquoted=function(e,t){if(this.isEOF())return null;var r=this.char();return 60===r||123===r||35===r&&("plural"===t||"selectordinal"===t)||125===r&&e>0?null:(this.bump(),ue(r))},e.prototype.parseArgument=function(e,t){var r=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(l.EXPECT_ARGUMENT_CLOSING_BRACE,Z(r,this.clonePosition()));if(125===this.char())return this.bump(),this.error(l.EMPTY_ARGUMENT,Z(r,this.clonePosition()));var n=this.parseIdentifierIfPossible().value;if(!n)return this.error(l.MALFORMED_ARGUMENT,Z(r,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(l.EXPECT_ARGUMENT_CLOSING_BRACE,Z(r,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:h.argument,value:n,location:Z(r,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(l.EXPECT_ARGUMENT_CLOSING_BRACE,Z(r,this.clonePosition())):this.parseArgumentOptions(e,t,n,r);default:return this.error(l.MALFORMED_ARGUMENT,Z(r,this.clonePosition()))}},e.prototype.parseIdentifierIfPossible=function(){var e=this.clonePosition(),t=this.offset(),r=se(this.message,t),n=t+r.length;return this.bumpTo(n),{value:r,location:Z(e,this.clonePosition())}},e.prototype.parseArgumentOptions=function(e,t,n,i){var o,s=this.clonePosition(),a=this.parseIdentifierIfPossible().value,u=this.clonePosition();switch(a){case"":return this.error(l.EXPECT_ARGUMENT_TYPE,Z(s,u));case"number":case"date":case"time":this.bumpSpace();var c=null;if(this.bumpIf(",")){this.bumpSpace();var f=this.clonePosition();if((b=this.parseSimpleArgStyleIfPossible()).err)return b;if(0===(v=pe(b.val)).length)return this.error(l.EXPECT_ARGUMENT_STYLE,Z(this.clonePosition(),this.clonePosition()));c={style:v,styleLocation:Z(f,this.clonePosition())}}if((_=this.tryParseArgumentClose(i)).err)return _;var g=Z(i,this.clonePosition());if(c&&ae(null==c?void 0:c.style,"::",0)){var d=he(c.style.slice(2));if("number"===a)return(b=this.parseNumberSkeletonFromString(d,c.styleLocation)).err?b:{val:{type:h.number,value:n,location:g,style:b.val},err:null};if(0===d.length)return this.error(l.EXPECT_DATE_TIME_SKELETON,g);var v={type:p.dateTime,pattern:d,location:c.styleLocation,parsedOptions:this.shouldParseSkeletons?x(d):{}};return{val:{type:"date"===a?h.date:h.time,value:n,location:g,style:v},err:null}}return{val:{type:"number"===a?h.number:"date"===a?h.date:h.time,value:n,location:g,style:null!==(o=null==c?void 0:c.style)&&void 0!==o?o:null},err:null};case"plural":case"selectordinal":case"select":var y=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(l.EXPECT_SELECT_ARGUMENT_OPTIONS,Z(y,r({},y)));this.bumpSpace();var m=this.parseIdentifierIfPossible(),E=0;if("select"!==a&&"offset"===m.value){if(!this.bumpIf(":"))return this.error(l.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,Z(this.clonePosition(),this.clonePosition()));var b;if(this.bumpSpace(),(b=this.tryParseDecimalInteger(l.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,l.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE)).err)return b;this.bumpSpace(),m=this.parseIdentifierIfPossible(),E=b.val}var _,T=this.tryParsePluralOrSelectOptions(e,a,t,m);if(T.err)return T;if((_=this.tryParseArgumentClose(i)).err)return _;var w=Z(i,this.clonePosition());return"select"===a?{val:{type:h.select,value:n,options:ce(T.val),location:w},err:null}:{val:{type:h.plural,value:n,options:ce(T.val),offset:E,pluralType:"plural"===a?"cardinal":"ordinal",location:w},err:null};default:return this.error(l.INVALID_ARGUMENT_TYPE,Z(s,u))}},e.prototype.tryParseArgumentClose=function(e){return this.isEOF()||125!==this.char()?this.error(l.EXPECT_ARGUMENT_CLOSING_BRACE,Z(e,this.clonePosition())):(this.bump(),{val:!0,err:null})},e.prototype.parseSimpleArgStyleIfPossible=function(){for(var e=0,t=this.clonePosition();!this.isEOF();){switch(this.char()){case 39:this.bump();var r=this.clonePosition();if(!this.bumpUntil("'"))return this.error(l.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,Z(r,this.clonePosition()));this.bump();break;case 123:e+=1,this.bump();break;case 125:if(!(e>0))return{val:this.message.slice(t.offset,this.offset()),err:null};e-=1;break;default:this.bump()}}return{val:this.message.slice(t.offset,this.offset()),err:null}},e.prototype.parseNumberSkeletonFromString=function(e,t){var r=[];try{r=function(e){if(0===e.length)throw new Error("Number skeleton cannot be empty");for(var t=[],r=0,n=e.split(G).filter((function(e){return e.length>0}));r<n.length;r++){var i=n[r].split("/");if(0===i.length)throw new Error("Invalid number skeleton");for(var o=i[0],s=i.slice(1),a=0,u=s;a<u.length;a++)if(0===u[a].length)throw new Error("Invalid number skeleton");t.push({stem:o,options:s})}return t}(e)}catch(e){return this.error(l.INVALID_NUMBER_SKELETON,t)}return{val:{type:p.number,tokens:r,location:t,parsedOptions:this.shouldParseSkeletons?W(r):{}},err:null}},e.prototype.tryParsePluralOrSelectOptions=function(e,t,r,n){for(var i,o=!1,s=[],a=new Set,u=n.value,c=n.location;;){if(0===u.length){var h=this.clonePosition();if("select"===t||!this.bumpIf("="))break;var p=this.tryParseDecimalInteger(l.EXPECT_PLURAL_ARGUMENT_SELECTOR,l.INVALID_PLURAL_ARGUMENT_SELECTOR);if(p.err)return p;c=Z(h,this.clonePosition()),u=this.message.slice(h.offset,this.offset())}if(a.has(u))return this.error("select"===t?l.DUPLICATE_SELECT_ARGUMENT_SELECTOR:l.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,c);"other"===u&&(o=!0),this.bumpSpace();var f=this.clonePosition();if(!this.bumpIf("{"))return this.error("select"===t?l.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:l.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,Z(this.clonePosition(),this.clonePosition()));var g=this.parseMessage(e+1,t,r);if(g.err)return g;var d=this.tryParseArgumentClose(f);if(d.err)return d;s.push([u,{value:g.val,location:Z(f,this.clonePosition())}]),a.add(u),this.bumpSpace(),u=(i=this.parseIdentifierIfPossible()).value,c=i.location}return 0===s.length?this.error("select"===t?l.EXPECT_SELECT_ARGUMENT_SELECTOR:l.EXPECT_PLURAL_ARGUMENT_SELECTOR,Z(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!o?this.error(l.MISSING_OTHER_CLAUSE,Z(this.clonePosition(),this.clonePosition())):{val:s,err:null}},e.prototype.tryParseDecimalInteger=function(e,t){var r=1,n=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(r=-1);for(var i=!1,o=0;!this.isEOF();){var s=this.char();if(!(s>=48&&s<=57))break;i=!0,o=10*o+(s-48),this.bump()}var a=Z(n,this.clonePosition());return i?ie(o*=r)?{val:o,err:null}:this.error(t,a):this.error(e,a)},e.prototype.offset=function(){return this.position.offset},e.prototype.isEOF=function(){return this.offset()===this.message.length},e.prototype.clonePosition=function(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}},e.prototype.char=function(){var e=this.position.offset;if(e>=this.message.length)throw Error("out of bound");var t=le(this.message,e);if(void 0===t)throw Error("Offset "+e+" is at invalid UTF-16 code unit boundary");return t},e.prototype.error=function(e,t){return{val:null,err:{kind:e,message:this.message,location:t}}},e.prototype.bump=function(){if(!this.isEOF()){var e=this.char();10===e?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=e<65536?1:2)}},e.prototype.bumpIf=function(e){if(ae(this.message,e,this.offset())){for(var t=0;t<e.length;t++)this.bump();return!0}return!1},e.prototype.bumpUntil=function(e){var t=this.offset(),r=this.message.indexOf(e,t);return r>=0?(this.bumpTo(r),!0):(this.bumpTo(this.message.length),!1)},e.prototype.bumpTo=function(e){if(this.offset()>e)throw Error("targetOffset "+e+" must be greater than or equal to the current offset "+this.offset());for(e=Math.min(e,this.message.length);;){var t=this.offset();if(t===e)break;if(t>e)throw Error("targetOffset "+e+" is at invalid UTF-16 code unit boundary");if(this.bump(),this.isEOF())break}},e.prototype.bumpSpace=function(){for(;!this.isEOF()&&ye(this.char());)this.bump()},e.prototype.peek=function(){if(this.isEOF())return null;var e=this.char(),t=this.offset(),r=this.message.charCodeAt(t+(e>=65536?2:1));return null!=r?r:null},e}();function ve(e){return e>=97&&e<=122||e>=65&&e<=90}function ye(e){return e>=9&&e<=13||32===e||133===e||e>=8206&&e<=8207||8232===e||8233===e}function me(e){return e>=33&&e<=35||36===e||e>=37&&e<=39||40===e||41===e||42===e||43===e||44===e||45===e||e>=46&&e<=47||e>=58&&e<=59||e>=60&&e<=62||e>=63&&e<=64||91===e||92===e||93===e||94===e||96===e||123===e||124===e||125===e||126===e||161===e||e>=162&&e<=165||166===e||167===e||169===e||171===e||172===e||174===e||176===e||177===e||182===e||187===e||191===e||215===e||247===e||e>=8208&&e<=8213||e>=8214&&e<=8215||8216===e||8217===e||8218===e||e>=8219&&e<=8220||8221===e||8222===e||8223===e||e>=8224&&e<=8231||e>=8240&&e<=8248||8249===e||8250===e||e>=8251&&e<=8254||e>=8257&&e<=8259||8260===e||8261===e||8262===e||e>=8263&&e<=8273||8274===e||8275===e||e>=8277&&e<=8286||e>=8592&&e<=8596||e>=8597&&e<=8601||e>=8602&&e<=8603||e>=8604&&e<=8607||8608===e||e>=8609&&e<=8610||8611===e||e>=8612&&e<=8613||8614===e||e>=8615&&e<=8621||8622===e||e>=8623&&e<=8653||e>=8654&&e<=8655||e>=8656&&e<=8657||8658===e||8659===e||8660===e||e>=8661&&e<=8691||e>=8692&&e<=8959||e>=8960&&e<=8967||8968===e||8969===e||8970===e||8971===e||e>=8972&&e<=8991||e>=8992&&e<=8993||e>=8994&&e<=9e3||9001===e||9002===e||e>=9003&&e<=9083||9084===e||e>=9085&&e<=9114||e>=9115&&e<=9139||e>=9140&&e<=9179||e>=9180&&e<=9185||e>=9186&&e<=9254||e>=9255&&e<=9279||e>=9280&&e<=9290||e>=9291&&e<=9311||e>=9472&&e<=9654||9655===e||e>=9656&&e<=9664||9665===e||e>=9666&&e<=9719||e>=9720&&e<=9727||e>=9728&&e<=9838||9839===e||e>=9840&&e<=10087||10088===e||10089===e||10090===e||10091===e||10092===e||10093===e||10094===e||10095===e||10096===e||10097===e||10098===e||10099===e||10100===e||10101===e||e>=10132&&e<=10175||e>=10176&&e<=10180||10181===e||10182===e||e>=10183&&e<=10213||10214===e||10215===e||10216===e||10217===e||10218===e||10219===e||10220===e||10221===e||10222===e||10223===e||e>=10224&&e<=10239||e>=10240&&e<=10495||e>=10496&&e<=10626||10627===e||10628===e||10629===e||10630===e||10631===e||10632===e||10633===e||10634===e||10635===e||10636===e||10637===e||10638===e||10639===e||10640===e||10641===e||10642===e||10643===e||10644===e||10645===e||10646===e||10647===e||10648===e||e>=10649&&e<=10711||10712===e||10713===e||10714===e||10715===e||e>=10716&&e<=10747||10748===e||10749===e||e>=10750&&e<=11007||e>=11008&&e<=11055||e>=11056&&e<=11076||e>=11077&&e<=11078||e>=11079&&e<=11084||e>=11085&&e<=11123||e>=11124&&e<=11125||e>=11126&&e<=11157||11158===e||e>=11159&&e<=11263||e>=11776&&e<=11777||11778===e||11779===e||11780===e||11781===e||e>=11782&&e<=11784||11785===e||11786===e||11787===e||11788===e||11789===e||e>=11790&&e<=11798||11799===e||e>=11800&&e<=11801||11802===e||11803===e||11804===e||11805===e||e>=11806&&e<=11807||11808===e||11809===e||11810===e||11811===e||11812===e||11813===e||11814===e||11815===e||11816===e||11817===e||e>=11818&&e<=11822||11823===e||e>=11824&&e<=11833||e>=11834&&e<=11835||e>=11836&&e<=11839||11840===e||11841===e||11842===e||e>=11843&&e<=11855||e>=11856&&e<=11857||11858===e||e>=11859&&e<=11903||e>=12289&&e<=12291||12296===e||12297===e||12298===e||12299===e||12300===e||12301===e||12302===e||12303===e||12304===e||12305===e||e>=12306&&e<=12307||12308===e||12309===e||12310===e||12311===e||12312===e||12313===e||12314===e||12315===e||12316===e||12317===e||e>=12318&&e<=12319||12320===e||12336===e||64830===e||64831===e||e>=65093&&e<=65094}function Ee(e){e.forEach((function(e){if(delete e.location,N(e)||C(e))for(var t in e.options)delete e.options[t].location,Ee(e.options[t].value);else A(e)&&k(e.style)||(P(e)||O(e))&&U(e.style)?delete e.style.location:I(e)&&Ee(e.children)}))}function be(e,t){void 0===t&&(t={}),t=r({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new de(e,t).parse();if(n.err){var i=SyntaxError(l[n.err.kind]);throw i.location=n.err.location,i.originalMessage=n.err.message,i}return(null==t?void 0:t.captureLocation)||Ee(n.val),n.val}function _e(e,t){var r=t&&t.cache?t.cache:Ne,n=t&&t.serializer?t.serializer:Ae;return(t&&t.strategy?t.strategy:Le)(e,{cache:r,serializer:n})}function Te(e,t,r,n){var i,o=null==(i=n)||"number"==typeof i||"boolean"==typeof i?n:r(n),s=t.get(o);return void 0===s&&(s=e.call(this,n),t.set(o,s)),s}function we(e,t,r){var n=Array.prototype.slice.call(arguments,3),i=r(n),o=t.get(i);return void 0===o&&(o=e.apply(this,n),t.set(i,o)),o}function Se(e,t,r,n,i){return r.bind(t,e,n,i)}function Le(e,t){return Se(e,this,1===e.length?Te:we,t.cache.create(),t.serializer)}var Ae=function(){return JSON.stringify(arguments)};function Pe(){this.cache=Object.create(null)}Pe.prototype.get=function(e){return this.cache[e]},Pe.prototype.set=function(e,t){this.cache[e]=t};var Oe,Ne={create:function(){return new Pe}},Ce={variadic:function(e,t){return Se(e,this,we,t.cache.create(),t.serializer)},monadic:function(e,t){return Se(e,this,Te,t.cache.create(),t.serializer)}};!function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"}(Oe||(Oe={}));var Re,Ie=function(e){function r(t,r,n){var i=e.call(this,t)||this;return i.code=r,i.originalMessage=n,i}return t(r,e),r.prototype.toString=function(){return"[formatjs Error: "+this.code+"] "+this.message},r}(Error),ke=function(e){function r(t,r,n,i){return e.call(this,'Invalid values for "'+t+'": "'+r+'". Options are "'+Object.keys(n).join('", "')+'"',Oe.INVALID_VALUE,i)||this}return t(r,e),r}(Ie),Ue=function(e){function r(t,r,n){return e.call(this,'Value for "'+t+'" must be of type '+r,Oe.INVALID_VALUE,n)||this}return t(r,e),r}(Ie),De=function(e){function r(t,r){return e.call(this,'The intl string context variable "'+t+'" was not provided to the string "'+r+'"',Oe.MISSING_VALUE,r)||this}return t(r,e),r}(Ie);function Me(e){return"function"==typeof e}function xe(e,t,r,n,i,o,s){if(1===e.length&&S(e[0]))return[{type:Re.literal,value:e[0].value}];for(var a=[],u=0,c=e;u<c.length;u++){var l=c[u];if(S(l))a.push({type:Re.literal,value:l.value});else if(R(l))"number"==typeof o&&a.push({type:Re.literal,value:r.getNumberFormat(t).format(o)});else{var h=l.value;if(!i||!(h in i))throw new De(h,s);var p=i[h];if(L(l))p&&"string"!=typeof p&&"number"!=typeof p||(p="string"==typeof p||"number"==typeof p?String(p):""),a.push({type:"string"==typeof p?Re.literal:Re.object,value:p});else if(P(l)){var f="string"==typeof l.style?n.date[l.style]:U(l.style)?l.style.parsedOptions:void 0;a.push({type:Re.literal,value:r.getDateTimeFormat(t,f).format(p)})}else if(O(l)){f="string"==typeof l.style?n.time[l.style]:U(l.style)?l.style.parsedOptions:void 0;a.push({type:Re.literal,value:r.getDateTimeFormat(t,f).format(p)})}else if(A(l)){(f="string"==typeof l.style?n.number[l.style]:k(l.style)?l.style.parsedOptions:void 0)&&f.scale&&(p*=f.scale||1),a.push({type:Re.literal,value:r.getNumberFormat(t,f).format(p)})}else{if(I(l)){var g=l.children,d=l.value,v=i[d];if(!Me(v))throw new Ue(d,"function",s);var y=v(xe(g,t,r,n,i,o).map((function(e){return e.value})));Array.isArray(y)||(y=[y]),a.push.apply(a,y.map((function(e){return{type:"string"==typeof e?Re.literal:Re.object,value:e}})))}if(N(l)){if(!(m=l.options[p]||l.options.other))throw new ke(l.value,p,Object.keys(l.options),s);a.push.apply(a,xe(m.value,t,r,n,i))}else if(C(l)){var m;if(!(m=l.options["="+p])){if(!Intl.PluralRules)throw new Ie('Intl.PluralRules is not available in this environment.\nTry polyfilling it using "@formatjs/intl-pluralrules"\n',Oe.MISSING_INTL_API,s);var E=r.getPluralRules(t,{type:l.pluralType}).select(p-(l.offset||0));m=l.options[E]||l.options.other}if(!m)throw new ke(l.value,p,Object.keys(l.options),s);a.push.apply(a,xe(m.value,t,r,n,i,p-(l.offset||0)))}else;}}}return function(e){return e.length<2?e:e.reduce((function(e,t){var r=e[e.length-1];return r&&r.type===Re.literal&&t.type===Re.literal?r.value+=t.value:e.push(t),e}),[])}(a)}function Ge(e,t){return t?Object.keys(e).reduce((function(n,i){var o,s;return n[i]=(o=e[i],(s=t[i])?r(r(r({},o||{}),s||{}),Object.keys(o).reduce((function(e,t){return e[t]=r(r({},o[t]),s[t]||{}),e}),{})):o),n}),r({},e)):e}function Fe(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,r){e[t]=r}}}}}!function(e){e[e.literal=0]="literal",e[e.object=1]="object"}(Re||(Re={}));var He=function(){function e(t,r,n,i){var o,s=this;if(void 0===r&&(r=e.defaultLocale),this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(e){var t=s.formatToParts(e);if(1===t.length)return t[0].value;var r=t.reduce((function(e,t){return e.length&&t.type===Re.literal&&"string"==typeof e[e.length-1]?e[e.length-1]+=t.value:e.push(t.value),e}),[]);return r.length<=1?r[0]||"":r},this.formatToParts=function(e){return xe(s.ast,s.locales,s.formatters,s.formats,e,void 0,s.message)},this.resolvedOptions=function(){return{locale:Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.ast},"string"==typeof t){if(this.message=t,!e.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");this.ast=e.__parse(t,{ignoreTag:null==i?void 0:i.ignoreTag})}else this.ast=t;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=Ge(e.formats,n),this.locales=r,this.formatters=i&&i.formatters||(void 0===(o=this.formatterCache)&&(o={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:_e((function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new((e=Intl.NumberFormat).bind.apply(e,a([void 0],t)))}),{cache:Fe(o.number),strategy:Ce.variadic}),getDateTimeFormat:_e((function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new((e=Intl.DateTimeFormat).bind.apply(e,a([void 0],t)))}),{cache:Fe(o.dateTime),strategy:Ce.variadic}),getPluralRules:_e((function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new((e=Intl.PluralRules).bind.apply(e,a([void 0],t)))}),{cache:Fe(o.pluralRules),strategy:Ce.variadic})})}return Object.defineProperty(e,"defaultLocale",{get:function(){return e.memoizedDefaultLocale||(e.memoizedDefaultLocale=(new Intl.NumberFormat).resolvedOptions().locale),e.memoizedDefaultLocale},enumerable:!1,configurable:!0}),e.memoizedDefaultLocale=null,e.__parse=be,e.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},e}(),je=function(){function e(e,t){var r=this;this.properties=e,this.translationService=t,this.format=function(e,t){try{return new He(e,r.properties.currentLanguage,void 0,{ignoreTag:!0}).format(t)}catch(t){if("MISSING_VALUE"===t.code)return console.warn(t.message),e}},this.escapeForRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},this.escapeParam=function(e){return"string"==typeof e?e.replace(/[,:\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(e),console.warn("Unsupported value type of above param. Consider converting to string."),e)}}return Object.defineProperty(e.prototype,"rawUnWrapRegex",{get:function(){return"(\\\\?)("+this.escapeForRegExp(this.properties.config.inputPrefix)+"(.*?)"+this.escapeForRegExp(this.properties.config.inputSuffix)+")"},enumerable:!1,configurable:!0}),e.parseUnwrapped=function(e){for(var t=e.match(/(?:[^\\,:\n]|\\.)+/g),r={key:T.removeEscapes(t.shift()),params:{}};t.length;){var n=s(t.splice(0,2),2),i=n[0],o=n[1];r.params[i]=o}return r},e.prototype.translate=function(e,t,r,o){return void 0===r&&(r=this.properties.currentLanguage),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return n=this.format,[4,this.translationService.getTranslation(e,r,o)];case 1:return[2,n.apply(this,[i.sent(),t])]}}))}))},e.prototype.instant=function(e,t,r,n){return void 0===r&&(r=this.properties.currentLanguage),this.format(this.translationService.getFromCacheOrFallback(e,r,n),t)},e.prototype.replace=function(e){return n(this,void 0,void 0,(function(){var t,r,n,o,a,u,c,l,h,p,f,g,d,v,y;return i(this,(function(i){switch(i.label){case 0:t=new RegExp(this.rawUnWrapRegex,"gs"),r=[],n=!1,a=0,u="",i.label=1;case 1:return null===(o=t.exec(e))?[3,3]:(c=s(o,4),l=c[0],h=c[1],p=c[2],f=c[3],g=o.index,d=o.input,u+=d.substr(a,g-a),a=g+l.length,"\\"!==h||T.isCharEscaped(g,e)?[4,this.getTranslatedWithMetadata(f)]:(u+=p,[3,1]));case 2:return v=i.sent(),r.push({key:v.key,params:v.params}),n=!0,u+=h+v.translated,[3,1];case 3:return u+=e.substring(a),y=T.removeEscapes(u),n?[2,{text:y,keys:r}]:[2,void 0]}}))}))},e.prototype.wrap=function(e,t){var r=this;void 0===t&&(t={});var n=Object.entries(t).map((function(e){var t=s(e,2),n=t[0],i=t[1];return r.escapeParam(n)+":"+r.escapeParam(i)})).join(",");return n=n.length?":"+n:"",""+this.properties.config.inputPrefix+this.escapeParam(e)+n+this.properties.config.inputSuffix},e.prototype.getTranslatedWithMetadata=function(t){return n(this,void 0,void 0,(function(){var r,n,o;return i(this,(function(i){switch(i.label){case 0:return r=e.parseUnwrapped(t),n=r.key,o=r.params,[4,this.translate(n,o,void 0,!1)];case 1:return[2,{translated:i.sent(),key:n,params:o}]}}))}))},e}(),Ke=function(){function e(e){this.properties=e,this.keysDown=new Set,this.mouseOn=new Set,this.mouseOnChanged=new y,this.keysChanged=new y,"undefined"==typeof window||this.initKeyListener()}return e.prototype.handle=function(e,t){var r=this;e._tolgee.listeningForHighlighting?console.error("Element is already listening mouse events! This is probably bug in tolgee"):(e._tolgee.listeningForHighlighting=!0,this.initEventListeners(e,t),this.mouseOnChanged.subscribe((function(){r.highlighted!==r.getMouseOn()&&r.onConditionsChanged()})),this.keysChanged.subscribe((function(){r.onConditionsChanged()})))},e.prototype.initEventListeners=function(e,t){var r=this,n=function(){return r.onMouseOver(e)},i=function(){return r.onMouseOut(e)},o=function(e){r.areKeysDown()&&(e.stopPropagation(),e.preventDefault(),t(e))};e.addEventListener("mouseover",n),e.addEventListener("click",o);var s=function(e){r.areKeysDown()&&(e.stopPropagation(),e.preventDefault())};e.addEventListener("mousedown",s),e.addEventListener("mouseup",s),e.addEventListener("mouseout",i),e._tolgee.removeAllEventListeners=function(){e.removeEventListener("mousedown",s),e.removeEventListener("mouseup",s),e.removeEventListener("mouseover",n),e.removeEventListener("click",o),e.removeEventListener("mouseout",i)}},e.prototype.onConditionsChanged=function(){this.unhighlight(),this.areKeysDown()&&this.getMouseOn()&&this.highlight()},e.prototype.highlight=function(){this.getMouseOn()._tolgee.highlight(),this.highlighted=this.getMouseOn()},e.prototype.unhighlight=function(){this.highlighted&&(this.highlighted._tolgee.unhighlight(),this.highlighted=null)},e.prototype.onMouseOut=function(e){this.mouseOn.delete(e),this.mouseOnChanged.emit(this.getMouseOn())},e.prototype.onMouseOver=function(e){this.filterMouseOn(),this.mouseOn.delete(e),this.mouseOn.add(e),this.mouseOnChanged.emit(this.getMouseOn())},e.prototype.getMouseOn=function(){var e=Array.from(this.mouseOn);return e.length?e[0]:void 0},e.prototype.initKeyListener=function(){var e=this;window.addEventListener("blur",(function(){e.keysDown=new Set,e.keysChanged.emit(e.areKeysDown())})),window.addEventListener("keydown",(function(t){var r=exports.ModifierKey[t.key];void 0!==r&&(e.keysDown.add(r),e.keysChanged.emit(e.areKeysDown()))})),window.addEventListener("keyup",(function(t){e.keysDown.delete(exports.ModifierKey[t.key]),e.keysChanged.emit(e.areKeysDown())}))},e.prototype.filterMouseOn=function(){var e=this;this.mouseOn.forEach((function(t){document.contains(t)||e.mouseOn.delete(t)}))},e.prototype.areKeysDown=function(){var e,t;try{for(var r=o(this.properties.config.highlightKeys),n=r.next();!n.done;n=r.next()){var i=n.value;if(!this.keysDown.has(i))return!1}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return!0},e}(),Ve=function(){function e(e){var t=this;this.dependencies=e,this.translationEdit=function(e,r){return n(t,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return"object"!=typeof this.renderer?[3,2]:[4,this.getKey(e,r)];case 1:return(t=n.sent())?(this.renderer.renderViewer(t),[2]):[2];case 2:return console.warn('Tolgee UI is not provided. To translate interactively provide tolgee ui constructor to "ui" configuration property. To disable highlighting use production mode.'),[2]}}))}))}}return Object.defineProperty(e.prototype,"renderer",{get:function(){return void 0===this._renderer&&"function"==typeof this.dependencies.properties.config.ui&&(this._renderer=new this.dependencies.properties.config.ui(this.dependencies)),this._renderer},enumerable:!1,configurable:!0}),e.getKeyOptions=function(e){var t=Array.from(e._tolgee.nodes).reduce((function(e,t){return a(a([],s(e)),s(t._tolgee.keys.map((function(e){return e.key}))))}),[]);return new Set(t)},e.prototype.listen=function(e){var t=this;this.dependencies.highlightFunctionInitializer.initFunctions(e),this.dependencies.mouseEventHandler.handle(e,(function(r){return n(t,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.translationEdit(r,e)];case 1:return[2,t.sent()]}}))}))}))},e.prototype.getKey=function(t,r){return n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return r._tolgee.wrappedWithElementOnlyKey?[2,r._tolgee.wrappedWithElementOnlyKey]:(n=e.getKeyOptions(r)).size>1?[4,this.renderer.getKey({keys:n,openEvent:t})]:[3,2];case 1:return[2,i.sent()];case 2:return 1===n.size?[2,Array.from(n)[0]]:(console.error("No key to translate. This seems like a bug in tolgee."),[2])}}))}))},e}(),Xe=function(){function e(e,t,r){this.properties=e,this.translationHighlighter=t,this.eventService=r,this.registeredElements=new Set}return e.prototype.register=function(e){(void 0!==this.getActiveNodes(e).next().value||e._tolgee.wrappedWithElementOnlyKey)&&("development"!==this.properties.config.mode||this.registeredElements.has(e)||this.translationHighlighter.listen(e),this.registeredElements.add(e),this.eventService.ELEMENT_REGISTERED.emit(e))},e.prototype.refreshAll=function(){var e,t;try{for(var r=o(this.registeredElements),n=r.next();!n.done;n=r.next()){var i=n.value;this.cleanElementInactiveNodes(i),0!==i._tolgee.nodes.size||i._tolgee.wrappedWithElementOnlyKey||this.cleanElement(i)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.cleanAll=function(){var e,t;try{for(var r=o(this.registeredElements),n=r.next();!n.done;n=r.next()){var i=n.value;this.cleanElement(i)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.findAllByKey=function(e){var t,r,n,i,s=[];try{for(var a=o(this.registeredElements),u=a.next();!u.done;u=a.next()){var c=u.value;if(c._tolgee.wrappedWithElementOnlyKey!==e)try{for(var l=(n=void 0,o(c._tolgee.nodes)),h=l.next();!h.done;h=l.next()){if(h.value._tolgee.keys.findIndex((function(t){return t.key===e}))>-1){s.push(c);break}}}catch(e){n={error:e}}finally{try{h&&!h.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}else s.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return s},e.prototype.cleanElementInactiveNodes=function(e){this.isElementActive(e)&&(e._tolgee.nodes=new Set(this.getActiveNodes(e)))},e.prototype.cleanElement=function(e){"function"==typeof e._tolgee.removeAllEventListeners&&e._tolgee.removeAllEventListeners(),e.removeAttribute("_tolgee"),delete e._tolgee,this.registeredElements.delete(e)},e.prototype.getActiveNodes=function(e){var t,r,n,s,a,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,5,6,7]),t=o(e._tolgee.nodes),r=t.next(),i.label=1;case 1:return r.done?[3,4]:(n=r.value,c.nodeContains(this.properties.config.targetElement,n)?[4,n]:[3,3]);case 2:i.sent(),i.label=3;case 3:return r=t.next(),[3,1];case 4:return[3,7];case 5:return s=i.sent(),a={error:s},[3,7];case 6:try{r&&!r.done&&(u=t.return)&&u.call(t)}finally{if(a)throw a.error}return[7];case 7:return[2]}}))},e.prototype.isElementActive=function(e){return this.properties.config.targetElement.contains(e)},e}(),Be=function(){function e(e,t,r,n){this.properties=e,this.textService=t,this.elementRegistrar=r,this.translationHighlighter=n}return e.initParentElement=function(e){return void 0===e._tolgee&&(e._tolgee={nodes:new Set},e.setAttribute("_tolgee","")),e},e.prototype.filterRestricted=function(e){var t=this.properties.config.restrictedElements;return e.filter((function(e){var r=c.closestElement(e);return-1===t.indexOf(r.tagName.toLowerCase())&&null===r.closest('[data-tolgee-restricted="true"]')}))},e.prototype.handleNodes=function(e){return n(this,void 0,void 0,(function(){var t,r,n,s,a,u,c,l,h,p,f,g;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,5,6,7]),t=o(e),r=t.next(),i.label=1;case 1:return r.done?[3,4]:(void 0===(n=r.value)._tolgee&&(n._tolgee={}),!0===(null==(s=n._tolgee)?void 0:s.locked)?[3,3]:(this.lockNode(n),[4,this.textService.replace(n.textContent)]));case 2:(a=i.sent())&&(u=a.text,c=a.keys,l=this.translateChildNode(n,u,c),(h=this.getParentElement(l))._tolgee.nodes.add(l),this.elementRegistrar.register(h)),this.unlockNode(n),i.label=3;case 3:return r=t.next(),[3,1];case 4:return[3,7];case 5:return p=i.sent(),f={error:p},[3,7];case 6:try{r&&!r.done&&(g=t.return)&&g.call(t)}finally{if(f)throw f.error}return[7];case 7:return[2]}}))}))},e.prototype.translateChildNode=function(e,t,r){return e._tolgee={oldTextContent:e.textContent,keys:r},e.textContent=t,e},e.prototype.lockNode=function(e){void 0===e._tolgee&&(e._tolgee={});var t=e._tolgee;return!0!==(null==t?void 0:t.locked)&&(t.locked=!0),e},e.prototype.unlockNode=function(e){e._tolgee&&(e._tolgee.locked=!1)},e.prototype.getParentElement=function(t){var r=this.getSuitableParent(t);return e.initParentElement(r)},e.prototype.getSuitableParent=function(e){var t=c.getParentElement(e);if(void 0===t)throw console.error(e),new Error("No suitable parent found for node above.");if(!this.properties.config.passToParent)return t;if(Array.isArray(this.properties.config.passToParent)){if(-1===this.properties.config.passToParent.findIndex((function(e){return t.tagName.toLowerCase()===e.toLowerCase()})))return t}return"function"!=typeof this.properties.config.passToParent||this.properties.config.passToParent(t)?this.getSuitableParent(t):t},e}(),Ye=function(e){function r(t,r,n,i){var o=e.call(this,t,n,i,r)||this;return o.properties=t,o.translationHighlighter=r,o.textService=n,o.nodeRegistrar=i,o}return t(r,e),r.prototype.handle=function(e){return n(this,void 0,void 0,(function(){var t,r,n,o,s;return i(this,(function(i){switch(i.label){case 0:return t=this.properties.config.inputPrefix,r=this.properties.config.inputSuffix,n="./descendant-or-self::text()[contains(., '"+t+"') and contains(., '"+r+"')]",o=c.evaluate(n,e),s=this.filterRestricted(o),[4,this.handleNodes(s)];case 1:return i.sent(),[2]}}))}))},r}(Be),ze=function(e){function r(t,r,n,i){var o=e.call(this,t,r,n,i)||this;return o.properties=t,o.textService=r,o.elementRegistrar=n,o.translationHighlighter=i,o}return t(r,e),r.prototype.handle=function(e){return n(this,void 0,void 0,(function(){var t,r,n,a,u,l,h,p,f,g,d,v,y,m,E,b,_,T;return i(this,(function(i){switch(i.label){case 0:t=this.properties.config.inputPrefix,r=this.properties.config.inputSuffix,i.label=1;case 1:i.trys.push([1,12,13,14]),n=o(Object.entries(this.properties.config.tagAttributes)),a=n.next(),i.label=2;case 2:if(a.done)return[3,11];u=s(a.value,2),l=u[0],h=u[1],i.label=3;case 3:i.trys.push([3,8,9,10]),_=void 0,p=o(h),f=p.next(),i.label=4;case 4:return f.done?[3,7]:(g=f.value,d="descendant-or-self::"+l+"/@"+g+"[contains(., '"+t+"') and contains(., '"+r+"')]",v=c.evaluate(d,e),[4,this.handleNodes(v)]);case 5:i.sent(),i.label=6;case 6:return f=p.next(),[3,4];case 7:return[3,10];case 8:return y=i.sent(),_={error:y},[3,10];case 9:try{f&&!f.done&&(T=p.return)&&T.call(p)}finally{if(_)throw _.error}return[7];case 10:return a=n.next(),[3,2];case 11:return[3,14];case 12:return m=i.sent(),E={error:m},[3,14];case 13:try{a&&!a.done&&(b=n.return)&&b.call(n)}finally{if(E)throw E.error}return[7];case 14:return[2]}}))}))},r}(Be),We=function(){function e(e,t,r,n,i,o,s){this.service=e,this.textHandler=t,this.eventService=r,this.properties=n,this.attributeHandler=i,this.textService=o,this.wrappedHandler=s,r.LANGUAGE_CHANGED.subscribe(this.refresh.bind(this)),r.TRANSLATION_CHANGED.subscribe(this.refresh.bind(this))}return e.prototype.handleSubtree=function(e){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.attributeHandler.handle(e)];case 1:return t.sent(),[4,this.textHandler.handle(e)];case 2:return t.sent(),[4,this.wrappedHandler.handle(e)];case 3:return t.sent(),[2]}}))}))},e.prototype.refresh=function(){return n(this,void 0,void 0,(function(){var e,t,r,n,s,a,u,l,h,p,f,g,d,v;return i(this,(function(i){switch(i.label){case 0:e=c.evaluate("//*[@_tolgee]",this.properties.config.targetElement),i.label=1;case 1:i.trys.push([1,12,13,14]),t=o(e),r=t.next(),i.label=2;case 2:if(r.done)return[3,11];n=r.value,i.label=3;case 3:i.trys.push([3,8,9,10]),d=void 0,s=o(n._tolgee.nodes),a=s.next(),i.label=4;case 4:return a.done?[3,7]:(u=a.value,[4,this.textService.replace(u._tolgee.oldTextContent)]);case 5:(l=i.sent())&&(u.textContent=l.text),i.label=6;case 6:return a=s.next(),[3,4];case 7:return[3,10];case 8:return h=i.sent(),d={error:h},[3,10];case 9:try{a&&!a.done&&(v=s.return)&&v.call(s)}finally{if(d)throw d.error}return[7];case 10:return r=t.next(),[3,2];case 11:return[3,14];case 12:return p=i.sent(),f={error:p},[3,14];case 13:try{r&&!r.done&&(g=t.return)&&g.call(t)}finally{if(f)throw f.error}return[7];case 14:return[2]}}))}))},e}(),Je=function(){function e(e,t,r,n,i){this.properties=e,this.coreHandler=t,this.basicTextHandler=r,this.attributeHandler=n,this.nodeRegistrar=i,this._observer=void 0}return Object.defineProperty(e.prototype,"observer",{get:function(){var e=this;return this._observer||"undefined"==typeof window||(this._observer=new MutationObserver((function(t){return n(e,void 0,void 0,(function(){var e,r,n,s,a,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,9,10,11]),e=o(t),r=e.next(),i.label=1;case 1:return r.done?[3,8]:"characterData"!==(n=r.value).type?[3,3]:[4,this.basicTextHandler.handle(n.target)];case 2:return i.sent(),[3,7];case 3:return"childList"!==n.type?[3,5]:[4,this.coreHandler.handleSubtree(n.target)];case 4:return i.sent(),[3,7];case 5:return"attributes"!==n.type?[3,7]:[4,this.attributeHandler.handle(n.target)];case 6:i.sent(),i.label=7;case 7:return r=e.next(),[3,1];case 8:return[3,11];case 9:return s=i.sent(),a={error:s},[3,11];case 10:try{r&&!r.done&&(u=e.return)&&u.call(e)}finally{if(a)throw a.error}return[7];case 11:return this.nodeRegistrar.refreshAll(),[2]}}))}))}))),this._observer},enumerable:!1,configurable:!0}),e.prototype.observe=function(){this.observer&&this.observer.observe(this.properties.config.targetElement,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},e.prototype.stopObserving=function(){this.observer&&this.observer.disconnect()},e}(),qe=function(){function e(e,t){this.properties=e,this.apiHttpService=t}return e.prototype.getLanguages=function(){return n(this,void 0,void 0,(function(){var e,t;return i(this,(function(r){switch(r.label){case 0:return this.languagePromise instanceof Promise||(this.languagePromise=this.apiHttpService.fetchJson("v2/projects/languages?size=1000")),t=Set.bind,[4,this.languagePromise];case 1:return e=new(t.apply(Set,[void 0,r.sent()._embedded.languages.map((function(e){return e.tag}))])),this.properties.preferredLanguages=new Set(Array.from(this.properties.preferredLanguages).filter((function(t){return e.has(t)}))),[2,e]}}))}))},e.prototype.getScopes=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.apiHttpService.fetchJson("api/apiKeys/scopes")];case 1:return[2,t.sent()];case 2:return e=t.sent(),console.error(e),console.error("Error getting scopes. Trying to switch to production mode!"),this.properties.config.mode="production",[3,3];case 3:return[2]}}))}))},e.prototype.isAuthorizedTo=function(e){return this.properties.scopes.indexOf(e)>-1},e.prototype.checkScope=function(e){if(!this.isAuthorizedTo(e))throw new Error("Api key not permitted to do this, please add 'translations.view' scope.")},e}(),Ze=function(e){function r(t,r,n,i){var o=e.call(this,t,n,i,r)||this;return o.properties=t,o.translationHighlighter=r,o.textService=n,o.elementRegistrar=i,o}return t(r,e),r.prototype.handle=function(e){return n(this,void 0,void 0,(function(){var t,r=this;return i(this,(function(n){return"./descendant-or-self::*[@data-tolgee-key-only]",t=c.evaluate("./descendant-or-self::*[@data-tolgee-key-only]",e),this.filterRestricted(t).forEach((function(e){var t=Be.initParentElement(e);t._tolgee.wrappedWithElementOnlyKey=e.getAttribute("data-tolgee-key-only"),r.elementRegistrar.register(t)})),[2]}))}))},r}(Be),$e=function(){function e(e,t,n,i){var o=this;this.messages=e,this.properties=t,this.eventService=n,this.elementRegistrar=i,this.handshakeSucceed=!1,this.takeScreenshot=function(){return new Promise((function(e,t){try{o.messages.send("TOLGEE_TAKE_SCREENSHOT"),o.messages.listen("TOLGEE_SCREENSHOT_TAKEN",(function(t){e(t)}))}catch(e){t(e)}}))},this.handshake=function(){var e=r(r({},o.properties),{config:r(r({},o.properties.config),{staticData:void 0,targetElement:void 0,_targetElement:void 0,ui:void 0})});o.messages.send("TOLGEE_READY",e),o.messages.listen("TOLGEE_PLUGIN_READY",(function(){o.handshakeSucceed=!0,o.messages.send("TOLGEE_READY",e),o.initListeners()}))}}return e.prototype.run=function(){try{this.messages.startListening(),this.handshake(),this.initOnRegisterKeyEmit()}catch(e){console.warn(e),console.warn("Can not start communication with browser plugin. Check waning above.")}},e.prototype.initOnRegisterKeyEmit=function(){var e=this;this.eventService.ELEMENT_REGISTERED.subscribe((function(t){t._tolgee.nodes.forEach((function(t){t._tolgee.keys.forEach((function(t){return e.messages.send("NEW_KEY",t)}))}))}))},e.prototype.stop=function(){this.messages.stopListening()},e.prototype.initListeners=function(){var e=this;this.messages.listenPopup("HIGHLIGHT_KEY",(function(t){var r,n;try{for(var i=o(e.elementRegistrar.findAllByKey(t)),s=i.next();!s.done;s=i.next()){s.value._tolgee.highlight()}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}})),this.messages.listenPopup("UNHIGHLIGHT_KEY",(function(t){var r,n;try{for(var i=o(e.elementRegistrar.findAllByKey(t)),s=i.next();!s.done;s=i.next()){s.value._tolgee.unhighlight()}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}))},e}(),Qe=function(){function e(){var e=this;this.listeners=[],this.listenersPopup=[],this.startListening=function(){var t=function(t){t.source==window&&e.listeners.forEach((function(e){e.type==t.data.type&&e.callback(t.data.data)}))};window.addEventListener("message",t,!1),"function"==typeof e._stopListening&&e._stopListening(),e._stopListening=function(){window.removeEventListener("message",t,!1)},e.startPopupListening()},this.startPopupListening=function(){e.listen("POPUP_TO_LIB",(function(t){e.listenersPopup.forEach((function(e){t.type==e.type&&e.callback(t.data)}))}))},this.listenPopup=function(t,r){e.listenersPopup.push({type:t,callback:r})},this.listen=function(t,r){e.listeners.push({type:t,callback:r})},this.send=function(e,t){try{window.postMessage({type:e,data:t},window.origin)}catch(e){console.warn("Can not send message.",e)}}}return e.prototype.stopListening=function(){this._stopListening()},e}(),et=function(){function e(e){this.properties=e}return e.prototype.initFunctions=function(e){this.initHighlightFunction(e),this.initUnhighlightFunction(e)},e.prototype.initHighlightFunction=function(e){var t=this;e._tolgee.highlight=function(){e._tolgee.initialBackgroundColor=e.style.backgroundColor,e.style.backgroundColor=t.properties.config.highlightColor}},e.prototype.initUnhighlightFunction=function(e){e._tolgee.unhighlight=function(){e.style.backgroundColor=e._tolgee.initialBackgroundColor}},e}(),tt=function(e){void 0===e&&(e=new g),this.properties=new d,this.eventService=new m,this.apiHttpService=new b(this.properties),this.mouseEventHandler=new Ke(this.properties),this.coreService=new qe(this.properties,this.apiHttpService),this.translationService=new w(this.properties,this.coreService,this.apiHttpService,this.eventService),this.textService=new je(this.properties,this.translationService),this.highlightFunctionInitializer=new et(this.properties),this.translationHighlighter=new Ve(this),this.elementRegistrar=new Xe(this.properties,this.translationHighlighter,this.eventService),this.textHandler=new Ye(this.properties,this.translationHighlighter,this.textService,this.elementRegistrar),this.attributeHandler=new ze(this.properties,this.textService,this.elementRegistrar,this.translationHighlighter),this.wrappedHandler=new Ze(this.properties,this.translationHighlighter,this.textService,this.elementRegistrar),this.coreHandler=new We(this.coreService,this.textHandler,this.eventService,this.properties,this.attributeHandler,this.textService,this.wrappedHandler),this.observer=new Je(this.properties,this.coreHandler,this.textHandler,this.attributeHandler,this.elementRegistrar),this.messages=new Qe,this.pluginManager=new $e(this.messages,this.properties,this.eventService,this.elementRegistrar),this.properties.config=e,this.translationService.initStatic(),this.translationHighlighter.pluginManager=this.pluginManager},rt=function(){function e(e){var t=this;this.translate=function(e,r,o){return void 0===r&&(r={}),void 0===o&&(o=!1),n(t,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"development"!==this.properties.config.mode||o?[3,3]:[4,this.loadScopes()];case 1:return t.sent(),[4,this.translationService.loadTranslations()];case 2:return t.sent(),[2,this.dependencyStore.textService.wrap(e,r)];case 3:return[2,this.dependencyStore.textService.translate(e,r)]}}))}))},this.instant=function(e,r,n,i){return void 0===r&&(r={}),void 0===n&&(n=!1),"development"!==t.properties.config.mode||n?t.dependencyStore.textService.instant(e,r,void 0,i):t.dependencyStore.textService.wrap(e,r)},this.stop=function(){t.dependencyStore.observer.stopObserving(),t.dependencyStore.elementRegistrar.cleanAll(),c.unmarkElementAsTargetElement(t.properties.config.targetElement)},this.dependencyStore=new tt(new g(e))}return Object.defineProperty(e.prototype,"properties",{get:function(){return this.dependencyStore.properties},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"translationService",{get:function(){return this.dependencyStore.translationService},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coreService",{get:function(){return this.dependencyStore.coreService},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lang",{get:function(){return this.properties.currentLanguage},set:function(e){this.properties.currentLanguage=e,this.dependencyStore.eventService.LANGUAGE_CHANGED.emit(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultLanguage",{get:function(){return this.properties.config.defaultLanguage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onLangChange",{get:function(){return this.dependencyStore.eventService.LANGUAGE_CHANGED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTranslationChange",{get:function(){return this.dependencyStore.eventService.TRANSLATION_CHANGED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onLangLoaded",{get:function(){return this.dependencyStore.eventService.LANGUAGE_LOADED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"initialLoading",{get:function(){var e,t,r,n;if("production"!==(null===(t=null===(e=this.properties)||void 0===e?void 0:e.config)||void 0===t?void 0:t.mode))return!0;var i=this.properties.currentLanguage,o=this.properties.config.fallbackLanguage,s=this.properties.config.preloadFallback,a=function(e){return void 0!==e&&"function"!=typeof e};return!a(null===(r=this.properties.config.staticData)||void 0===r?void 0:r[i])||!!s&&!a(null===(n=this.properties.config.staticData)||void 0===n?void 0:n[o])},enumerable:!1,configurable:!0}),e.prototype.run=function(){return n(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return"development"!==this.properties.config.mode?[3,2]:[4,this.loadScopes()];case 1:e.sent(),e.label=2;case 2:return[4,this.translationService.loadTranslations()];case 3:return e.sent(),[4,this.dependencyStore.pluginManager.run()];case 4:return e.sent(),this.properties.config.preloadFallback?[4,this.translationService.loadTranslations(this.properties.config.fallbackLanguage)]:[3,6];case 5:e.sent(),e.label=6;case 6:return[4,this.refresh()];case 7:return e.sent(),this.properties.config.watch&&this.dependencyStore.observer.observe(),[2]}}))}))},e.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.dependencyStore.coreHandler.handleSubtree(this.properties.config.targetElement)]}))}))},e.prototype.loadScopes=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return void 0!==this.properties.scopes?[3,2]:(e=this.properties,[4,this.dependencyStore.coreService.getScopes()]);case 1:e.scopes=t.sent(),t.label=2;case 2:return[2]}}))}))},e}();exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE="data-tolgee-key-only",exports.Tolgee=rt,exports.TolgeeConfig=g,exports.TranslationData=_;
|
|
16
|
+
var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};function t(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return(r=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function n(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))}function i(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function o(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function a(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}var u,c=function(){function e(){}return e.evaluateGenerator=function(e,t){var r,n;return i(this,(function(i){switch(i.label){case 0:n=document.evaluate(e,t,void 0,XPathResult.ANY_TYPE),i.label=1;case 1:return null===(r=n.iterateNext())?[3,3]:[4,r];case 2:return i.sent(),[3,1];case 3:return[2]}}))},e.evaluate=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Array.from(this.evaluateGenerator.apply(this,a([],s(e))))},e.evaluateToSingle=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=this.evaluate.apply(this,a([],s(e)));if(1===r.length)return r[0];if(r.length<1)throw new Error("No element found");throw new Error("Multiple elements found")},e.closestElement=function(e){return e instanceof Text?e.parentElement:e},e.getParentElement=function(e){return e.parentElement?e.parentElement:e.ownerElement?e.ownerElement:void 0},e.isElementTargetElement=function(e){return e.hasAttribute("_tolgee-target")},e.markElementAsTargetElement=function(e){e.setAttribute("_tolgee-target","")},e.unmarkElementAsTargetElement=function(e){e.removeAttribute("_tolgee-target")},e.nodeContains=function(e,t){if(e.contains(t))return!0;if(t instanceof Attr){var r=Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&r)return!0}return!1},e}();exports.ModifierKey=void 0,(u=exports.ModifierKey||(exports.ModifierKey={}))[u.Alt=0]="Alt",u[u.Control=1]="Control",u[u.Shift=2]="Shift",u[u.Meta=3]="Meta";var l,h,p,f=function(){if("undefined"!=typeof document)return document.body},g=function(e){this.apiUrl="https://app.tolgee.io",this.inputPrefix="%-%tolgee:",this.inputSuffix="%-%",this.defaultLanguage="en",this.filesUrlPrefix="i18n/",this.tagAttributes={textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},this.highlightKeys=[exports.ModifierKey.Alt],this.passToParent=["option","optgroup"],this.restrictedElements=["script","style"],this.highlightColor="rgb(224 240 255)",this.preloadFallback=!1,Object.defineProperty(this,"targetElement",{set:function(e){if(void 0!==this.targetElement)throw new Error("Target element is already defined!");if(void 0===e&&(this._targetElement=f()),c.isElementTargetElement(e))throw console.error("Target element: ",this._targetElement),new Error("An tolgee instance is inited with provided target element");this._targetElement=e,c.markElementAsTargetElement(this._targetElement)},get:function(){return this._targetElement}}),Object.assign(this,e||{}),void 0===this._targetElement&&(this._targetElement=f()),this.mode=this.mode||(this.apiKey?"development":"production"),this.fallbackLanguage=this.fallbackLanguage||this.defaultLanguage,void 0===this.watch&&(this.watch="development"===this.mode)},d=function(){function e(){}return Object.defineProperty(e.prototype,"currentLanguage",{get:function(){var e;if(this.config.forceLanguage)return this.config.forceLanguage;"undefined"!=typeof localStorage?(e=localStorage.getItem("__tolgee_currentLanguage"),this.config.availableLanguages&&(this.config.availableLanguages.indexOf(e)>-1||(e=void 0))):e=this._currentLanguage;return e||(e=this.getLanguageByNavigator(),this.currentLanguage=e),e},set:function(e){"undefined"!=typeof localStorage?localStorage.setItem("__tolgee_currentLanguage",e):this._currentLanguage=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"preferredLanguages",{get:function(){return new Set(JSON.parse(localStorage.getItem("__tolgee_preferredLanguages")))},set:function(e){localStorage.setItem("__tolgee_preferredLanguages",JSON.stringify(Array.from(e)))},enumerable:!1,configurable:!0}),e.prototype.getLanguageByNavigator=function(){if("undefined"!=typeof window&&this.config.availableLanguages){var e=window.navigator.language,t=this.config.availableLanguages.find((function(t){return t===e}));if(t)return t;var r=function(e){return e.replace(/^(.+?)(-.*)?$/,"$1")},n=r(window.navigator.language),i=this.config.availableLanguages.find((function(e){return r(e)===n}));if(i)return i}return this.config.defaultLanguage},e}(),v=function(){function e(e){this.onUnsubscribe=e}return e.prototype.unsubscribe=function(){this.onUnsubscribe()},e}(),y=function(){function e(){this.idCounter=0,this._subscriptions=new Map}return Object.defineProperty(e.prototype,"subscriptions",{get:function(){return this._subscriptions},enumerable:!1,configurable:!0}),e.prototype.emit=function(e){var t,r,n=[];try{for(var i=o(this.subscriptions.values()),s=i.next();!s.done;s=i.next()){var a=(0,s.value)(e);"function"==typeof(null==a?void 0:a.then)&&n.push(a)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}if(0!==n.length)return new Promise((function(e){return Promise.all(n).then((function(){return e()}))}))},e.prototype.subscribe=function(e){var t=this,r=this.idCounter++,n=new v((function(){return t.unsubscribe(r)}));return this.subscriptions.set(r,e),n},e.prototype.unsubscribe=function(e){this._subscriptions.delete(e)||console.warn("Event to unsubscribe was not found")},e}(),m=function(){this.TRANSLATION_CHANGED=new y,this.LANGUAGE_CHANGED=new y,this.LANGUAGE_LOADED=new y,this.ELEMENT_REGISTERED=new y},E=function(e){function r(t,n){var i=e.call(this,"Api http error")||this;return i.response=t,i.code=n,Object.setPrototypeOf(i,r.prototype),i}return t(r,e),r}(Error),b=function(){function e(e){this.properties=e}return e.handleErrors=function(e){return n(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:if(!(e.status>=400))return[3,5];t=new E(e),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,e.json()];case 2:return r=n.sent(),t.code=r.code,[3,4];case 3:return n.sent(),console.warn("Tolgee server responded with invalid status code."),[3,4];case 4:throw t;case 5:return[2,e]}}))}))},e.prototype.fetch=function(){for(var t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];return n(this,void 0,void 0,(function(){var n,o,u;return i(this,(function(i){switch(i.label){case 0:return"object"!=typeof t[0]?[3,2]:[4,fetch(r(r({},t[0]),{url:this.getUrl(t[0].url)})).then((function(t){return e.handleErrors(t)}))];case 1:return[2,i.sent()];case 2:return n=s(t),o=n[0],u=n.slice(1),[4,fetch.apply(void 0,a([this.getUrl(o)],s(u))).then((function(t){return e.handleErrors(t)}))];case 3:return[2,i.sent()]}}))}))},e.prototype.fetchJson=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.fetch.apply(this,a([],s(e))).then((function(e){return e.json()}))];case 1:return[2,t.sent()]}}))}))},e.prototype.post=function(e,t,o){void 0===o&&(o={});for(var u=[],c=3;c<arguments.length;c++)u[c-3]=arguments[c];return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.fetch.apply(this,a([e,r({body:JSON.stringify(t),method:"POST",headers:{"Content-Type":"application/json"}},o)],s(u)))];case 1:return[2,n.sent()]}}))}))},e.prototype.postJson=function(e,t,r){void 0===r&&(r={});for(var o=[],u=3;u<arguments.length;u++)o[u-3]=arguments[u];return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.post.apply(this,a([e,t,r],s(o))).then((function(e){return e.json()}))];case 1:return[2,n.sent()]}}))}))},e.prototype.getUrl=function(e){var t=e.indexOf("?")<0?"?":"&";return this.properties.config.apiUrl+"/"+e+t+"ak="+this.properties.config.apiKey},e}(),_=function(e,t,r){this.key=e,this.translations=t,this.id=r},T=function(){function e(e,t,o,u){var c=this;this.properties=e,this.coreService=t,this.apiHttpService=o,this.eventService=u,this.translationsCache=new Map,this.fetchPromises={},this.getTranslationsOfKey=function(e,t){return void 0===t&&(t=new Set([c.properties.currentLanguage])),n(c,void 0,void 0,(function(){var n,o,u,c,l,h,p,f,g;return i(this,(function(i){switch(i.label){case 0:this.coreService.checkScope("translations.view"),i.label=1;case 1:return i.trys.push([1,3,,7]),n=a([],s(t)),o=n.map((function(e){return"languages="+e})).join("&"),[4,this.apiHttpService.fetchJson("v2/projects/translations?"+o+"&filterKeyName="+encodeURIComponent(e))];case 2:return u=i.sent(),c=n.reduce((function(e,t){var n;return r(r({},e),((n={})[t]="",n))}),{}),(null==(l=null===(g=null===(f=u._embedded)||void 0===f?void 0:f.keys)||void 0===g?void 0:g[0])?void 0:l.translations)&&Object.entries(l.translations).forEach((function(e){var t=s(e,2),r=t[0],n=t[1];return c[r]=n.text})),[2,new _(e,c,null==l?void 0:l.keyId)];case 3:return(h=i.sent())instanceof E&&404===h.response.status&&"language_not_found"===h.code?(p=this.properties,[4,this.coreService.getLanguages()]):[3,5];case 4:return p.preferredLanguages=i.sent(),console.error("Requested language not found, refreshing the page!"),location.reload(),[3,6];case 5:throw h;case 6:return[3,7];case 7:return[2]}}))}))}}return e.translationByValue=function(e,t,r,n){return e||(n||(r?"":t))},e.prototype.initStatic=function(){var e,t=this;"production"===this.properties.config.mode&&"object"==typeof(null===(e=this.properties.config)||void 0===e?void 0:e.staticData)&&Object.entries(this.properties.config.staticData).forEach((function(e){var r=s(e,2),n=r[0],i=r[1];"function"!=typeof i&&t.setLanguageData(n,i)}))},e.prototype.loadTranslations=function(e){return void 0===e&&(e=this.properties.currentLanguage),n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return null!=this.translationsCache.get(e)?[3,2]:(this.fetchPromises[e]instanceof Promise||(this.fetchPromises[e]=this.fetchTranslations(e)),[4,this.fetchPromises[e]]);case 1:t.sent(),this.eventService.LANGUAGE_LOADED.emit(e),t.label=2;case 2:return this.fetchPromises[e]=void 0,[2]}}))}))},e.prototype.getTranslation=function(t,r,o,s){return void 0===r&&(r=this.properties.currentLanguage),void 0===o&&(o=!1),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return(n=this.getFromCache(t,r))?[3,3]:[4,this.loadTranslations(r)];case 1:return i.sent(),(n=this.getFromCache(t,r))?[3,3]:(n=this.getFromCache(t,this.properties.config.fallbackLanguage))?[3,3]:[4,this.loadTranslations(this.properties.config.fallbackLanguage)];case 2:i.sent(),n=this.getFromCache(t,this.properties.config.fallbackLanguage),i.label=3;case 3:return[2,e.translationByValue(n,t,o,s)]}}))}))},e.prototype.setTranslations=function(e){return n(this,void 0,void 0,(function(){var t,r=this;return i(this,(function(n){switch(n.label){case 0:return this.coreService.checkScope("translations.edit"),[4,this.apiHttpService.postJson("v2/projects/translations",{key:e.key,translations:e.translations})];case 1:return t=n.sent(),Object.keys(e.translations).forEach((function(t){var n=r.translationsCache.get(t);n&&(n[e.key]=e.translations[t])})),[2,t]}}))}))},e.prototype.uploadScreenshot=function(e,t){return n(this,void 0,void 0,(function(){var r,n;return i(this,(function(i){switch(i.label){case 0:return this.coreService.checkScope("translations.edit"),r=new FormData,[4,fetch(t).then((function(e){return e.blob()}))];case 1:return n=i.sent(),r.append("screenshot",n),[2,this.apiHttpService.post("v2/projects/keys/"+e+"/screenshots",void 0,{headers:{},body:r})]}}))}))},e.prototype.getFromCacheOrFallback=function(t,r,n,i){void 0===r&&(r=this.properties.currentLanguage),void 0===n&&(n=!1);var o=this.getFromCache(t,r)||this.getFromCache(t,this.properties.config.fallbackLanguage);return e.translationByValue(o,t,n,i)},e.prototype.fetchTranslations=function(e){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"development"!==this.properties.config.mode?[3,2]:[4,this.fetchTranslationsDevelopment(e)];case 1:return[2,t.sent()];case 2:return[4,this.fetchTranslationsProduction(e)];case 3:return[2,t.sent()]}}))}))},e.prototype.fetchTranslationsProduction=function(e){var t,r;return n(this,void 0,void 0,(function(){var n,o,s,a;return i(this,(function(i){switch(i.label){case 0:return"function"!=typeof(n=null===(r=null===(t=this.properties.config)||void 0===t?void 0:t.staticData)||void 0===r?void 0:r[e])?[3,2]:[4,n()];case 1:return a=i.sent(),this.setLanguageData(e,a),[2];case 2:if(void 0!==n)return this.setLanguageData(e,n),[2];i.label=3;case 3:o=""+(this.properties.config.filesUrlPrefix||"/")+e+".json",i.label=4;case 4:return i.trys.push([4,10,,11]),[4,fetch(o)];case 5:if((s=i.sent()).status>=400)return console.error("Server responded with error status while loading localization data."),this.setLanguageData(e,{}),[2];i.label=6;case 6:return i.trys.push([6,8,,9]),[4,s.json()];case 7:return a=i.sent(),this.setLanguageData(e,a),[3,9];case 8:return i.sent(),console.error("Error parsing json retrieved from "+o+"."),this.setEmptyLanguageData(e),[3,9];case 9:return[3,11];case 10:return i.sent(),console.error("Error fetching localization data from "+o+"."),this.setEmptyLanguageData(e),[3,11];case 11:return[2]}}))}))},e.prototype.fetchTranslationsDevelopment=function(e){return n(this,void 0,void 0,(function(){var t,r;return i(this,(function(n){switch(n.label){case 0:this.coreService.checkScope("translations.view"),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.apiHttpService.fetchJson("v2/projects/translations/"+e)];case 2:return t=n.sent(),this.setLanguageData(e,t[e]||{}),[3,4];case 3:return r=n.sent(),console.error("Error while fetching localization data from API.",r),this.setEmptyLanguageData(e),[2];case 4:return[2]}}))}))},e.prototype.setEmptyLanguageData=function(e){this.translationsCache.set(e,{})},e.prototype.setLanguageData=function(e,t){var r=function(e){var t={};return Object.entries(e).forEach((function(e){var n=s(e,2),i=n[0],o=n[1];"object"!=typeof o?t[i]=o:Object.entries(r(o)).forEach((function(e){var r=s(e,2),n=r[0],o=r[1];t[i+"."+n]=o}))})),t};this.translationsCache.set(e,r(t))},e.prototype.getFromCache=function(e,t){void 0===t&&(t=this.properties.currentLanguage);var r=this.translationsCache.get(t);if(void 0!==r)return r[e]},e}(),w=function(){function e(){}return e.splitOnNonEscapedDelimiter=function(e,t){for(var r=[],n="",i=!1,o=0;o<e.length;o++){var s=e[o];"\\"!==s||i?i?(i=!1,n+=s):s!==t?n+=s:(r.push(n),n=""):i=!0}return r.push(n),r},e.isCharEscaped=function(e,t){for(var r=0;e>-1&&"\\"===t[e-1];)r++,e--;return r%2==1},e.removeEscapes=function(e){for(var t="",r=!1,n=0;n<e.length;n++){var i=e[n];"\\"!==i||r?r?(r=!1,t+=i):t+=i:r=!0}return t},e}();function S(e){return e.type===h.literal}function L(e){return e.type===h.argument}function A(e){return e.type===h.number}function P(e){return e.type===h.date}function O(e){return e.type===h.time}function N(e){return e.type===h.select}function C(e){return e.type===h.plural}function R(e){return e.type===h.pound}function I(e){return e.type===h.tag}function k(e){return!(!e||"object"!=typeof e||e.type!==p.number)}function U(e){return!(!e||"object"!=typeof e||e.type!==p.dateTime)}!function(e){e[e.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",e[e.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",e[e.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",e[e.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",e[e.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",e[e.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",e[e.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",e[e.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",e[e.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",e[e.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",e[e.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",e[e.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",e[e.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",e[e.INVALID_TAG=23]="INVALID_TAG",e[e.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",e[e.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",e[e.UNCLOSED_TAG=27]="UNCLOSED_TAG"}(l||(l={})),function(e){e[e.literal=0]="literal",e[e.argument=1]="argument",e[e.number=2]="number",e[e.date=3]="date",e[e.time=4]="time",e[e.select=5]="select",e[e.plural=6]="plural",e[e.pound=7]="pound",e[e.tag=8]="tag"}(h||(h={})),function(e){e[e.number=0]="number",e[e.dateTime=1]="dateTime"}(p||(p={}));var D=/[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/,M=/(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g;function x(e){var t={};return e.replace(M,(function(e){var r=e.length;switch(e[0]){case"G":t.era=4===r?"long":5===r?"narrow":"short";break;case"y":t.year=2===r?"2-digit":"numeric";break;case"Y":case"u":case"U":case"r":throw new RangeError("`Y/u/U/r` (year) patterns are not supported, use `y` instead");case"q":case"Q":throw new RangeError("`q/Q` (quarter) patterns are not supported");case"M":case"L":t.month=["numeric","2-digit","short","long","narrow"][r-1];break;case"w":case"W":throw new RangeError("`w/W` (week) patterns are not supported");case"d":t.day=["numeric","2-digit"][r-1];break;case"D":case"F":case"g":throw new RangeError("`D/F/g` (day) patterns are not supported, use `d` instead");case"E":t.weekday=4===r?"short":5===r?"narrow":"short";break;case"e":if(r<4)throw new RangeError("`e..eee` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"c":if(r<4)throw new RangeError("`c..ccc` (weekday) patterns are not supported");t.weekday=["short","long","narrow","short"][r-4];break;case"a":t.hour12=!0;break;case"b":case"B":throw new RangeError("`b/B` (period) patterns are not supported, use `a` instead");case"h":t.hourCycle="h12",t.hour=["numeric","2-digit"][r-1];break;case"H":t.hourCycle="h23",t.hour=["numeric","2-digit"][r-1];break;case"K":t.hourCycle="h11",t.hour=["numeric","2-digit"][r-1];break;case"k":t.hourCycle="h24",t.hour=["numeric","2-digit"][r-1];break;case"j":case"J":case"C":throw new RangeError("`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead");case"m":t.minute=["numeric","2-digit"][r-1];break;case"s":t.second=["numeric","2-digit"][r-1];break;case"S":case"A":throw new RangeError("`S/A` (second) patterns are not supported, use `s` instead");case"z":t.timeZoneName=r<4?"short":"long";break;case"Z":case"O":case"v":case"V":case"X":case"x":throw new RangeError("`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead")}return""})),t}var G=/[\t-\r \x85\u200E\u200F\u2028\u2029]/i;var F,H=/^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g,j=/^(@+)?(\+|#+)?$/g,V=/(\*)(0+)|(#+)(0+)|(0+)/g,K=/^(0+)$/;function X(e){var t={};return e.replace(j,(function(e,r,n){return"string"!=typeof n?(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length):"+"===n?t.minimumSignificantDigits=r.length:"#"===r[0]?t.maximumSignificantDigits=r.length:(t.minimumSignificantDigits=r.length,t.maximumSignificantDigits=r.length+("string"==typeof n?n.length:0)),""})),t}function Y(e){switch(e){case"sign-auto":return{signDisplay:"auto"};case"sign-accounting":case"()":return{currencySign:"accounting"};case"sign-always":case"+!":return{signDisplay:"always"};case"sign-accounting-always":case"()!":return{signDisplay:"always",currencySign:"accounting"};case"sign-except-zero":case"+?":return{signDisplay:"exceptZero"};case"sign-accounting-except-zero":case"()?":return{signDisplay:"exceptZero",currencySign:"accounting"};case"sign-never":case"+_":return{signDisplay:"never"}}}function B(e){var t;if("E"===e[0]&&"E"===e[1]?(t={notation:"engineering"},e=e.slice(2)):"E"===e[0]&&(t={notation:"scientific"},e=e.slice(1)),t){var r=e.slice(0,2);if("+!"===r?(t.signDisplay="always",e=e.slice(2)):"+?"===r&&(t.signDisplay="exceptZero",e=e.slice(2)),!K.test(e))throw new Error("Malformed concise eng/scientific notation");t.minimumIntegerDigits=e.length}return t}function z(e){var t=Y(e);return t||{}}function W(e){for(var t={},n=0,i=e;n<i.length;n++){var o=i[n];switch(o.stem){case"percent":case"%":t.style="percent";continue;case"%x100":t.style="percent",t.scale=100;continue;case"currency":t.style="currency",t.currency=o.options[0];continue;case"group-off":case",_":t.useGrouping=!1;continue;case"precision-integer":case".":t.maximumFractionDigits=0;continue;case"measure-unit":case"unit":t.style="unit",t.unit=o.options[0].replace(/^(.*?)-/,"");continue;case"compact-short":case"K":t.notation="compact",t.compactDisplay="short";continue;case"compact-long":case"KK":t.notation="compact",t.compactDisplay="long";continue;case"scientific":t=r(r(r({},t),{notation:"scientific"}),o.options.reduce((function(e,t){return r(r({},e),z(t))}),{}));continue;case"engineering":t=r(r(r({},t),{notation:"engineering"}),o.options.reduce((function(e,t){return r(r({},e),z(t))}),{}));continue;case"notation-simple":t.notation="standard";continue;case"unit-width-narrow":t.currencyDisplay="narrowSymbol",t.unitDisplay="narrow";continue;case"unit-width-short":t.currencyDisplay="code",t.unitDisplay="short";continue;case"unit-width-full-name":t.currencyDisplay="name",t.unitDisplay="long";continue;case"unit-width-iso-code":t.currencyDisplay="symbol";continue;case"scale":t.scale=parseFloat(o.options[0]);continue;case"integer-width":if(o.options.length>1)throw new RangeError("integer-width stems only accept a single optional option");o.options[0].replace(V,(function(e,r,n,i,o,s){if(r)t.minimumIntegerDigits=n.length;else{if(i&&o)throw new Error("We currently do not support maximum integer digits");if(s)throw new Error("We currently do not support exact integer digits")}return""}));continue}if(K.test(o.stem))t.minimumIntegerDigits=o.stem.length;else if(H.test(o.stem)){if(o.options.length>1)throw new RangeError("Fraction-precision stems only accept a single optional option");o.stem.replace(H,(function(e,r,n,i,o,s){return"*"===n?t.minimumFractionDigits=r.length:i&&"#"===i[0]?t.maximumFractionDigits=i.length:o&&s?(t.minimumFractionDigits=o.length,t.maximumFractionDigits=o.length+s.length):(t.minimumFractionDigits=r.length,t.maximumFractionDigits=r.length),""})),o.options.length&&(t=r(r({},t),X(o.options[0])))}else if(j.test(o.stem))t=r(r({},t),X(o.stem));else{var s=Y(o.stem);s&&(t=r(r({},t),s));var a=B(o.stem);a&&(t=r(r({},t),a))}}return t}var J=new RegExp("^"+D.source+"*"),q=new RegExp(D.source+"*$");function Z(e,t){return{start:e,end:t}}var $=!!String.prototype.startsWith,Q=!!String.fromCodePoint,ee=!!Object.fromEntries,te=!!String.prototype.codePointAt,re=!!String.prototype.trimStart,ne=!!String.prototype.trimEnd,ie=!!Number.isSafeInteger?Number.isSafeInteger:function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e&&Math.abs(e)<=9007199254740991},oe=!0;try{oe="a"===(null===(F=fe("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu").exec("a"))||void 0===F?void 0:F[0])}catch(e){oe=!1}var se,ae=$?function(e,t,r){return e.startsWith(t,r)}:function(e,t,r){return e.slice(r,r+t.length)===t},ue=Q?String.fromCodePoint:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r,n="",i=e.length,o=0;i>o;){if((r=e[o++])>1114111)throw RangeError(r+" is not a valid code point");n+=r<65536?String.fromCharCode(r):String.fromCharCode(55296+((r-=65536)>>10),r%1024+56320)}return n},ce=ee?Object.fromEntries:function(e){for(var t={},r=0,n=e;r<n.length;r++){var i=n[r],o=i[0],s=i[1];t[o]=s}return t},le=te?function(e,t){return e.codePointAt(t)}:function(e,t){var r=e.length;if(!(t<0||t>=r)){var n,i=e.charCodeAt(t);return i<55296||i>56319||t+1===r||(n=e.charCodeAt(t+1))<56320||n>57343?i:n-56320+(i-55296<<10)+65536}},he=re?function(e){return e.trimStart()}:function(e){return e.replace(J,"")},pe=ne?function(e){return e.trimEnd()}:function(e){return e.replace(q,"")};function fe(e,t){return new RegExp(e,t)}if(oe){var ge=fe("([^\\p{White_Space}\\p{Pattern_Syntax}]*)","yu");se=function(e,t){var r;return ge.lastIndex=t,null!==(r=ge.exec(e)[1])&&void 0!==r?r:""}}else se=function(e,t){for(var r=[];;){var n=le(e,t);if(void 0===n||ye(n)||me(n))break;r.push(n),t+=n>=65536?2:1}return ue.apply(void 0,r)};var de=function(){function e(e,t){void 0===t&&(t={}),this.message=e,this.position={offset:0,line:1,column:1},this.ignoreTag=!!t.ignoreTag,this.requiresOtherClause=!!t.requiresOtherClause,this.shouldParseSkeletons=!!t.shouldParseSkeletons}return e.prototype.parse=function(){if(0!==this.offset())throw Error("parser can only be used once");return this.parseMessage(0,"",!1)},e.prototype.parseMessage=function(e,t,r){for(var n=[];!this.isEOF();){var i=this.char();if(123===i){if((o=this.parseArgument(e,r)).err)return o;n.push(o.val)}else{if(125===i&&e>0)break;if(35!==i||"plural"!==t&&"selectordinal"!==t){if(60===i&&!this.ignoreTag&&47===this.peek()){if(r)break;return this.error(l.UNMATCHED_CLOSING_TAG,Z(this.clonePosition(),this.clonePosition()))}if(60===i&&!this.ignoreTag&&ve(this.peek()||0)){if((o=this.parseTag(e,t)).err)return o;n.push(o.val)}else{var o;if((o=this.parseLiteral(e,t)).err)return o;n.push(o.val)}}else{var s=this.clonePosition();this.bump(),n.push({type:h.pound,location:Z(s,this.clonePosition())})}}}return{val:n,err:null}},e.prototype.parseTag=function(e,t){var r=this.clonePosition();this.bump();var n=this.parseTagName();if(this.bumpSpace(),this.bumpIf("/>"))return{val:{type:h.literal,value:"<"+n+"/>",location:Z(r,this.clonePosition())},err:null};if(this.bumpIf(">")){var i=this.parseMessage(e+1,t,!0);if(i.err)return i;var o=i.val,s=this.clonePosition();if(this.bumpIf("</")){if(this.isEOF()||!ve(this.char()))return this.error(l.INVALID_TAG,Z(s,this.clonePosition()));var a=this.clonePosition();return n!==this.parseTagName()?this.error(l.UNMATCHED_CLOSING_TAG,Z(a,this.clonePosition())):(this.bumpSpace(),this.bumpIf(">")?{val:{type:h.tag,value:n,children:o,location:Z(r,this.clonePosition())},err:null}:this.error(l.INVALID_TAG,Z(s,this.clonePosition())))}return this.error(l.UNCLOSED_TAG,Z(r,this.clonePosition()))}return this.error(l.INVALID_TAG,Z(r,this.clonePosition()))},e.prototype.parseTagName=function(){var e,t=this.offset();for(this.bump();!this.isEOF()&&(45===(e=this.char())||46===e||e>=48&&e<=57||95===e||e>=97&&e<=122||e>=65&&e<=90||183==e||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8255&&e<=8256||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533||e>=65536&&e<=983039);)this.bump();return this.message.slice(t,this.offset())},e.prototype.parseLiteral=function(e,t){for(var r=this.clonePosition(),n="";;){var i=this.tryParseQuote(t);if(i)n+=i;else{var o=this.tryParseUnquoted(e,t);if(o)n+=o;else{var s=this.tryParseLeftAngleBracket();if(!s)break;n+=s}}}var a=Z(r,this.clonePosition());return{val:{type:h.literal,value:n,location:a},err:null}},e.prototype.tryParseLeftAngleBracket=function(){return this.isEOF()||60!==this.char()||!this.ignoreTag&&(ve(e=this.peek()||0)||47===e)?null:(this.bump(),"<");var e},e.prototype.tryParseQuote=function(e){if(this.isEOF()||39!==this.char())return null;switch(this.peek()){case 39:return this.bump(),this.bump(),"'";case 123:case 60:case 62:case 125:break;case 35:if("plural"===e||"selectordinal"===e)break;return null;default:return null}this.bump();var t=[this.char()];for(this.bump();!this.isEOF();){var r=this.char();if(39===r){if(39!==this.peek()){this.bump();break}t.push(39),this.bump()}else t.push(r);this.bump()}return ue.apply(void 0,t)},e.prototype.tryParseUnquoted=function(e,t){if(this.isEOF())return null;var r=this.char();return 60===r||123===r||35===r&&("plural"===t||"selectordinal"===t)||125===r&&e>0?null:(this.bump(),ue(r))},e.prototype.parseArgument=function(e,t){var r=this.clonePosition();if(this.bump(),this.bumpSpace(),this.isEOF())return this.error(l.EXPECT_ARGUMENT_CLOSING_BRACE,Z(r,this.clonePosition()));if(125===this.char())return this.bump(),this.error(l.EMPTY_ARGUMENT,Z(r,this.clonePosition()));var n=this.parseIdentifierIfPossible().value;if(!n)return this.error(l.MALFORMED_ARGUMENT,Z(r,this.clonePosition()));if(this.bumpSpace(),this.isEOF())return this.error(l.EXPECT_ARGUMENT_CLOSING_BRACE,Z(r,this.clonePosition()));switch(this.char()){case 125:return this.bump(),{val:{type:h.argument,value:n,location:Z(r,this.clonePosition())},err:null};case 44:return this.bump(),this.bumpSpace(),this.isEOF()?this.error(l.EXPECT_ARGUMENT_CLOSING_BRACE,Z(r,this.clonePosition())):this.parseArgumentOptions(e,t,n,r);default:return this.error(l.MALFORMED_ARGUMENT,Z(r,this.clonePosition()))}},e.prototype.parseIdentifierIfPossible=function(){var e=this.clonePosition(),t=this.offset(),r=se(this.message,t),n=t+r.length;return this.bumpTo(n),{value:r,location:Z(e,this.clonePosition())}},e.prototype.parseArgumentOptions=function(e,t,n,i){var o,s=this.clonePosition(),a=this.parseIdentifierIfPossible().value,u=this.clonePosition();switch(a){case"":return this.error(l.EXPECT_ARGUMENT_TYPE,Z(s,u));case"number":case"date":case"time":this.bumpSpace();var c=null;if(this.bumpIf(",")){this.bumpSpace();var f=this.clonePosition();if((b=this.parseSimpleArgStyleIfPossible()).err)return b;if(0===(v=pe(b.val)).length)return this.error(l.EXPECT_ARGUMENT_STYLE,Z(this.clonePosition(),this.clonePosition()));c={style:v,styleLocation:Z(f,this.clonePosition())}}if((_=this.tryParseArgumentClose(i)).err)return _;var g=Z(i,this.clonePosition());if(c&&ae(null==c?void 0:c.style,"::",0)){var d=he(c.style.slice(2));if("number"===a)return(b=this.parseNumberSkeletonFromString(d,c.styleLocation)).err?b:{val:{type:h.number,value:n,location:g,style:b.val},err:null};if(0===d.length)return this.error(l.EXPECT_DATE_TIME_SKELETON,g);var v={type:p.dateTime,pattern:d,location:c.styleLocation,parsedOptions:this.shouldParseSkeletons?x(d):{}};return{val:{type:"date"===a?h.date:h.time,value:n,location:g,style:v},err:null}}return{val:{type:"number"===a?h.number:"date"===a?h.date:h.time,value:n,location:g,style:null!==(o=null==c?void 0:c.style)&&void 0!==o?o:null},err:null};case"plural":case"selectordinal":case"select":var y=this.clonePosition();if(this.bumpSpace(),!this.bumpIf(","))return this.error(l.EXPECT_SELECT_ARGUMENT_OPTIONS,Z(y,r({},y)));this.bumpSpace();var m=this.parseIdentifierIfPossible(),E=0;if("select"!==a&&"offset"===m.value){if(!this.bumpIf(":"))return this.error(l.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,Z(this.clonePosition(),this.clonePosition()));var b;if(this.bumpSpace(),(b=this.tryParseDecimalInteger(l.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE,l.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE)).err)return b;this.bumpSpace(),m=this.parseIdentifierIfPossible(),E=b.val}var _,T=this.tryParsePluralOrSelectOptions(e,a,t,m);if(T.err)return T;if((_=this.tryParseArgumentClose(i)).err)return _;var w=Z(i,this.clonePosition());return"select"===a?{val:{type:h.select,value:n,options:ce(T.val),location:w},err:null}:{val:{type:h.plural,value:n,options:ce(T.val),offset:E,pluralType:"plural"===a?"cardinal":"ordinal",location:w},err:null};default:return this.error(l.INVALID_ARGUMENT_TYPE,Z(s,u))}},e.prototype.tryParseArgumentClose=function(e){return this.isEOF()||125!==this.char()?this.error(l.EXPECT_ARGUMENT_CLOSING_BRACE,Z(e,this.clonePosition())):(this.bump(),{val:!0,err:null})},e.prototype.parseSimpleArgStyleIfPossible=function(){for(var e=0,t=this.clonePosition();!this.isEOF();){switch(this.char()){case 39:this.bump();var r=this.clonePosition();if(!this.bumpUntil("'"))return this.error(l.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE,Z(r,this.clonePosition()));this.bump();break;case 123:e+=1,this.bump();break;case 125:if(!(e>0))return{val:this.message.slice(t.offset,this.offset()),err:null};e-=1;break;default:this.bump()}}return{val:this.message.slice(t.offset,this.offset()),err:null}},e.prototype.parseNumberSkeletonFromString=function(e,t){var r=[];try{r=function(e){if(0===e.length)throw new Error("Number skeleton cannot be empty");for(var t=[],r=0,n=e.split(G).filter((function(e){return e.length>0}));r<n.length;r++){var i=n[r].split("/");if(0===i.length)throw new Error("Invalid number skeleton");for(var o=i[0],s=i.slice(1),a=0,u=s;a<u.length;a++)if(0===u[a].length)throw new Error("Invalid number skeleton");t.push({stem:o,options:s})}return t}(e)}catch(e){return this.error(l.INVALID_NUMBER_SKELETON,t)}return{val:{type:p.number,tokens:r,location:t,parsedOptions:this.shouldParseSkeletons?W(r):{}},err:null}},e.prototype.tryParsePluralOrSelectOptions=function(e,t,r,n){for(var i,o=!1,s=[],a=new Set,u=n.value,c=n.location;;){if(0===u.length){var h=this.clonePosition();if("select"===t||!this.bumpIf("="))break;var p=this.tryParseDecimalInteger(l.EXPECT_PLURAL_ARGUMENT_SELECTOR,l.INVALID_PLURAL_ARGUMENT_SELECTOR);if(p.err)return p;c=Z(h,this.clonePosition()),u=this.message.slice(h.offset,this.offset())}if(a.has(u))return this.error("select"===t?l.DUPLICATE_SELECT_ARGUMENT_SELECTOR:l.DUPLICATE_PLURAL_ARGUMENT_SELECTOR,c);"other"===u&&(o=!0),this.bumpSpace();var f=this.clonePosition();if(!this.bumpIf("{"))return this.error("select"===t?l.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT:l.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT,Z(this.clonePosition(),this.clonePosition()));var g=this.parseMessage(e+1,t,r);if(g.err)return g;var d=this.tryParseArgumentClose(f);if(d.err)return d;s.push([u,{value:g.val,location:Z(f,this.clonePosition())}]),a.add(u),this.bumpSpace(),u=(i=this.parseIdentifierIfPossible()).value,c=i.location}return 0===s.length?this.error("select"===t?l.EXPECT_SELECT_ARGUMENT_SELECTOR:l.EXPECT_PLURAL_ARGUMENT_SELECTOR,Z(this.clonePosition(),this.clonePosition())):this.requiresOtherClause&&!o?this.error(l.MISSING_OTHER_CLAUSE,Z(this.clonePosition(),this.clonePosition())):{val:s,err:null}},e.prototype.tryParseDecimalInteger=function(e,t){var r=1,n=this.clonePosition();this.bumpIf("+")||this.bumpIf("-")&&(r=-1);for(var i=!1,o=0;!this.isEOF();){var s=this.char();if(!(s>=48&&s<=57))break;i=!0,o=10*o+(s-48),this.bump()}var a=Z(n,this.clonePosition());return i?ie(o*=r)?{val:o,err:null}:this.error(t,a):this.error(e,a)},e.prototype.offset=function(){return this.position.offset},e.prototype.isEOF=function(){return this.offset()===this.message.length},e.prototype.clonePosition=function(){return{offset:this.position.offset,line:this.position.line,column:this.position.column}},e.prototype.char=function(){var e=this.position.offset;if(e>=this.message.length)throw Error("out of bound");var t=le(this.message,e);if(void 0===t)throw Error("Offset "+e+" is at invalid UTF-16 code unit boundary");return t},e.prototype.error=function(e,t){return{val:null,err:{kind:e,message:this.message,location:t}}},e.prototype.bump=function(){if(!this.isEOF()){var e=this.char();10===e?(this.position.line+=1,this.position.column=1,this.position.offset+=1):(this.position.column+=1,this.position.offset+=e<65536?1:2)}},e.prototype.bumpIf=function(e){if(ae(this.message,e,this.offset())){for(var t=0;t<e.length;t++)this.bump();return!0}return!1},e.prototype.bumpUntil=function(e){var t=this.offset(),r=this.message.indexOf(e,t);return r>=0?(this.bumpTo(r),!0):(this.bumpTo(this.message.length),!1)},e.prototype.bumpTo=function(e){if(this.offset()>e)throw Error("targetOffset "+e+" must be greater than or equal to the current offset "+this.offset());for(e=Math.min(e,this.message.length);;){var t=this.offset();if(t===e)break;if(t>e)throw Error("targetOffset "+e+" is at invalid UTF-16 code unit boundary");if(this.bump(),this.isEOF())break}},e.prototype.bumpSpace=function(){for(;!this.isEOF()&&ye(this.char());)this.bump()},e.prototype.peek=function(){if(this.isEOF())return null;var e=this.char(),t=this.offset(),r=this.message.charCodeAt(t+(e>=65536?2:1));return null!=r?r:null},e}();function ve(e){return e>=97&&e<=122||e>=65&&e<=90}function ye(e){return e>=9&&e<=13||32===e||133===e||e>=8206&&e<=8207||8232===e||8233===e}function me(e){return e>=33&&e<=35||36===e||e>=37&&e<=39||40===e||41===e||42===e||43===e||44===e||45===e||e>=46&&e<=47||e>=58&&e<=59||e>=60&&e<=62||e>=63&&e<=64||91===e||92===e||93===e||94===e||96===e||123===e||124===e||125===e||126===e||161===e||e>=162&&e<=165||166===e||167===e||169===e||171===e||172===e||174===e||176===e||177===e||182===e||187===e||191===e||215===e||247===e||e>=8208&&e<=8213||e>=8214&&e<=8215||8216===e||8217===e||8218===e||e>=8219&&e<=8220||8221===e||8222===e||8223===e||e>=8224&&e<=8231||e>=8240&&e<=8248||8249===e||8250===e||e>=8251&&e<=8254||e>=8257&&e<=8259||8260===e||8261===e||8262===e||e>=8263&&e<=8273||8274===e||8275===e||e>=8277&&e<=8286||e>=8592&&e<=8596||e>=8597&&e<=8601||e>=8602&&e<=8603||e>=8604&&e<=8607||8608===e||e>=8609&&e<=8610||8611===e||e>=8612&&e<=8613||8614===e||e>=8615&&e<=8621||8622===e||e>=8623&&e<=8653||e>=8654&&e<=8655||e>=8656&&e<=8657||8658===e||8659===e||8660===e||e>=8661&&e<=8691||e>=8692&&e<=8959||e>=8960&&e<=8967||8968===e||8969===e||8970===e||8971===e||e>=8972&&e<=8991||e>=8992&&e<=8993||e>=8994&&e<=9e3||9001===e||9002===e||e>=9003&&e<=9083||9084===e||e>=9085&&e<=9114||e>=9115&&e<=9139||e>=9140&&e<=9179||e>=9180&&e<=9185||e>=9186&&e<=9254||e>=9255&&e<=9279||e>=9280&&e<=9290||e>=9291&&e<=9311||e>=9472&&e<=9654||9655===e||e>=9656&&e<=9664||9665===e||e>=9666&&e<=9719||e>=9720&&e<=9727||e>=9728&&e<=9838||9839===e||e>=9840&&e<=10087||10088===e||10089===e||10090===e||10091===e||10092===e||10093===e||10094===e||10095===e||10096===e||10097===e||10098===e||10099===e||10100===e||10101===e||e>=10132&&e<=10175||e>=10176&&e<=10180||10181===e||10182===e||e>=10183&&e<=10213||10214===e||10215===e||10216===e||10217===e||10218===e||10219===e||10220===e||10221===e||10222===e||10223===e||e>=10224&&e<=10239||e>=10240&&e<=10495||e>=10496&&e<=10626||10627===e||10628===e||10629===e||10630===e||10631===e||10632===e||10633===e||10634===e||10635===e||10636===e||10637===e||10638===e||10639===e||10640===e||10641===e||10642===e||10643===e||10644===e||10645===e||10646===e||10647===e||10648===e||e>=10649&&e<=10711||10712===e||10713===e||10714===e||10715===e||e>=10716&&e<=10747||10748===e||10749===e||e>=10750&&e<=11007||e>=11008&&e<=11055||e>=11056&&e<=11076||e>=11077&&e<=11078||e>=11079&&e<=11084||e>=11085&&e<=11123||e>=11124&&e<=11125||e>=11126&&e<=11157||11158===e||e>=11159&&e<=11263||e>=11776&&e<=11777||11778===e||11779===e||11780===e||11781===e||e>=11782&&e<=11784||11785===e||11786===e||11787===e||11788===e||11789===e||e>=11790&&e<=11798||11799===e||e>=11800&&e<=11801||11802===e||11803===e||11804===e||11805===e||e>=11806&&e<=11807||11808===e||11809===e||11810===e||11811===e||11812===e||11813===e||11814===e||11815===e||11816===e||11817===e||e>=11818&&e<=11822||11823===e||e>=11824&&e<=11833||e>=11834&&e<=11835||e>=11836&&e<=11839||11840===e||11841===e||11842===e||e>=11843&&e<=11855||e>=11856&&e<=11857||11858===e||e>=11859&&e<=11903||e>=12289&&e<=12291||12296===e||12297===e||12298===e||12299===e||12300===e||12301===e||12302===e||12303===e||12304===e||12305===e||e>=12306&&e<=12307||12308===e||12309===e||12310===e||12311===e||12312===e||12313===e||12314===e||12315===e||12316===e||12317===e||e>=12318&&e<=12319||12320===e||12336===e||64830===e||64831===e||e>=65093&&e<=65094}function Ee(e){e.forEach((function(e){if(delete e.location,N(e)||C(e))for(var t in e.options)delete e.options[t].location,Ee(e.options[t].value);else A(e)&&k(e.style)||(P(e)||O(e))&&U(e.style)?delete e.style.location:I(e)&&Ee(e.children)}))}function be(e,t){void 0===t&&(t={}),t=r({shouldParseSkeletons:!0,requiresOtherClause:!0},t);var n=new de(e,t).parse();if(n.err){var i=SyntaxError(l[n.err.kind]);throw i.location=n.err.location,i.originalMessage=n.err.message,i}return(null==t?void 0:t.captureLocation)||Ee(n.val),n.val}function _e(e,t){var r=t&&t.cache?t.cache:Ne,n=t&&t.serializer?t.serializer:Ae;return(t&&t.strategy?t.strategy:Le)(e,{cache:r,serializer:n})}function Te(e,t,r,n){var i,o=null==(i=n)||"number"==typeof i||"boolean"==typeof i?n:r(n),s=t.get(o);return void 0===s&&(s=e.call(this,n),t.set(o,s)),s}function we(e,t,r){var n=Array.prototype.slice.call(arguments,3),i=r(n),o=t.get(i);return void 0===o&&(o=e.apply(this,n),t.set(i,o)),o}function Se(e,t,r,n,i){return r.bind(t,e,n,i)}function Le(e,t){return Se(e,this,1===e.length?Te:we,t.cache.create(),t.serializer)}var Ae=function(){return JSON.stringify(arguments)};function Pe(){this.cache=Object.create(null)}Pe.prototype.get=function(e){return this.cache[e]},Pe.prototype.set=function(e,t){this.cache[e]=t};var Oe,Ne={create:function(){return new Pe}},Ce={variadic:function(e,t){return Se(e,this,we,t.cache.create(),t.serializer)},monadic:function(e,t){return Se(e,this,Te,t.cache.create(),t.serializer)}};!function(e){e.MISSING_VALUE="MISSING_VALUE",e.INVALID_VALUE="INVALID_VALUE",e.MISSING_INTL_API="MISSING_INTL_API"}(Oe||(Oe={}));var Re,Ie=function(e){function r(t,r,n){var i=e.call(this,t)||this;return i.code=r,i.originalMessage=n,i}return t(r,e),r.prototype.toString=function(){return"[formatjs Error: "+this.code+"] "+this.message},r}(Error),ke=function(e){function r(t,r,n,i){return e.call(this,'Invalid values for "'+t+'": "'+r+'". Options are "'+Object.keys(n).join('", "')+'"',Oe.INVALID_VALUE,i)||this}return t(r,e),r}(Ie),Ue=function(e){function r(t,r,n){return e.call(this,'Value for "'+t+'" must be of type '+r,Oe.INVALID_VALUE,n)||this}return t(r,e),r}(Ie),De=function(e){function r(t,r){return e.call(this,'The intl string context variable "'+t+'" was not provided to the string "'+r+'"',Oe.MISSING_VALUE,r)||this}return t(r,e),r}(Ie);function Me(e){return"function"==typeof e}function xe(e,t,r,n,i,o,s){if(1===e.length&&S(e[0]))return[{type:Re.literal,value:e[0].value}];for(var a=[],u=0,c=e;u<c.length;u++){var l=c[u];if(S(l))a.push({type:Re.literal,value:l.value});else if(R(l))"number"==typeof o&&a.push({type:Re.literal,value:r.getNumberFormat(t).format(o)});else{var h=l.value;if(!i||!(h in i))throw new De(h,s);var p=i[h];if(L(l))p&&"string"!=typeof p&&"number"!=typeof p||(p="string"==typeof p||"number"==typeof p?String(p):""),a.push({type:"string"==typeof p?Re.literal:Re.object,value:p});else if(P(l)){var f="string"==typeof l.style?n.date[l.style]:U(l.style)?l.style.parsedOptions:void 0;a.push({type:Re.literal,value:r.getDateTimeFormat(t,f).format(p)})}else if(O(l)){f="string"==typeof l.style?n.time[l.style]:U(l.style)?l.style.parsedOptions:void 0;a.push({type:Re.literal,value:r.getDateTimeFormat(t,f).format(p)})}else if(A(l)){(f="string"==typeof l.style?n.number[l.style]:k(l.style)?l.style.parsedOptions:void 0)&&f.scale&&(p*=f.scale||1),a.push({type:Re.literal,value:r.getNumberFormat(t,f).format(p)})}else{if(I(l)){var g=l.children,d=l.value,v=i[d];if(!Me(v))throw new Ue(d,"function",s);var y=v(xe(g,t,r,n,i,o).map((function(e){return e.value})));Array.isArray(y)||(y=[y]),a.push.apply(a,y.map((function(e){return{type:"string"==typeof e?Re.literal:Re.object,value:e}})))}if(N(l)){if(!(m=l.options[p]||l.options.other))throw new ke(l.value,p,Object.keys(l.options),s);a.push.apply(a,xe(m.value,t,r,n,i))}else if(C(l)){var m;if(!(m=l.options["="+p])){if(!Intl.PluralRules)throw new Ie('Intl.PluralRules is not available in this environment.\nTry polyfilling it using "@formatjs/intl-pluralrules"\n',Oe.MISSING_INTL_API,s);var E=r.getPluralRules(t,{type:l.pluralType}).select(p-(l.offset||0));m=l.options[E]||l.options.other}if(!m)throw new ke(l.value,p,Object.keys(l.options),s);a.push.apply(a,xe(m.value,t,r,n,i,p-(l.offset||0)))}else;}}}return function(e){return e.length<2?e:e.reduce((function(e,t){var r=e[e.length-1];return r&&r.type===Re.literal&&t.type===Re.literal?r.value+=t.value:e.push(t),e}),[])}(a)}function Ge(e,t){return t?Object.keys(e).reduce((function(n,i){var o,s;return n[i]=(o=e[i],(s=t[i])?r(r(r({},o||{}),s||{}),Object.keys(o).reduce((function(e,t){return e[t]=r(r({},o[t]),s[t]||{}),e}),{})):o),n}),r({},e)):e}function Fe(e){return{create:function(){return{get:function(t){return e[t]},set:function(t,r){e[t]=r}}}}}!function(e){e[e.literal=0]="literal",e[e.object=1]="object"}(Re||(Re={}));var He=function(){function e(t,r,n,i){var o,s=this;if(void 0===r&&(r=e.defaultLocale),this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(e){var t=s.formatToParts(e);if(1===t.length)return t[0].value;var r=t.reduce((function(e,t){return e.length&&t.type===Re.literal&&"string"==typeof e[e.length-1]?e[e.length-1]+=t.value:e.push(t.value),e}),[]);return r.length<=1?r[0]||"":r},this.formatToParts=function(e){return xe(s.ast,s.locales,s.formatters,s.formats,e,void 0,s.message)},this.resolvedOptions=function(){return{locale:Intl.NumberFormat.supportedLocalesOf(s.locales)[0]}},this.getAst=function(){return s.ast},"string"==typeof t){if(this.message=t,!e.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");this.ast=e.__parse(t,{ignoreTag:null==i?void 0:i.ignoreTag})}else this.ast=t;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=Ge(e.formats,n),this.locales=r,this.formatters=i&&i.formatters||(void 0===(o=this.formatterCache)&&(o={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:_e((function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new((e=Intl.NumberFormat).bind.apply(e,a([void 0],t)))}),{cache:Fe(o.number),strategy:Ce.variadic}),getDateTimeFormat:_e((function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new((e=Intl.DateTimeFormat).bind.apply(e,a([void 0],t)))}),{cache:Fe(o.dateTime),strategy:Ce.variadic}),getPluralRules:_e((function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new((e=Intl.PluralRules).bind.apply(e,a([void 0],t)))}),{cache:Fe(o.pluralRules),strategy:Ce.variadic})})}return Object.defineProperty(e,"defaultLocale",{get:function(){return e.memoizedDefaultLocale||(e.memoizedDefaultLocale=(new Intl.NumberFormat).resolvedOptions().locale),e.memoizedDefaultLocale},enumerable:!1,configurable:!0}),e.memoizedDefaultLocale=null,e.__parse=be,e.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},e}(),je=function(){function e(e,t){var r=this;this.properties=e,this.translationService=t,this.format=function(e,t){try{return new He(e,r.properties.currentLanguage,void 0,{ignoreTag:!0}).format(t)}catch(t){if("MISSING_VALUE"===t.code)return console.warn(t.message),e}},this.escapeForRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},this.escapeParam=function(e){return"string"==typeof e?e.replace(/[,:\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(e),console.warn("Unsupported value type of above param. Consider converting to string."),e)}}return Object.defineProperty(e.prototype,"rawUnWrapRegex",{get:function(){return"(\\\\?)("+this.escapeForRegExp(this.properties.config.inputPrefix)+"(.*?)"+this.escapeForRegExp(this.properties.config.inputSuffix)+")"},enumerable:!1,configurable:!0}),e.parseUnwrapped=function(e){var t,r,n=!1,i="",s="",a="KEY",u={key:"",params:{},defaultValue:void 0};try{for(var c=o(e),l=c.next();!l.done;l=c.next()){var h=l.value;"\\"!==h||n?n?(n=!1,i+=h):"KEY"!==a||","!==h?"KEY"!==a||":"!==h?"DEFAULT_VALUE"!==a||":"!==h?"PARAM_NAME"!==a||":"!==h?"PARAM_VALUE"!==a||","!==h?i+=h:(a="PARAM_NAME",u.params[s]=i,i=""):(a="PARAM_VALUE",s=i,i=""):(a="PARAM_NAME",u.defaultValue=i,i=""):(a="PARAM_NAME",u.key=i,i=""):(a="DEFAULT_VALUE",u.key=i,i=""):n=!0}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}return"KEY"===a&&(u.key=i),"DEFAULT_VALUE"===a&&(u.defaultValue=i),"PARAM_VALUE"===a&&(u.params[s]=i),u},e.prototype.translate=function(e,t,r,o,s){return void 0===r&&(r=this.properties.currentLanguage),n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return n=this.format,[4,this.translationService.getTranslation(e,r,o,s)];case 1:return[2,n.apply(this,[i.sent(),t])]}}))}))},e.prototype.instant=function(e,t,r,n,i){return void 0===r&&(r=this.properties.currentLanguage),this.format(this.translationService.getFromCacheOrFallback(e,r,n,i),t)},e.prototype.replace=function(e){return n(this,void 0,void 0,(function(){var t,r,n,o,a,u,c,l,h,p,f,g,d,v;return i(this,(function(i){switch(i.label){case 0:t=new RegExp(this.rawUnWrapRegex,"gs"),r=[],n=!1,a=0,u="",i.label=1;case 1:if(null===(o=t.exec(e)))return[3,3];if(c=o[1],l=s(o,4),h=l[0],p=l[2],f=l[3],g=o.index,d=o.input,u+=d.substr(a,g-a),a=g+h.length,"\\"===c){if(!w.isCharEscaped(g,e))return u+=p,[3,1];c=""}return[4,this.getTranslatedWithMetadata(f)];case 2:return v=i.sent(),r.push({key:v.key,params:v.params,defaultValue:v.defaultValue}),n=!0,u+=c+v.translated,[3,1];case 3:return u+=e.substring(a),n?[2,{text:u,keys:r}]:[2,void 0]}}))}))},e.prototype.wrap=function(e,t,r){var n=this;void 0===t&&(t={}),void 0===r&&(r=void 0);var i=Object.entries(t).map((function(e){var t=s(e,2),r=t[0],i=t[1];return n.escapeParam(r)+":"+n.escapeParam(i)})).join(",");i=i.length?":"+i:"";var o=void 0!==r?","+this.escapeParam(r):"";return""+this.properties.config.inputPrefix+this.escapeParam(e)+o+i+this.properties.config.inputSuffix},e.prototype.getTranslatedWithMetadata=function(t){return n(this,void 0,void 0,(function(){var r,n,o,s;return i(this,(function(i){switch(i.label){case 0:return r=e.parseUnwrapped(t),n=r.key,o=r.params,s=r.defaultValue,[4,this.translate(n,o,void 0,!1,s)];case 1:return[2,{translated:i.sent(),key:n,params:o,defaultValue:s}]}}))}))},e}(),Ve=function(){function e(e){this.properties=e,this.keysDown=new Set,this.mouseOn=new Set,this.mouseOnChanged=new y,this.keysChanged=new y,"undefined"==typeof window||this.initKeyListener()}return e.prototype.handle=function(e,t){var r=this;e._tolgee.listeningForHighlighting?console.error("Element is already listening mouse events! This is probably bug in tolgee"):(e._tolgee.listeningForHighlighting=!0,this.initEventListeners(e,t),this.mouseOnChanged.subscribe((function(){r.highlighted!==r.getMouseOn()&&r.onConditionsChanged()})),this.keysChanged.subscribe((function(){r.onConditionsChanged()})))},e.prototype.initEventListeners=function(e,t){var r=this,n=function(){return r.onMouseOver(e)},i=function(){return r.onMouseOut(e)},o=function(e){r.areKeysDown()&&(e.stopPropagation(),e.preventDefault(),t(e))};e.addEventListener("mouseover",n),e.addEventListener("click",o);var s=function(e){r.areKeysDown()&&(e.stopPropagation(),e.preventDefault())};e.addEventListener("mousedown",s),e.addEventListener("mouseup",s),e.addEventListener("mouseout",i),e._tolgee.removeAllEventListeners=function(){e.removeEventListener("mousedown",s),e.removeEventListener("mouseup",s),e.removeEventListener("mouseover",n),e.removeEventListener("click",o),e.removeEventListener("mouseout",i)}},e.prototype.onConditionsChanged=function(){this.unhighlight(),this.areKeysDown()&&this.getMouseOn()&&this.highlight()},e.prototype.highlight=function(){this.getMouseOn()._tolgee.highlight(),this.highlighted=this.getMouseOn()},e.prototype.unhighlight=function(){this.highlighted&&(this.highlighted._tolgee.unhighlight(),this.highlighted=null)},e.prototype.onMouseOut=function(e){this.mouseOn.delete(e),this.mouseOnChanged.emit(this.getMouseOn())},e.prototype.onMouseOver=function(e){this.filterMouseOn(),this.mouseOn.delete(e),this.mouseOn.add(e),this.mouseOnChanged.emit(this.getMouseOn())},e.prototype.getMouseOn=function(){var e=Array.from(this.mouseOn);return e.length?e[0]:void 0},e.prototype.initKeyListener=function(){var e=this;window.addEventListener("blur",(function(){e.keysDown=new Set,e.keysChanged.emit(e.areKeysDown())})),window.addEventListener("keydown",(function(t){var r=exports.ModifierKey[t.key];void 0!==r&&(e.keysDown.add(r),e.keysChanged.emit(e.areKeysDown()))})),window.addEventListener("keyup",(function(t){e.keysDown.delete(exports.ModifierKey[t.key]),e.keysChanged.emit(e.areKeysDown())}))},e.prototype.filterMouseOn=function(){var e=this;this.mouseOn.forEach((function(t){document.contains(t)||e.mouseOn.delete(t)}))},e.prototype.areKeysDown=function(){var e,t;try{for(var r=o(this.properties.config.highlightKeys),n=r.next();!n.done;n=r.next()){var i=n.value;if(!this.keysDown.has(i))return!1}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}return!0},e}(),Ke=function(){function e(e){var t=this;this.dependencies=e,this.translationEdit=function(e,r){return n(t,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return"object"!=typeof this.renderer?[3,2]:[4,this.getKey(e,r)];case 1:return(t=n.sent())?(this.renderer.renderViewer(t),[2]):[2];case 2:return console.warn('Tolgee UI is not provided. To translate interactively provide tolgee ui constructor to "ui" configuration property. To disable highlighting use production mode.'),[2]}}))}))}}return Object.defineProperty(e.prototype,"renderer",{get:function(){return void 0===this._renderer&&"function"==typeof this.dependencies.properties.config.ui&&(this._renderer=new this.dependencies.properties.config.ui(this.dependencies)),this._renderer},enumerable:!1,configurable:!0}),e.getKeyOptions=function(e){var t=Array.from(e._tolgee.nodes).reduce((function(e,t){return a(a([],s(e)),s(t._tolgee.keys.map((function(e){return e.key}))))}),[]);return new Set(t)},e.prototype.listen=function(e){var t=this;this.dependencies.highlightFunctionInitializer.initFunctions(e),this.dependencies.mouseEventHandler.handle(e,(function(r){return n(t,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.translationEdit(r,e)];case 1:return[2,t.sent()]}}))}))}))},e.prototype.getKey=function(t,r){return n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return r._tolgee.wrappedWithElementOnlyKey?[2,r._tolgee.wrappedWithElementOnlyKey]:(n=e.getKeyOptions(r)).size>1?[4,this.renderer.getKey({keys:n,openEvent:t})]:[3,2];case 1:return[2,i.sent()];case 2:return 1===n.size?[2,Array.from(n)[0]]:(console.error("No key to translate. This seems like a bug in tolgee."),[2])}}))}))},e}(),Xe=function(){function e(e,t,r){this.properties=e,this.translationHighlighter=t,this.eventService=r,this.registeredElements=new Set}return e.prototype.register=function(e){(void 0!==this.getActiveNodes(e).next().value||e._tolgee.wrappedWithElementOnlyKey)&&("development"!==this.properties.config.mode||this.registeredElements.has(e)||this.translationHighlighter.listen(e),this.registeredElements.add(e),this.eventService.ELEMENT_REGISTERED.emit(e))},e.prototype.refreshAll=function(){var e,t;try{for(var r=o(this.registeredElements),n=r.next();!n.done;n=r.next()){var i=n.value;this.cleanElementInactiveNodes(i),0!==i._tolgee.nodes.size||i._tolgee.wrappedWithElementOnlyKey||this.cleanElement(i)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.cleanAll=function(){var e,t;try{for(var r=o(this.registeredElements),n=r.next();!n.done;n=r.next()){var i=n.value;this.cleanElement(i)}}catch(t){e={error:t}}finally{try{n&&!n.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}},e.prototype.findAllByKey=function(e){var t,r,n,i,s=[];try{for(var a=o(this.registeredElements),u=a.next();!u.done;u=a.next()){var c=u.value;if(c._tolgee.wrappedWithElementOnlyKey!==e)try{for(var l=(n=void 0,o(c._tolgee.nodes)),h=l.next();!h.done;h=l.next()){if(h.value._tolgee.keys.findIndex((function(t){return t.key===e}))>-1){s.push(c);break}}}catch(e){n={error:e}}finally{try{h&&!h.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}else s.push(c)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}return s},e.prototype.cleanElementInactiveNodes=function(e){this.isElementActive(e)&&(e._tolgee.nodes=new Set(this.getActiveNodes(e)))},e.prototype.cleanElement=function(e){"function"==typeof e._tolgee.removeAllEventListeners&&e._tolgee.removeAllEventListeners(),e.removeAttribute("_tolgee"),delete e._tolgee,this.registeredElements.delete(e)},e.prototype.getActiveNodes=function(e){var t,r,n,s,a,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,5,6,7]),t=o(e._tolgee.nodes),r=t.next(),i.label=1;case 1:return r.done?[3,4]:(n=r.value,c.nodeContains(this.properties.config.targetElement,n)?[4,n]:[3,3]);case 2:i.sent(),i.label=3;case 3:return r=t.next(),[3,1];case 4:return[3,7];case 5:return s=i.sent(),a={error:s},[3,7];case 6:try{r&&!r.done&&(u=t.return)&&u.call(t)}finally{if(a)throw a.error}return[7];case 7:return[2]}}))},e.prototype.isElementActive=function(e){return this.properties.config.targetElement.contains(e)},e}(),Ye=function(){function e(e,t,r,n){this.properties=e,this.textService=t,this.elementRegistrar=r,this.translationHighlighter=n}return e.initParentElement=function(e){return void 0===e._tolgee&&(e._tolgee={nodes:new Set},e.setAttribute("_tolgee","")),e},e.prototype.filterRestricted=function(e){var t=this.properties.config.restrictedElements;return e.filter((function(e){var r=c.closestElement(e);return-1===t.indexOf(r.tagName.toLowerCase())&&null===r.closest('[data-tolgee-restricted="true"]')}))},e.prototype.handleNodes=function(e){return n(this,void 0,void 0,(function(){var t,r,n,s,a,u,c,l,h,p,f,g;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,5,6,7]),t=o(e),r=t.next(),i.label=1;case 1:return r.done?[3,4]:(void 0===(n=r.value)._tolgee&&(n._tolgee={}),!0===(null==(s=n._tolgee)?void 0:s.locked)?[3,3]:(this.lockNode(n),[4,this.textService.replace(n.textContent)]));case 2:(a=i.sent())&&(u=a.text,c=a.keys,l=this.translateChildNode(n,u,c),(h=this.getParentElement(l))._tolgee.nodes.add(l),this.elementRegistrar.register(h)),this.unlockNode(n),i.label=3;case 3:return r=t.next(),[3,1];case 4:return[3,7];case 5:return p=i.sent(),f={error:p},[3,7];case 6:try{r&&!r.done&&(g=t.return)&&g.call(t)}finally{if(f)throw f.error}return[7];case 7:return[2]}}))}))},e.prototype.translateChildNode=function(e,t,r){return e._tolgee={oldTextContent:e.textContent,keys:r},e.textContent=t,e},e.prototype.lockNode=function(e){void 0===e._tolgee&&(e._tolgee={});var t=e._tolgee;return!0!==(null==t?void 0:t.locked)&&(t.locked=!0),e},e.prototype.unlockNode=function(e){e._tolgee&&(e._tolgee.locked=!1)},e.prototype.getParentElement=function(t){var r=this.getSuitableParent(t);return e.initParentElement(r)},e.prototype.getSuitableParent=function(e){var t=c.getParentElement(e);if(void 0===t)throw console.error(e),new Error("No suitable parent found for node above.");if(!this.properties.config.passToParent)return t;if(Array.isArray(this.properties.config.passToParent)){if(-1===this.properties.config.passToParent.findIndex((function(e){return t.tagName.toLowerCase()===e.toLowerCase()})))return t}return"function"!=typeof this.properties.config.passToParent||this.properties.config.passToParent(t)?this.getSuitableParent(t):t},e}(),Be=function(e){function r(t,r,n,i){var o=e.call(this,t,n,i,r)||this;return o.properties=t,o.translationHighlighter=r,o.textService=n,o.nodeRegistrar=i,o}return t(r,e),r.prototype.handle=function(e){return n(this,void 0,void 0,(function(){var t,r,n,o,s;return i(this,(function(i){switch(i.label){case 0:return t=this.properties.config.inputPrefix,r=this.properties.config.inputSuffix,n="./descendant-or-self::text()[contains(., '"+t+"') and contains(., '"+r+"')]",o=c.evaluate(n,e),s=this.filterRestricted(o),[4,this.handleNodes(s)];case 1:return i.sent(),[2]}}))}))},r}(Ye),ze=function(e){function r(t,r,n,i){var o=e.call(this,t,r,n,i)||this;return o.properties=t,o.textService=r,o.elementRegistrar=n,o.translationHighlighter=i,o}return t(r,e),r.prototype.handle=function(e){return n(this,void 0,void 0,(function(){var t,r,n,a,u,l,h,p,f,g,d,v,y,m,E,b,_,T;return i(this,(function(i){switch(i.label){case 0:t=this.properties.config.inputPrefix,r=this.properties.config.inputSuffix,i.label=1;case 1:i.trys.push([1,12,13,14]),n=o(Object.entries(this.properties.config.tagAttributes)),a=n.next(),i.label=2;case 2:if(a.done)return[3,11];u=s(a.value,2),l=u[0],h=u[1],i.label=3;case 3:i.trys.push([3,8,9,10]),_=void 0,p=o(h),f=p.next(),i.label=4;case 4:return f.done?[3,7]:(g=f.value,d="descendant-or-self::"+l+"/@"+g+"[contains(., '"+t+"') and contains(., '"+r+"')]",v=c.evaluate(d,e),[4,this.handleNodes(v)]);case 5:i.sent(),i.label=6;case 6:return f=p.next(),[3,4];case 7:return[3,10];case 8:return y=i.sent(),_={error:y},[3,10];case 9:try{f&&!f.done&&(T=p.return)&&T.call(p)}finally{if(_)throw _.error}return[7];case 10:return a=n.next(),[3,2];case 11:return[3,14];case 12:return m=i.sent(),E={error:m},[3,14];case 13:try{a&&!a.done&&(b=n.return)&&b.call(n)}finally{if(E)throw E.error}return[7];case 14:return[2]}}))}))},r}(Ye),We=function(){function e(e,t,r,n,i,o,s){this.service=e,this.textHandler=t,this.eventService=r,this.properties=n,this.attributeHandler=i,this.textService=o,this.wrappedHandler=s,r.LANGUAGE_CHANGED.subscribe(this.refresh.bind(this)),r.TRANSLATION_CHANGED.subscribe(this.refresh.bind(this))}return e.prototype.handleSubtree=function(e){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.attributeHandler.handle(e)];case 1:return t.sent(),[4,this.textHandler.handle(e)];case 2:return t.sent(),[4,this.wrappedHandler.handle(e)];case 3:return t.sent(),[2]}}))}))},e.prototype.refresh=function(){return n(this,void 0,void 0,(function(){var e,t,r,n,s,a,u,l,h,p,f,g,d,v;return i(this,(function(i){switch(i.label){case 0:e=c.evaluate("//*[@_tolgee]",this.properties.config.targetElement),i.label=1;case 1:i.trys.push([1,12,13,14]),t=o(e),r=t.next(),i.label=2;case 2:if(r.done)return[3,11];n=r.value,i.label=3;case 3:i.trys.push([3,8,9,10]),d=void 0,s=o(n._tolgee.nodes),a=s.next(),i.label=4;case 4:return a.done?[3,7]:(u=a.value,[4,this.textService.replace(u._tolgee.oldTextContent)]);case 5:(l=i.sent())&&(u.textContent=l.text),i.label=6;case 6:return a=s.next(),[3,4];case 7:return[3,10];case 8:return h=i.sent(),d={error:h},[3,10];case 9:try{a&&!a.done&&(v=s.return)&&v.call(s)}finally{if(d)throw d.error}return[7];case 10:return r=t.next(),[3,2];case 11:return[3,14];case 12:return p=i.sent(),f={error:p},[3,14];case 13:try{r&&!r.done&&(g=t.return)&&g.call(t)}finally{if(f)throw f.error}return[7];case 14:return[2]}}))}))},e}(),Je=function(){function e(e,t,r,n,i){this.properties=e,this.coreHandler=t,this.basicTextHandler=r,this.attributeHandler=n,this.nodeRegistrar=i,this._observer=void 0}return Object.defineProperty(e.prototype,"observer",{get:function(){var e=this;return this._observer||"undefined"==typeof window||(this._observer=new MutationObserver((function(t){return n(e,void 0,void 0,(function(){var e,r,n,s,a,u;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,9,10,11]),e=o(t),r=e.next(),i.label=1;case 1:return r.done?[3,8]:"characterData"!==(n=r.value).type?[3,3]:[4,this.basicTextHandler.handle(n.target)];case 2:return i.sent(),[3,7];case 3:return"childList"!==n.type?[3,5]:[4,this.coreHandler.handleSubtree(n.target)];case 4:return i.sent(),[3,7];case 5:return"attributes"!==n.type?[3,7]:[4,this.attributeHandler.handle(n.target)];case 6:i.sent(),i.label=7;case 7:return r=e.next(),[3,1];case 8:return[3,11];case 9:return s=i.sent(),a={error:s},[3,11];case 10:try{r&&!r.done&&(u=e.return)&&u.call(e)}finally{if(a)throw a.error}return[7];case 11:return this.nodeRegistrar.refreshAll(),[2]}}))}))}))),this._observer},enumerable:!1,configurable:!0}),e.prototype.observe=function(){this.observer&&this.observer.observe(this.properties.config.targetElement,{attributes:!0,childList:!0,subtree:!0,characterData:!0})},e.prototype.stopObserving=function(){this.observer&&this.observer.disconnect()},e}(),qe=function(){function e(e,t){this.properties=e,this.apiHttpService=t}return e.prototype.getLanguages=function(){return n(this,void 0,void 0,(function(){var e,t;return i(this,(function(r){switch(r.label){case 0:return this.languagePromise instanceof Promise||(this.languagePromise=this.apiHttpService.fetchJson("v2/projects/languages?size=1000")),t=Set.bind,[4,this.languagePromise];case 1:return e=new(t.apply(Set,[void 0,r.sent()._embedded.languages.map((function(e){return e.tag}))])),this.properties.preferredLanguages=new Set(Array.from(this.properties.preferredLanguages).filter((function(t){return e.has(t)}))),[2,e]}}))}))},e.prototype.getScopes=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.apiHttpService.fetchJson("api/apiKeys/scopes")];case 1:return[2,t.sent()];case 2:return e=t.sent(),console.error(e),console.error("Error getting scopes. Trying to switch to production mode!"),this.properties.config.mode="production",[3,3];case 3:return[2]}}))}))},e.prototype.isAuthorizedTo=function(e){return this.properties.scopes.indexOf(e)>-1},e.prototype.checkScope=function(e){if(!this.isAuthorizedTo(e))throw new Error("Api key not permitted to do this, please add 'translations.view' scope.")},e}(),Ze=function(e){function r(t,r,n,i){var o=e.call(this,t,n,i,r)||this;return o.properties=t,o.translationHighlighter=r,o.textService=n,o.elementRegistrar=i,o}return t(r,e),r.prototype.handle=function(e){return n(this,void 0,void 0,(function(){var t,r=this;return i(this,(function(n){return"./descendant-or-self::*[@data-tolgee-key-only]",t=c.evaluate("./descendant-or-self::*[@data-tolgee-key-only]",e),this.filterRestricted(t).forEach((function(e){var t=Ye.initParentElement(e);t._tolgee.wrappedWithElementOnlyKey=e.getAttribute("data-tolgee-key-only"),r.elementRegistrar.register(t)})),[2]}))}))},r}(Ye),$e=function(){function e(e,t,n,i){var o=this;this.messages=e,this.properties=t,this.eventService=n,this.elementRegistrar=i,this.handshakeSucceed=!1,this.takeScreenshot=function(){return new Promise((function(e,t){try{o.messages.send("TOLGEE_TAKE_SCREENSHOT"),o.messages.listen("TOLGEE_SCREENSHOT_TAKEN",(function(t){e(t)}))}catch(e){t(e)}}))},this.handshake=function(){var e=r(r({},o.properties),{config:r(r({},o.properties.config),{staticData:void 0,targetElement:void 0,_targetElement:void 0,ui:void 0})});o.messages.send("TOLGEE_READY",e),o.messages.listen("TOLGEE_PLUGIN_READY",(function(){o.handshakeSucceed=!0,o.messages.send("TOLGEE_READY",e),o.initListeners()}))}}return e.prototype.run=function(){try{this.messages.startListening(),this.handshake(),this.initOnRegisterKeyEmit()}catch(e){console.warn(e),console.warn("Can not start communication with browser plugin. Check waning above.")}},e.prototype.initOnRegisterKeyEmit=function(){var e=this;this.eventService.ELEMENT_REGISTERED.subscribe((function(t){t._tolgee.nodes.forEach((function(t){t._tolgee.keys.forEach((function(t){return e.messages.send("NEW_KEY",t)}))}))}))},e.prototype.stop=function(){this.messages.stopListening()},e.prototype.initListeners=function(){var e=this;this.messages.listenPopup("HIGHLIGHT_KEY",(function(t){var r,n;try{for(var i=o(e.elementRegistrar.findAllByKey(t)),s=i.next();!s.done;s=i.next()){s.value._tolgee.highlight()}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}})),this.messages.listenPopup("UNHIGHLIGHT_KEY",(function(t){var r,n;try{for(var i=o(e.elementRegistrar.findAllByKey(t)),s=i.next();!s.done;s=i.next()){s.value._tolgee.unhighlight()}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}}))},e}(),Qe=function(){function e(){var e=this;this.listeners=[],this.listenersPopup=[],this.startListening=function(){var t=function(t){t.source==window&&e.listeners.forEach((function(e){e.type==t.data.type&&e.callback(t.data.data)}))};window.addEventListener("message",t,!1),"function"==typeof e._stopListening&&e._stopListening(),e._stopListening=function(){window.removeEventListener("message",t,!1)},e.startPopupListening()},this.startPopupListening=function(){e.listen("POPUP_TO_LIB",(function(t){e.listenersPopup.forEach((function(e){t.type==e.type&&e.callback(t.data)}))}))},this.listenPopup=function(t,r){e.listenersPopup.push({type:t,callback:r})},this.listen=function(t,r){e.listeners.push({type:t,callback:r})},this.send=function(e,t){try{window.postMessage({type:e,data:t},window.origin)}catch(e){console.warn("Can not send message.",e)}}}return e.prototype.stopListening=function(){this._stopListening()},e}(),et=function(){function e(e){this.properties=e}return e.prototype.initFunctions=function(e){this.initHighlightFunction(e),this.initUnhighlightFunction(e)},e.prototype.initHighlightFunction=function(e){var t=this;e._tolgee.highlight=function(){e._tolgee.initialBackgroundColor=e.style.backgroundColor,e.style.backgroundColor=t.properties.config.highlightColor}},e.prototype.initUnhighlightFunction=function(e){e._tolgee.unhighlight=function(){e.style.backgroundColor=e._tolgee.initialBackgroundColor}},e}(),tt=function(e){void 0===e&&(e=new g),this.properties=new d,this.eventService=new m,this.apiHttpService=new b(this.properties),this.mouseEventHandler=new Ve(this.properties),this.coreService=new qe(this.properties,this.apiHttpService),this.translationService=new T(this.properties,this.coreService,this.apiHttpService,this.eventService),this.textService=new je(this.properties,this.translationService),this.highlightFunctionInitializer=new et(this.properties),this.translationHighlighter=new Ke(this),this.elementRegistrar=new Xe(this.properties,this.translationHighlighter,this.eventService),this.textHandler=new Be(this.properties,this.translationHighlighter,this.textService,this.elementRegistrar),this.attributeHandler=new ze(this.properties,this.textService,this.elementRegistrar,this.translationHighlighter),this.wrappedHandler=new Ze(this.properties,this.translationHighlighter,this.textService,this.elementRegistrar),this.coreHandler=new We(this.coreService,this.textHandler,this.eventService,this.properties,this.attributeHandler,this.textService,this.wrappedHandler),this.observer=new Je(this.properties,this.coreHandler,this.textHandler,this.attributeHandler,this.elementRegistrar),this.messages=new Qe,this.pluginManager=new $e(this.messages,this.properties,this.eventService,this.elementRegistrar),this.properties.config=e,this.translationService.initStatic(),this.translationHighlighter.pluginManager=this.pluginManager},rt=function(){function e(e){var t=this;this.stop=function(){t.dependencyStore.observer.stopObserving(),t.dependencyStore.elementRegistrar.cleanAll(),c.unmarkElementAsTargetElement(t.properties.config.targetElement)},this.dependencyStore=new tt(new g(e))}return Object.defineProperty(e.prototype,"properties",{get:function(){return this.dependencyStore.properties},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"translationService",{get:function(){return this.dependencyStore.translationService},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coreService",{get:function(){return this.dependencyStore.coreService},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lang",{get:function(){return this.properties.currentLanguage},set:function(e){this.properties.currentLanguage=e,this.dependencyStore.eventService.LANGUAGE_CHANGED.emit(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultLanguage",{get:function(){return this.properties.config.defaultLanguage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onLangChange",{get:function(){return this.dependencyStore.eventService.LANGUAGE_CHANGED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTranslationChange",{get:function(){return this.dependencyStore.eventService.TRANSLATION_CHANGED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onLangLoaded",{get:function(){return this.dependencyStore.eventService.LANGUAGE_LOADED},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"initialLoading",{get:function(){var e,t,r,n;if("production"!==(null===(t=null===(e=this.properties)||void 0===e?void 0:e.config)||void 0===t?void 0:t.mode))return!0;var i=this.properties.currentLanguage,o=this.properties.config.fallbackLanguage,s=this.properties.config.preloadFallback,a=function(e){return void 0!==e&&"function"!=typeof e};return!a(null===(r=this.properties.config.staticData)||void 0===r?void 0:r[i])||!!s&&!a(null===(n=this.properties.config.staticData)||void 0===n?void 0:n[o])},enumerable:!1,configurable:!0}),e.prototype.run=function(){return n(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return"development"!==this.properties.config.mode?[3,2]:[4,this.loadScopes()];case 1:e.sent(),e.label=2;case 2:return[4,this.translationService.loadTranslations()];case 3:return e.sent(),[4,this.dependencyStore.pluginManager.run()];case 4:return e.sent(),this.properties.config.preloadFallback?[4,this.translationService.loadTranslations(this.properties.config.fallbackLanguage)]:[3,6];case 5:e.sent(),e.label=6;case 6:return[4,this.refresh()];case 7:return e.sent(),this.properties.config.watch&&this.dependencyStore.observer.observe(),[2]}}))}))},e.prototype.refresh=function(){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.dependencyStore.coreHandler.handleSubtree(this.properties.config.targetElement)]}))}))},e.prototype.translate=function(e,t,r,o){return void 0===t&&(t={}),void 0===r&&(r=!1),void 0===o&&(o=void 0),n(this,void 0,void 0,(function(){var n,s;return i(this,(function(i){switch(i.label){case 0:return n="string"==typeof e?e:e.key,"object"==typeof e&&(t=void 0!==(s=e).params?s.params:t,r=void 0!==s.noWrap?s.noWrap:r,o=void 0!==s.defaultValue?s.defaultValue:o),"development"!==this.properties.config.mode||r?[3,3]:[4,this.loadScopes()];case 1:return i.sent(),[4,this.translationService.loadTranslations()];case 2:return i.sent(),[2,this.dependencyStore.textService.wrap(n,t,o)];case 3:return[2,this.dependencyStore.textService.translate(n,t,void 0,void 0,o)]}}))}))},e.prototype.instant=function(e,t,r,n,i){void 0===t&&(t={}),void 0===r&&(r=!1);var o="string"==typeof e?e:e.key;if("object"==typeof e){var s=e;t=void 0!==s.params?s.params:t,r=void 0!==s.noWrap?s.noWrap:r,i=void 0!==s.defaultValue?s.defaultValue:i,n=void 0!==s.orEmpty?s.orEmpty:n}return"development"!==this.properties.config.mode||r?this.dependencyStore.textService.instant(o,t,void 0,n,i):this.dependencyStore.textService.wrap(o,t,i)},e.prototype.loadScopes=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(t){switch(t.label){case 0:return void 0!==this.properties.scopes?[3,2]:(e=this.properties,[4,this.dependencyStore.coreService.getScopes()]);case 1:e.scopes=t.sent(),t.label=2;case 2:return[2]}}))}))},e}();exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE="data-tolgee-key-only",exports.Tolgee=rt,exports.TolgeeConfig=g,exports.TranslationData=_;
|
|
17
17
|
//# sourceMappingURL=tolgee.cjs.min.js.map
|