Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tolgee/core

Package Overview
Dependencies
Maintainers
2
Versions
357
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tolgee/core - npm Package Compare versions

Comparing version 4.10.0-rc.72ff5c5.0 to 4.10.0-rc.a50bdc6.0

2

dist/tolgee.cjs.js

@@ -774,3 +774,3 @@ 'use strict';

let observerOptions = initObserverOptions();
let devCredentials = {};
let devCredentials = undefined;
function init(options) {

@@ -777,0 +777,0 @@ state = initState(options, state);

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=()=>{let e=[];return Object.freeze({listen:n=>{const t=e=>{n(e)};return e.push(t),{unsubscribe:()=>{e=e.filter((e=>t!==e))}}},emit:n=>{e.forEach((e=>e({value:n})))}})};function n(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function t(e){return n(e)||[]}function a(e,n){return"object"!=typeof(a=n)||Array.isArray(a)||null===a?t(n):t(null==n?void 0:n[e]);var a}function i(e){return Array.from(new Set(e))}function o(e,n){const t=e.get(n)||0;e.set(n,t+1)}function r(e,n){let t=e.get(n)||1;t-=1,t<=0?e.delete(n):e.set(n,t)}const s=e=>{const n=new Set,a=new Set,i=n=>{if(n.has(void 0)){const t=new Set(n.keys());return t.delete(void 0),e().forEach((e=>t.add(e))),t}return n};let s=[];const g=()=>{if(0===s.length)return;n.forEach((e=>{e({value:void 0})}));const e=new Set;let t=new Set;s.forEach((n=>{void 0===(null==n?void 0:n.ns)?e.add(void 0):n.ns.forEach((n=>e.add(n))),void 0===(null==n?void 0:n.key)?t=void 0:void 0!==t&&t.add(n.key)}));const o=Array.from(i(e).keys());(t||[void 0]).forEach((e=>{((e,n)=>{a.forEach((t=>{const a=i(t.namespaces),o=void 0===n||-1!==(null==n?void 0:n.findIndex((e=>a.has(e)))),r=void 0===e||t.keys.has(e)||0===t.keys.size;o&&r&&t.fn({value:void 0})}))})(e,o)})),s=[]};return Object.freeze({listenSome:e=>{const n={fn:n=>{e(n)},keys:new Map,namespaces:new Map};a.add(n);const i={unsubscribe:()=>{a.delete(n)},subscribeNs:e=>(t(e).forEach((e=>o(n.namespaces,e))),i),unsubscribeNs:e=>(t(e).forEach((e=>r(n.namespaces,e))),i),subscribeKey:e=>{const{key:a,ns:r}=e;return o(n.keys,a),t(r).forEach((e=>o(n.namespaces,e))),void 0===r&&o(n.namespaces,void 0),i},unsubscribeKey:e=>{const{key:a,ns:o}=e;return r(n.keys,a),t(o).forEach((e=>r(n.namespaces,e))),void 0===o&&r(n.namespaces,void 0),i}};return i},listen:e=>{n.add(e);return{unsubscribe:()=>{n.delete(e)}}},emit:(e,n)=>{s.push(e),n?Promise.resolve().then((()=>{g()})):g()}})},g=e=>{const n=new Map;return Object.entries(e).forEach((([e,t])=>{null!=t&&("object"!=typeof t?n.set(e,t):g(t).forEach(((t,a)=>{n.set(e+"."+a,t)})))})),n},c=e=>{const[n,t]=e.split(":");return{language:n,namespace:t||""}},u=({language:e,namespace:n})=>n?`${e}:${n}`:e,l=(e,n,a,i,o,r,s)=>{const l=new Map,d=new Map;let f={},p=0;function v(n,t,a){const i=u(n);d.set(i,{data:g(t),version:a}),e.emit(n)}function b(e,n){v(e,n,p)}function h(e,n=!1){const t=d.get(u(e));return t&&n?t.version===p:Boolean(t)}function m(e){var n;return null===(n=d.get(u(i(e))))||void 0===n?void 0:n.data}function y(e){let t;if(!t){const n=f[u(e)];"function"==typeof n&&(t=n())}return t||(t=n(e)),t||(t=Promise.resolve({})),t}return Object.freeze({addStaticData:function(e){e&&(f=Object.assign(Object.assign({},f),e),Object.entries(e).forEach((([e,n])=>{if("function"!=typeof n){const t=c(e),a=d.get(e);a&&0!==a.version||v(t,n,0)}})))},invalidate:function(){l.clear(),p+=1},addRecord:b,exists:h,getRecord:m,getTranslation:function(e,n){var t;return null===(t=d.get(u(e)))||void 0===t?void 0:t.data.get(n)},getTranslationNs:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return i}return Array.from(new Set(e))},getTranslationFallback:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return n}},changeTranslation:function(n,t,a){var i;const o=null===(i=d.get(u(n)))||void 0===i?void 0:i.data;null==o||o.set(t,a),e.emit(Object.assign(Object.assign({},n),{key:t}))},isFetching:function(e){if(o())return!0;if(void 0===e)return l.size>0;const n=t(e);return Boolean(Array.from(l.keys()).find((e=>n.includes(c(e).namespace))))},isLoading:function(e,n){const a=t(n);return Boolean(o()||Array.from(l.keys()).find((n=>{const t=c(n);return(!a.length||a.includes(t.namespace))&&!h({namespace:t.namespace,language:e})})))},loadRecords:async function(e,n){const t=e.map((e=>{const t=i(e),o=u(t),r=l.get(o);if(r)return{new:!1,promise:r,keyObject:t,cacheKey:o};const s=function(e,n){var t;let i;return n&&(i=null===(t=a(e))||void 0===t?void 0:t.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),y(e))))),i||(i=y(e)),i}(t,n);return l.set(o,s),{new:!0,promise:s,keyObject:t,cacheKey:o}}));r.notify(),s.notify();const o=await Promise.all(t.map((e=>e.promise)));return t.forEach(((e,n)=>{const t=l.get(e.cacheKey)!==e.promise;if(e.new&&!t){l.delete(e.cacheKey);const t=o[n];t&&b(e.keyObject,t)}})),r.notify(),s.notify(),t.map((e=>m(e.keyObject)))},getAllRecords:function(){return Array.from(d.entries()).map((([e,n])=>Object.assign(Object.assign({},c(e)),{data:n.data})))}})};function d(e){return Boolean(e&&"function"==typeof e.then)}const f=(e,n)=>d(e)?Promise.resolve(e).then(n):n(e),p=e=>`Tolgee: You need to specify '${e}' option`,v=(e,n,a,i,o,r,s)=>{const g={ui:void 0,observer:void 0},c={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},u=async(e,{keysAndDefaults:n})=>{var a;const i=n.map((({key:e,ns:n,defaultValue:a})=>({key:e,defaultValue:a,ns:t(o({key:e,ns:n,defaultValue:a})),translation:r({key:e,ns:n})})));null===(a=c.ui)||void 0===a||a.handleElementClick(e,i)},l=(e,n)=>{var t,a;return(null===(a=null===(t=c.observer)||void 0===t?void 0:t.highlight)||void 0===a?void 0:a.call(t,e,n))||{unhighlight(){}}},p=e=>{const n=r(e);return v(Object.assign(Object.assign({},e),{translation:n,formatEnabled:!0}))},v=({key:n,translation:t,defaultValue:a,noWrap:i,params:o,orEmpty:r,ns:s,formatEnabled:g})=>{var u;const l=t||a;let d=l||(r?"":n);c.observer&&!i&&(d=c.observer.wrap({key:n,translation:d,defaultValue:a,params:o,ns:s}));const f=e(),p=g||!(null===(u=c.observer)||void 0===u?void 0:u.outputNotFormattable);if(l&&f&&p)for(const e of c.formatters)d=e.format({translation:d,language:f,params:o});return c.finalFormatter&&l&&f&&p&&(d=c.finalFormatter.format({translation:d,language:f,params:o})),d};return Object.freeze({setFinalFormatter:e=>{c.finalFormatter=e},addFormatter:e=>{e&&c.formatters.push(e)},formatTranslation:v,setObserver:e=>{g.observer=e},hasObserver:()=>Boolean(g.observer),setUi:e=>{g.ui=(null==e?void 0:e.UI)||e},hasUi:()=>Boolean(g.ui),addBackend:e=>{e&&c.backends.push(e)},setDevBackend:e=>{c.devBackend=e},getDevBackend:()=>c.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const t of c.backends){const a=t.getRecord({language:e,namespace:n});if(d(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:t})=>{var a;return null===(a=c.devBackend)||void 0===a?void 0:a.getRecord({apiKey:n().apiKey,apiUrl:n().apiUrl,language:e,namespace:t})},setLanguageDetector:e=>{c.languageDetector=e},getLanguageDetector:()=>c.languageDetector,setLanguageStorage:e=>{c.languageStorage=e},getLanguageStorage:()=>c.languageStorage,getInitialLanguage:()=>{var e;const n=i(),t=null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage();return f(t,(e=>n&&!n.includes(e)||!e?(()=>{if(!c.languageDetector)return;const e=i();return c.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var n;null===(n=c.languageStorage)||void 0===n||n.setLanguage(e)},run:e=>{var t,i;c.ui=g.ui&&new g.ui({apiKey:n().apiKey,apiUrl:n().apiUrl,highlight:l,changeTranslation:s}),c.observer||(c.observer=null===(t=g.observer)||void 0===t?void 0:t.call(g,{translate:p,onClick:u,options:a()})),null===(i=c.observer)||void 0===i||i.run({mouseHighlight:e})},stop:()=>{var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=c.observer)||void 0===e||e.retranslate()},highlight:l,wrap:e=>{var n;return c.observer?null===(n=c.observer)||void 0===n?void 0:n.wrap(e):e.translation},unwrap:e=>{var n;return c.observer?null===(n=c.observer)||void 0===n?void 0:n.unwrap(e):{text:e,keys:[]}}})},b=(e,n,t)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=n();a!==e&&t(e),a=e}})},h={tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"]},m=e=>Object.assign(Object.assign({},h),e),y={defaultNs:"",filesUrlPrefix:"i18n/"},O=(e,n)=>{const t=Object.assign(Object.assign(Object.assign({},y),null==n?void 0:n.initialOptions),e),a=t.apiUrl;return t.apiUrl=a?a.replace(/\/+$/,""):a,{initialOptions:t,activeNamespaces:(null==n?void 0:n.activeNamespaces)||new Map,language:null==n?void 0:n.language,pendingLanguage:null==n?void 0:n.language,isInitialLoading:!1,isRunning:!1}};function L(e){var{ns:n,noWrap:t,orEmpty:a,params:i}=e,o=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(t[a[i]]=e[a[i]])}return t}(e,["ns","noWrap","orEmpty","params"]);return{ns:n,noWrap:t,orEmpty:a,params:Object.assign(Object.assign({},o),i)}}const k=(e,...n)=>{let t,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof n[0]?(a.defaultValue=n[0],t=n[1]):"object"==typeof n[0]&&(t=n[0])),t&&(a=Object.assign(Object.assign({},L(t)),a)),a},j=({options:n})=>{const o=(n=>{const t=e(),a=e(),i=e(),o=e(),r=e(),g=e(),c=s(n),u=e(),l=e();return g.listen((()=>c.emit())),a.listen((()=>c.emit())),u.listen((({value:e})=>{c.emit({ns:[e.namespace],key:e.key},!0)})),Object.freeze({onPendingLanguageChange:t,onLanguageChange:a,onKeyChange:i,onKeyUpdate:c,onLoadingChange:o,onFetchingChange:r,onInitialLoaded:g,onRunningChange:l,onCacheChange:u,on:(e,n)=>{switch(e){case"pendingLanguage":return t.listen(n);case"language":return a.listen(n);case"loading":return o.listen(n);case"fetching":return r.listen(n);case"initialLoad":return g.listen(n);case"running":return l.listen(n);case"cache":return u.listen(n);case"keyUpdate":return c.listen(n)}}})})((function(){return u.getFallbackNamespaces()})),r=b(!1,(()=>y.isFetching()),o.onFetchingChange.emit),g=b(!1,(()=>R()),o.onLoadingChange.emit),u=((e,n,o)=>{let r=O(),s=m(),g={};function u(){return r.language||r.initialOptions.language}function l(){return Object.assign(Object.assign({},r.initialOptions),g)}return Object.freeze({init:function(e){r=O(e,r)},isRunning:function(){return r.isRunning},setRunning:function(e){r.isRunning!==e&&(r.isRunning=e,o.emit(e))},isInitialLoading:function(){return r.isInitialLoading},setInitialLoading:function(e){r.isInitialLoading=e},getLanguage:u,setLanguage:function(n){r.language!==n&&(r.language=n,e.emit(n))},getPendingLanguage:function(){return r.pendingLanguage||u()},setPendingLanguage:function(e){r.pendingLanguage!==e&&(r.pendingLanguage=e,n.emit(e))},getInitialOptions:l,addActiveNs:function(e){t(e).forEach((e=>{const n=r.activeNamespaces.get(e);void 0!==n?r.activeNamespaces.set(e,n+1):r.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){t(e).forEach((e=>{const n=r.activeNamespaces.get(e);void 0!==n&&n>1?r.activeNamespaces.set(e,n-1):r.activeNamespaces.delete(e)}))},getRequiredNamespaces:function(){return i([...r.initialOptions.ns||[r.initialOptions.defaultNs],...r.activeNamespaces.keys()])},getFallbackLangs:function(e){const n=e||u();return n?i([n,...a(n,r.initialOptions.fallbackLanguage)]):[]},getFallbackNamespaces:function(){const e=r.initialOptions.defaultNs;return i([..."string"==typeof e?[e]:[],...t(r.initialOptions.fallbackNs)])},getAvailableLanguages:function(){if(r.initialOptions.availableLanguages)return r.initialOptions.availableLanguages;if(r.initialOptions.staticData){const e=Object.keys(r.initialOptions.staticData).map((e=>c(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?l().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){g=e},setObserverOptions:function(e){s=m(e)},getObserverOptions:function(){return s}})})(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),h=v(u.getLanguage,u.getInitialOptions,u.getObserverOptions,u.getAvailableLanguages,(function({key:e,ns:n}){const a=void 0!==n?t(n):u.getFallbackNamespaces(),i=u.getFallbackLangs();return y.getTranslationNs(a,i,e)}),N,L),y=l(o.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,u.withDefaultNs,u.isInitialLoading,r,g);function L(e,n,t){const a=u.withDefaultNs(e),i=y.getTranslation(a,n);return y.changeTranslation(a,n,t),{revert:()=>{y.changeTranslation(a,n,i)}}}function j(e){u.init(e),y.addStaticData(u.getInitialOptions().staticData)}function R(e){return y.isLoading(u.getLanguage(),e)}function E(){return Boolean(u.getInitialOptions().apiKey&&u.getInitialOptions().apiUrl&&h.getDevBackend())}function w(e,n){const a=function(e,n){const a=u.getFallbackLangs(e),i=void 0!==n?t(n):u.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{y.exists({language:e,namespace:n},!0)||o.push({language:e,namespace:n})}))})),o}(e,n);if(a.length)return f(T(a),(()=>{}))}function N({key:e,ns:n}){const a=void 0!==n?t(n):u.getFallbackNamespaces(),i=u.getFallbackLangs();return y.getTranslationFallback(a,i,e)}function A(){const e=f(function(){if(u.getLanguage())return;if(!u.getInitialOptions().defaultLanguage)throw new Error(p("defaultLanguage"));const e=h.getInitialLanguage();return f(e,(e=>{const n=e||u.getInitialOptions().defaultLanguage;n&&u.setLanguage(n)}))}(),(()=>w()));if(d(e))return u.setInitialLoading(!0),r.notify(),g.notify(),Promise.resolve(e).then((()=>{u.setInitialLoading(!1),r.notify(),g.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}function T(e){return y.loadRecords(e,E())}n&&j(n),o.onKeyUpdate.listen((()=>{u.isRunning()&&h.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),u),h),y),{init:j,changeLanguage:async function(e){u.getPendingLanguage()===e&&u.getLanguage()===e||(u.setPendingLanguage(e),u.isRunning()&&await w(e),e===u.getPendingLanguage()&&(u.setLanguage(e),h.setStoredLanguage(e)))},getTranslation:N,changeTranslation:L,addActiveNs:async function(e,n){n||u.addActiveNs(e),u.isRunning()&&await w(void 0,e)},loadRequiredRecords:w,loadRecords:T,loadRecord:async function(e){return(await T([e]))[0]},isLoading:R,isLoaded:function(e){const n=u.getLanguage();if(!n)return!1;const a=u.getFallbackLangs(n),i=void 0!==e?t(e):u.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{y.exists({language:e,namespace:n})||o.push({language:e,namespace:n})}))})),0===o.length},t:(...e)=>{const n=k(...e),t=N(n);return h.formatTranslation(Object.assign(Object.assign({},n),{translation:t}))},isDev:E,run:function(){let e;return(()=>{const e=h.getLanguageDetector();if(e&&!u.getAvailableLanguages())throw new Error(p("availableLanguages"));if(!u.getLanguage()&&!u.getInitialOptions().defaultLanguage)throw e?new Error(p("defaultLanguage")):new Error(p("language"))})(),u.isRunning()||(E()&&y.invalidate(),u.setRunning(!0),h.run(E()),e=A()),Promise.resolve(e)},stop:function(){u.isRunning()&&(h.stop(),u.setRunning(!1))}}))};exports.DEVTOOLS_ID="__tolgee_dev_tools",exports.RESTRICTED_ASCENDANT_ATTRIBUTE="data-tolgee-restricted",exports.TOLGEE_ATTRIBUTE_NAME="_tolgee",exports.TOLGEE_HIGHLIGHTER_CLASS="_tolgee-highlighter",exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE="data-tolgee-key-only",exports.Tolgee=e=>{const n=j({options:e}),t=Object.freeze({setFinalFormatter:n.setFinalFormatter,addFormatter:n.addFormatter,setObserver:n.setObserver,hasObserver:n.hasObserver,setUi:n.setUi,hasUi:n.hasUi,setDevBackend:n.setDevBackend,addBackend:n.addBackend,setLanguageDetector:n.setLanguageDetector,setLanguageStorage:n.setLanguageStorage,overrideCredentials:n.overrideCredentials}),a=e=>{const t=n.isRunning();t&&n.stop(),e(),t&&n.run()},i=Object.freeze({on:n.on,onKeyUpdate:n.onKeyUpdate.listenSome,getLanguage:n.getLanguage,getPendingLanguage:n.getPendingLanguage,changeLanguage:n.changeLanguage,changeTranslation:n.changeTranslation,addActiveNs:n.addActiveNs,removeActiveNs:n.removeActiveNs,loadRecords:n.loadRecords,loadRecord:n.loadRecord,addStaticData:n.addStaticData,getRecord:n.getRecord,getAllRecords:n.getAllRecords,isLoaded:n.isLoaded,isInitialLoading:n.isInitialLoading,isLoading:n.isLoading,isFetching:n.isFetching,isRunning:n.isRunning,run:n.run,stop:n.stop,t:n.t,highlight:n.highlight,getInitialOptions:n.getInitialOptions,isDev:n.isDev,wrap:n.wrap,unwrap:n.unwrap,setObserverOptions:e=>(n.setObserverOptions(e),i),use:e=>(e&&a((()=>e(i,t))),i),init:e=>(a((()=>n.init(e))),i)});return i},exports.getFallback=n,exports.getFallbackArray=t,exports.getTranslateParams=k;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=()=>{let e=[];return Object.freeze({listen:n=>{const t=e=>{n(e)};return e.push(t),{unsubscribe:()=>{e=e.filter((e=>t!==e))}}},emit:n=>{e.forEach((e=>e({value:n})))}})};function n(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function t(e){return n(e)||[]}function a(e,n){return"object"!=typeof(a=n)||Array.isArray(a)||null===a?t(n):t(null==n?void 0:n[e]);var a}function i(e){return Array.from(new Set(e))}function o(e,n){const t=e.get(n)||0;e.set(n,t+1)}function r(e,n){let t=e.get(n)||1;t-=1,t<=0?e.delete(n):e.set(n,t)}const s=e=>{const n=new Set,a=new Set,i=n=>{if(n.has(void 0)){const t=new Set(n.keys());return t.delete(void 0),e().forEach((e=>t.add(e))),t}return n};let s=[];const g=()=>{if(0===s.length)return;n.forEach((e=>{e({value:void 0})}));const e=new Set;let t=new Set;s.forEach((n=>{void 0===(null==n?void 0:n.ns)?e.add(void 0):n.ns.forEach((n=>e.add(n))),void 0===(null==n?void 0:n.key)?t=void 0:void 0!==t&&t.add(n.key)}));const o=Array.from(i(e).keys());(t||[void 0]).forEach((e=>{((e,n)=>{a.forEach((t=>{const a=i(t.namespaces),o=void 0===n||-1!==(null==n?void 0:n.findIndex((e=>a.has(e)))),r=void 0===e||t.keys.has(e)||0===t.keys.size;o&&r&&t.fn({value:void 0})}))})(e,o)})),s=[]};return Object.freeze({listenSome:e=>{const n={fn:n=>{e(n)},keys:new Map,namespaces:new Map};a.add(n);const i={unsubscribe:()=>{a.delete(n)},subscribeNs:e=>(t(e).forEach((e=>o(n.namespaces,e))),i),unsubscribeNs:e=>(t(e).forEach((e=>r(n.namespaces,e))),i),subscribeKey:e=>{const{key:a,ns:r}=e;return o(n.keys,a),t(r).forEach((e=>o(n.namespaces,e))),void 0===r&&o(n.namespaces,void 0),i},unsubscribeKey:e=>{const{key:a,ns:o}=e;return r(n.keys,a),t(o).forEach((e=>r(n.namespaces,e))),void 0===o&&r(n.namespaces,void 0),i}};return i},listen:e=>{n.add(e);return{unsubscribe:()=>{n.delete(e)}}},emit:(e,n)=>{s.push(e),n?Promise.resolve().then((()=>{g()})):g()}})},g=e=>{const n=new Map;return Object.entries(e).forEach((([e,t])=>{null!=t&&("object"!=typeof t?n.set(e,t):g(t).forEach(((t,a)=>{n.set(e+"."+a,t)})))})),n},c=e=>{const[n,t]=e.split(":");return{language:n,namespace:t||""}},u=({language:e,namespace:n})=>n?`${e}:${n}`:e,l=(e,n,a,i,o,r,s)=>{const l=new Map,d=new Map;let f={},p=0;function v(n,t,a){const i=u(n);d.set(i,{data:g(t),version:a}),e.emit(n)}function b(e,n){v(e,n,p)}function h(e,n=!1){const t=d.get(u(e));return t&&n?t.version===p:Boolean(t)}function m(e){var n;return null===(n=d.get(u(i(e))))||void 0===n?void 0:n.data}function y(e){let t;if(!t){const n=f[u(e)];"function"==typeof n&&(t=n())}return t||(t=n(e)),t||(t=Promise.resolve({})),t}return Object.freeze({addStaticData:function(e){e&&(f=Object.assign(Object.assign({},f),e),Object.entries(e).forEach((([e,n])=>{if("function"!=typeof n){const t=c(e),a=d.get(e);a&&0!==a.version||v(t,n,0)}})))},invalidate:function(){l.clear(),p+=1},addRecord:b,exists:h,getRecord:m,getTranslation:function(e,n){var t;return null===(t=d.get(u(e)))||void 0===t?void 0:t.data.get(n)},getTranslationNs:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return i}return Array.from(new Set(e))},getTranslationFallback:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return n}},changeTranslation:function(n,t,a){var i;const o=null===(i=d.get(u(n)))||void 0===i?void 0:i.data;null==o||o.set(t,a),e.emit(Object.assign(Object.assign({},n),{key:t}))},isFetching:function(e){if(o())return!0;if(void 0===e)return l.size>0;const n=t(e);return Boolean(Array.from(l.keys()).find((e=>n.includes(c(e).namespace))))},isLoading:function(e,n){const a=t(n);return Boolean(o()||Array.from(l.keys()).find((n=>{const t=c(n);return(!a.length||a.includes(t.namespace))&&!h({namespace:t.namespace,language:e})})))},loadRecords:async function(e,n){const t=e.map((e=>{const t=i(e),o=u(t),r=l.get(o);if(r)return{new:!1,promise:r,keyObject:t,cacheKey:o};const s=function(e,n){var t;let i;return n&&(i=null===(t=a(e))||void 0===t?void 0:t.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),y(e))))),i||(i=y(e)),i}(t,n);return l.set(o,s),{new:!0,promise:s,keyObject:t,cacheKey:o}}));r.notify(),s.notify();const o=await Promise.all(t.map((e=>e.promise)));return t.forEach(((e,n)=>{const t=l.get(e.cacheKey)!==e.promise;if(e.new&&!t){l.delete(e.cacheKey);const t=o[n];t&&b(e.keyObject,t)}})),r.notify(),s.notify(),t.map((e=>m(e.keyObject)))},getAllRecords:function(){return Array.from(d.entries()).map((([e,n])=>Object.assign(Object.assign({},c(e)),{data:n.data})))}})};function d(e){return Boolean(e&&"function"==typeof e.then)}const f=(e,n)=>d(e)?Promise.resolve(e).then(n):n(e),p=e=>`Tolgee: You need to specify '${e}' option`,v=(e,n,a,i,o,r,s)=>{const g={ui:void 0,observer:void 0},c={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},u=async(e,{keysAndDefaults:n})=>{var a;const i=n.map((({key:e,ns:n,defaultValue:a})=>({key:e,defaultValue:a,ns:t(o({key:e,ns:n,defaultValue:a})),translation:r({key:e,ns:n})})));null===(a=c.ui)||void 0===a||a.handleElementClick(e,i)},l=(e,n)=>{var t,a;return(null===(a=null===(t=c.observer)||void 0===t?void 0:t.highlight)||void 0===a?void 0:a.call(t,e,n))||{unhighlight(){}}},p=e=>{const n=r(e);return v(Object.assign(Object.assign({},e),{translation:n,formatEnabled:!0}))},v=({key:n,translation:t,defaultValue:a,noWrap:i,params:o,orEmpty:r,ns:s,formatEnabled:g})=>{var u;const l=t||a;let d=l||(r?"":n);c.observer&&!i&&(d=c.observer.wrap({key:n,translation:d,defaultValue:a,params:o,ns:s}));const f=e(),p=g||!(null===(u=c.observer)||void 0===u?void 0:u.outputNotFormattable);if(l&&f&&p)for(const e of c.formatters)d=e.format({translation:d,language:f,params:o});return c.finalFormatter&&l&&f&&p&&(d=c.finalFormatter.format({translation:d,language:f,params:o})),d};return Object.freeze({setFinalFormatter:e=>{c.finalFormatter=e},addFormatter:e=>{e&&c.formatters.push(e)},formatTranslation:v,setObserver:e=>{g.observer=e},hasObserver:()=>Boolean(g.observer),setUi:e=>{g.ui=(null==e?void 0:e.UI)||e},hasUi:()=>Boolean(g.ui),addBackend:e=>{e&&c.backends.push(e)},setDevBackend:e=>{c.devBackend=e},getDevBackend:()=>c.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const t of c.backends){const a=t.getRecord({language:e,namespace:n});if(d(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:t})=>{var a;return null===(a=c.devBackend)||void 0===a?void 0:a.getRecord({apiKey:n().apiKey,apiUrl:n().apiUrl,language:e,namespace:t})},setLanguageDetector:e=>{c.languageDetector=e},getLanguageDetector:()=>c.languageDetector,setLanguageStorage:e=>{c.languageStorage=e},getLanguageStorage:()=>c.languageStorage,getInitialLanguage:()=>{var e;const n=i(),t=null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage();return f(t,(e=>n&&!n.includes(e)||!e?(()=>{if(!c.languageDetector)return;const e=i();return c.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var n;null===(n=c.languageStorage)||void 0===n||n.setLanguage(e)},run:e=>{var t,i;c.ui=g.ui&&new g.ui({apiKey:n().apiKey,apiUrl:n().apiUrl,highlight:l,changeTranslation:s}),c.observer||(c.observer=null===(t=g.observer)||void 0===t?void 0:t.call(g,{translate:p,onClick:u,options:a()})),null===(i=c.observer)||void 0===i||i.run({mouseHighlight:e})},stop:()=>{var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=c.observer)||void 0===e||e.retranslate()},highlight:l,wrap:e=>{var n;return c.observer?null===(n=c.observer)||void 0===n?void 0:n.wrap(e):e.translation},unwrap:e=>{var n;return c.observer?null===(n=c.observer)||void 0===n?void 0:n.unwrap(e):{text:e,keys:[]}}})},b=(e,n,t)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=n();a!==e&&t(e),a=e}})},h={tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"]},m=e=>Object.assign(Object.assign({},h),e),y={defaultNs:"",filesUrlPrefix:"i18n/"},O=(e,n)=>{const t=Object.assign(Object.assign(Object.assign({},y),null==n?void 0:n.initialOptions),e),a=t.apiUrl;return t.apiUrl=a?a.replace(/\/+$/,""):a,{initialOptions:t,activeNamespaces:(null==n?void 0:n.activeNamespaces)||new Map,language:null==n?void 0:n.language,pendingLanguage:null==n?void 0:n.language,isInitialLoading:!1,isRunning:!1}};function L(e){var{ns:n,noWrap:t,orEmpty:a,params:i}=e,o=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(t[a[i]]=e[a[i]])}return t}(e,["ns","noWrap","orEmpty","params"]);return{ns:n,noWrap:t,orEmpty:a,params:Object.assign(Object.assign({},o),i)}}const k=(e,...n)=>{let t,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof n[0]?(a.defaultValue=n[0],t=n[1]):"object"==typeof n[0]&&(t=n[0])),t&&(a=Object.assign(Object.assign({},L(t)),a)),a},j=({options:n})=>{const o=(n=>{const t=e(),a=e(),i=e(),o=e(),r=e(),g=e(),c=s(n),u=e(),l=e();return g.listen((()=>c.emit())),a.listen((()=>c.emit())),u.listen((({value:e})=>{c.emit({ns:[e.namespace],key:e.key},!0)})),Object.freeze({onPendingLanguageChange:t,onLanguageChange:a,onKeyChange:i,onKeyUpdate:c,onLoadingChange:o,onFetchingChange:r,onInitialLoaded:g,onRunningChange:l,onCacheChange:u,on:(e,n)=>{switch(e){case"pendingLanguage":return t.listen(n);case"language":return a.listen(n);case"loading":return o.listen(n);case"fetching":return r.listen(n);case"initialLoad":return g.listen(n);case"running":return l.listen(n);case"cache":return u.listen(n);case"keyUpdate":return c.listen(n)}}})})((function(){return u.getFallbackNamespaces()})),r=b(!1,(()=>y.isFetching()),o.onFetchingChange.emit),g=b(!1,(()=>R()),o.onLoadingChange.emit),u=((e,n,o)=>{let r,s=O(),g=m();function u(){return s.language||s.initialOptions.language}function l(){return Object.assign(Object.assign({},s.initialOptions),r)}return Object.freeze({init:function(e){s=O(e,s)},isRunning:function(){return s.isRunning},setRunning:function(e){s.isRunning!==e&&(s.isRunning=e,o.emit(e))},isInitialLoading:function(){return s.isInitialLoading},setInitialLoading:function(e){s.isInitialLoading=e},getLanguage:u,setLanguage:function(n){s.language!==n&&(s.language=n,e.emit(n))},getPendingLanguage:function(){return s.pendingLanguage||u()},setPendingLanguage:function(e){s.pendingLanguage!==e&&(s.pendingLanguage=e,n.emit(e))},getInitialOptions:l,addActiveNs:function(e){t(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n?s.activeNamespaces.set(e,n+1):s.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){t(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n&&n>1?s.activeNamespaces.set(e,n-1):s.activeNamespaces.delete(e)}))},getRequiredNamespaces:function(){return i([...s.initialOptions.ns||[s.initialOptions.defaultNs],...s.activeNamespaces.keys()])},getFallbackLangs:function(e){const n=e||u();return n?i([n,...a(n,s.initialOptions.fallbackLanguage)]):[]},getFallbackNamespaces:function(){const e=s.initialOptions.defaultNs;return i([..."string"==typeof e?[e]:[],...t(s.initialOptions.fallbackNs)])},getAvailableLanguages:function(){if(s.initialOptions.availableLanguages)return s.initialOptions.availableLanguages;if(s.initialOptions.staticData){const e=Object.keys(s.initialOptions.staticData).map((e=>c(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?l().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){r=e},setObserverOptions:function(e){g=m(e)},getObserverOptions:function(){return g}})})(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),h=v(u.getLanguage,u.getInitialOptions,u.getObserverOptions,u.getAvailableLanguages,(function({key:e,ns:n}){const a=void 0!==n?t(n):u.getFallbackNamespaces(),i=u.getFallbackLangs();return y.getTranslationNs(a,i,e)}),N,L),y=l(o.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,u.withDefaultNs,u.isInitialLoading,r,g);function L(e,n,t){const a=u.withDefaultNs(e),i=y.getTranslation(a,n);return y.changeTranslation(a,n,t),{revert:()=>{y.changeTranslation(a,n,i)}}}function j(e){u.init(e),y.addStaticData(u.getInitialOptions().staticData)}function R(e){return y.isLoading(u.getLanguage(),e)}function E(){return Boolean(u.getInitialOptions().apiKey&&u.getInitialOptions().apiUrl&&h.getDevBackend())}function w(e,n){const a=function(e,n){const a=u.getFallbackLangs(e),i=void 0!==n?t(n):u.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{y.exists({language:e,namespace:n},!0)||o.push({language:e,namespace:n})}))})),o}(e,n);if(a.length)return f(T(a),(()=>{}))}function N({key:e,ns:n}){const a=void 0!==n?t(n):u.getFallbackNamespaces(),i=u.getFallbackLangs();return y.getTranslationFallback(a,i,e)}function A(){const e=f(function(){if(u.getLanguage())return;if(!u.getInitialOptions().defaultLanguage)throw new Error(p("defaultLanguage"));const e=h.getInitialLanguage();return f(e,(e=>{const n=e||u.getInitialOptions().defaultLanguage;n&&u.setLanguage(n)}))}(),(()=>w()));if(d(e))return u.setInitialLoading(!0),r.notify(),g.notify(),Promise.resolve(e).then((()=>{u.setInitialLoading(!1),r.notify(),g.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}function T(e){return y.loadRecords(e,E())}n&&j(n),o.onKeyUpdate.listen((()=>{u.isRunning()&&h.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),u),h),y),{init:j,changeLanguage:async function(e){u.getPendingLanguage()===e&&u.getLanguage()===e||(u.setPendingLanguage(e),u.isRunning()&&await w(e),e===u.getPendingLanguage()&&(u.setLanguage(e),h.setStoredLanguage(e)))},getTranslation:N,changeTranslation:L,addActiveNs:async function(e,n){n||u.addActiveNs(e),u.isRunning()&&await w(void 0,e)},loadRequiredRecords:w,loadRecords:T,loadRecord:async function(e){return(await T([e]))[0]},isLoading:R,isLoaded:function(e){const n=u.getLanguage();if(!n)return!1;const a=u.getFallbackLangs(n),i=void 0!==e?t(e):u.getRequiredNamespaces(),o=[];return a.forEach((e=>{i.forEach((n=>{y.exists({language:e,namespace:n})||o.push({language:e,namespace:n})}))})),0===o.length},t:(...e)=>{const n=k(...e),t=N(n);return h.formatTranslation(Object.assign(Object.assign({},n),{translation:t}))},isDev:E,run:function(){let e;return(()=>{const e=h.getLanguageDetector();if(e&&!u.getAvailableLanguages())throw new Error(p("availableLanguages"));if(!u.getLanguage()&&!u.getInitialOptions().defaultLanguage)throw e?new Error(p("defaultLanguage")):new Error(p("language"))})(),u.isRunning()||(E()&&y.invalidate(),u.setRunning(!0),h.run(E()),e=A()),Promise.resolve(e)},stop:function(){u.isRunning()&&(h.stop(),u.setRunning(!1))}}))};exports.DEVTOOLS_ID="__tolgee_dev_tools",exports.RESTRICTED_ASCENDANT_ATTRIBUTE="data-tolgee-restricted",exports.TOLGEE_ATTRIBUTE_NAME="_tolgee",exports.TOLGEE_HIGHLIGHTER_CLASS="_tolgee-highlighter",exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE="data-tolgee-key-only",exports.Tolgee=e=>{const n=j({options:e}),t=Object.freeze({setFinalFormatter:n.setFinalFormatter,addFormatter:n.addFormatter,setObserver:n.setObserver,hasObserver:n.hasObserver,setUi:n.setUi,hasUi:n.hasUi,setDevBackend:n.setDevBackend,addBackend:n.addBackend,setLanguageDetector:n.setLanguageDetector,setLanguageStorage:n.setLanguageStorage,overrideCredentials:n.overrideCredentials}),a=e=>{const t=n.isRunning();t&&n.stop(),e(),t&&n.run()},i=Object.freeze({on:n.on,onKeyUpdate:n.onKeyUpdate.listenSome,getLanguage:n.getLanguage,getPendingLanguage:n.getPendingLanguage,changeLanguage:n.changeLanguage,changeTranslation:n.changeTranslation,addActiveNs:n.addActiveNs,removeActiveNs:n.removeActiveNs,loadRecords:n.loadRecords,loadRecord:n.loadRecord,addStaticData:n.addStaticData,getRecord:n.getRecord,getAllRecords:n.getAllRecords,isLoaded:n.isLoaded,isInitialLoading:n.isInitialLoading,isLoading:n.isLoading,isFetching:n.isFetching,isRunning:n.isRunning,run:n.run,stop:n.stop,t:n.t,highlight:n.highlight,getInitialOptions:n.getInitialOptions,isDev:n.isDev,wrap:n.wrap,unwrap:n.unwrap,setObserverOptions:e=>(n.setObserverOptions(e),i),use:e=>(e&&a((()=>e(i,t))),i),init:e=>(a((()=>n.init(e))),i)});return i},exports.getFallback=n,exports.getFallbackArray=t,exports.getTranslateParams=k;
//# sourceMappingURL=tolgee.cjs.min.js.map

@@ -776,3 +776,3 @@ (function (global, factory) {

let observerOptions = initObserverOptions();
let devCredentials = {};
let devCredentials = undefined;
function init(options) {

@@ -779,0 +779,0 @@ state = initState(options, state);

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/core"]={})}(this,(function(e){"use strict";const n=()=>{let e=[];return Object.freeze({listen:n=>{const t=e=>{n(e)};return e.push(t),{unsubscribe:()=>{e=e.filter((e=>t!==e))}}},emit:n=>{e.forEach((e=>e({value:n})))}})};function t(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function a(e){return t(e)||[]}function i(e,n){return"object"!=typeof(t=n)||Array.isArray(t)||null===t?a(n):a(null==n?void 0:n[e]);var t}function o(e){return Array.from(new Set(e))}function r(e,n){const t=e.get(n)||0;e.set(n,t+1)}function s(e,n){let t=e.get(n)||1;t-=1,t<=0?e.delete(n):e.set(n,t)}const g=e=>{const n=new Set,t=new Set,i=n=>{if(n.has(void 0)){const t=new Set(n.keys());return t.delete(void 0),e().forEach((e=>t.add(e))),t}return n};let o=[];const g=()=>{if(0===o.length)return;n.forEach((e=>{e({value:void 0})}));const e=new Set;let a=new Set;o.forEach((n=>{void 0===(null==n?void 0:n.ns)?e.add(void 0):n.ns.forEach((n=>e.add(n))),void 0===(null==n?void 0:n.key)?a=void 0:void 0!==a&&a.add(n.key)}));const r=Array.from(i(e).keys());(a||[void 0]).forEach((e=>{((e,n)=>{t.forEach((t=>{const a=i(t.namespaces),o=void 0===n||-1!==(null==n?void 0:n.findIndex((e=>a.has(e)))),r=void 0===e||t.keys.has(e)||0===t.keys.size;o&&r&&t.fn({value:void 0})}))})(e,r)})),o=[]};return Object.freeze({listenSome:e=>{const n={fn:n=>{e(n)},keys:new Map,namespaces:new Map};t.add(n);const i={unsubscribe:()=>{t.delete(n)},subscribeNs:e=>(a(e).forEach((e=>r(n.namespaces,e))),i),unsubscribeNs:e=>(a(e).forEach((e=>s(n.namespaces,e))),i),subscribeKey:e=>{const{key:t,ns:o}=e;return r(n.keys,t),a(o).forEach((e=>r(n.namespaces,e))),void 0===o&&r(n.namespaces,void 0),i},unsubscribeKey:e=>{const{key:t,ns:o}=e;return s(n.keys,t),a(o).forEach((e=>s(n.namespaces,e))),void 0===o&&s(n.namespaces,void 0),i}};return i},listen:e=>{n.add(e);return{unsubscribe:()=>{n.delete(e)}}},emit:(e,n)=>{o.push(e),n?Promise.resolve().then((()=>{g()})):g()}})},c=e=>{const n=new Map;return Object.entries(e).forEach((([e,t])=>{null!=t&&("object"!=typeof t?n.set(e,t):c(t).forEach(((t,a)=>{n.set(e+"."+a,t)})))})),n},l=e=>{const[n,t]=e.split(":");return{language:n,namespace:t||""}},u=({language:e,namespace:n})=>n?`${e}:${n}`:e,d=(e,n,t,i,o,r,s)=>{const g=new Map,d=new Map;let f={},p=0;function v(n,t,a){const i=u(n);d.set(i,{data:c(t),version:a}),e.emit(n)}function b(e,n){v(e,n,p)}function h(e,n=!1){const t=d.get(u(e));return t&&n?t.version===p:Boolean(t)}function m(e){var n;return null===(n=d.get(u(i(e))))||void 0===n?void 0:n.data}function y(e){let t;if(!t){const n=f[u(e)];"function"==typeof n&&(t=n())}return t||(t=n(e)),t||(t=Promise.resolve({})),t}return Object.freeze({addStaticData:function(e){e&&(f=Object.assign(Object.assign({},f),e),Object.entries(e).forEach((([e,n])=>{if("function"!=typeof n){const t=l(e),a=d.get(e);a&&0!==a.version||v(t,n,0)}})))},invalidate:function(){g.clear(),p+=1},addRecord:b,exists:h,getRecord:m,getTranslation:function(e,n){var t;return null===(t=d.get(u(e)))||void 0===t?void 0:t.data.get(n)},getTranslationNs:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return i}return Array.from(new Set(e))},getTranslationFallback:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return n}},changeTranslation:function(n,t,a){var i;const o=null===(i=d.get(u(n)))||void 0===i?void 0:i.data;null==o||o.set(t,a),e.emit(Object.assign(Object.assign({},n),{key:t}))},isFetching:function(e){if(o())return!0;if(void 0===e)return g.size>0;const n=a(e);return Boolean(Array.from(g.keys()).find((e=>n.includes(l(e).namespace))))},isLoading:function(e,n){const t=a(n);return Boolean(o()||Array.from(g.keys()).find((n=>{const a=l(n);return(!t.length||t.includes(a.namespace))&&!h({namespace:a.namespace,language:e})})))},loadRecords:async function(e,n){const a=e.map((e=>{const a=i(e),o=u(a),r=g.get(o);if(r)return{new:!1,promise:r,keyObject:a,cacheKey:o};const s=function(e,n){var a;let i;return n&&(i=null===(a=t(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),y(e))))),i||(i=y(e)),i}(a,n);return g.set(o,s),{new:!0,promise:s,keyObject:a,cacheKey:o}}));r.notify(),s.notify();const o=await Promise.all(a.map((e=>e.promise)));return a.forEach(((e,n)=>{const t=g.get(e.cacheKey)!==e.promise;if(e.new&&!t){g.delete(e.cacheKey);const t=o[n];t&&b(e.keyObject,t)}})),r.notify(),s.notify(),a.map((e=>m(e.keyObject)))},getAllRecords:function(){return Array.from(d.entries()).map((([e,n])=>Object.assign(Object.assign({},l(e)),{data:n.data})))}})};function f(e){return Boolean(e&&"function"==typeof e.then)}const p=(e,n)=>f(e)?Promise.resolve(e).then(n):n(e),v=e=>`Tolgee: You need to specify '${e}' option`,b=(e,n,t,i,o,r,s)=>{const g={ui:void 0,observer:void 0},c={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},l=async(e,{keysAndDefaults:n})=>{var t;const i=n.map((({key:e,ns:n,defaultValue:t})=>({key:e,defaultValue:t,ns:a(o({key:e,ns:n,defaultValue:t})),translation:r({key:e,ns:n})})));null===(t=c.ui)||void 0===t||t.handleElementClick(e,i)},u=(e,n)=>{var t,a;return(null===(a=null===(t=c.observer)||void 0===t?void 0:t.highlight)||void 0===a?void 0:a.call(t,e,n))||{unhighlight(){}}},d=e=>{const n=r(e);return v(Object.assign(Object.assign({},e),{translation:n,formatEnabled:!0}))},v=({key:n,translation:t,defaultValue:a,noWrap:i,params:o,orEmpty:r,ns:s,formatEnabled:g})=>{var l;const u=t||a;let d=u||(r?"":n);c.observer&&!i&&(d=c.observer.wrap({key:n,translation:d,defaultValue:a,params:o,ns:s}));const f=e(),p=g||!(null===(l=c.observer)||void 0===l?void 0:l.outputNotFormattable);if(u&&f&&p)for(const e of c.formatters)d=e.format({translation:d,language:f,params:o});return c.finalFormatter&&u&&f&&p&&(d=c.finalFormatter.format({translation:d,language:f,params:o})),d};return Object.freeze({setFinalFormatter:e=>{c.finalFormatter=e},addFormatter:e=>{e&&c.formatters.push(e)},formatTranslation:v,setObserver:e=>{g.observer=e},hasObserver:()=>Boolean(g.observer),setUi:e=>{g.ui=(null==e?void 0:e.UI)||e},hasUi:()=>Boolean(g.ui),addBackend:e=>{e&&c.backends.push(e)},setDevBackend:e=>{c.devBackend=e},getDevBackend:()=>c.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const t of c.backends){const a=t.getRecord({language:e,namespace:n});if(f(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:t})=>{var a;return null===(a=c.devBackend)||void 0===a?void 0:a.getRecord({apiKey:n().apiKey,apiUrl:n().apiUrl,language:e,namespace:t})},setLanguageDetector:e=>{c.languageDetector=e},getLanguageDetector:()=>c.languageDetector,setLanguageStorage:e=>{c.languageStorage=e},getLanguageStorage:()=>c.languageStorage,getInitialLanguage:()=>{var e;const n=i(),t=null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage();return p(t,(e=>n&&!n.includes(e)||!e?(()=>{if(!c.languageDetector)return;const e=i();return c.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var n;null===(n=c.languageStorage)||void 0===n||n.setLanguage(e)},run:e=>{var a,i;c.ui=g.ui&&new g.ui({apiKey:n().apiKey,apiUrl:n().apiUrl,highlight:u,changeTranslation:s}),c.observer||(c.observer=null===(a=g.observer)||void 0===a?void 0:a.call(g,{translate:d,onClick:l,options:t()})),null===(i=c.observer)||void 0===i||i.run({mouseHighlight:e})},stop:()=>{var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=c.observer)||void 0===e||e.retranslate()},highlight:u,wrap:e=>{var n;return c.observer?null===(n=c.observer)||void 0===n?void 0:n.wrap(e):e.translation},unwrap:e=>{var n;return c.observer?null===(n=c.observer)||void 0===n?void 0:n.unwrap(e):{text:e,keys:[]}}})},h=(e,n,t)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=n();a!==e&&t(e),a=e}})},m={tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"]},y=e=>Object.assign(Object.assign({},m),e),O={defaultNs:"",filesUrlPrefix:"i18n/"},L=(e,n)=>{const t=Object.assign(Object.assign(Object.assign({},O),null==n?void 0:n.initialOptions),e),a=t.apiUrl;return t.apiUrl=a?a.replace(/\/+$/,""):a,{initialOptions:t,activeNamespaces:(null==n?void 0:n.activeNamespaces)||new Map,language:null==n?void 0:n.language,pendingLanguage:null==n?void 0:n.language,isInitialLoading:!1,isRunning:!1}};function k(e){var{ns:n,noWrap:t,orEmpty:a,params:i}=e,o=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(t[a[i]]=e[a[i]])}return t}(e,["ns","noWrap","orEmpty","params"]);return{ns:n,noWrap:t,orEmpty:a,params:Object.assign(Object.assign({},o),i)}}const j=(e,...n)=>{let t,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof n[0]?(a.defaultValue=n[0],t=n[1]):"object"==typeof n[0]&&(t=n[0])),t&&(a=Object.assign(Object.assign({},k(t)),a)),a},R=({options:e})=>{const t=(e=>{const t=n(),a=n(),i=n(),o=n(),r=n(),s=n(),c=g(e),l=n(),u=n();return s.listen((()=>c.emit())),a.listen((()=>c.emit())),l.listen((({value:e})=>{c.emit({ns:[e.namespace],key:e.key},!0)})),Object.freeze({onPendingLanguageChange:t,onLanguageChange:a,onKeyChange:i,onKeyUpdate:c,onLoadingChange:o,onFetchingChange:r,onInitialLoaded:s,onRunningChange:u,onCacheChange:l,on:(e,n)=>{switch(e){case"pendingLanguage":return t.listen(n);case"language":return a.listen(n);case"loading":return o.listen(n);case"fetching":return r.listen(n);case"initialLoad":return s.listen(n);case"running":return u.listen(n);case"cache":return l.listen(n);case"keyUpdate":return c.listen(n)}}})})((function(){return c.getFallbackNamespaces()})),r=h(!1,(()=>m.isFetching()),t.onFetchingChange.emit),s=h(!1,(()=>R()),t.onLoadingChange.emit),c=((e,n,t)=>{let r=L(),s=y(),g={};function c(){return r.language||r.initialOptions.language}function u(){return Object.assign(Object.assign({},r.initialOptions),g)}return Object.freeze({init:function(e){r=L(e,r)},isRunning:function(){return r.isRunning},setRunning:function(e){r.isRunning!==e&&(r.isRunning=e,t.emit(e))},isInitialLoading:function(){return r.isInitialLoading},setInitialLoading:function(e){r.isInitialLoading=e},getLanguage:c,setLanguage:function(n){r.language!==n&&(r.language=n,e.emit(n))},getPendingLanguage:function(){return r.pendingLanguage||c()},setPendingLanguage:function(e){r.pendingLanguage!==e&&(r.pendingLanguage=e,n.emit(e))},getInitialOptions:u,addActiveNs:function(e){a(e).forEach((e=>{const n=r.activeNamespaces.get(e);void 0!==n?r.activeNamespaces.set(e,n+1):r.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){a(e).forEach((e=>{const n=r.activeNamespaces.get(e);void 0!==n&&n>1?r.activeNamespaces.set(e,n-1):r.activeNamespaces.delete(e)}))},getRequiredNamespaces:function(){return o([...r.initialOptions.ns||[r.initialOptions.defaultNs],...r.activeNamespaces.keys()])},getFallbackLangs:function(e){const n=e||c();return n?o([n,...i(n,r.initialOptions.fallbackLanguage)]):[]},getFallbackNamespaces:function(){const e=r.initialOptions.defaultNs;return o([..."string"==typeof e?[e]:[],...a(r.initialOptions.fallbackNs)])},getAvailableLanguages:function(){if(r.initialOptions.availableLanguages)return r.initialOptions.availableLanguages;if(r.initialOptions.staticData){const e=Object.keys(r.initialOptions.staticData).map((e=>l(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?u().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){g=e},setObserverOptions:function(e){s=y(e)},getObserverOptions:function(){return s}})})(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),u=b(c.getLanguage,c.getInitialOptions,c.getObserverOptions,c.getAvailableLanguages,(function({key:e,ns:n}){const t=void 0!==n?a(n):c.getFallbackNamespaces(),i=c.getFallbackLangs();return m.getTranslationNs(t,i,e)}),N,O),m=d(t.onCacheChange,u.getBackendRecord,u.getBackendDevRecord,c.withDefaultNs,c.isInitialLoading,r,s);function O(e,n,t){const a=c.withDefaultNs(e),i=m.getTranslation(a,n);return m.changeTranslation(a,n,t),{revert:()=>{m.changeTranslation(a,n,i)}}}function k(e){c.init(e),m.addStaticData(c.getInitialOptions().staticData)}function R(e){return m.isLoading(c.getLanguage(),e)}function E(){return Boolean(c.getInitialOptions().apiKey&&c.getInitialOptions().apiUrl&&u.getDevBackend())}function w(e,n){const t=function(e,n){const t=c.getFallbackLangs(e),i=void 0!==n?a(n):c.getRequiredNamespaces(),o=[];return t.forEach((e=>{i.forEach((n=>{m.exists({language:e,namespace:n},!0)||o.push({language:e,namespace:n})}))})),o}(e,n);if(t.length)return p(A(t),(()=>{}))}function N({key:e,ns:n}){const t=void 0!==n?a(n):c.getFallbackNamespaces(),i=c.getFallbackLangs();return m.getTranslationFallback(t,i,e)}function T(){const e=p(function(){if(c.getLanguage())return;if(!c.getInitialOptions().defaultLanguage)throw new Error(v("defaultLanguage"));const e=u.getInitialLanguage();return p(e,(e=>{const n=e||c.getInitialOptions().defaultLanguage;n&&c.setLanguage(n)}))}(),(()=>w()));if(f(e))return c.setInitialLoading(!0),r.notify(),s.notify(),Promise.resolve(e).then((()=>{c.setInitialLoading(!1),r.notify(),s.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}function A(e){return m.loadRecords(e,E())}e&&k(e),t.onKeyUpdate.listen((()=>{c.isRunning()&&u.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),c),u),m),{init:k,changeLanguage:async function(e){c.getPendingLanguage()===e&&c.getLanguage()===e||(c.setPendingLanguage(e),c.isRunning()&&await w(e),e===c.getPendingLanguage()&&(c.setLanguage(e),u.setStoredLanguage(e)))},getTranslation:N,changeTranslation:O,addActiveNs:async function(e,n){n||c.addActiveNs(e),c.isRunning()&&await w(void 0,e)},loadRequiredRecords:w,loadRecords:A,loadRecord:async function(e){return(await A([e]))[0]},isLoading:R,isLoaded:function(e){const n=c.getLanguage();if(!n)return!1;const t=c.getFallbackLangs(n),i=void 0!==e?a(e):c.getRequiredNamespaces(),o=[];return t.forEach((e=>{i.forEach((n=>{m.exists({language:e,namespace:n})||o.push({language:e,namespace:n})}))})),0===o.length},t:(...e)=>{const n=j(...e),t=N(n);return u.formatTranslation(Object.assign(Object.assign({},n),{translation:t}))},isDev:E,run:function(){let e;return(()=>{const e=u.getLanguageDetector();if(e&&!c.getAvailableLanguages())throw new Error(v("availableLanguages"));if(!c.getLanguage()&&!c.getInitialOptions().defaultLanguage)throw e?new Error(v("defaultLanguage")):new Error(v("language"))})(),c.isRunning()||(E()&&m.invalidate(),c.setRunning(!0),u.run(E()),e=T()),Promise.resolve(e)},stop:function(){c.isRunning()&&(u.stop(),c.setRunning(!1))}}))};e.DEVTOOLS_ID="__tolgee_dev_tools",e.RESTRICTED_ASCENDANT_ATTRIBUTE="data-tolgee-restricted",e.TOLGEE_ATTRIBUTE_NAME="_tolgee",e.TOLGEE_HIGHLIGHTER_CLASS="_tolgee-highlighter",e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE="data-tolgee-key-only",e.Tolgee=e=>{const n=R({options:e}),t=Object.freeze({setFinalFormatter:n.setFinalFormatter,addFormatter:n.addFormatter,setObserver:n.setObserver,hasObserver:n.hasObserver,setUi:n.setUi,hasUi:n.hasUi,setDevBackend:n.setDevBackend,addBackend:n.addBackend,setLanguageDetector:n.setLanguageDetector,setLanguageStorage:n.setLanguageStorage,overrideCredentials:n.overrideCredentials}),a=e=>{const t=n.isRunning();t&&n.stop(),e(),t&&n.run()},i=Object.freeze({on:n.on,onKeyUpdate:n.onKeyUpdate.listenSome,getLanguage:n.getLanguage,getPendingLanguage:n.getPendingLanguage,changeLanguage:n.changeLanguage,changeTranslation:n.changeTranslation,addActiveNs:n.addActiveNs,removeActiveNs:n.removeActiveNs,loadRecords:n.loadRecords,loadRecord:n.loadRecord,addStaticData:n.addStaticData,getRecord:n.getRecord,getAllRecords:n.getAllRecords,isLoaded:n.isLoaded,isInitialLoading:n.isInitialLoading,isLoading:n.isLoading,isFetching:n.isFetching,isRunning:n.isRunning,run:n.run,stop:n.stop,t:n.t,highlight:n.highlight,getInitialOptions:n.getInitialOptions,isDev:n.isDev,wrap:n.wrap,unwrap:n.unwrap,setObserverOptions:e=>(n.setObserverOptions(e),i),use:e=>(e&&a((()=>e(i,t))),i),init:e=>(a((()=>n.init(e))),i)});return i},e.getFallback=t,e.getFallbackArray=a,e.getTranslateParams=j,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/core"]={})}(this,(function(e){"use strict";const n=()=>{let e=[];return Object.freeze({listen:n=>{const t=e=>{n(e)};return e.push(t),{unsubscribe:()=>{e=e.filter((e=>t!==e))}}},emit:n=>{e.forEach((e=>e({value:n})))}})};function t(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function a(e){return t(e)||[]}function i(e,n){return"object"!=typeof(t=n)||Array.isArray(t)||null===t?a(n):a(null==n?void 0:n[e]);var t}function o(e){return Array.from(new Set(e))}function r(e,n){const t=e.get(n)||0;e.set(n,t+1)}function s(e,n){let t=e.get(n)||1;t-=1,t<=0?e.delete(n):e.set(n,t)}const g=e=>{const n=new Set,t=new Set,i=n=>{if(n.has(void 0)){const t=new Set(n.keys());return t.delete(void 0),e().forEach((e=>t.add(e))),t}return n};let o=[];const g=()=>{if(0===o.length)return;n.forEach((e=>{e({value:void 0})}));const e=new Set;let a=new Set;o.forEach((n=>{void 0===(null==n?void 0:n.ns)?e.add(void 0):n.ns.forEach((n=>e.add(n))),void 0===(null==n?void 0:n.key)?a=void 0:void 0!==a&&a.add(n.key)}));const r=Array.from(i(e).keys());(a||[void 0]).forEach((e=>{((e,n)=>{t.forEach((t=>{const a=i(t.namespaces),o=void 0===n||-1!==(null==n?void 0:n.findIndex((e=>a.has(e)))),r=void 0===e||t.keys.has(e)||0===t.keys.size;o&&r&&t.fn({value:void 0})}))})(e,r)})),o=[]};return Object.freeze({listenSome:e=>{const n={fn:n=>{e(n)},keys:new Map,namespaces:new Map};t.add(n);const i={unsubscribe:()=>{t.delete(n)},subscribeNs:e=>(a(e).forEach((e=>r(n.namespaces,e))),i),unsubscribeNs:e=>(a(e).forEach((e=>s(n.namespaces,e))),i),subscribeKey:e=>{const{key:t,ns:o}=e;return r(n.keys,t),a(o).forEach((e=>r(n.namespaces,e))),void 0===o&&r(n.namespaces,void 0),i},unsubscribeKey:e=>{const{key:t,ns:o}=e;return s(n.keys,t),a(o).forEach((e=>s(n.namespaces,e))),void 0===o&&s(n.namespaces,void 0),i}};return i},listen:e=>{n.add(e);return{unsubscribe:()=>{n.delete(e)}}},emit:(e,n)=>{o.push(e),n?Promise.resolve().then((()=>{g()})):g()}})},c=e=>{const n=new Map;return Object.entries(e).forEach((([e,t])=>{null!=t&&("object"!=typeof t?n.set(e,t):c(t).forEach(((t,a)=>{n.set(e+"."+a,t)})))})),n},l=e=>{const[n,t]=e.split(":");return{language:n,namespace:t||""}},u=({language:e,namespace:n})=>n?`${e}:${n}`:e,d=(e,n,t,i,o,r,s)=>{const g=new Map,d=new Map;let f={},p=0;function v(n,t,a){const i=u(n);d.set(i,{data:c(t),version:a}),e.emit(n)}function b(e,n){v(e,n,p)}function h(e,n=!1){const t=d.get(u(e));return t&&n?t.version===p:Boolean(t)}function m(e){var n;return null===(n=d.get(u(i(e))))||void 0===n?void 0:n.data}function y(e){let t;if(!t){const n=f[u(e)];"function"==typeof n&&(t=n())}return t||(t=n(e)),t||(t=Promise.resolve({})),t}return Object.freeze({addStaticData:function(e){e&&(f=Object.assign(Object.assign({},f),e),Object.entries(e).forEach((([e,n])=>{if("function"!=typeof n){const t=l(e),a=d.get(e);a&&0!==a.version||v(t,n,0)}})))},invalidate:function(){g.clear(),p+=1},addRecord:b,exists:h,getRecord:m,getTranslation:function(e,n){var t;return null===(t=d.get(u(e)))||void 0===t?void 0:t.data.get(n)},getTranslationNs:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return i}return Array.from(new Set(e))},getTranslationFallback:function(e,n,t){var a;for(const i of e)for(const e of n){const n=null===(a=d.get(u({language:e,namespace:i})))||void 0===a?void 0:a.data.get(t);if(null!=n)return n}},changeTranslation:function(n,t,a){var i;const o=null===(i=d.get(u(n)))||void 0===i?void 0:i.data;null==o||o.set(t,a),e.emit(Object.assign(Object.assign({},n),{key:t}))},isFetching:function(e){if(o())return!0;if(void 0===e)return g.size>0;const n=a(e);return Boolean(Array.from(g.keys()).find((e=>n.includes(l(e).namespace))))},isLoading:function(e,n){const t=a(n);return Boolean(o()||Array.from(g.keys()).find((n=>{const a=l(n);return(!t.length||t.includes(a.namespace))&&!h({namespace:a.namespace,language:e})})))},loadRecords:async function(e,n){const a=e.map((e=>{const a=i(e),o=u(a),r=g.get(o);if(r)return{new:!1,promise:r,keyObject:a,cacheKey:o};const s=function(e,n){var a;let i;return n&&(i=null===(a=t(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),y(e))))),i||(i=y(e)),i}(a,n);return g.set(o,s),{new:!0,promise:s,keyObject:a,cacheKey:o}}));r.notify(),s.notify();const o=await Promise.all(a.map((e=>e.promise)));return a.forEach(((e,n)=>{const t=g.get(e.cacheKey)!==e.promise;if(e.new&&!t){g.delete(e.cacheKey);const t=o[n];t&&b(e.keyObject,t)}})),r.notify(),s.notify(),a.map((e=>m(e.keyObject)))},getAllRecords:function(){return Array.from(d.entries()).map((([e,n])=>Object.assign(Object.assign({},l(e)),{data:n.data})))}})};function f(e){return Boolean(e&&"function"==typeof e.then)}const p=(e,n)=>f(e)?Promise.resolve(e).then(n):n(e),v=e=>`Tolgee: You need to specify '${e}' option`,b=(e,n,t,i,o,r,s)=>{const g={ui:void 0,observer:void 0},c={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},l=async(e,{keysAndDefaults:n})=>{var t;const i=n.map((({key:e,ns:n,defaultValue:t})=>({key:e,defaultValue:t,ns:a(o({key:e,ns:n,defaultValue:t})),translation:r({key:e,ns:n})})));null===(t=c.ui)||void 0===t||t.handleElementClick(e,i)},u=(e,n)=>{var t,a;return(null===(a=null===(t=c.observer)||void 0===t?void 0:t.highlight)||void 0===a?void 0:a.call(t,e,n))||{unhighlight(){}}},d=e=>{const n=r(e);return v(Object.assign(Object.assign({},e),{translation:n,formatEnabled:!0}))},v=({key:n,translation:t,defaultValue:a,noWrap:i,params:o,orEmpty:r,ns:s,formatEnabled:g})=>{var l;const u=t||a;let d=u||(r?"":n);c.observer&&!i&&(d=c.observer.wrap({key:n,translation:d,defaultValue:a,params:o,ns:s}));const f=e(),p=g||!(null===(l=c.observer)||void 0===l?void 0:l.outputNotFormattable);if(u&&f&&p)for(const e of c.formatters)d=e.format({translation:d,language:f,params:o});return c.finalFormatter&&u&&f&&p&&(d=c.finalFormatter.format({translation:d,language:f,params:o})),d};return Object.freeze({setFinalFormatter:e=>{c.finalFormatter=e},addFormatter:e=>{e&&c.formatters.push(e)},formatTranslation:v,setObserver:e=>{g.observer=e},hasObserver:()=>Boolean(g.observer),setUi:e=>{g.ui=(null==e?void 0:e.UI)||e},hasUi:()=>Boolean(g.ui),addBackend:e=>{e&&c.backends.push(e)},setDevBackend:e=>{c.devBackend=e},getDevBackend:()=>c.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const t of c.backends){const a=t.getRecord({language:e,namespace:n});if(f(a))return null==a?void 0:a.catch((e=>(console.error(e),{})));if(void 0!==a)return a}},getBackendDevRecord:({language:e,namespace:t})=>{var a;return null===(a=c.devBackend)||void 0===a?void 0:a.getRecord({apiKey:n().apiKey,apiUrl:n().apiUrl,language:e,namespace:t})},setLanguageDetector:e=>{c.languageDetector=e},getLanguageDetector:()=>c.languageDetector,setLanguageStorage:e=>{c.languageStorage=e},getLanguageStorage:()=>c.languageStorage,getInitialLanguage:()=>{var e;const n=i(),t=null===(e=c.languageStorage)||void 0===e?void 0:e.getLanguage();return p(t,(e=>n&&!n.includes(e)||!e?(()=>{if(!c.languageDetector)return;const e=i();return c.languageDetector.getLanguage({availableLanguages:e})})():e))},setStoredLanguage:e=>{var n;null===(n=c.languageStorage)||void 0===n||n.setLanguage(e)},run:e=>{var a,i;c.ui=g.ui&&new g.ui({apiKey:n().apiKey,apiUrl:n().apiUrl,highlight:u,changeTranslation:s}),c.observer||(c.observer=null===(a=g.observer)||void 0===a?void 0:a.call(g,{translate:d,onClick:l,options:t()})),null===(i=c.observer)||void 0===i||i.run({mouseHighlight:e})},stop:()=>{var e;c.ui=void 0,null===(e=c.observer)||void 0===e||e.stop()},retranslate:()=>{var e;null===(e=c.observer)||void 0===e||e.retranslate()},highlight:u,wrap:e=>{var n;return c.observer?null===(n=c.observer)||void 0===n?void 0:n.wrap(e):e.translation},unwrap:e=>{var n;return c.observer?null===(n=c.observer)||void 0===n?void 0:n.unwrap(e):{text:e,keys:[]}}})},h=(e,n,t)=>{let a=e;return Object.freeze({init:function(e){a=e},notify:function(){const e=n();a!==e&&t(e),a=e}})},m={tagAttributes:{textarea:["placeholder"],input:["value","placeholder"],img:["alt"],"*":["aria-label","title"]},restrictedElements:["script","style"],highlightKeys:["Alt"],highlightColor:"rgb(255, 0, 0)",highlightWidth:5,inputPrefix:"%-%tolgee:",inputSuffix:"%-%",passToParent:["option","optgroup"]},y=e=>Object.assign(Object.assign({},m),e),O={defaultNs:"",filesUrlPrefix:"i18n/"},L=(e,n)=>{const t=Object.assign(Object.assign(Object.assign({},O),null==n?void 0:n.initialOptions),e),a=t.apiUrl;return t.apiUrl=a?a.replace(/\/+$/,""):a,{initialOptions:t,activeNamespaces:(null==n?void 0:n.activeNamespaces)||new Map,language:null==n?void 0:n.language,pendingLanguage:null==n?void 0:n.language,isInitialLoading:!1,isRunning:!1}};function k(e){var{ns:n,noWrap:t,orEmpty:a,params:i}=e,o=function(e,n){var t={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&n.indexOf(a)<0&&(t[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(a=Object.getOwnPropertySymbols(e);i<a.length;i++)n.indexOf(a[i])<0&&Object.prototype.propertyIsEnumerable.call(e,a[i])&&(t[a[i]]=e[a[i]])}return t}(e,["ns","noWrap","orEmpty","params"]);return{ns:n,noWrap:t,orEmpty:a,params:Object.assign(Object.assign({},o),i)}}const j=(e,...n)=>{let t,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof n[0]?(a.defaultValue=n[0],t=n[1]):"object"==typeof n[0]&&(t=n[0])),t&&(a=Object.assign(Object.assign({},k(t)),a)),a},R=({options:e})=>{const t=(e=>{const t=n(),a=n(),i=n(),o=n(),r=n(),s=n(),c=g(e),l=n(),u=n();return s.listen((()=>c.emit())),a.listen((()=>c.emit())),l.listen((({value:e})=>{c.emit({ns:[e.namespace],key:e.key},!0)})),Object.freeze({onPendingLanguageChange:t,onLanguageChange:a,onKeyChange:i,onKeyUpdate:c,onLoadingChange:o,onFetchingChange:r,onInitialLoaded:s,onRunningChange:u,onCacheChange:l,on:(e,n)=>{switch(e){case"pendingLanguage":return t.listen(n);case"language":return a.listen(n);case"loading":return o.listen(n);case"fetching":return r.listen(n);case"initialLoad":return s.listen(n);case"running":return u.listen(n);case"cache":return l.listen(n);case"keyUpdate":return c.listen(n)}}})})((function(){return c.getFallbackNamespaces()})),r=h(!1,(()=>m.isFetching()),t.onFetchingChange.emit),s=h(!1,(()=>R()),t.onLoadingChange.emit),c=((e,n,t)=>{let r,s=L(),g=y();function c(){return s.language||s.initialOptions.language}function u(){return Object.assign(Object.assign({},s.initialOptions),r)}return Object.freeze({init:function(e){s=L(e,s)},isRunning:function(){return s.isRunning},setRunning:function(e){s.isRunning!==e&&(s.isRunning=e,t.emit(e))},isInitialLoading:function(){return s.isInitialLoading},setInitialLoading:function(e){s.isInitialLoading=e},getLanguage:c,setLanguage:function(n){s.language!==n&&(s.language=n,e.emit(n))},getPendingLanguage:function(){return s.pendingLanguage||c()},setPendingLanguage:function(e){s.pendingLanguage!==e&&(s.pendingLanguage=e,n.emit(e))},getInitialOptions:u,addActiveNs:function(e){a(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n?s.activeNamespaces.set(e,n+1):s.activeNamespaces.set(e,1)}))},removeActiveNs:function(e){a(e).forEach((e=>{const n=s.activeNamespaces.get(e);void 0!==n&&n>1?s.activeNamespaces.set(e,n-1):s.activeNamespaces.delete(e)}))},getRequiredNamespaces:function(){return o([...s.initialOptions.ns||[s.initialOptions.defaultNs],...s.activeNamespaces.keys()])},getFallbackLangs:function(e){const n=e||c();return n?o([n,...i(n,s.initialOptions.fallbackLanguage)]):[]},getFallbackNamespaces:function(){const e=s.initialOptions.defaultNs;return o([..."string"==typeof e?[e]:[],...a(s.initialOptions.fallbackNs)])},getAvailableLanguages:function(){if(s.initialOptions.availableLanguages)return s.initialOptions.availableLanguages;if(s.initialOptions.staticData){const e=Object.keys(s.initialOptions.staticData).map((e=>l(e).language));return Array.from(new Set(e))}},withDefaultNs:function(e){return{namespace:void 0===e.namespace?u().defaultNs:e.namespace,language:e.language}},overrideCredentials:function(e){r=e},setObserverOptions:function(e){g=y(e)},getObserverOptions:function(){return g}})})(t.onLanguageChange,t.onPendingLanguageChange,t.onRunningChange),u=b(c.getLanguage,c.getInitialOptions,c.getObserverOptions,c.getAvailableLanguages,(function({key:e,ns:n}){const t=void 0!==n?a(n):c.getFallbackNamespaces(),i=c.getFallbackLangs();return m.getTranslationNs(t,i,e)}),N,O),m=d(t.onCacheChange,u.getBackendRecord,u.getBackendDevRecord,c.withDefaultNs,c.isInitialLoading,r,s);function O(e,n,t){const a=c.withDefaultNs(e),i=m.getTranslation(a,n);return m.changeTranslation(a,n,t),{revert:()=>{m.changeTranslation(a,n,i)}}}function k(e){c.init(e),m.addStaticData(c.getInitialOptions().staticData)}function R(e){return m.isLoading(c.getLanguage(),e)}function E(){return Boolean(c.getInitialOptions().apiKey&&c.getInitialOptions().apiUrl&&u.getDevBackend())}function w(e,n){const t=function(e,n){const t=c.getFallbackLangs(e),i=void 0!==n?a(n):c.getRequiredNamespaces(),o=[];return t.forEach((e=>{i.forEach((n=>{m.exists({language:e,namespace:n},!0)||o.push({language:e,namespace:n})}))})),o}(e,n);if(t.length)return p(A(t),(()=>{}))}function N({key:e,ns:n}){const t=void 0!==n?a(n):c.getFallbackNamespaces(),i=c.getFallbackLangs();return m.getTranslationFallback(t,i,e)}function T(){const e=p(function(){if(c.getLanguage())return;if(!c.getInitialOptions().defaultLanguage)throw new Error(v("defaultLanguage"));const e=u.getInitialLanguage();return p(e,(e=>{const n=e||c.getInitialOptions().defaultLanguage;n&&c.setLanguage(n)}))}(),(()=>w()));if(f(e))return c.setInitialLoading(!0),r.notify(),s.notify(),Promise.resolve(e).then((()=>{c.setInitialLoading(!1),r.notify(),s.notify(),t.onInitialLoaded.emit()}));t.onInitialLoaded.emit()}function A(e){return m.loadRecords(e,E())}e&&k(e),t.onKeyUpdate.listen((()=>{c.isRunning()&&u.retranslate()}));return Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},t),c),u),m),{init:k,changeLanguage:async function(e){c.getPendingLanguage()===e&&c.getLanguage()===e||(c.setPendingLanguage(e),c.isRunning()&&await w(e),e===c.getPendingLanguage()&&(c.setLanguage(e),u.setStoredLanguage(e)))},getTranslation:N,changeTranslation:O,addActiveNs:async function(e,n){n||c.addActiveNs(e),c.isRunning()&&await w(void 0,e)},loadRequiredRecords:w,loadRecords:A,loadRecord:async function(e){return(await A([e]))[0]},isLoading:R,isLoaded:function(e){const n=c.getLanguage();if(!n)return!1;const t=c.getFallbackLangs(n),i=void 0!==e?a(e):c.getRequiredNamespaces(),o=[];return t.forEach((e=>{i.forEach((n=>{m.exists({language:e,namespace:n})||o.push({language:e,namespace:n})}))})),0===o.length},t:(...e)=>{const n=j(...e),t=N(n);return u.formatTranslation(Object.assign(Object.assign({},n),{translation:t}))},isDev:E,run:function(){let e;return(()=>{const e=u.getLanguageDetector();if(e&&!c.getAvailableLanguages())throw new Error(v("availableLanguages"));if(!c.getLanguage()&&!c.getInitialOptions().defaultLanguage)throw e?new Error(v("defaultLanguage")):new Error(v("language"))})(),c.isRunning()||(E()&&m.invalidate(),c.setRunning(!0),u.run(E()),e=T()),Promise.resolve(e)},stop:function(){c.isRunning()&&(u.stop(),c.setRunning(!1))}}))};e.DEVTOOLS_ID="__tolgee_dev_tools",e.RESTRICTED_ASCENDANT_ATTRIBUTE="data-tolgee-restricted",e.TOLGEE_ATTRIBUTE_NAME="_tolgee",e.TOLGEE_HIGHLIGHTER_CLASS="_tolgee-highlighter",e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE="data-tolgee-key-only",e.Tolgee=e=>{const n=R({options:e}),t=Object.freeze({setFinalFormatter:n.setFinalFormatter,addFormatter:n.addFormatter,setObserver:n.setObserver,hasObserver:n.hasObserver,setUi:n.setUi,hasUi:n.hasUi,setDevBackend:n.setDevBackend,addBackend:n.addBackend,setLanguageDetector:n.setLanguageDetector,setLanguageStorage:n.setLanguageStorage,overrideCredentials:n.overrideCredentials}),a=e=>{const t=n.isRunning();t&&n.stop(),e(),t&&n.run()},i=Object.freeze({on:n.on,onKeyUpdate:n.onKeyUpdate.listenSome,getLanguage:n.getLanguage,getPendingLanguage:n.getPendingLanguage,changeLanguage:n.changeLanguage,changeTranslation:n.changeTranslation,addActiveNs:n.addActiveNs,removeActiveNs:n.removeActiveNs,loadRecords:n.loadRecords,loadRecord:n.loadRecord,addStaticData:n.addStaticData,getRecord:n.getRecord,getAllRecords:n.getAllRecords,isLoaded:n.isLoaded,isInitialLoading:n.isInitialLoading,isLoading:n.isLoading,isFetching:n.isFetching,isRunning:n.isRunning,run:n.run,stop:n.stop,t:n.t,highlight:n.highlight,getInitialOptions:n.getInitialOptions,isDev:n.isDev,wrap:n.wrap,unwrap:n.unwrap,setObserverOptions:e=>(n.setObserverOptions(e),i),use:e=>(e&&a((()=>e(i,t))),i),init:e=>(a((()=>n.init(e))),i)});return i},e.getFallback=t,e.getFallbackArray=a,e.getTranslateParams=j,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=tolgee.umd.min.js.map

@@ -122,3 +122,3 @@ import type { Options } from './Controller/State/initState';

};
export declare type DevCredentials = {
export declare type DevCredentials = undefined | {
apiUrl?: string;

@@ -125,0 +125,0 @@ apiKey?: string;

{
"name": "@tolgee/core",
"version": "4.10.0-rc.72ff5c5.0",
"version": "4.10.0-rc.a50bdc6.0",
"description": "Library providing ability to translate messages directly in context of developed application.",

@@ -64,3 +64,3 @@ "main": "./dist/tolgee.cjs.js",

},
"gitHead": "5cb6f72646bce5c96d4f692731668fdbb746cc9d"
"gitHead": "aea12256728ecbae32b6c3d9b0c2bd8d1f8786d4"
}

@@ -20,3 +20,3 @@ import {

let observerOptions = initObserverOptions();
let devCredentials: DevCredentials = {};
let devCredentials: DevCredentials = undefined;

@@ -23,0 +23,0 @@ function init(options?: Partial<Options>) {

@@ -174,6 +174,8 @@ import type { Options } from './Controller/State/initState';

export type DevCredentials = {
apiUrl?: string;
apiKey?: string;
};
export type DevCredentials =
| undefined
| {
apiUrl?: string;
apiKey?: string;
};

@@ -180,0 +182,0 @@ export type BackendDevProps = {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc