@tolgee/web
Advanced tools
Comparing version 5.11.4 to 5.11.5-prerelease.c74f049c.0
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return Boolean(e&&"function"==typeof e.then)}function t(t,n){return e(t)?Promise.resolve(t).then(n):n(t)}function n(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function o(e){return a(e)||[]}function r(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?o(t):o(null==t?void 0:t[e]);var n}function i(e){return Array.from(new Set(e))}function s(e){return e?e.replace(/\/+$/,""):e}Object.defineProperty(exports,"__esModule",{value:!0});const l=(e=fetch)=>(t,n)=>e(t,Object.assign(Object.assign({},n),{headers:Object.assign({"X-Tolgee-SDK-Type":"JS","X-Tolgee-SDK-Version":"5.11.4"},null==n?void 0:n.headers)}));function c(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function u(e,t,n){const a=new Set,r=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());r.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(i.push(t),n?setTimeout(s,0):s())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};r.add(t);const a={unsubscribe:()=>{r.delete(t)},subscribeNs:e=>(o(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const g=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):g(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},d=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},f=({language:e,namespace:t})=>t?`${e}:${t}`:e;function p(e,t,n,a,r,s,l){const c=new Map,u=new Map;let p={},v=0;function h(t,n,a){const o=f(t);u.set(o,{data:g(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=p[f(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(p=Object.assign(Object.assign({},p),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=d(e),a=u.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){c.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=u.get(f(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=u.get(f(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=u.get(f(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(f({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return i(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(f({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=u.get(f(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return c.size>0;const t=o(e);return Boolean(Array.from(c.keys()).find((e=>t.includes(d(e).namespace))))},isLoading(e,t){const n=o(t);return Boolean(r()||Array.from(c.keys()).find((t=>{const a=d(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=f(o),i=c.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return c.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));s.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=c.get(e.cacheKey)!==e.promise;if(e.new&&!n){c.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),s.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},d(e)),{data:t.data})))});return b}function v(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const h="invalid",m={defaultNs:"",observerOptions:{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"],fullKeyEncode:!1},observerType:"invisible",onFormatError:h,apiUrl:"https://app.tolgee.io",fetch:l()},b=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function y(e,t){const n=b(m,null==t?void 0:t.initialOptions,e);return n.apiUrl=s(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=l(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function E(n,a,o,r,i,s,l){const c={ui:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},g=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:r({key:e,ns:t}),translation:i({key:e,ns:t})})));null===(n=u.ui)||void 0===n||n.handleElementClick(a,t)},d=(e,t)=>{var n;return(null===(n=u.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function f(e){const t=i({key:e.key,ns:e.ns});return x.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function p(){return{fetch:a().fetch}}function m(e){u.observer=null==e?void 0:e()}function b(){return Boolean(u.observer)}function y(e){e&&u.formatters.push(e)}function E(e){u.finalFormatter=e}function O(e){c.ui=e}function L(){return Boolean(c.ui)}function w(e){u.languageStorage=e}function k(e){u.languageDetector=e}function j(e){e&&u.backends.push(e)}function A(e){u.devBackend=e}const x=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:E,addFormatter:y,setObserver:m,hasObserver:b,setUi:O,hasUi:L,setDevBackend:A,addBackend:j,setLanguageDetector:k,setLanguageStorage:w}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();u.ui=null===(e=c.ui)||void 0===e?void 0:e.call(c,{apiKey:n,apiUrl:o,projectId:r,highlight:x.highlight,changeTranslation:s,findPositions:d,onPermanentChange:l}),null===(t=u.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:f,onClick:g})},stop(){var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},getLanguageStorage:()=>u.languageStorage,getInitialLanguage(){var e;const n=o();return t(null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage(p()),(e=>n&&!n.includes(e)||!e?function(){if(!u.languageDetector)return;const e=o();return u.languageDetector.getLanguage(Object.assign({availableLanguages:e},p()))}():e))},setStoredLanguage(e){var t;null===(t=u.languageStorage)||void 0===t||t.setLanguage(e,p())},getDevBackend:()=>u.devBackend,getBackendRecord:({language:t,namespace:n})=>{for(const a of u.backends){const o=a.getRecord(Object.assign({language:t,namespace:n},p()));if(e(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=u.devBackend)||void 0===n?void 0:n.getRecord(Object.assign({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t},p()))},getLanguageDetector:()=>u.languageDetector,retranslate(){var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=u.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(x.getDevBackend()),formatTranslation(e){var t,{formatEnabled:o}=e,r=v(e,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,p=s||l;let m=p||(d?"":i);const b=n(),y=o||!(null===(t=u.observer)||void 0===t?void 0:t.outputNotFormattable),E=e=>u.observer&&!c?u.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;m=E(m);try{if(p&&b&&y)for(const e of u.formatters)m=e.format({translation:m,language:b,params:g});u.finalFormatter&&p&&b&&y&&(m=u.finalFormatter.format({translation:m,language:b,params:g}))}catch(e){console.error(e);const t=("string"==typeof(O=e)?O:"string"==typeof(null==O?void 0:O.message)?O.message:void 0)||h,n=a().onFormatError,o=typeof n;m="string"===o?n:"function"===o?n(t,r):h,m=E(m)}var O;return m}});return x}const O=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const L=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:o,language:r}=e,i=v(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function w({options:a}){const l=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:c(a),onLanguageChange:c(a),onLoadingChange:c(a),onFetchingChange:c(a),onInitialLoaded:c(a),onRunningChange:c(a),onCacheChange:c(a),onUpdate:u(a,e,t),onPermanentChange:c(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t);case"permanentChange":return o.onPermanentChange.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(b,w),g=O(!1,(()=>m.isFetching()),l.onFetchingChange.emit),f=O(!1,(()=>R.isLoading()),l.onLoadingChange.emit),v=function(e,t,n){let a,l=y();const c=Object.freeze({init(e){l=y(e,l)},isRunning:()=>l.isRunning,setRunning(e){l.isRunning!==e&&(l.isRunning=e,n.emit(e))},isInitialLoading:()=>l.isInitialLoading,setInitialLoading(e){l.isInitialLoading=e},getLanguage:()=>l.language||l.initialOptions.language,setLanguage(t){l.language!==t&&(l.language=t,e.emit(t))},getPendingLanguage:()=>l.pendingLanguage||c.getLanguage(),setPendingLanguage(e){l.pendingLanguage!==e&&(l.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},l.initialOptions),a),addActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t?l.activeNamespaces.set(e,t+1):l.activeNamespaces.set(e,1)}))},removeActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t&&t>1?l.activeNamespaces.set(e,t-1):l.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>i([...l.initialOptions.ns||[l.initialOptions.defaultNs],...o(l.initialOptions.fallbackNs),...l.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||c.getLanguage();return t?i([t,...r(t,l.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>o(l.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?l.initialOptions.defaultNs:e,getAvailableLanguages(){if(l.initialOptions.availableLanguages)return l.initialOptions.availableLanguages;if(l.initialOptions.staticData){const e=Object.keys(l.initialOptions.staticData).map((e=>d(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?c.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:s(e.apiUrl)}):void 0}});return c}(l.onLanguageChange,l.onPendingLanguageChange,l.onRunningChange),h=E(v.getLanguage,v.getInitialOptions,v.getAvailableLanguages,(function({key:e,ns:t}){const n=v.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),T,A,(function(e){l.onPermanentChange.emit({key:e.key,namespace:e.namespace})})),m=p(l.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,v.withDefaultNs,v.isInitialLoading,g,f);function b(){return v.getFallbackNs()}function w(e){return v.getDefaultNs(e)}function k(e){return[...o(w(e)),...b()]}function j(e){return[...o(e||w()),...v.getRequiredNamespaces()]}function A(e,t,n){const a=v.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function x(e){v.init(e),m.addStaticData(v.getInitialOptions().staticData)}function P(e,n){const a=function(e,t){const n=v.getFallbackLangs(e),a=j(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,n);if(a.length)return t(R.loadRecords(a),(()=>{}))}function T({key:e,ns:t,language:n}){const a=k(t||void 0),o=v.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function N(){const n=t(function(){if(v.getLanguage())return;return t(h.getInitialLanguage(),(e=>{const t=e||v.getInitialOptions().defaultLanguage;t&&v.setLanguage(t)}))}(),(()=>P()));if(e(n))return v.setInitialLoading(!0),g.notify(),f.notify(),Promise.resolve(n).then((()=>{v.setInitialLoading(!1),g.notify(),f.notify(),l.onInitialLoaded.emit()}));l.onInitialLoaded.emit()}a&&x(a),l.onUpdate.listen((()=>{v.isRunning()&&h.retranslate()}));const R=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},l),v),h),m),{init:x,getTranslation:T,changeTranslation:A,async changeLanguage(e){v.getPendingLanguage()===e&&v.getLanguage()===e||(v.setPendingLanguage(e),v.isRunning()&&await P(e),e===v.getPendingLanguage()&&(v.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||v.addActiveNs(e),v.isRunning()&&await P(void 0,e)},loadRecords:e=>m.loadRecords(e,R.isDev()),loadRecord:async e=>(await R.loadRecords([e]))[0],isLoading:e=>m.isLoading(v.getLanguage(),e),isLoaded(e){const t=v.getLanguage();if(!t)return!1;const n=v.getFallbackLangs(t),a=j(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=L(...e),n=T(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(v.getInitialOptions().apiKey&&v.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!v.getAvailableLanguages())throw new Error(n("availableLanguages"));if(!v.getLanguage()&&!v.getInitialOptions().defaultLanguage)throw new Error(n(["defaultLanguage","language"]))}(),v.isRunning()||(v.setRunning(!0),h.run(),e=N()),Promise.resolve(e)},stop(){v.isRunning()&&(h.stop(),v.setRunning(!1))}}));return R}const k=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=b(e.options,n),t),init(t){const n=function(e){const t=w({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(b(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},j=0,A=1,x=2;class P extends Error{constructor(e,t,n){let a;a=e===j?"Empty parameter":e===A?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function T(e){return/\s/.test(e)}const N=0,R=1,C=2,S=3,D=4,I=new Set([C,R,N]),$="'",_=new Set(["{","}",$]),U=e=>/[0-9a-zA-Z_]/.test(e);function F(e,t){const[n,a]=function(e){let t=N,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new P(t,s,e)}const c=()=>{r.push(n),n=""},u=()=>{""===a&&l(j),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case N:o===$?(n+=o,t=R):"{"===o?(c(),t=S):(n+=o,t=N);break;case R:_.has(o)?(n=n.slice(0,-1)+o,t=C):(n+=o,t=N);break;case C:o===$?t=N:(n+=o,t=C);break;case S:"}"===o?(u(),t=N):T(o)?""!==a&&(u(),t=D):(U(o)||l(A),a+=o,t=S);break;case D:"}"==o?t=N:T(o)?t=D:l(A)}return I.has(t)||l(x),c(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const B="__tolgee_dev_tools",M="data-tolgee-key-only",K="data-tolgee-restricted",V="_tolgee",z="_tolgee-highlighter";function Y(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function G(e){if(Y())throw new Error(`${e}: Can't run on the server`)}function W(e,t){return{oldTextContent:e,keys:t}}const X={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function H({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(z),Object.entries(X).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function J(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function q(e){return e.textContent}function Z(e,t){e.textContent=t}function Q(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function ee(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const te={capture:!0},ne={capture:!0,passive:!0};function ae({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const c=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,u=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&O()){const a=c.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;O()&&(t=e.target,!Boolean(E(t,(e=>e.id===B))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),O()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function O(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){u.removeEventListener("blur",v,te),u.removeEventListener("keydown",h,te),u.removeEventListener("keyup",m,te),u.removeEventListener("mousemove",p,ne),u.removeEventListener("scroll",b,ne),u.removeEventListener("click",y,te),u.removeEventListener("mouseenter",f,te),u.removeEventListener("mouseover",f,te),u.removeEventListener("mouseout",f,te),u.removeEventListener("mouseleave",f,te),u.removeEventListener("mousedown",f,te),u.removeEventListener("mouseup",f,te)},run(){u.addEventListener("blur",v,te),u.addEventListener("keydown",h,te),u.addEventListener("keyup",m,te),u.addEventListener("mousemove",p,ne),u.addEventListener("scroll",b,ne),u.addEventListener("click",y,te),u.addEventListener("mouseenter",f,te),u.addEventListener("mouseover",f,te),u.addEventListener("mouseout",f,te),u.addEventListener("mouseleave",f,te),u.addEventListener("mousedown",f,te),u.addEventListener("mouseup",f,te)}})}function oe(e,t,n){const o=H({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=ae({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())Q(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(n,a,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${K}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(V,"true")),s.nodes.set(a,r),o.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(V),t.remove(e)}(e,n))}))},findAll(e,n){const o=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>ee({key:e,ns:a(n)},{key:t.key,ns:a(t.ns)})))){o.push(r);break}}})),o},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t))}))}})}function re(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function o({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(Y())return{stop(){t=!1},wrapper:o};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=J(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>J(t.getTextXPath(),e)});return n}(a,o),l=oe(a,n,r);function c(e){for(const t of e){const e=q(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;Z(t,a);const r=W(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function u(e){J(`./descendant-or-self::*[@${M}]`,e).forEach((e=>{const t=e.getAttributeNode(M),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:q(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":u(t.target),e=s.handleChildList(t.target);break;case"attributes":u(t.target),e=s.handleAttributes(t.target)}c(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),u(d),c(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null===(n=null==e?void 0:e.elementRegistry)||void 0===n?void 0:n.forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){var a;const o=(null===(a=null==e?void 0:e.elementRegistry)||void 0===a?void 0:a.findAll(t,n))||[];return o.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){var o;const r=(null===(o=null==e?void 0:e.elementRegistry)||void 0===o?void 0:o.findAll(t,n))||[],i=[];return r.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),r.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{ee({key:t,ns:a(n)},{key:e.key,ns:a(e.ns)})&&i.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),i},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const ie=["",""],se=RegExp(`([${ie.join("")}]{9})+`,"gu");function le(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>ie[Number(e)])).join("")}function ce(e){const t=Array.from(e).map((e=>ie.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function ue({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null===(t=e.match(se))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ce))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(o){const{k:e,d:t,n:a}=o;n.push({key:e,defaultValue:t,ns:a})}}));const o=function(e){return e.replace(se,"")}(e);return{text:o,keys:n}},wrap({key:a,defaultValue:o,translation:r,ns:i}){let s;if(e){s=le(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:o}),r=t.valueToNumber(e);s=le(String.fromCodePoint(r))}const l=r||"";return"string"==typeof l?l+s:l},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${ie[0]}${ie[0]}') or contains(., '${ie[1]}${ie[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${ie[0]}${ie[0]}') or contains(., '${ie[1]}${ie[0]}')]`})}function ge(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function de({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${u}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!ge(d,n)){u+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const fe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function pe(e){const t=fe.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function ve(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|pe(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function he(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=ve(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function me({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const be="tolgee-in-context-tools.umd.min.js",ye="@tolgee/in-context-tools",Ee="InContextTools",Oe="https://cdn.jsdelivr.net/npm";let Le=null;function we(e){var t;return Le||(Le=(t=`${Oe}/@tolgee/web@${e}/dist/${be}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[ye][Ee]))),Le}const ke="__tolgee_apiKey",je="__tolgee_apiUrl";function Ae(){const e=sessionStorage.getItem(ke)||void 0,t=sessionStorage.getItem(je)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function xe(){sessionStorage.removeItem(ke),sessionStorage.removeItem(je)}exports.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(exports.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=me({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(xe)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ae()&&(async()=>{const e=await we("5.11.4");return t=>{const n=Ae();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const Pe="__tolgee_currentLanguage";function Te(e){return e.endsWith("/")?e.slice(0,-1):e}const Ne={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Te(n)}/${e}/${t}.json`:`${Te(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Re(e){const t=Object.assign(Object.assign(Object.assign({},Ne),e),{headers:Object.assign(Object.assign({},Ne.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:s})=>s(a({namespace:e,language:t,prefix:n}),Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}exports.BackendFetch=e=>(t,n)=>(n.addBackend(Re(e)),t),exports.DEVTOOLS_ID=B,exports.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o,fetch:r}){var i;const s=null!==(i=he(t))&&void 0!==i?i:o;let l=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(l+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return r(l,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e),exports.DevTools=()=>e=>e,exports.FormatSimple=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>F(e,t)}),e),exports.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){G("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e),exports.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(G("LanguageStorage"),localStorage.getItem(Pe)||void 0),setLanguage(e){G("LanguageStorage"),localStorage.setItem(Pe,e)}}),e),exports.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=re();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=de({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&Z(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=re();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ue({fullKeyEncode:t.options.fullKeyEncode});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),exports.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",exports.TOLGEE_ATTRIBUTE_NAME=V,exports.TOLGEE_RESTRICT_ATTRIBUTE=K,exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=M,exports.Tolgee=function(){return k().use(exports.BrowserExtensionPlugin())},exports.TolgeeCore=k,exports.createFetchFunction=l,exports.getFallback=a,exports.getFallbackArray=o,exports.getProjectIdFromApiKey=he,exports.getTranslateProps=L; | ||
"use strict";function e(e){return Boolean(e&&"function"==typeof e.then)}function t(t,n){return e(t)?Promise.resolve(t).then(n):n(t)}function n(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function o(e){return a(e)||[]}function r(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?o(t):o(null==t?void 0:t[e]);var n}function i(e){return Array.from(new Set(e))}function s(e){return e?e.replace(/\/+$/,""):e}Object.defineProperty(exports,"__esModule",{value:!0});const l=(e,t)=>fetch(e,t),c=(e=l)=>(t,n)=>e(t,Object.assign(Object.assign({},n),{headers:Object.assign({"X-Tolgee-SDK-Type":"JS","X-Tolgee-SDK-Version":"5.11.5-prerelease.c74f049c.0"},null==n?void 0:n.headers)}));function u(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function g(e,t,n){const a=new Set,r=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());r.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(i.push(t),n?setTimeout(s,0):s())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};r.add(t);const a={unsubscribe:()=>{r.delete(t)},subscribeNs:e=>(o(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const d=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):d(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},f=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},p=({language:e,namespace:t})=>t?`${e}:${t}`:e;function v(e,t,n,a,r,s,l){const c=new Map,u=new Map;let g={},v=0;function h(t,n,a){const o=p(t);u.set(o,{data:d(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=g[p(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(g=Object.assign(Object.assign({},g),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=f(e),a=u.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){c.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=u.get(p(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=u.get(p(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=u.get(p(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(p({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return i(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(p({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=u.get(p(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return c.size>0;const t=o(e);return Boolean(Array.from(c.keys()).find((e=>t.includes(f(e).namespace))))},isLoading(e,t){const n=o(t);return Boolean(r()||Array.from(c.keys()).find((t=>{const a=f(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=p(o),i=c.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return c.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));s.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=c.get(e.cacheKey)!==e.promise;if(e.new&&!n){c.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),s.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},f(e)),{data:t.data})))});return b}function h(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const m="invalid",b={defaultNs:"",observerOptions:{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"],fullKeyEncode:!1},observerType:"invisible",onFormatError:m,apiUrl:"https://app.tolgee.io",fetch:c()},y=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function E(e,t){const n=y(b,null==t?void 0:t.initialOptions,e);return n.apiUrl=s(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=c(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function O(n,a,o,r,i,s,l,c){const u={ui:void 0},g={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},d=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,fallbackNamespaces:r(t),namespace:i({key:e,ns:t})[0],translation:s({key:e,ns:t})})));null===(n=g.ui)||void 0===n||n.handleElementClick(a,t)},f=(e,t)=>{var n;return(null===(n=g.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function p(e){const t=s({key:e.key,ns:e.ns});return T.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function v(){return{fetch:a().fetch}}function b(e){g.observer=null==e?void 0:e()}function y(){return Boolean(g.observer)}function E(e){e&&g.formatters.push(e)}function O(e){g.finalFormatter=e}function L(e){u.ui=e}function w(){return Boolean(u.ui)}function k(e){g.languageStorage=e}function j(e){g.languageDetector=e}function A(e){e&&g.backends.push(e)}function x(e){g.devBackend=e}const T=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:O,addFormatter:E,setObserver:b,hasObserver:y,setUi:L,hasUi:w,setDevBackend:x,addBackend:A,setLanguageDetector:j,setLanguageStorage:k}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();g.ui=null===(e=u.ui)||void 0===e?void 0:e.call(u,{apiKey:n,apiUrl:o,projectId:r,highlight:T.highlight,changeTranslation:l,findPositions:f,onPermanentChange:c}),null===(t=g.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:p,onClick:d})},stop(){var e;g.ui=void 0,null===(e=g.observer)||void 0===e||e.stop()},getLanguageStorage:()=>g.languageStorage,getInitialLanguage(){var e;const n=o();return t(null===(e=g.languageStorage)||void 0===e?void 0:e.getLanguage(v()),(e=>n&&!n.includes(e)||!e?function(){if(!g.languageDetector)return;const e=o();return g.languageDetector.getLanguage(Object.assign({availableLanguages:e},v()))}():e))},setStoredLanguage(e){var t;null===(t=g.languageStorage)||void 0===t||t.setLanguage(e,v())},getDevBackend:()=>g.devBackend,getBackendRecord:({language:t,namespace:n})=>{for(const a of g.backends){const o=a.getRecord(Object.assign({language:t,namespace:n},v()));if(e(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=g.devBackend)||void 0===n?void 0:n.getRecord(Object.assign({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t},v()))},getLanguageDetector:()=>g.languageDetector,retranslate(){var e;null===(e=g.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=g.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(T.getDevBackend()),formatTranslation(e){var t,{formatEnabled:o}=e,r=h(e,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:u,orEmpty:d,ns:f}=r,p=s||l;let v=p||(d?"":i);const b=n(),y=o||!(null===(t=g.observer)||void 0===t?void 0:t.outputNotFormattable),E=e=>g.observer&&!c?g.observer.wrap({key:i,translation:e,defaultValue:l,params:u,ns:f}):e;v=E(v);try{if(p&&b&&y)for(const e of g.formatters)v=e.format({translation:v,language:b,params:u});g.finalFormatter&&p&&b&&y&&(v=g.finalFormatter.format({translation:v,language:b,params:u}))}catch(e){console.error(e);const t=("string"==typeof(O=e)?O:"string"==typeof(null==O?void 0:O.message)?O.message:void 0)||m,n=a().onFormatError,o=typeof n;v="string"===o?n:"function"===o?n(t,r):m,v=E(v)}var O;return v}});return T}const L=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const w=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:o,language:r}=e,i=h(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function k({options:a}){const l=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:u(a),onLanguageChange:u(a),onLoadingChange:u(a),onFetchingChange:u(a),onInitialLoaded:u(a),onRunningChange:u(a),onCacheChange:u(a),onUpdate:g(a,e,t),onPermanentChange:u(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t);case"permanentChange":return o.onPermanentChange.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(b,y),c=L(!1,(()=>m.isFetching()),l.onFetchingChange.emit),d=L(!1,(()=>C.isLoading()),l.onLoadingChange.emit),p=function(e,t,n){let a,l=E();const c=Object.freeze({init(e){l=E(e,l)},isRunning:()=>l.isRunning,setRunning(e){l.isRunning!==e&&(l.isRunning=e,n.emit(e))},isInitialLoading:()=>l.isInitialLoading,setInitialLoading(e){l.isInitialLoading=e},getLanguage:()=>l.language||l.initialOptions.language,setLanguage(t){l.language!==t&&(l.language=t,e.emit(t))},getPendingLanguage:()=>l.pendingLanguage||c.getLanguage(),setPendingLanguage(e){l.pendingLanguage!==e&&(l.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},l.initialOptions),a),addActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t?l.activeNamespaces.set(e,t+1):l.activeNamespaces.set(e,1)}))},removeActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t&&t>1?l.activeNamespaces.set(e,t-1):l.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>i([...l.initialOptions.ns||[l.initialOptions.defaultNs],...o(l.initialOptions.fallbackNs),...l.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||c.getLanguage();return t?i([t,...r(t,l.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>o(l.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?l.initialOptions.defaultNs:e,getAvailableLanguages(){if(l.initialOptions.availableLanguages)return l.initialOptions.availableLanguages;if(l.initialOptions.staticData){const e=Object.keys(l.initialOptions.staticData).map((e=>f(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?c.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:s(e.apiUrl)}):void 0}});return c}(l.onLanguageChange,l.onPendingLanguageChange,l.onRunningChange),h=O(p.getLanguage,p.getInitialOptions,p.getAvailableLanguages,k,P,N,A,(function(e){l.onPermanentChange.emit({key:e.key,namespace:e.namespace})})),m=v(l.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,p.withDefaultNs,p.isInitialLoading,c,d);function b(){return p.getFallbackNs()}function y(e){return p.getDefaultNs(e)}function k(e){return[...o(y(e)),...b()]}function j(e){return[...o(null!=e?e:y()),...p.getRequiredNamespaces()]}function A(e,t,n){const a=p.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function x(e){p.init(e),m.addStaticData(p.getInitialOptions().staticData)}function T(e,n){const a=function(e,t){const n=p.getFallbackLangs(e),a=j(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,n);if(a.length)return t(C.loadRecords(a),(()=>{}))}function P({key:e,ns:t}){const n=p.getFallbackLangs(),a=k(null!=t?t:void 0);return m.getTranslationNs(a,n,e)}function N({key:e,ns:t,language:n}){const a=k(null!=t?t:void 0),o=p.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function R(){const n=t(function(){if(p.getLanguage())return;return t(h.getInitialLanguage(),(e=>{const t=e||p.getInitialOptions().defaultLanguage;t&&p.setLanguage(t)}))}(),(()=>T()));if(e(n))return p.setInitialLoading(!0),c.notify(),d.notify(),Promise.resolve(n).then((()=>{p.setInitialLoading(!1),c.notify(),d.notify(),l.onInitialLoaded.emit()}));l.onInitialLoaded.emit()}a&&x(a),l.onUpdate.listen((()=>{p.isRunning()&&h.retranslate()}));const C=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},l),p),h),m),{init:x,getTranslation:N,changeTranslation:A,getTranslationNs:P,getDefaultAndFallbackNs:k,async changeLanguage(e){p.getPendingLanguage()===e&&p.getLanguage()===e||(p.setPendingLanguage(e),p.isRunning()&&await T(e),e===p.getPendingLanguage()&&(p.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||p.addActiveNs(e),p.isRunning()&&await T(void 0,e)},loadRecords:e=>m.loadRecords(e,C.isDev()),loadRecord:async e=>(await C.loadRecords([e]))[0],isLoading:e=>m.isLoading(p.getLanguage(),e),isLoaded(e){const t=p.getLanguage();if(!t)return!1;const n=p.getFallbackLangs(t),a=j(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=w(...e),n=N(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(p.getInitialOptions().apiKey&&p.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!p.getAvailableLanguages())throw new Error(n("availableLanguages"));if(!p.getLanguage()&&!p.getInitialOptions().defaultLanguage)throw new Error(n(["defaultLanguage","language"]))}(),p.isRunning()||(p.setRunning(!0),h.run(),e=R()),Promise.resolve(e)},stop(){p.isRunning()&&(h.stop(),p.setRunning(!1))}}));return C}const j=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=y(e.options,n),t),init(t){const n=function(e){const t=k({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(y(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},A=0,x=1,T=2;class P extends Error{constructor(e,t,n){let a;a=e===A?"Empty parameter":e===x?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function N(e){return/\s/.test(e)}const R=0,C=1,S=2,D=3,I=4,$=new Set([S,C,R]),_="'",U=new Set(["{","}",_]),F=e=>/[0-9a-zA-Z_]/.test(e);function B(e,t){const[n,a]=function(e){let t=R,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new P(t,s,e)}const c=()=>{r.push(n),n=""},u=()=>{""===a&&l(A),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case R:o===_?(n+=o,t=C):"{"===o?(c(),t=D):(n+=o,t=R);break;case C:U.has(o)?(n=n.slice(0,-1)+o,t=S):(n+=o,t=R);break;case S:o===_?t=R:(n+=o,t=S);break;case D:"}"===o?(u(),t=R):N(o)?""!==a&&(u(),t=I):(F(o)||l(x),a+=o,t=D);break;case I:"}"==o?t=R:N(o)?t=I:l(x)}return $.has(t)||l(T),c(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const M="__tolgee_dev_tools",K="data-tolgee-key-only",V="data-tolgee-restricted",z="_tolgee",Y="_tolgee-highlighter";function G(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function W(e){if(G())throw new Error(`${e}: Can't run on the server`)}function X(e,t){return{oldTextContent:e,keys:t}}const H={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function J({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(Y),Object.entries(H).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function q(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function Z(e){return e.textContent}function Q(e,t){e.textContent=t}function ee(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function te(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const ne={capture:!0},ae={capture:!0,passive:!0};function oe({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const c=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,u=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&O()){const a=c.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;O()&&(t=e.target,!Boolean(E(t,(e=>e.id===M))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),O()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function O(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){u.removeEventListener("blur",v,ne),u.removeEventListener("keydown",h,ne),u.removeEventListener("keyup",m,ne),u.removeEventListener("mousemove",p,ae),u.removeEventListener("scroll",b,ae),u.removeEventListener("click",y,ne),u.removeEventListener("mouseenter",f,ne),u.removeEventListener("mouseover",f,ne),u.removeEventListener("mouseout",f,ne),u.removeEventListener("mouseleave",f,ne),u.removeEventListener("mousedown",f,ne),u.removeEventListener("mouseup",f,ne)},run(){u.addEventListener("blur",v,ne),u.addEventListener("keydown",h,ne),u.addEventListener("keyup",m,ne),u.addEventListener("mousemove",p,ae),u.addEventListener("scroll",b,ae),u.addEventListener("click",y,ne),u.addEventListener("mouseenter",f,ne),u.addEventListener("mouseover",f,ne),u.addEventListener("mouseout",f,ne),u.addEventListener("mouseleave",f,ne),u.addEventListener("mousedown",f,ne),u.addEventListener("mouseup",f,ne)}})}function re(e,t,n){const o=J({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=oe({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())ee(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(n,a,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${V}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(z,"true")),s.nodes.set(a,r),o.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(z),t.remove(e)}(e,n))}))},findAll(e,n){const o=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>te({key:e,ns:a(n)},{key:t.key,ns:a(t.ns)})))){o.push(r);break}}})),o},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t))}))}})}function ie(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function o({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(G())return{stop(){t=!1},wrapper:o};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=q(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>q(t.getTextXPath(),e)});return n}(a,o),l=re(a,n,r);function c(e){for(const t of e){const e=Z(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;Q(t,a);const r=X(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function u(e){q(`./descendant-or-self::*[@${K}]`,e).forEach((e=>{const t=e.getAttributeNode(K),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:Z(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":u(t.target),e=s.handleChildList(t.target);break;case"attributes":u(t.target),e=s.handleAttributes(t.target)}c(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),u(d),c(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null===(n=null==e?void 0:e.elementRegistry)||void 0===n?void 0:n.forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){var a;const o=(null===(a=null==e?void 0:e.elementRegistry)||void 0===a?void 0:a.findAll(t,n))||[];return o.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){var o;const r=(null===(o=null==e?void 0:e.elementRegistry)||void 0===o?void 0:o.findAll(t,n))||[],i=[];return r.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),r.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{te({key:t,ns:a(n)},{key:e.key,ns:a(e.ns)})&&i.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),i},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const se=["",""],le=RegExp(`([${se.join("")}]{9})+`,"gu");function ce(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>se[Number(e)])).join("")}function ue(e){const t=Array.from(e).map((e=>se.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function ge({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null===(t=e.match(le))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ue))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(o){const{k:e,d:t,n:a}=o;n.push({key:e,defaultValue:t,ns:a})}}));const o=function(e){return e.replace(le,"")}(e);return{text:o,keys:n}},wrap({key:a,defaultValue:o,translation:r,ns:i}){let s;if(e){s=ce(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:o}),r=t.valueToNumber(e);s=ce(String.fromCodePoint(r))}const l=r||"";return"string"==typeof l?l+s:l},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${se[0]}${se[0]}') or contains(., '${se[1]}${se[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${se[0]}${se[0]}') or contains(., '${se[1]}${se[0]}')]`})}function de(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function fe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${u}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!de(d,n)){u+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const pe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function ve(e){const t=pe.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function he(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|ve(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function me(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=he(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function be({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const ye="tolgee-in-context-tools.umd.min.js",Ee="@tolgee/in-context-tools",Oe="InContextTools",Le="https://cdn.jsdelivr.net/npm";let we=null;function ke(e){var t;return we||(we=(t=`${Le}/@tolgee/web@${e}/dist/${ye}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[Ee][Oe]))),we}const je="__tolgee_apiKey",Ae="__tolgee_apiUrl";function xe(){const e=sessionStorage.getItem(je)||void 0,t=sessionStorage.getItem(Ae)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Te(){sessionStorage.removeItem(je),sessionStorage.removeItem(Ae)}exports.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(exports.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=be({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(Te)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return xe()&&(async()=>{const e=await ke("5.11.5-prerelease.c74f049c.0");return t=>{const n=xe();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const Pe="__tolgee_currentLanguage";function Ne(e){return e.endsWith("/")?e.slice(0,-1):e}const Re={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Ne(n)}/${e}/${t}.json`:`${Ne(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ce(e){const t=Object.assign(Object.assign(Object.assign({},Re),e),{headers:Object.assign(Object.assign({},Re.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:s})=>s(a({namespace:e,language:t,prefix:n}),Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}exports.BackendFetch=e=>(t,n)=>(n.addBackend(Ce(e)),t),exports.DEVTOOLS_ID=M,exports.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o,fetch:r}){var i;const s=null!==(i=me(t))&&void 0!==i?i:o;let l=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(l+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return r(l,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e),exports.DevTools=()=>e=>e,exports.FormatSimple=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>B(e,t)}),e),exports.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){W("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e),exports.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(W("LanguageStorage"),localStorage.getItem(Pe)||void 0),setLanguage(e){W("LanguageStorage"),localStorage.setItem(Pe,e)}}),e),exports.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=ie();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=fe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&Q(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=ie();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ge({fullKeyEncode:t.options.fullKeyEncode});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),exports.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",exports.TOLGEE_ATTRIBUTE_NAME=z,exports.TOLGEE_RESTRICT_ATTRIBUTE=V,exports.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=K,exports.Tolgee=function(){return j().use(exports.BrowserExtensionPlugin())},exports.TolgeeCore=j,exports.createFetchFunction=c,exports.getFallback=a,exports.getFallbackArray=o,exports.getProjectIdFromApiKey=me,exports.getTranslateProps=w; | ||
//# sourceMappingURL=tolgee-web.production.cjs.min.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e){return Boolean(e&&"function"==typeof e.then)}function t(t,n){return e(t)?Promise.resolve(t).then(n):n(t)}function n(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function o(e){return a(e)||[]}function r(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?o(t):o(null==t?void 0:t[e]);var n}function i(e){return Array.from(new Set(e))}function s(e){return e?e.replace(/\/+$/,""):e}const c=(e=fetch)=>(t,n)=>e(t,Object.assign(Object.assign({},n),{headers:Object.assign({"X-Tolgee-SDK-Type":"JS","X-Tolgee-SDK-Version":"5.11.4"},null==n?void 0:n.headers)}));function l(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function u(e,t,n){const a=new Set,r=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());r.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(i.push(t),n?setTimeout(s,0):s())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};r.add(t);const a={unsubscribe:()=>{r.delete(t)},subscribeNs:e=>(o(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const g=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):g(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},d=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},f=({language:e,namespace:t})=>t?`${e}:${t}`:e;function p(e,t,n,a,r,s,c){const l=new Map,u=new Map;let p={},v=0;function h(t,n,a){const o=f(t);u.set(o,{data:g(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=p[f(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(p=Object.assign(Object.assign({},p),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=d(e),a=u.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){l.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=u.get(f(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=u.get(f(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=u.get(f(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(f({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return i(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(f({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=u.get(f(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return l.size>0;const t=o(e);return Boolean(Array.from(l.keys()).find((e=>t.includes(d(e).namespace))))},isLoading(e,t){const n=o(t);return Boolean(r()||Array.from(l.keys()).find((t=>{const a=d(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=f(o),i=l.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return l.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));s.notify(),c.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=l.get(e.cacheKey)!==e.promise;if(e.new&&!n){l.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),s.notify(),c.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},d(e)),{data:t.data})))});return b}function v(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const h="invalid",m={defaultNs:"",observerOptions:{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"],fullKeyEncode:!1},observerType:"invisible",onFormatError:h,apiUrl:"https://app.tolgee.io",fetch:c()},b=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function y(e,t){const n=b(m,null==t?void 0:t.initialOptions,e);return n.apiUrl=s(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=c(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function E(n,a,o,r,i,s,c){const l={ui:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},g=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:r({key:e,ns:t}),translation:i({key:e,ns:t})})));null===(n=u.ui)||void 0===n||n.handleElementClick(a,t)},d=(e,t)=>{var n;return(null===(n=u.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function f(e){const t=i({key:e.key,ns:e.ns});return P.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function p(){return{fetch:a().fetch}}function m(e){u.observer=null==e?void 0:e()}function b(){return Boolean(u.observer)}function y(e){e&&u.formatters.push(e)}function E(e){u.finalFormatter=e}function O(e){l.ui=e}function L(){return Boolean(l.ui)}function w(e){u.languageStorage=e}function k(e){u.languageDetector=e}function j(e){e&&u.backends.push(e)}function A(e){u.devBackend=e}const P=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:E,addFormatter:y,setObserver:m,hasObserver:b,setUi:O,hasUi:L,setDevBackend:A,addBackend:j,setLanguageDetector:k,setLanguageStorage:w}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();u.ui=null===(e=l.ui)||void 0===e?void 0:e.call(l,{apiKey:n,apiUrl:o,projectId:r,highlight:P.highlight,changeTranslation:s,findPositions:d,onPermanentChange:c}),null===(t=u.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:f,onClick:g})},stop(){var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},getLanguageStorage:()=>u.languageStorage,getInitialLanguage(){var e;const n=o();return t(null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage(p()),(e=>n&&!n.includes(e)||!e?function(){if(!u.languageDetector)return;const e=o();return u.languageDetector.getLanguage(Object.assign({availableLanguages:e},p()))}():e))},setStoredLanguage(e){var t;null===(t=u.languageStorage)||void 0===t||t.setLanguage(e,p())},getDevBackend:()=>u.devBackend,getBackendRecord:({language:t,namespace:n})=>{for(const a of u.backends){const o=a.getRecord(Object.assign({language:t,namespace:n},p()));if(e(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=u.devBackend)||void 0===n?void 0:n.getRecord(Object.assign({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t},p()))},getLanguageDetector:()=>u.languageDetector,retranslate(){var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=u.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(P.getDevBackend()),formatTranslation(e){var t,{formatEnabled:o}=e,r=v(e,["formatEnabled"]);const{key:i,translation:s,defaultValue:c,noWrap:l,params:g,orEmpty:d,ns:f}=r,p=s||c;let m=p||(d?"":i);const b=n(),y=o||!(null===(t=u.observer)||void 0===t?void 0:t.outputNotFormattable),E=e=>u.observer&&!l?u.observer.wrap({key:i,translation:e,defaultValue:c,params:g,ns:f}):e;m=E(m);try{if(p&&b&&y)for(const e of u.formatters)m=e.format({translation:m,language:b,params:g});u.finalFormatter&&p&&b&&y&&(m=u.finalFormatter.format({translation:m,language:b,params:g}))}catch(e){console.error(e);const t=("string"==typeof(O=e)?O:"string"==typeof(null==O?void 0:O.message)?O.message:void 0)||h,n=a().onFormatError,o=typeof n;m="string"===o?n:"function"===o?n(t,r):h,m=E(m)}var O;return m}});return P}const O=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const L=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:o,language:r}=e,i=v(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function w({options:a}){const c=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:l(a),onLanguageChange:l(a),onLoadingChange:l(a),onFetchingChange:l(a),onInitialLoaded:l(a),onRunningChange:l(a),onCacheChange:l(a),onUpdate:u(a,e,t),onPermanentChange:l(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t);case"permanentChange":return o.onPermanentChange.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(b,w),g=O(!1,(()=>m.isFetching()),c.onFetchingChange.emit),f=O(!1,(()=>C.isLoading()),c.onLoadingChange.emit),v=function(e,t,n){let a,c=y();const l=Object.freeze({init(e){c=y(e,c)},isRunning:()=>c.isRunning,setRunning(e){c.isRunning!==e&&(c.isRunning=e,n.emit(e))},isInitialLoading:()=>c.isInitialLoading,setInitialLoading(e){c.isInitialLoading=e},getLanguage:()=>c.language||c.initialOptions.language,setLanguage(t){c.language!==t&&(c.language=t,e.emit(t))},getPendingLanguage:()=>c.pendingLanguage||l.getLanguage(),setPendingLanguage(e){c.pendingLanguage!==e&&(c.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},c.initialOptions),a),addActiveNs(e){o(e).forEach((e=>{const t=c.activeNamespaces.get(e);void 0!==t?c.activeNamespaces.set(e,t+1):c.activeNamespaces.set(e,1)}))},removeActiveNs(e){o(e).forEach((e=>{const t=c.activeNamespaces.get(e);void 0!==t&&t>1?c.activeNamespaces.set(e,t-1):c.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>i([...c.initialOptions.ns||[c.initialOptions.defaultNs],...o(c.initialOptions.fallbackNs),...c.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||l.getLanguage();return t?i([t,...r(t,c.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>o(c.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?c.initialOptions.defaultNs:e,getAvailableLanguages(){if(c.initialOptions.availableLanguages)return c.initialOptions.availableLanguages;if(c.initialOptions.staticData){const e=Object.keys(c.initialOptions.staticData).map((e=>d(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?l.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:s(e.apiUrl)}):void 0}});return l}(c.onLanguageChange,c.onPendingLanguageChange,c.onRunningChange),h=E(v.getLanguage,v.getInitialOptions,v.getAvailableLanguages,(function({key:e,ns:t}){const n=v.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),N,A,(function(e){c.onPermanentChange.emit({key:e.key,namespace:e.namespace})})),m=p(c.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,v.withDefaultNs,v.isInitialLoading,g,f);function b(){return v.getFallbackNs()}function w(e){return v.getDefaultNs(e)}function k(e){return[...o(w(e)),...b()]}function j(e){return[...o(e||w()),...v.getRequiredNamespaces()]}function A(e,t,n){const a=v.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function P(e){v.init(e),m.addStaticData(v.getInitialOptions().staticData)}function x(e,n){const a=function(e,t){const n=v.getFallbackLangs(e),a=j(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,n);if(a.length)return t(C.loadRecords(a),(()=>{}))}function N({key:e,ns:t,language:n}){const a=k(t||void 0),o=v.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function T(){const n=t(function(){if(v.getLanguage())return;return t(h.getInitialLanguage(),(e=>{const t=e||v.getInitialOptions().defaultLanguage;t&&v.setLanguage(t)}))}(),(()=>x()));if(e(n))return v.setInitialLoading(!0),g.notify(),f.notify(),Promise.resolve(n).then((()=>{v.setInitialLoading(!1),g.notify(),f.notify(),c.onInitialLoaded.emit()}));c.onInitialLoaded.emit()}a&&P(a),c.onUpdate.listen((()=>{v.isRunning()&&h.retranslate()}));const C=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c),v),h),m),{init:P,getTranslation:N,changeTranslation:A,async changeLanguage(e){v.getPendingLanguage()===e&&v.getLanguage()===e||(v.setPendingLanguage(e),v.isRunning()&&await x(e),e===v.getPendingLanguage()&&(v.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||v.addActiveNs(e),v.isRunning()&&await x(void 0,e)},loadRecords:e=>m.loadRecords(e,C.isDev()),loadRecord:async e=>(await C.loadRecords([e]))[0],isLoading:e=>m.isLoading(v.getLanguage(),e),isLoaded(e){const t=v.getLanguage();if(!t)return!1;const n=v.getFallbackLangs(t),a=j(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=L(...e),n=N(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(v.getInitialOptions().apiKey&&v.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!v.getAvailableLanguages())throw new Error(n("availableLanguages"));if(!v.getLanguage()&&!v.getInitialOptions().defaultLanguage)throw new Error(n(["defaultLanguage","language"]))}(),v.isRunning()||(v.setRunning(!0),h.run(),e=T()),Promise.resolve(e)},stop(){v.isRunning()&&(h.stop(),v.setRunning(!1))}}));return C}const k=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=b(e.options,n),t),init(t){const n=function(e){const t=w({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(b(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},j=0,A=1,P=2;class x extends Error{constructor(e,t,n){let a;a=e===j?"Empty parameter":e===A?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function N(e){return/\s/.test(e)}const T=0,C=1,R=2,S=3,D=4,$=new Set([R,C,T]),I="'",U=new Set(["{","}",I]),_=e=>/[0-9a-zA-Z_]/.test(e);function F(e,t){const[n,a]=function(e){let t=T,n="",a="",o="";const r=[],i=[];let s=0;function c(t){throw new x(t,s,e)}const l=()=>{r.push(n),n=""},u=()=>{""===a&&c(j),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case T:o===I?(n+=o,t=C):"{"===o?(l(),t=S):(n+=o,t=T);break;case C:U.has(o)?(n=n.slice(0,-1)+o,t=R):(n+=o,t=T);break;case R:o===I?t=T:(n+=o,t=R);break;case S:"}"===o?(u(),t=T):N(o)?""!==a&&(u(),t=D):(_(o)||c(A),a+=o,t=S);break;case D:"}"==o?t=T:N(o)?t=D:c(A)}return $.has(t)||c(P),l(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const M=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>F(e,t)}),e),V="__tolgee_dev_tools",K="__tolgee_preferredLanguages",z="data-tolgee-key-only",B="data-tolgee-restricted",X="_tolgee",W="_tolgee-highlighter";function Y(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function G(e){if(Y())throw new Error(`${e}: Can't run on the server`)}function H(e,t){return{oldTextContent:e,keys:t}}const J={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function q({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(W),Object.entries(J).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function Z(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function Q(e){return e.textContent}function ee(e,t){e.textContent=t}function te(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function ne(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const ae={capture:!0},oe={capture:!0,passive:!0};function re({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,c=new Set;const l=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,u=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&O()){const a=l.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;O()&&(t=e.target,!Boolean(E(t,(e=>e.id===V))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){c=new Set,d()}function h(e){const t=e.key;void 0!==t&&c.add(t),d()}function m(e){c.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),O()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function O(){for(const t of e)if(!c.has(t))return!1;return!0}return Object.freeze({stop(){u.removeEventListener("blur",v,ae),u.removeEventListener("keydown",h,ae),u.removeEventListener("keyup",m,ae),u.removeEventListener("mousemove",p,oe),u.removeEventListener("scroll",b,oe),u.removeEventListener("click",y,ae),u.removeEventListener("mouseenter",f,ae),u.removeEventListener("mouseover",f,ae),u.removeEventListener("mouseout",f,ae),u.removeEventListener("mouseleave",f,ae),u.removeEventListener("mousedown",f,ae),u.removeEventListener("mouseup",f,ae)},run(){u.addEventListener("blur",v,ae),u.addEventListener("keydown",h,ae),u.addEventListener("keyup",m,ae),u.addEventListener("mousemove",p,oe),u.addEventListener("scroll",b,oe),u.addEventListener("click",y,ae),u.addEventListener("mouseenter",f,ae),u.addEventListener("mouseover",f,ae),u.addEventListener("mouseout",f,ae),u.addEventListener("mouseleave",f,ae),u.addEventListener("mousedown",f,ae),u.addEventListener("mouseup",f,ae)}})}function ie(e,t,n){const o=q({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=re({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:c(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())te(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function c(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(n,a,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${B}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(X,"true")),s.nodes.set(a,r),o.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(X),t.remove(e)}(e,n))}))},findAll(e,n){const o=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>ne({key:e,ns:a(n)},{key:t.key,ns:a(t.ns)})))){o.push(r);break}}})),o},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t))}))}})}function se(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function o({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(Y())return{stop(){t=!1},wrapper:o};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=Z(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>Z(t.getTextXPath(),e)});return n}(a,o),c=ie(a,n,r);function l(e){for(const t of e){const e=Q(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;ee(t,a);const r=H(e,o),s=i.getSuitableParent(t);c.register(s,t,r)}}}function u(e){Z(`./descendant-or-self::*[@${z}]`,e).forEach((e=>{const t=e.getAttributeNode(z),n=i.getSuitableParent(t);c.register(n,t,{oldTextContent:"",keys:[{key:Q(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":u(t.target),e=s.handleChildList(t.target);break;case"attributes":u(t.target),e=s.handleAttributes(t.target)}l(e)}c.refreshAll()}})),d=a.targetElement||document.body;return t=!0,c.run(e),u(d),l(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,c.stop(),g.disconnect()},elementRegistry:c,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null===(n=null==e?void 0:e.elementRegistry)||void 0===n?void 0:n.forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){var a;const o=(null===(a=null==e?void 0:e.elementRegistry)||void 0===a?void 0:a.findAll(t,n))||[];return o.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){var o;const r=(null===(o=null==e?void 0:e.elementRegistry)||void 0===o?void 0:o.findAll(t,n))||[],i=[];return r.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),r.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{ne({key:t,ns:a(n)},{key:e.key,ns:a(e.ns)})&&i.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),i},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const ce=["",""],le=RegExp(`([${ce.join("")}]{9})+`,"gu");function ue(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>ce[Number(e)])).join("")}function ge(e){const t=Array.from(e).map((e=>ce.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function de({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null===(t=e.match(le))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ge))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(o){const{k:e,d:t,n:a}=o;n.push({key:e,defaultValue:t,ns:a})}}));const o=function(e){return e.replace(le,"")}(e);return{text:o,keys:n}},wrap({key:a,defaultValue:o,translation:r,ns:i}){let s;if(e){s=ue(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:o}),r=t.valueToNumber(e);s=ue(String.fromCodePoint(r))}const c=r||"";return"string"==typeof c?c+s:c},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${ce[0]}${ce[0]}') or contains(., '${ce[1]}${ce[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${ce[0]}${ce[0]}') or contains(., '${ce[1]}${ce[0]}')]`})}function fe(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function pe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const c=void 0!==o?`,${r(o)}`:"",l="string"==typeof i?[i]:i,u=(null==l?void 0:l.length)?`|${l.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${u}${c}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,c=!1,l=0,u="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(u+=f.substr(l,d-l),l=d+t.length,"\\"===e){if(!fe(d,n)){u+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),c=!0,u+=e+p.translated}return u+=n.substring(l),c?{text:u,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const ve=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=se();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=pe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&ee(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=se();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=de({fullKeyEncode:t.options.fullKeyEncode});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),he="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function me(e){const t=he.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function be(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|me(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function ye(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=be(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}const Ee=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o,fetch:r}){var i;const s=null!==(i=ye(t))&&void 0!==i?i:o;let c=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(c+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return r(c,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e);function Oe({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const Le="tolgee-in-context-tools.umd.min.js",we="@tolgee/in-context-tools",ke="InContextTools",je="https://cdn.jsdelivr.net/npm";let Ae=null;function Pe(e){var t;return Ae||(Ae=(t=`${je}/@tolgee/web@${e}/dist/${Le}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[we][ke]))),Ae}const xe="__tolgee_apiKey",Ne="__tolgee_apiUrl";function Te(){const e=sessionStorage.getItem(xe)||void 0,t=sessionStorage.getItem(Ne)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Ce(){sessionStorage.removeItem(xe),sessionStorage.removeItem(Ne)}let Re=()=>e=>e;"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(Re=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=Oe({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(Ce)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Te()&&(async()=>{const e=await Pe("5.11.4");return t=>{const n=Te();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const Se="__tolgee_currentLanguage";const De=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(G("LanguageStorage"),localStorage.getItem(Se)||void 0),setLanguage(e){G("LanguageStorage"),localStorage.setItem(Se,e)}}),e);const $e=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){G("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e);function Ie(e){return e.endsWith("/")?e.slice(0,-1):e}const Ue={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Ie(n)}/${e}/${t}.json`:`${Ie(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function _e(e){const t=Object.assign(Object.assign(Object.assign({},Ue),e),{headers:Object.assign(Object.assign({},Ue.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:s})=>s(a({namespace:e,language:t,prefix:n}),Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}const Fe=e=>(t,n)=>(n.addBackend(_e(e)),t);function Me(){return k().use(Re())}const Ve=()=>e=>e;export{Fe as BackendFetch,Re as BrowserExtensionPlugin,V as DEVTOOLS_ID,Ee as DevBackend,Ve as DevTools,M as FormatSimple,$e as LanguageDetector,De as LanguageStorage,ve as ObserverPlugin,K as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,X as TOLGEE_ATTRIBUTE_NAME,B as TOLGEE_RESTRICT_ATTRIBUTE,z as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,Me as Tolgee,k as TolgeeCore,c as createFetchFunction,a as getFallback,o as getFallbackArray,ye as getProjectIdFromApiKey,L as getTranslateProps}; | ||
function e(e){return Boolean(e&&"function"==typeof e.then)}function t(t,n){return e(t)?Promise.resolve(t).then(n):n(t)}function n(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function a(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function o(e){return a(e)||[]}function r(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?o(t):o(null==t?void 0:t[e]);var n}function i(e){return Array.from(new Set(e))}function s(e){return e?e.replace(/\/+$/,""):e}const l=(e,t)=>fetch(e,t),c=(e=l)=>(t,n)=>e(t,Object.assign(Object.assign({},n),{headers:Object.assign({"X-Tolgee-SDK-Type":"JS","X-Tolgee-SDK-Version":"5.11.5-prerelease.c74f049c.0"},null==n?void 0:n.headers)}));function u(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function g(e,t,n){const a=new Set,r=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());r.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(i.push(t),n?setTimeout(s,0):s())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};r.add(t);const a={unsubscribe:()=>{r.delete(t)},subscribeNs:e=>(o(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const d=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):d(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},f=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},p=({language:e,namespace:t})=>t?`${e}:${t}`:e;function v(e,t,n,a,r,s,l){const c=new Map,u=new Map;let g={},v=0;function h(t,n,a){const o=p(t);u.set(o,{data:d(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=g[p(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(g=Object.assign(Object.assign({},g),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=f(e),a=u.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){c.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=u.get(p(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=u.get(p(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=u.get(p(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(p({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return i(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(p({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=u.get(p(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(r())return!0;if(void 0===e)return c.size>0;const t=o(e);return Boolean(Array.from(c.keys()).find((e=>t.includes(f(e).namespace))))},isLoading(e,t){const n=o(t);return Boolean(r()||Array.from(c.keys()).find((t=>{const a=f(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=p(o),i=c.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return c.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));s.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=c.get(e.cacheKey)!==e.promise;if(e.new&&!n){c.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),s.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},f(e)),{data:t.data})))});return b}function h(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const m="invalid",b={defaultNs:"",observerOptions:{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"],fullKeyEncode:!1},observerType:"invisible",onFormatError:m,apiUrl:"https://app.tolgee.io",fetch:c()},y=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function E(e,t){const n=y(b,null==t?void 0:t.initialOptions,e);return n.apiUrl=s(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=c(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function O(n,a,o,r,i,s,l,c){const u={ui:void 0},g={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},d=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,fallbackNamespaces:r(t),namespace:i({key:e,ns:t})[0],translation:s({key:e,ns:t})})));null===(n=g.ui)||void 0===n||n.handleElementClick(a,t)},f=(e,t)=>{var n;return(null===(n=g.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function p(e){const t=s({key:e.key,ns:e.ns});return N.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function v(){return{fetch:a().fetch}}function b(e){g.observer=null==e?void 0:e()}function y(){return Boolean(g.observer)}function E(e){e&&g.formatters.push(e)}function O(e){g.finalFormatter=e}function L(e){u.ui=e}function w(){return Boolean(u.ui)}function k(e){g.languageStorage=e}function j(e){g.languageDetector=e}function A(e){e&&g.backends.push(e)}function P(e){g.devBackend=e}const N=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:O,addFormatter:E,setObserver:b,hasObserver:y,setUi:L,hasUi:w,setDevBackend:P,addBackend:A,setLanguageDetector:j,setLanguageStorage:k}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();g.ui=null===(e=u.ui)||void 0===e?void 0:e.call(u,{apiKey:n,apiUrl:o,projectId:r,highlight:N.highlight,changeTranslation:l,findPositions:f,onPermanentChange:c}),null===(t=g.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:p,onClick:d})},stop(){var e;g.ui=void 0,null===(e=g.observer)||void 0===e||e.stop()},getLanguageStorage:()=>g.languageStorage,getInitialLanguage(){var e;const n=o();return t(null===(e=g.languageStorage)||void 0===e?void 0:e.getLanguage(v()),(e=>n&&!n.includes(e)||!e?function(){if(!g.languageDetector)return;const e=o();return g.languageDetector.getLanguage(Object.assign({availableLanguages:e},v()))}():e))},setStoredLanguage(e){var t;null===(t=g.languageStorage)||void 0===t||t.setLanguage(e,v())},getDevBackend:()=>g.devBackend,getBackendRecord:({language:t,namespace:n})=>{for(const a of g.backends){const o=a.getRecord(Object.assign({language:t,namespace:n},v()));if(e(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=g.devBackend)||void 0===n?void 0:n.getRecord(Object.assign({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t},v()))},getLanguageDetector:()=>g.languageDetector,retranslate(){var e;null===(e=g.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=g.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(N.getDevBackend()),formatTranslation(e){var t,{formatEnabled:o}=e,r=h(e,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:u,orEmpty:d,ns:f}=r,p=s||l;let v=p||(d?"":i);const b=n(),y=o||!(null===(t=g.observer)||void 0===t?void 0:t.outputNotFormattable),E=e=>g.observer&&!c?g.observer.wrap({key:i,translation:e,defaultValue:l,params:u,ns:f}):e;v=E(v);try{if(p&&b&&y)for(const e of g.formatters)v=e.format({translation:v,language:b,params:u});g.finalFormatter&&p&&b&&y&&(v=g.finalFormatter.format({translation:v,language:b,params:u}))}catch(e){console.error(e);const t=("string"==typeof(O=e)?O:"string"==typeof(null==O?void 0:O.message)?O.message:void 0)||m,n=a().onFormatError,o=typeof n;v="string"===o?n:"function"===o?n(t,r):m,v=E(v)}var O;return v}});return N}const L=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const w=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:o,language:r}=e,i=h(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function k({options:a}){const l=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:u(a),onLanguageChange:u(a),onLoadingChange:u(a),onFetchingChange:u(a),onInitialLoaded:u(a),onRunningChange:u(a),onCacheChange:u(a),onUpdate:g(a,e,t),onPermanentChange:u(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t);case"permanentChange":return o.onPermanentChange.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(b,y),c=L(!1,(()=>m.isFetching()),l.onFetchingChange.emit),d=L(!1,(()=>R.isLoading()),l.onLoadingChange.emit),p=function(e,t,n){let a,l=E();const c=Object.freeze({init(e){l=E(e,l)},isRunning:()=>l.isRunning,setRunning(e){l.isRunning!==e&&(l.isRunning=e,n.emit(e))},isInitialLoading:()=>l.isInitialLoading,setInitialLoading(e){l.isInitialLoading=e},getLanguage:()=>l.language||l.initialOptions.language,setLanguage(t){l.language!==t&&(l.language=t,e.emit(t))},getPendingLanguage:()=>l.pendingLanguage||c.getLanguage(),setPendingLanguage(e){l.pendingLanguage!==e&&(l.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},l.initialOptions),a),addActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t?l.activeNamespaces.set(e,t+1):l.activeNamespaces.set(e,1)}))},removeActiveNs(e){o(e).forEach((e=>{const t=l.activeNamespaces.get(e);void 0!==t&&t>1?l.activeNamespaces.set(e,t-1):l.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>i([...l.initialOptions.ns||[l.initialOptions.defaultNs],...o(l.initialOptions.fallbackNs),...l.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||c.getLanguage();return t?i([t,...r(t,l.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>o(l.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?l.initialOptions.defaultNs:e,getAvailableLanguages(){if(l.initialOptions.availableLanguages)return l.initialOptions.availableLanguages;if(l.initialOptions.staticData){const e=Object.keys(l.initialOptions.staticData).map((e=>f(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?c.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:s(e.apiUrl)}):void 0}});return c}(l.onLanguageChange,l.onPendingLanguageChange,l.onRunningChange),h=O(p.getLanguage,p.getInitialOptions,p.getAvailableLanguages,k,x,T,A,(function(e){l.onPermanentChange.emit({key:e.key,namespace:e.namespace})})),m=v(l.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,p.withDefaultNs,p.isInitialLoading,c,d);function b(){return p.getFallbackNs()}function y(e){return p.getDefaultNs(e)}function k(e){return[...o(y(e)),...b()]}function j(e){return[...o(null!=e?e:y()),...p.getRequiredNamespaces()]}function A(e,t,n){const a=p.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function P(e){p.init(e),m.addStaticData(p.getInitialOptions().staticData)}function N(e,n){const a=function(e,t){const n=p.getFallbackLangs(e),a=j(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,n);if(a.length)return t(R.loadRecords(a),(()=>{}))}function x({key:e,ns:t}){const n=p.getFallbackLangs(),a=k(null!=t?t:void 0);return m.getTranslationNs(a,n,e)}function T({key:e,ns:t,language:n}){const a=k(null!=t?t:void 0),o=p.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function C(){const n=t(function(){if(p.getLanguage())return;return t(h.getInitialLanguage(),(e=>{const t=e||p.getInitialOptions().defaultLanguage;t&&p.setLanguage(t)}))}(),(()=>N()));if(e(n))return p.setInitialLoading(!0),c.notify(),d.notify(),Promise.resolve(n).then((()=>{p.setInitialLoading(!1),c.notify(),d.notify(),l.onInitialLoaded.emit()}));l.onInitialLoaded.emit()}a&&P(a),l.onUpdate.listen((()=>{p.isRunning()&&h.retranslate()}));const R=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},l),p),h),m),{init:P,getTranslation:T,changeTranslation:A,getTranslationNs:x,getDefaultAndFallbackNs:k,async changeLanguage(e){p.getPendingLanguage()===e&&p.getLanguage()===e||(p.setPendingLanguage(e),p.isRunning()&&await N(e),e===p.getPendingLanguage()&&(p.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||p.addActiveNs(e),p.isRunning()&&await N(void 0,e)},loadRecords:e=>m.loadRecords(e,R.isDev()),loadRecord:async e=>(await R.loadRecords([e]))[0],isLoading:e=>m.isLoading(p.getLanguage(),e),isLoaded(e){const t=p.getLanguage();if(!t)return!1;const n=p.getFallbackLangs(t),a=j(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=w(...e),n=T(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(p.getInitialOptions().apiKey&&p.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!p.getAvailableLanguages())throw new Error(n("availableLanguages"));if(!p.getLanguage()&&!p.getInitialOptions().defaultLanguage)throw new Error(n(["defaultLanguage","language"]))}(),p.isRunning()||(p.setRunning(!0),h.run(),e=C()),Promise.resolve(e)},stop(){p.isRunning()&&(h.stop(),p.setRunning(!1))}}));return R}const j=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=y(e.options,n),t),init(t){const n=function(e){const t=k({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(y(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},A=0,P=1,N=2;class x extends Error{constructor(e,t,n){let a;a=e===A?"Empty parameter":e===P?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function T(e){return/\s/.test(e)}const C=0,R=1,S=2,D=3,$=4,I=new Set([S,R,C]),U="'",_=new Set(["{","}",U]),F=e=>/[0-9a-zA-Z_]/.test(e);function M(e,t){const[n,a]=function(e){let t=C,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new x(t,s,e)}const c=()=>{r.push(n),n=""},u=()=>{""===a&&l(A),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case C:o===U?(n+=o,t=R):"{"===o?(c(),t=D):(n+=o,t=C);break;case R:_.has(o)?(n=n.slice(0,-1)+o,t=S):(n+=o,t=C);break;case S:o===U?t=C:(n+=o,t=S);break;case D:"}"===o?(u(),t=C):T(o)?""!==a&&(u(),t=$):(F(o)||l(P),a+=o,t=D);break;case $:"}"==o?t=C:T(o)?t=$:l(P)}return I.has(t)||l(N),c(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const V=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>M(e,t)}),e),K="__tolgee_dev_tools",z="__tolgee_preferredLanguages",B="data-tolgee-key-only",X="data-tolgee-restricted",W="_tolgee",Y="_tolgee-highlighter";function G(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function H(e){if(G())throw new Error(`${e}: Can't run on the server`)}function J(e,t){return{oldTextContent:e,keys:t}}const q={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function Z({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(Y),Object.entries(q).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function Q(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function ee(e){return e.textContent}function te(e,t){e.textContent=t}function ne(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function ae(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const oe={capture:!0},re={capture:!0,passive:!0};function ie({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const c=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,u=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&O()){const a=c.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;O()&&(t=e.target,!Boolean(E(t,(e=>e.id===K))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),O()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function O(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){u.removeEventListener("blur",v,oe),u.removeEventListener("keydown",h,oe),u.removeEventListener("keyup",m,oe),u.removeEventListener("mousemove",p,re),u.removeEventListener("scroll",b,re),u.removeEventListener("click",y,oe),u.removeEventListener("mouseenter",f,oe),u.removeEventListener("mouseover",f,oe),u.removeEventListener("mouseout",f,oe),u.removeEventListener("mouseleave",f,oe),u.removeEventListener("mousedown",f,oe),u.removeEventListener("mouseup",f,oe)},run(){u.addEventListener("blur",v,oe),u.addEventListener("keydown",h,oe),u.addEventListener("keyup",m,oe),u.addEventListener("mousemove",p,re),u.addEventListener("scroll",b,re),u.addEventListener("click",y,oe),u.addEventListener("mouseenter",f,oe),u.addEventListener("mouseover",f,oe),u.addEventListener("mouseout",f,oe),u.addEventListener("mouseleave",f,oe),u.addEventListener("mousedown",f,oe),u.addEventListener("mouseup",f,oe)}})}function se(e,t,n){const o=Z({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=ie({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())ne(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(n,a,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${X}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(W,"true")),s.nodes.set(a,r),o.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(W),t.remove(e)}(e,n))}))},findAll(e,n){const o=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>ae({key:e,ns:a(n)},{key:t.key,ns:a(t.ns)})))){o.push(r);break}}})),o},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t))}))}})}function le(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function o({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(G())return{stop(){t=!1},wrapper:o};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=Q(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>Q(t.getTextXPath(),e)});return n}(a,o),l=se(a,n,r);function c(e){for(const t of e){const e=ee(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;te(t,a);const r=J(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function u(e){Q(`./descendant-or-self::*[@${B}]`,e).forEach((e=>{const t=e.getAttributeNode(B),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:ee(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":u(t.target),e=s.handleChildList(t.target);break;case"attributes":u(t.target),e=s.handleAttributes(t.target)}c(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),u(d),c(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=o(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null===(n=null==e?void 0:e.elementRegistry)||void 0===n?void 0:n.forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){var a;const o=(null===(a=null==e?void 0:e.elementRegistry)||void 0===a?void 0:a.findAll(t,n))||[];return o.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){var o;const r=(null===(o=null==e?void 0:e.elementRegistry)||void 0===o?void 0:o.findAll(t,n))||[],i=[];return r.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),r.forEach((e=>{const o=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{ae({key:t,ns:a(n)},{key:e.key,ns:a(e.ns)})&&i.push({position:{x:o.x,y:o.y,width:o.width,height:o.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),i},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const ce=["",""],ue=RegExp(`([${ce.join("")}]{9})+`,"gu");function ge(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>ce[Number(e)])).join("")}function de(e){const t=Array.from(e).map((e=>ce.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function fe({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null===(t=e.match(ue))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(de))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(o){const{k:e,d:t,n:a}=o;n.push({key:e,defaultValue:t,ns:a})}}));const o=function(e){return e.replace(ue,"")}(e);return{text:o,keys:n}},wrap({key:a,defaultValue:o,translation:r,ns:i}){let s;if(e){s=ge(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:o}),r=t.valueToNumber(e);s=ge(String.fromCodePoint(r))}const l=r||"";return"string"==typeof l?l+s:l},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${ce[0]}${ce[0]}') or contains(., '${ce[1]}${ce[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${ce[0]}${ce[0]}') or contains(., '${ce[1]}${ce[0]}')]`})}function pe(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function ve({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${u}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!pe(d,n)){u+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const he=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=le();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ve({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&te(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=le();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=fe({fullKeyEncode:t.options.fullKeyEncode});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),me="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function be(e){const t=me.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function ye(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|be(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function Ee(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=ye(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}const Oe=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o,fetch:r}){var i;const s=null!==(i=Ee(t))&&void 0!==i?i:o;let l=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(l+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return r(l,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e);function Le({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const we="tolgee-in-context-tools.umd.min.js",ke="@tolgee/in-context-tools",je="InContextTools",Ae="https://cdn.jsdelivr.net/npm";let Pe=null;function Ne(e){var t;return Pe||(Pe=(t=`${Ae}/@tolgee/web@${e}/dist/${we}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[ke][je]))),Pe}const xe="__tolgee_apiKey",Te="__tolgee_apiUrl";function Ce(){const e=sessionStorage.getItem(xe)||void 0,t=sessionStorage.getItem(Te)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Re(){sessionStorage.removeItem(xe),sessionStorage.removeItem(Te)}let Se=()=>e=>e;"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(Se=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=Le({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(Re)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Ce()&&(async()=>{const e=await Ne("5.11.5-prerelease.c74f049c.0");return t=>{const n=Ce();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const De="__tolgee_currentLanguage";const $e=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(H("LanguageStorage"),localStorage.getItem(De)||void 0),setLanguage(e){H("LanguageStorage"),localStorage.setItem(De,e)}}),e);const Ie=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){H("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e);function Ue(e){return e.endsWith("/")?e.slice(0,-1):e}const _e={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Ue(n)}/${e}/${t}.json`:`${Ue(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Fe(e){const t=Object.assign(Object.assign(Object.assign({},_e),e),{headers:Object.assign(Object.assign({},_e.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:s})=>s(a({namespace:e,language:t,prefix:n}),Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}const Me=e=>(t,n)=>(n.addBackend(Fe(e)),t);function Ve(){return j().use(Se())}const Ke=()=>e=>e;export{Me as BackendFetch,Se as BrowserExtensionPlugin,K as DEVTOOLS_ID,Oe as DevBackend,Ke as DevTools,V as FormatSimple,Ie as LanguageDetector,$e as LanguageStorage,he as ObserverPlugin,z as PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY,W as TOLGEE_ATTRIBUTE_NAME,X as TOLGEE_RESTRICT_ATTRIBUTE,B as TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE,Ve as Tolgee,j as TolgeeCore,c as createFetchFunction,a as getFallback,o as getFallbackArray,Ee as getProjectIdFromApiKey,w as getTranslateProps}; | ||
//# sourceMappingURL=tolgee-web.production.esm.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/web"]={})}(this,(function(e){"use strict";function t(e){return Boolean(e&&"function"==typeof e.then)}function n(e,n){return t(e)?Promise.resolve(e).then(n):n(e)}function a(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function o(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function r(e){return o(e)||[]}function i(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?r(t):r(null==t?void 0:t[e]);var n}function s(e){return Array.from(new Set(e))}function l(e){return e?e.replace(/\/+$/,""):e}const c=(e=fetch)=>(t,n)=>e(t,Object.assign(Object.assign({},n),{headers:Object.assign({"X-Tolgee-SDK-Type":"JS","X-Tolgee-SDK-Version":"5.11.4"},null==n?void 0:n.headers)}));function u(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function g(e,t,n){const a=new Set,o=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());o.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(i.push(t),n?setTimeout(s,0):s())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(r(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const d=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):d(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},f=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},p=({language:e,namespace:t})=>t?`${e}:${t}`:e;function v(e,t,n,a,o,i,l){const c=new Map,u=new Map;let g={},v=0;function h(t,n,a){const o=p(t);u.set(o,{data:d(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=g[p(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(g=Object.assign(Object.assign({},g),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=f(e),a=u.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){c.clear(),v+=1},addRecord(e,t){h(e,t,v)},exists(e,t=!1){const n=u.get(p(e));return n&&t?n.version===v:Boolean(n)},getRecord(e){var t;return null===(t=u.get(p(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=u.get(p(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(p({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return s(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(p({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=u.get(p(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(o())return!0;if(void 0===e)return c.size>0;const t=r(e);return Boolean(Array.from(c.keys()).find((e=>t.includes(f(e).namespace))))},isLoading(e,t){const n=r(t);return Boolean(o()||Array.from(c.keys()).find((t=>{const a=f(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=p(o),i=c.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return c.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));i.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=c.get(e.cacheKey)!==e.promise;if(e.new&&!n){c.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),i.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},f(e)),{data:t.data})))});return b}function h(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const m="invalid",b={defaultNs:"",observerOptions:{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"],fullKeyEncode:!1},observerType:"invisible",onFormatError:m,apiUrl:"https://app.tolgee.io",fetch:c()},y=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function E(e,t){const n=y(b,null==t?void 0:t.initialOptions,e);return n.apiUrl=l(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=c(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function O(e,a,o,r,i,s,l){const c={ui:void 0},u={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},g=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,ns:r({key:e,ns:t}),translation:i({key:e,ns:t})})));null===(n=u.ui)||void 0===n||n.handleElementClick(a,t)},d=(e,t)=>{var n;return(null===(n=u.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function f(e){const t=i({key:e.key,ns:e.ns});return T.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function p(){return{fetch:a().fetch}}function v(e){u.observer=null==e?void 0:e()}function b(){return Boolean(u.observer)}function y(e){e&&u.formatters.push(e)}function E(e){u.finalFormatter=e}function O(e){c.ui=e}function L(){return Boolean(c.ui)}function w(e){u.languageStorage=e}function k(e){u.languageDetector=e}function j(e){e&&u.backends.push(e)}function A(e){u.devBackend=e}const T=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:E,addFormatter:y,setObserver:v,hasObserver:b,setUi:O,hasUi:L,setDevBackend:A,addBackend:j,setLanguageDetector:k,setLanguageStorage:w}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();u.ui=null===(e=c.ui)||void 0===e?void 0:e.call(c,{apiKey:n,apiUrl:o,projectId:r,highlight:T.highlight,changeTranslation:s,findPositions:d,onPermanentChange:l}),null===(t=u.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:f,onClick:g})},stop(){var e;u.ui=void 0,null===(e=u.observer)||void 0===e||e.stop()},getLanguageStorage:()=>u.languageStorage,getInitialLanguage(){var e;const t=o();return n(null===(e=u.languageStorage)||void 0===e?void 0:e.getLanguage(p()),(e=>t&&!t.includes(e)||!e?function(){if(!u.languageDetector)return;const e=o();return u.languageDetector.getLanguage(Object.assign({availableLanguages:e},p()))}():e))},setStoredLanguage(e){var t;null===(t=u.languageStorage)||void 0===t||t.setLanguage(e,p())},getDevBackend:()=>u.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const a of u.backends){const o=a.getRecord(Object.assign({language:e,namespace:n},p()));if(t(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=u.devBackend)||void 0===n?void 0:n.getRecord(Object.assign({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t},p()))},getLanguageDetector:()=>u.languageDetector,retranslate(){var e;null===(e=u.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=u.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return u.observer?null===(t=u.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(T.getDevBackend()),formatTranslation(t){var n,{formatEnabled:o}=t,r=h(t,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:g,orEmpty:d,ns:f}=r,p=s||l;let v=p||(d?"":i);const b=e(),y=o||!(null===(n=u.observer)||void 0===n?void 0:n.outputNotFormattable),E=e=>u.observer&&!c?u.observer.wrap({key:i,translation:e,defaultValue:l,params:g,ns:f}):e;v=E(v);try{if(p&&b&&y)for(const e of u.formatters)v=e.format({translation:v,language:b,params:g});u.finalFormatter&&p&&b&&y&&(v=u.finalFormatter.format({translation:v,language:b,params:g}))}catch(e){console.error(e);const t=("string"==typeof(O=e)?O:"string"==typeof(null==O?void 0:O.message)?O.message:void 0)||m,n=a().onFormatError,o=typeof n;v="string"===o?n:"function"===o?n(t,r):m,v=E(v)}var O;return v}});return T}const L=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const w=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:o,language:r}=e,i=h(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function k({options:e}){const o=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:u(a),onLanguageChange:u(a),onLoadingChange:u(a),onFetchingChange:u(a),onInitialLoaded:u(a),onRunningChange:u(a),onCacheChange:u(a),onUpdate:g(a,e,t),onPermanentChange:u(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t);case"permanentChange":return o.onPermanentChange.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(b,y),c=L(!1,(()=>m.isFetching()),o.onFetchingChange.emit),d=L(!1,(()=>R.isLoading()),o.onLoadingChange.emit),p=function(e,t,n){let a,o=E();const c=Object.freeze({init(e){o=E(e,o)},isRunning:()=>o.isRunning,setRunning(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:()=>o.isInitialLoading,setInitialLoading(e){o.isInitialLoading=e},getLanguage:()=>o.language||o.initialOptions.language,setLanguage(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:()=>o.pendingLanguage||c.getLanguage(),setPendingLanguage(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},o.initialOptions),a),addActiveNs(e){r(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs(e){r(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t&&t>1?o.activeNamespaces.set(e,t-1):o.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>s([...o.initialOptions.ns||[o.initialOptions.defaultNs],...r(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||c.getLanguage();return t?s([t,...i(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>r(o.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?o.initialOptions.defaultNs:e,getAvailableLanguages(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>f(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?c.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:l(e.apiUrl)}):void 0}});return c}(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),h=O(p.getLanguage,p.getInitialOptions,p.getAvailableLanguages,(function({key:e,ns:t}){const n=p.getFallbackLangs(),a=k(t||void 0);return m.getTranslationNs(a,n,e)}),x,A,(function(e){o.onPermanentChange.emit({key:e.key,namespace:e.namespace})})),m=v(o.onCacheChange,h.getBackendRecord,h.getBackendDevRecord,p.withDefaultNs,p.isInitialLoading,c,d);function b(){return p.getFallbackNs()}function y(e){return p.getDefaultNs(e)}function k(e){return[...r(y(e)),...b()]}function j(e){return[...r(e||y()),...p.getRequiredNamespaces()]}function A(e,t,n){const a=p.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function T(e){p.init(e),m.addStaticData(p.getInitialOptions().staticData)}function P(e,t){const a=function(e,t){const n=p.getFallbackLangs(e),a=j(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,t);if(a.length)return n(R.loadRecords(a),(()=>{}))}function x({key:e,ns:t,language:n}){const a=k(t||void 0),o=p.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function N(){const e=n(function(){if(p.getLanguage())return;return n(h.getInitialLanguage(),(e=>{const t=e||p.getInitialOptions().defaultLanguage;t&&p.setLanguage(t)}))}(),(()=>P()));if(t(e))return p.setInitialLoading(!0),c.notify(),d.notify(),Promise.resolve(e).then((()=>{p.setInitialLoading(!1),c.notify(),d.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}e&&T(e),o.onUpdate.listen((()=>{p.isRunning()&&h.retranslate()}));const R=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),p),h),m),{init:T,getTranslation:x,changeTranslation:A,async changeLanguage(e){p.getPendingLanguage()===e&&p.getLanguage()===e||(p.setPendingLanguage(e),p.isRunning()&&await P(e),e===p.getPendingLanguage()&&(p.setLanguage(e),h.setStoredLanguage(e)))},async addActiveNs(e,t){t||p.addActiveNs(e),p.isRunning()&&await P(void 0,e)},loadRecords:e=>m.loadRecords(e,R.isDev()),loadRecord:async e=>(await R.loadRecords([e]))[0],isLoading:e=>m.isLoading(p.getLanguage(),e),isLoaded(e){const t=p.getLanguage();if(!t)return!1;const n=p.getFallbackLangs(t),a=j(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=w(...e),n=x(t);return h.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(p.getInitialOptions().apiKey&&p.getInitialOptions().apiUrl),run(){let e;return function(){if((h.getLanguageDetector()||h.getLanguageStorage())&&!p.getAvailableLanguages())throw new Error(a("availableLanguages"));if(!p.getLanguage()&&!p.getInitialOptions().defaultLanguage)throw new Error(a(["defaultLanguage","language"]))}(),p.isRunning()||(p.setRunning(!0),h.run(),e=N()),Promise.resolve(e)},stop(){p.isRunning()&&(h.stop(),p.setRunning(!1))}}));return R}const j=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=y(e.options,n),t),init(t){const n=function(e){const t=k({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(y(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},A=0,T=1,P=2;class x extends Error{constructor(e,t,n){let a;a=e===A?"Empty parameter":e===T?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function N(e){return/\s/.test(e)}const R=0,C=1,S=2,D=3,I=4,$=new Set([S,C,R]),_="'",U=new Set(["{","}",_]),F=e=>/[0-9a-zA-Z_]/.test(e);function B(e,t){const[n,a]=function(e){let t=R,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new x(t,s,e)}const c=()=>{r.push(n),n=""},u=()=>{""===a&&l(A),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case R:o===_?(n+=o,t=C):"{"===o?(c(),t=D):(n+=o,t=R);break;case C:U.has(o)?(n=n.slice(0,-1)+o,t=S):(n+=o,t=R);break;case S:o===_?t=R:(n+=o,t=S);break;case D:"}"===o?(u(),t=R):N(o)?""!==a&&(u(),t=I):(F(o)||l(T),a+=o,t=D);break;case I:"}"==o?t=R:N(o)?t=I:l(T)}return $.has(t)||l(P),c(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const M="__tolgee_dev_tools",K="data-tolgee-key-only",V="data-tolgee-restricted",z="_tolgee",Y="_tolgee-highlighter";function G(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function W(e){if(G())throw new Error(`${e}: Can't run on the server`)}function X(e,t){return{oldTextContent:e,keys:t}}const H={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function J({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(Y),Object.entries(H).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function q(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function Z(e){return e.textContent}function Q(e,t){e.textContent=t}function ee(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function te(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const ne={capture:!0},ae={capture:!0,passive:!0};function oe({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const c=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,u=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&O()){const a=c.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;O()&&(t=e.target,!Boolean(E(t,(e=>e.id===M))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),O()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function O(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){u.removeEventListener("blur",v,ne),u.removeEventListener("keydown",h,ne),u.removeEventListener("keyup",m,ne),u.removeEventListener("mousemove",p,ae),u.removeEventListener("scroll",b,ae),u.removeEventListener("click",y,ne),u.removeEventListener("mouseenter",f,ne),u.removeEventListener("mouseover",f,ne),u.removeEventListener("mouseout",f,ne),u.removeEventListener("mouseleave",f,ne),u.removeEventListener("mousedown",f,ne),u.removeEventListener("mouseup",f,ne)},run(){u.addEventListener("blur",v,ne),u.addEventListener("keydown",h,ne),u.addEventListener("keyup",m,ne),u.addEventListener("mousemove",p,ae),u.addEventListener("scroll",b,ae),u.addEventListener("click",y,ne),u.addEventListener("mouseenter",f,ne),u.addEventListener("mouseover",f,ne),u.addEventListener("mouseout",f,ne),u.addEventListener("mouseleave",f,ne),u.addEventListener("mousedown",f,ne),u.addEventListener("mouseup",f,ne)}})}function re(e,t,n){const a=J({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=oe({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())ee(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(n,o,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${V}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(z,"true")),s.nodes.set(o,r),a.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(z),t.remove(e)}(e,n))}))},findAll(e,n){const a=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>te({key:e,ns:o(n)},{key:t.key,ns:o(t.ns)})))){a.push(r);break}}})),a},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t))}))}})}function ie(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function a({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(G())return{stop(){t=!1},wrapper:o};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=q(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>q(t.getTextXPath(),e)});return n}(a,o),l=re(a,n,r);function c(e){for(const t of e){const e=Z(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;Q(t,a);const r=X(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function u(e){q(`./descendant-or-self::*[@${K}]`,e).forEach((e=>{const t=e.getAttributeNode(K),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:Z(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":u(t.target),e=s.handleChildList(t.target);break;case"attributes":u(t.target),e=s.handleAttributes(t.target)}c(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),u(d),c(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=a(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null===(n=null==e?void 0:e.elementRegistry)||void 0===n?void 0:n.forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){var a;const o=(null===(a=null==e?void 0:e.elementRegistry)||void 0===a?void 0:a.findAll(t,n))||[];return o.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){var a;const r=(null===(a=null==e?void 0:e.elementRegistry)||void 0===a?void 0:a.findAll(t,n))||[],i=[];return r.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),r.forEach((e=>{const a=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{te({key:t,ns:o(n)},{key:e.key,ns:o(e.ns)})&&i.push({position:{x:a.x,y:a.y,width:a.width,height:a.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),i},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const se=["",""],le=RegExp(`([${se.join("")}]{9})+`,"gu");function ce(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>se[Number(e)])).join("")}function ue(e){const t=Array.from(e).map((e=>se.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function ge({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null===(t=e.match(le))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ue))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(o){const{k:e,d:t,n:a}=o;n.push({key:e,defaultValue:t,ns:a})}}));const o=function(e){return e.replace(le,"")}(e);return{text:o,keys:n}},wrap({key:a,defaultValue:o,translation:r,ns:i}){let s;if(e){s=ce(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:o}),r=t.valueToNumber(e);s=ce(String.fromCodePoint(r))}const l=r||"";return"string"==typeof l?l+s:l},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${se[0]}${se[0]}') or contains(., '${se[1]}${se[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${se[0]}${se[0]}') or contains(., '${se[1]}${se[0]}')]`})}function de(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function fe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${u}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!de(d,n)){u+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const pe="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function ve(e){const t=pe.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function he(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|ve(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function me(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=he(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function be({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const ye="tolgee-in-context-tools.umd.min.js",Ee="@tolgee/in-context-tools",Oe="InContextTools",Le="https://cdn.jsdelivr.net/npm";let we=null;function ke(e){var t;return we||(we=(t=`${Le}/@tolgee/web@${e}/dist/${ye}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[Ee][Oe]))),we}const je="__tolgee_apiKey",Ae="__tolgee_apiUrl";function Te(){const e=sessionStorage.getItem(je)||void 0,t=sessionStorage.getItem(Ae)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function Pe(){sessionStorage.removeItem(je),sessionStorage.removeItem(Ae)}e.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=be({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(Pe)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Te()&&(async()=>{const e=await ke("5.11.4");return t=>{const n=Te();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const xe="__tolgee_currentLanguage";function Ne(e){return e.endsWith("/")?e.slice(0,-1):e}const Re={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Ne(n)}/${e}/${t}.json`:`${Ne(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Ce(e){const t=Object.assign(Object.assign(Object.assign({},Re),e),{headers:Object.assign(Object.assign({},Re.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:s})=>s(a({namespace:e,language:t,prefix:n}),Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}e.BackendFetch=e=>(t,n)=>(n.addBackend(Ce(e)),t),e.DEVTOOLS_ID=M,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o,fetch:r}){var i;const s=null!==(i=me(t))&&void 0!==i?i:o;let l=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(l+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return r(l,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e),e.DevTools=()=>e=>e,e.FormatSimple=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>B(e,t)}),e),e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){W("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e),e.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(W("LanguageStorage"),localStorage.getItem(xe)||void 0),setLanguage(e){W("LanguageStorage"),localStorage.setItem(xe,e)}}),e),e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=ie();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=fe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&Q(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=ie();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=ge({fullKeyEncode:t.options.fullKeyEncode});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.TOLGEE_ATTRIBUTE_NAME=z,e.TOLGEE_RESTRICT_ATTRIBUTE=V,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=K,e.Tolgee=function(){return j().use(e.BrowserExtensionPlugin())},e.TolgeeCore=j,e.createFetchFunction=c,e.getFallback=o,e.getFallbackArray=r,e.getProjectIdFromApiKey=me,e.getTranslateProps=w,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/web"]={})}(this,(function(e){"use strict";function t(e){return Boolean(e&&"function"==typeof e.then)}function n(e,n){return t(e)?Promise.resolve(e).then(n):n(e)}function a(e){const t=(Array.isArray(e)?e:[e]).map((e=>`'${e}'`)),n=t.slice(-2).join(" or ");return`Tolgee: You need to specify ${[...t.slice(0,-2),n].join(", ")} option`}function o(e){return"string"==typeof e?[e]:Array.isArray(e)?e:void 0}function r(e){return o(e)||[]}function i(e,t){return"object"!=typeof(n=t)||Array.isArray(n)||null===n?r(t):r(null==t?void 0:t[e]);var n}function s(e){return Array.from(new Set(e))}function l(e){return e?e.replace(/\/+$/,""):e}const c=(e,t)=>fetch(e,t),u=(e=c)=>(t,n)=>e(t,Object.assign(Object.assign({},n),{headers:Object.assign({"X-Tolgee-SDK-Type":"JS","X-Tolgee-SDK-Version":"5.11.5-prerelease.c74f049c.0"},null==n?void 0:n.headers)}));function g(e){let t=[];return Object.freeze({listen(e){const n=t=>{e(t)};return t.push(n),{unsubscribe(){t=t.filter((e=>n!==e))}}},emit(n){e()&&t.forEach((e=>e({value:n})))}})}function d(e,t,n){const a=new Set,o=new Set;let i=[];function s(){if(0===i.length)return;const e=i;i=[],a.forEach((e=>{e({value:void 0})}));let n=new Set;e.forEach((e=>{void 0===e?n=void 0:void 0!==n&&e.forEach((e=>n.add(e)))}));!function(e){const n=new Set(t());o.forEach((t=>{(void 0===e||-1!==(null==e?void 0:e.findIndex((e=>n.has(e)||t.namespaces.has(e)))))&&t.fn({value:void 0})}))}(n?Array.from(n.keys()):void 0)}return Object.freeze({emit(t,n){e()&&(i.push(t),n?setTimeout(s,0):s())},listen(e){a.add(e);return{unsubscribe:()=>{a.delete(e)}}},listenSome(e){const t={fn:t=>{e(t)},namespaces:new Set};o.add(t);const a={unsubscribe:()=>{o.delete(t)},subscribeNs:e=>(r(e).forEach((e=>t.namespaces.add(e))),void 0===e&&t.namespaces.add(n()),a)};return a}})}const f=e=>{const t=new Map;return Object.entries(e).forEach((([e,n])=>{null!=n&&("object"!=typeof n?t.set(e,n):f(n).forEach(((n,a)=>{t.set(e+"."+a,n)})))})),t},p=e=>{const[t,...n]=e.split(":");return{language:t,namespace:n.join(":")||""}},v=({language:e,namespace:t})=>t?`${e}:${t}`:e;function h(e,t,n,a,o,i,l){const c=new Map,u=new Map;let g={},d=0;function h(t,n,a){const o=v(t);u.set(o,{data:f(n),version:a}),e.emit(t)}function m(e){let n;if(!n){const t=g[v(e)];"function"==typeof t&&(n=t())}return n||(n=t(e)),n}const b=Object.freeze({addStaticData(e){e&&(g=Object.assign(Object.assign({},g),e),Object.entries(e).forEach((([e,t])=>{if("function"!=typeof t){const n=p(e),a=u.get(e);a&&0!==a.version||h(n,t,0)}})))},invalidate(){c.clear(),d+=1},addRecord(e,t){h(e,t,d)},exists(e,t=!1){const n=u.get(v(e));return n&&t?n.version===d:Boolean(n)},getRecord(e){var t;return null===(t=u.get(v(a(e))))||void 0===t?void 0:t.data},getTranslation(e,t){var n;return null===(n=u.get(v(e)))||void 0===n?void 0:n.data.get(t)},getTranslationNs(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(v({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return[o]}return s(e)},getTranslationFallback(e,t,n){var a;for(const o of e)for(const e of t){const t=null===(a=u.get(v({language:e,namespace:o})))||void 0===a?void 0:a.data.get(n);if(null!=t)return t}},changeTranslation(t,n,a){var o;const r=null===(o=u.get(v(t)))||void 0===o?void 0:o.data;null==r||r.set(n,a),e.emit(Object.assign(Object.assign({},t),{key:n}))},isFetching(e){if(o())return!0;if(void 0===e)return c.size>0;const t=r(e);return Boolean(Array.from(c.keys()).find((e=>t.includes(p(e).namespace))))},isLoading(e,t){const n=r(t);return Boolean(o()||Array.from(c.keys()).find((t=>{const a=p(t);return(!n.length||n.includes(a.namespace))&&!b.exists({namespace:a.namespace,language:e})})))},async loadRecords(e,t){const o=e.map((e=>{const o=a(e),r=v(o),i=c.get(r);if(i)return{new:!1,promise:i,keyObject:o,cacheKey:r};const s=function(e,t){var a;let o;return t&&(o=null===(a=n(e))||void 0===a?void 0:a.catch((()=>(console.warn("Tolgee: Failed to fetch data from dev backend"),m(e))))),o||(o=m(e)),o}(o,t)||Promise.resolve(void 0);return c.set(r,s),{new:!0,promise:s,keyObject:o,cacheKey:r}}));i.notify(),l.notify();const r=await Promise.all(o.map((e=>e.promise)));return o.forEach(((e,t)=>{const n=c.get(e.cacheKey)!==e.promise;if(e.new&&!n){c.delete(e.cacheKey);const n=r[t];n?b.addRecord(e.keyObject,n):b.getRecord(e.keyObject)||b.addRecord(e.keyObject,{})}})),i.notify(),l.notify(),o.map((e=>b.getRecord(e.keyObject)))},getAllRecords:()=>Array.from(u.entries()).map((([e,t])=>Object.assign(Object.assign({},p(e)),{data:t.data})))});return b}function m(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}const b="invalid",y={defaultNs:"",observerOptions:{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"],fullKeyEncode:!1},observerType:"invisible",onFormatError:b,apiUrl:"https://app.tolgee.io",fetch:u()},E=(...e)=>{let t={};return e.forEach((e=>{t=Object.assign(Object.assign(Object.assign({},t),e),{observerOptions:Object.assign(Object.assign({},t.observerOptions),null==e?void 0:e.observerOptions)})})),t};function O(e,t){const n=E(y,null==t?void 0:t.initialOptions,e);return n.apiUrl=l(n.apiUrl),(null==e?void 0:e.fetch)&&(n.fetch=u(e.fetch)),{initialOptions:n,activeNamespaces:(null==t?void 0:t.activeNamespaces)||new Map,language:null==t?void 0:t.language,pendingLanguage:null==t?void 0:t.language,isInitialLoading:!1,isRunning:!1}}function L(e,a,o,r,i,s,l,c){const u={ui:void 0},g={formatters:[],finalFormatter:void 0,observer:void 0,devBackend:void 0,backends:[],ui:void 0,languageDetector:void 0,languageStorage:void 0},d=async({keysAndDefaults:e,event:t})=>{var n;const a=e.map((({key:e,ns:t,defaultValue:n})=>({key:e,defaultValue:n,fallbackNamespaces:r(t),namespace:i({key:e,ns:t})[0],translation:s({key:e,ns:t})})));null===(n=g.ui)||void 0===n||n.handleElementClick(a,t)},f=(e,t)=>{var n;return(null===(n=g.observer)||void 0===n?void 0:n.findPositions(e,t))||[]};function p(e){const t=s({key:e.key,ns:e.ns});return P.formatTranslation(Object.assign(Object.assign({},e),{translation:t,formatEnabled:!0}))}function v(){return{fetch:a().fetch}}function h(e){g.observer=null==e?void 0:e()}function y(){return Boolean(g.observer)}function E(e){e&&g.formatters.push(e)}function O(e){g.finalFormatter=e}function L(e){u.ui=e}function w(){return Boolean(u.ui)}function k(e){g.languageStorage=e}function j(e){g.languageDetector=e}function A(e){e&&g.backends.push(e)}function T(e){g.devBackend=e}const P=Object.freeze({addPlugin:function(e,t){t(e,Object.freeze({setFinalFormatter:O,addFormatter:E,setObserver:h,hasObserver:y,setUi:L,hasUi:w,setDevBackend:T,addBackend:A,setLanguageDetector:j,setLanguageStorage:k}))},run(){var e,t;const{apiKey:n,apiUrl:o,projectId:r,observerOptions:i}=a();g.ui=null===(e=u.ui)||void 0===e?void 0:e.call(u,{apiKey:n,apiUrl:o,projectId:r,highlight:P.highlight,changeTranslation:l,findPositions:f,onPermanentChange:c}),null===(t=g.observer)||void 0===t||t.run({mouseHighlight:!0,options:i,translate:p,onClick:d})},stop(){var e;g.ui=void 0,null===(e=g.observer)||void 0===e||e.stop()},getLanguageStorage:()=>g.languageStorage,getInitialLanguage(){var e;const t=o();return n(null===(e=g.languageStorage)||void 0===e?void 0:e.getLanguage(v()),(e=>t&&!t.includes(e)||!e?function(){if(!g.languageDetector)return;const e=o();return g.languageDetector.getLanguage(Object.assign({availableLanguages:e},v()))}():e))},setStoredLanguage(e){var t;null===(t=g.languageStorage)||void 0===t||t.setLanguage(e,v())},getDevBackend:()=>g.devBackend,getBackendRecord:({language:e,namespace:n})=>{for(const a of g.backends){const o=a.getRecord(Object.assign({language:e,namespace:n},v()));if(t(o))return null==o?void 0:o.catch((e=>(console.error(e),{})));if(void 0!==o)return o}},getBackendDevRecord:({language:e,namespace:t})=>{var n;const{apiKey:o,apiUrl:r,projectId:i}=a();return null===(n=g.devBackend)||void 0===n?void 0:n.getRecord(Object.assign({apiKey:o,apiUrl:r,projectId:i,language:e,namespace:t},v()))},getLanguageDetector:()=>g.languageDetector,retranslate(){var e;null===(e=g.observer)||void 0===e||e.retranslate()},highlight:(e,t)=>{var n,a;return(null===(a=null===(n=g.observer)||void 0===n?void 0:n.highlight)||void 0===a?void 0:a.call(n,e,t))||{unhighlight(){}}},unwrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.unwrap(e):{text:e,keys:[]}},wrap(e){var t;return g.observer?null===(t=g.observer)||void 0===t?void 0:t.wrap(e):e.translation},hasDevBackend:()=>Boolean(P.getDevBackend()),formatTranslation(t){var n,{formatEnabled:o}=t,r=m(t,["formatEnabled"]);const{key:i,translation:s,defaultValue:l,noWrap:c,params:u,orEmpty:d,ns:f}=r,p=s||l;let v=p||(d?"":i);const h=e(),y=o||!(null===(n=g.observer)||void 0===n?void 0:n.outputNotFormattable),E=e=>g.observer&&!c?g.observer.wrap({key:i,translation:e,defaultValue:l,params:u,ns:f}):e;v=E(v);try{if(p&&h&&y)for(const e of g.formatters)v=e.format({translation:v,language:h,params:u});g.finalFormatter&&p&&h&&y&&(v=g.finalFormatter.format({translation:v,language:h,params:u}))}catch(e){console.error(e);const t=("string"==typeof(O=e)?O:"string"==typeof(null==O?void 0:O.message)?O.message:void 0)||b,n=a().onFormatError,o=typeof n;v="string"===o?n:"function"===o?n(t,r):b,v=E(v)}var O;return v}});return P}const w=(e,t,n)=>{let a=e;return Object.freeze({init(e){a=e},notify(){const e=t();a!==e&&n(e),a=e}})};const k=(e,...t)=>{let n,a={};return"object"==typeof e?a=e:(a.key=e,"string"==typeof t[0]?(a.defaultValue=t[0],n=t[1]):"object"==typeof t[0]&&(n=t[0])),n&&(a=Object.assign(Object.assign({},function(e){var{ns:t,noWrap:n,orEmpty:a,params:o,language:r}=e,i=m(e,["ns","noWrap","orEmpty","params","language"]);const s={ns:t,noWrap:n,orEmpty:a,language:r};return Object.assign(Object.assign({},s),{params:Object.assign({},i)})}(n)),a)),a};function j({options:e}){const o=function(e,t){let n=!0;function a(){return n}const o=Object.freeze({onPendingLanguageChange:g(a),onLanguageChange:g(a),onLoadingChange:g(a),onFetchingChange:g(a),onInitialLoaded:g(a),onRunningChange:g(a),onCacheChange:g(a),onUpdate:d(a,e,t),onPermanentChange:g(a),setEmitterActive(e){n=e},on:(e,t)=>{switch(e){case"pendingLanguage":return o.onPendingLanguageChange.listen(t);case"language":return o.onLanguageChange.listen(t);case"loading":return o.onLoadingChange.listen(t);case"fetching":return o.onFetchingChange.listen(t);case"initialLoad":return o.onInitialLoaded.listen(t);case"running":return o.onRunningChange.listen(t);case"cache":return o.onCacheChange.listen(t);case"update":return o.onUpdate.listen(t);case"permanentChange":return o.onPermanentChange.listen(t)}}});return o.onInitialLoaded.listen((()=>o.onUpdate.emit())),o.onLanguageChange.listen((()=>o.onUpdate.emit())),o.onCacheChange.listen((({value:e})=>o.onUpdate.emit([e.namespace],!0))),o}(b,y),c=w(!1,(()=>m.isFetching()),o.onFetchingChange.emit),u=w(!1,(()=>C.isLoading()),o.onLoadingChange.emit),f=function(e,t,n){let a,o=O();const c=Object.freeze({init(e){o=O(e,o)},isRunning:()=>o.isRunning,setRunning(e){o.isRunning!==e&&(o.isRunning=e,n.emit(e))},isInitialLoading:()=>o.isInitialLoading,setInitialLoading(e){o.isInitialLoading=e},getLanguage:()=>o.language||o.initialOptions.language,setLanguage(t){o.language!==t&&(o.language=t,e.emit(t))},getPendingLanguage:()=>o.pendingLanguage||c.getLanguage(),setPendingLanguage(e){o.pendingLanguage!==e&&(o.pendingLanguage=e,t.emit(e))},getInitialOptions:()=>Object.assign(Object.assign({},o.initialOptions),a),addActiveNs(e){r(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t?o.activeNamespaces.set(e,t+1):o.activeNamespaces.set(e,1)}))},removeActiveNs(e){r(e).forEach((e=>{const t=o.activeNamespaces.get(e);void 0!==t&&t>1?o.activeNamespaces.set(e,t-1):o.activeNamespaces.delete(e)}))},getRequiredNamespaces:()=>s([...o.initialOptions.ns||[o.initialOptions.defaultNs],...r(o.initialOptions.fallbackNs),...o.activeNamespaces.keys()]),getFallbackLangs(e){const t=e||c.getLanguage();return t?s([t,...i(t,o.initialOptions.fallbackLanguage)]):[]},getFallbackNs:()=>r(o.initialOptions.fallbackNs),getDefaultNs:e=>void 0===e?o.initialOptions.defaultNs:e,getAvailableLanguages(){if(o.initialOptions.availableLanguages)return o.initialOptions.availableLanguages;if(o.initialOptions.staticData){const e=Object.keys(o.initialOptions.staticData).map((e=>p(e).language));return Array.from(new Set(e))}},withDefaultNs:e=>({namespace:void 0===e.namespace?c.getInitialOptions().defaultNs:e.namespace,language:e.language}),overrideCredentials(e){a=e?Object.assign(Object.assign({},e),{apiUrl:l(e.apiUrl)}):void 0}});return c}(o.onLanguageChange,o.onPendingLanguageChange,o.onRunningChange),v=L(f.getLanguage,f.getInitialOptions,f.getAvailableLanguages,E,x,N,A,(function(e){o.onPermanentChange.emit({key:e.key,namespace:e.namespace})})),m=h(o.onCacheChange,v.getBackendRecord,v.getBackendDevRecord,f.withDefaultNs,f.isInitialLoading,c,u);function b(){return f.getFallbackNs()}function y(e){return f.getDefaultNs(e)}function E(e){return[...r(y(e)),...b()]}function j(e){return[...r(null!=e?e:y()),...f.getRequiredNamespaces()]}function A(e,t,n){const a=f.withDefaultNs(e),o=m.getTranslation(a,t);return m.changeTranslation(a,t,n),{revert(){m.changeTranslation(a,t,o)}}}function T(e){f.init(e),m.addStaticData(f.getInitialOptions().staticData)}function P(e,t){const a=function(e,t){const n=f.getFallbackLangs(e),a=j(t),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t},!0)||o.push({language:e,namespace:t})}))})),o}(e,t);if(a.length)return n(C.loadRecords(a),(()=>{}))}function x({key:e,ns:t}){const n=f.getFallbackLangs(),a=E(null!=t?t:void 0);return m.getTranslationNs(a,n,e)}function N({key:e,ns:t,language:n}){const a=E(null!=t?t:void 0),o=f.getFallbackLangs(n);return m.getTranslationFallback(a,o,e)}function R(){const e=n(function(){if(f.getLanguage())return;return n(v.getInitialLanguage(),(e=>{const t=e||f.getInitialOptions().defaultLanguage;t&&f.setLanguage(t)}))}(),(()=>P()));if(t(e))return f.setInitialLoading(!0),c.notify(),u.notify(),Promise.resolve(e).then((()=>{f.setInitialLoading(!1),c.notify(),u.notify(),o.onInitialLoaded.emit()}));o.onInitialLoaded.emit()}e&&T(e),o.onUpdate.listen((()=>{f.isRunning()&&v.retranslate()}));const C=Object.freeze(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},o),f),v),m),{init:T,getTranslation:N,changeTranslation:A,getTranslationNs:x,getDefaultAndFallbackNs:E,async changeLanguage(e){f.getPendingLanguage()===e&&f.getLanguage()===e||(f.setPendingLanguage(e),f.isRunning()&&await P(e),e===f.getPendingLanguage()&&(f.setLanguage(e),v.setStoredLanguage(e)))},async addActiveNs(e,t){t||f.addActiveNs(e),f.isRunning()&&await P(void 0,e)},loadRecords:e=>m.loadRecords(e,C.isDev()),loadRecord:async e=>(await C.loadRecords([e]))[0],isLoading:e=>m.isLoading(f.getLanguage(),e),isLoaded(e){const t=f.getLanguage();if(!t)return!1;const n=f.getFallbackLangs(t),a=j(e),o=[];return n.forEach((e=>{a.forEach((t=>{m.exists({language:e,namespace:t})||o.push({language:e,namespace:t})}))})),0===o.length},t:(...e)=>{const t=k(...e),n=N(t);return v.formatTranslation(Object.assign(Object.assign({},t),{translation:n}))},isDev:()=>Boolean(f.getInitialOptions().apiKey&&f.getInitialOptions().apiUrl),run(){let e;return function(){if((v.getLanguageDetector()||v.getLanguageStorage())&&!f.getAvailableLanguages())throw new Error(a("availableLanguages"));if(!f.getLanguage()&&!f.getInitialOptions().defaultLanguage)throw new Error(a(["defaultLanguage","language"]))}(),f.isRunning()||(f.setRunning(!0),v.run(),e=R()),Promise.resolve(e)},stop(){f.isRunning()&&(v.stop(),f.setRunning(!1))}}));return C}const A=()=>{const e={plugins:[],options:{}},t=Object.freeze({use:n=>(e.plugins.push(n),t),updateDefaults:n=>(e.options=E(e.options,n),t),init(t){const n=function(e){const t=j({options:e});function n(e){const n=t.isRunning();n&&t.stop(),e(),t.isDev()&&t.invalidate(),n&&t.run()}t.isDev()&&t.invalidate();const a=Object.freeze({on:t.on,onNsUpdate:t.onUpdate.listenSome,setEmitterActive:t.setEmitterActive,getLanguage:t.getLanguage,getPendingLanguage:t.getPendingLanguage,changeLanguage:t.changeLanguage,changeTranslation:t.changeTranslation,addActiveNs:t.addActiveNs,removeActiveNs:t.removeActiveNs,loadRecords:t.loadRecords,loadRecord:t.loadRecord,addStaticData:t.addStaticData,getRecord:t.getRecord,getAllRecords:t.getAllRecords,isLoaded:t.isLoaded,isInitialLoading:t.isInitialLoading,isLoading:t.isLoading,isFetching:t.isFetching,isRunning:t.isRunning,run:t.run,stop:t.stop,t:t.t,highlight:t.highlight,getInitialOptions:t.getInitialOptions,isDev:t.isDev,wrap:t.wrap,unwrap:t.unwrap,overrideCredentials(e){n((()=>t.overrideCredentials(e)))},addPlugin(e){e&&n((()=>t.addPlugin(a,e)))},updateOptions(e){e&&n((()=>t.init(e)))}});return a}(E(e.options,t));return e.plugins.forEach(n.addPlugin),n}});return t},T=0,P=1,x=2;class N extends Error{constructor(e,t,n){let a;a=e===T?"Empty parameter":e===P?"Unexpected character":"Unexpected end",super(`Tolgee parser: ${a} at ${t} in "${n}"`),this.code=e,this.index=t}}function R(e){return/\s/.test(e)}const C=0,S=1,D=2,I=3,$=4,_=new Set([D,S,C]),U="'",F=new Set(["{","}",U]),B=e=>/[0-9a-zA-Z_]/.test(e);function M(e,t){const[n,a]=function(e){let t=C,n="",a="",o="";const r=[],i=[];let s=0;function l(t){throw new N(t,s,e)}const c=()=>{r.push(n),n=""},u=()=>{""===a&&l(T),i.push(a),a=""};for(s=0;s<e.length;s++)switch(o=e[s],t){case C:o===U?(n+=o,t=S):"{"===o?(c(),t=I):(n+=o,t=C);break;case S:F.has(o)?(n=n.slice(0,-1)+o,t=D):(n+=o,t=C);break;case D:o===U?t=C:(n+=o,t=D);break;case I:"}"===o?(u(),t=C):R(o)?""!==a&&(u(),t=$):(B(o)||l(P),a+=o,t=I);break;case $:"}"==o?t=C:R(o)?t=$:l(P)}return _.has(t)||l(x),c(),[r,i]}(e),o=[n[0]];for(let r=1;r<n.length;r++){const i=null==t?void 0:t[a[r-1]];if(void 0===i)throw new Error(`Missing parameter "${a[r-1]}" in "${e}"`);o.push(String(i)),o.push(n[r])}return o.join("")}const K="__tolgee_dev_tools",V="data-tolgee-key-only",z="data-tolgee-restricted",Y="_tolgee",G="_tolgee-highlighter";function W(){var e,t;return void 0===(null===(t=null===(e=globalThis.window)||void 0===e?void 0:e.document)||void 0===t?void 0:t.createElement)}function X(e){if(W())throw new Error(`${e}: Can't run on the server`)}function H(e,t){return{oldTextContent:e,keys:t}}const J={pointerEvents:"none",position:"fixed",boxSizing:"content-box",zIndex:String(Number.MAX_SAFE_INTEGER),contain:"layout",display:"block",borderStyle:"solid",borderRadius:"4px"};function q({highlightColor:e,highlightWidth:t}){return Object.freeze({initHighlighter(n,a){!function(n,a){a.highlight=()=>{if(!n.isConnected)return;let o=a.highlightEl;o||(o=document.createElement("div"),o.classList.add(G),Object.entries(J).forEach((([e,t])=>{o.style[e]=t})),o.style.borderColor=e,a.highlightEl=o,document.body.appendChild(o));const r=n.getBoundingClientRect();o.style.borderWidth=t+"px",o.style.top=r.top-t+"px",o.style.left=r.left-t+"px",o.style.width=r.width+"px",o.style.height=r.height+"px"}}(n,a),function(e,t){t.unhighlight=()=>{var e;null===(e=t.highlightEl)||void 0===e||e.remove(),t.highlightEl=void 0}}(0,a)}})}function Z(e,t){var n;const a=function(e){switch(e.nodeType){case Node.ATTRIBUTE_NODE:return e.ownerElement||void 0;case Node.TEXT_NODE:return e.parentElement||void 0;case Node.DOCUMENT_NODE:case Node.ELEMENT_NODE:return e;default:return}}(t),o=[];if(!a)return o;const r=null===document||void 0===document?void 0:document.evaluate(e,a,void 0,XPathResult.ANY_TYPE);let i;for(;i=null===(n=null==r?void 0:r.iterateNext)||void 0===n?void 0:n.call(r);)o.push(i);return o}function Q(e){return e.textContent}function ee(e,t){e.textContent=t}function te(e,t){if(e.contains(t))return!0;if(t instanceof Attr){const n=t.ownerElement&&Object.values(t.ownerElement.attributes).indexOf(t)>-1;if(e.contains(t.ownerElement)&&n)return!0}return!1}function ne(e,t){var n;const a=void 0===e.key||void 0===t.key||t.key===e.key,o=void 0===e.ns||void 0===t.ns||-1!==(null===(n=e.ns)||void 0===n?void 0:n.findIndex((e=>{var n;return null===(n=t.ns)||void 0===n?void 0:n.includes(e)})));return a&&o}const ae={capture:!0},oe={capture:!0,passive:!0};function re({highlightKeys:e,elementStore:t,onClick:n,options:a}){var o,r;let i,s,l=new Set;const c=(null===(o=a.targetElement)||void 0===o?void 0:o.getRootNode())||document,u=(null===(r=a.targetElement)||void 0===r?void 0:r.ownerDocument)||document;function g(){var e;const n=t.get(i);n&&(n.preventClean=!1,null===(e=n.unhighlight)||void 0===e||e.call(n),i=void 0)}function d(){const e=s;let n;if(e&&O()){const a=c.elementFromPoint(e.x,e.y);a&&(n=function(e){return E(e,(e=>t.get(e)))}(a))}!function(e){var n;if(i!==e){g();const a=t.get(e);a&&(a.preventClean=!0,null===(n=a.highlight)||void 0===n||n.call(a),i=e)}}(n)}function f(e){var t;O()&&(t=e.target,!Boolean(E(t,(e=>e.id===K))))&&(e.stopPropagation(),e.preventDefault())}function p(e){var t;t={x:e.clientX,y:e.clientY},s=t,d()}function v(){l=new Set,d()}function h(e){const t=e.key;void 0!==t&&l.add(t),d()}function m(e){l.delete(e.key),d()}function b(){var e;const n=t.get(i);null===(e=null==n?void 0:n.highlight)||void 0===e||e.call(n)}function y(e){f(e),O()&&i&&(n(e,i),g())}function E(e,t){return t(e)?e:(null==e?void 0:e.parentElement)?E(e.parentElement,t):void 0}function O(){for(const t of e)if(!l.has(t))return!1;return!0}return Object.freeze({stop(){u.removeEventListener("blur",v,ae),u.removeEventListener("keydown",h,ae),u.removeEventListener("keyup",m,ae),u.removeEventListener("mousemove",p,oe),u.removeEventListener("scroll",b,oe),u.removeEventListener("click",y,ae),u.removeEventListener("mouseenter",f,ae),u.removeEventListener("mouseover",f,ae),u.removeEventListener("mouseout",f,ae),u.removeEventListener("mouseleave",f,ae),u.removeEventListener("mousedown",f,ae),u.removeEventListener("mouseup",f,ae)},run(){u.addEventListener("blur",v,ae),u.addEventListener("keydown",h,ae),u.addEventListener("keyup",m,ae),u.addEventListener("mousemove",p,oe),u.addEventListener("scroll",b,oe),u.addEventListener("click",y,ae),u.addEventListener("mouseenter",f,ae),u.addEventListener("mouseover",f,ae),u.addEventListener("mouseout",f,ae),u.addEventListener("mouseleave",f,ae),u.addEventListener("mousedown",f,ae),u.addEventListener("mouseup",f,ae)}})}function ie(e,t,n){const a=q({highlightColor:e.highlightColor,highlightWidth:e.highlightWidth}),r=re({highlightKeys:e.highlightKeys,elementStore:t,onClick(e,a){const o=t.get(a);n({event:e,keysAndDefaults:l(o)})},options:e});function i(e){e.nodes=new Map(function*(e){for(const[t,n]of e.nodes.entries())te(s(),t)&&(yield[t,n])}(e))}function s(){return e.targetElement||document.body}function l(e){return function(e){return Array.from(e.nodes.values()).reduce(((e,t)=>[...e,...t.keys.map((e=>({key:e.key,defaultValue:e.defaultValue,ns:e.ns})))]),[])}(e)}return Object.freeze({register(n,o,r){if(function(t){return-1!==e.restrictedElements.indexOf(t.tagName.toLowerCase())||null!==t.closest(`[${z}]`)}(n))return;const i=n;let s=t.get(i);s||(s=function(e){return{element:e,nodes:new Map}}(i),t.set(i,s),i.setAttribute(Y,"true")),s.nodes.set(o,r),a.initHighlighter(i,s)},forEachElement:t.forEachElement,refreshAll(){t.forEachElement(((e,n)=>{n.preventClean||(i(n),0===n.nodes.size&&function(e,n){var a;n.highlightEl&&(null===(a=n.unhighlight)||void 0===a||a.call(n)),e.removeAttribute(Y),t.remove(e)}(e,n))}))},findAll(e,n){const a=[];return t.forEachElement(((t,r)=>{for(const t of r.nodes.values()){if(t.keys.find((t=>ne({key:e,ns:o(n)},{key:t.key,ns:o(t.ns)})))){a.push(r);break}}})),a},run(e){e&&r.run()},stop(){r.stop(),t.forEachElement(((e,t)=>{var n;t.highlightEl&&(null===(n=t.unhighlight)||void 0===n||n.call(t))}))}})}function se(){let e,t=!1;const n=function(){const e=new Map;return Object.freeze({set(t,n){e.set(t,n)},get:t=>t&&e.get(t),remove:t=>e.delete(t),forEachElement(t){e.forEach(((e,n)=>t(n,e)))}})}();function a({mouseHighlight:e,options:a,wrapper:o,onClick:r}){if(W())return{stop(){t=!1},wrapper:o};const i=function(e){const t=Object.freeze({getSuitableParent(n){const a=function(e){return e.parentElement?e.parentElement:e.ownerElement&&e.ownerElement||void 0}(n);if(void 0===a)throw console.error(n),new Error("No suitable parent found for node above.");if(!e.passToParent)return a;if(Array.isArray(e.passToParent)){const t=e=>a.tagName.toLowerCase()===e.toLowerCase();if(-1===e.passToParent.findIndex(t))return a}return"function"!=typeof e.passToParent||e.passToParent(a)?t.getSuitableParent(a):a}});return t}(a),s=function(e,t){const n=Object.freeze({handleAttributes(n){let a=[];for(const[o,r]of Object.entries(e.tagAttributes))for(const e of r){const r=Z(t.getAttributeXPath({tag:o,attribute:e}),n);a=[...a,...r]}return a},handleChildList(e){let t=[];return t=t.concat(n.handleAttributes(e)),t=t.concat(n.handleText(e)),t},handleText:e=>Z(t.getTextXPath(),e)});return n}(a,o),l=ie(a,n,r);function c(e){for(const t of e){const e=Q(t),n=e?o.unwrap(e):null;if(n){const{text:a,keys:o}=n;ee(t,a);const r=H(e,o),s=i.getSuitableParent(t);l.register(s,t,r)}}}function u(e){Z(`./descendant-or-self::*[@${V}]`,e).forEach((e=>{const t=e.getAttributeNode(V),n=i.getSuitableParent(t);l.register(n,t,{oldTextContent:"",keys:[{key:Q(t)}],keyAttributeOnly:!0})}))}const g=new MutationObserver((e=>{if(t){for(const t of e){let e=[];switch(t.type){case"characterData":e=s.handleText(t.target);break;case"childList":u(t.target),e=s.handleChildList(t.target);break;case"attributes":u(t.target),e=s.handleAttributes(t.target)}c(e)}l.refreshAll()}})),d=a.targetElement||document.body;return t=!0,l.run(e),u(d),c(s.handleChildList(d)),g.observe(d,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),{stop(){t=!1,l.stop(),g.disconnect()},elementRegistry:l,wrapper:o}}return Object.freeze({run(t){e=a(t)},stop(){null==e||e.stop()},forEachElement(t){var n,a;null===(a=null===(n=null==e?void 0:e.elementRegistry)||void 0===n?void 0:n.forEachElement)||void 0===a||a.call(n,t)},highlight(t,n){var a;const o=(null===(a=null==e?void 0:e.elementRegistry)||void 0===a?void 0:a.findAll(t,n))||[];return o.forEach((e=>{var t;return null===(t=e.highlight)||void 0===t?void 0:t.call(e)})),{unhighlight(){o.forEach((e=>{var t;return null===(t=e.unhighlight)||void 0===t?void 0:t.call(e)}))}}},findPositions(t,n){var a;const r=(null===(a=null==e?void 0:e.elementRegistry)||void 0===a?void 0:a.findAll(t,n))||[],i=[];return r.sort(((e,t)=>e.element.compareDocumentPosition(t.element)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)),r.forEach((e=>{const a=e.element.getBoundingClientRect();e.nodes.forEach((e=>{e.keys.forEach((e=>{ne({key:t,ns:o(n)},{key:e.key,ns:o(e.ns)})&&i.push({position:{x:a.x,y:a.y,width:a.width,height:a.height},keyName:e.key,keyNamespace:e.ns||""})}))}))})),i},unwrap:t=>e?e.wrapper.unwrap(t):{text:t,keys:[]},wrap:t=>e?e.wrapper.wrap(t):t.translation||""})}const le=["",""],ce=RegExp(`([${le.join("")}]{9})+`,"gu");function ue(e){const t=function(e){return Array.from((new TextEncoder).encode(e))}(e).map(Number),n=t.map((e=>function(e){const t=8-e.length;return"0".repeat(t)+e}(e.toString(2))+"0")).join("");return Array.from(n).map((e=>le[Number(e)])).join("")}function ge(e){const t=Array.from(e).map((e=>le.indexOf(e))).map(String).join("").match(/(.{9})/g),n=Uint8Array.from((null==t?void 0:t.map((e=>parseInt(e.slice(0,8),2))))||[]);return a=n,(new TextDecoder).decode(new Uint8Array(a));var a}function de({fullKeyEncode:e}){const t=function(){const e=[];return Object.freeze({valueToNumber(t){let n=e.indexOf(t);return-1===n&&(n=e.length,e.push(t)),n},numberToValue:t=>e[t]})}();function n(e){const t={k:e.key,n:e.ns||void 0,d:e.defaultValue};return JSON.stringify(t)}return Object.freeze({unwrap(e){const n=[],a=function(e){var t;const n=null===(t=e.match(ce))||void 0===t?void 0:t.filter((e=>e.length>8));return(null==n?void 0:n.map(ge))||[]}(e);a.forEach((e=>{const a=function(e){if(e.length<=4){const[n]=function(e){const t=[];for(const n of e)t.push(n.codePointAt(0));return t}(e);return t.numberToValue(n)}return e}(e),o=function(e){try{return JSON.parse(e||"{}")}catch(e){return void console.error(e)}}(a);if(o){const{k:e,d:t,n:a}=o;n.push({key:e,defaultValue:t,ns:a})}}));const o=function(e){return e.replace(ce,"")}(e);return{text:o,keys:n}},wrap({key:a,defaultValue:o,translation:r,ns:i}){let s;if(e){s=ue(n({key:a,ns:i}))}else{const e=n({key:a,ns:i,defaultValue:o}),r=t.valueToNumber(e);s=ue(String.fromCodePoint(r))}const l=r||"";return"string"==typeof l?l+s:l},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${le[0]}${le[0]}') or contains(., '${le[1]}${le[0]}')]`,getAttributeXPath:({tag:e,attribute:t})=>`descendant-or-self::${e}/@${t}[contains(., '${le[0]}${le[0]}') or contains(., '${le[1]}${le[0]}')]`})}function fe(e,t){let n=0;for(;e>-1&&"\\"===t[e-1];)n++,e--;return n%2==1}function pe({inputPrefix:e,inputSuffix:t,translate:n}){function a(e){const{key:t,params:a,defaultValue:o,ns:r}=function(e){let t=!1,n="",a="",o="KEY";const r={key:"",ns:void 0,params:{},defaultValue:void 0},i=e=>{r.ns=e};for(const s of e)"\\"!==s||t?t?(t=!1,n+=s):"KEY"!==o||","!==s?"KEY"!==o||"|"!==s?"NAMESPACE"!==o||","!==s?"KEY"!==o||":"!==s?"DEFAULT_VALUE"!==o||":"!==s?"PARAM_NAME"!==o||":"!==s?"PARAM_VALUE"!==o||","!==s?n+=s:(o="PARAM_NAME",r.params[a]=n,n=""):(o="PARAM_VALUE",a=n,n=""):(o="PARAM_NAME",r.defaultValue=n,n=""):(o="PARAM_NAME",r.key=n,n=""):(o="DEFAULT_VALUE",i(n),n=""):(o="NAMESPACE",r.key=n,n=""):(o="DEFAULT_VALUE",r.key=n,n=""):t=!0;return"KEY"===o&&(r.key=n),"DEFAULT_VALUE"===o&&(r.defaultValue=n),"PARAM_VALUE"===o&&(r.params[a]=n),"NAMESPACE"===o&&i(n),r}(e);return{translated:n({key:t,params:a,defaultValue:o,ns:r,noWrap:!0}),key:t,params:a,defaultValue:o,ns:r}}function o(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function r(e){return"string"==typeof e?e.replace(/[,:|\\]/gs,"\\$&"):"number"==typeof e||"bigint"==typeof e?e.toString():(console.warn(`Parameters of type "${typeof e}" are not supported in "text" wrapper mode.`),e)}return Object.freeze({wrap({key:n,params:a,defaultValue:o,ns:i}){let s=Object.entries(a||{}).map((([e,t])=>`${r(e)}:${r(t)}`)).join(",");s=s.length?`:${s}`:"";const l=void 0!==o?`,${r(o)}`:"",c="string"==typeof i?[i]:i,u=(null==c?void 0:c.length)?`|${c.map((e=>r(e))).join("|")}`:"";return`${e}${r(n)}${u}${l}${s}${t}`},unwrap(n){const r=new RegExp(`(\\\\?)(${o(e)}(.*?)${o(t)})`,"gs"),i=[];let s,l=!1,c=0,u="";for(;null!==(s=r.exec(n));){let e=s[1];const[t,o,r,g]=s,{index:d,input:f}=s;if(u+=f.substr(c,d-c),c=d+t.length,"\\"===e){if(!fe(d,n)){u+=r;continue}e=""}const p=a(g);i.push({key:p.key,params:p.params,defaultValue:p.defaultValue,ns:p.ns}),l=!0,u+=e+p.translated}return u+=n.substring(c),l?{text:u,keys:i}:{text:n,keys:[]}},getTextXPath:()=>`./descendant-or-self::text()[contains(., '${e}') and contains(., '${t}')]`,getAttributeXPath:({tag:n,attribute:a})=>`descendant-or-self::${n}/@${a}[contains(., '${e}') and contains(., '${t}')]`})}const ve="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function he(e){const t=ve.indexOf(e);if(-1===t)throw new Error("Invalid character found: "+e);return t}function me(e){const t=(e=e.toUpperCase()).length;let n=0,a=0,o=0;const r=new Uint8Array(5*t/8|0);for(let i=0;i<t;i++)a=a<<5|he(e[i]),n+=5,n>=8&&(r[o++]=a>>>n-8&255,n-=8);return function(e){const t=new Uint8Array(e),n=t.length;let a="",o=Math.pow(2,16)-1;for(let e=0;e<n;e+=o)e+o>n&&(o=n-e),a+=String.fromCharCode.apply(null,t.subarray(e,e+o));return a}(r.buffer)}function be(e){if(e)try{const[t,n]=e.split("_");if("tgpak"===t){const[e]=me(n).split("_");return Number(e)}}catch(e){console.warn("Tolgee: Api key can't be parsed")}}function ye({message:e,recievingMessage:t,data:n,attempts:a=1}){let o=!1;const r=()=>new Promise(((a,o)=>{const r=function(e,t){const n=n=>{var a,o;e.includes(null===(a=n.data)||void 0===a?void 0:a.type)&&t(null===(o=n.data)||void 0===o?void 0:o.data)};return window.addEventListener("message",n,!1),{unsubscribe(){window.removeEventListener("message",n)}}}(t,(function(e){clearTimeout(i),s(),a(e)}));window.postMessage({type:e,data:n},window.origin);const i=setTimeout((function(){s(),o()}),300);function s(){r.unsubscribe()}}));return{cancel(){o=!0},promise:(async()=>{for(let e=0;e<a;e++){if(o)return new Promise((()=>{}));try{return await r()}catch(e){continue}}if(!o)throw`Didn't recieve ${t.join(" or ")} in time.`;return new Promise((()=>{}))})()}}const Ee="tolgee-in-context-tools.umd.min.js",Oe="@tolgee/in-context-tools",Le="InContextTools",we="https://cdn.jsdelivr.net/npm";let ke=null;function je(e){var t;return ke||(ke=(t=`${we}/@tolgee/web@${e}/dist/${Ee}`,new Promise(((e,n)=>{const a=document.createElement("script");a.src=t,a.addEventListener("load",(()=>e())),a.addEventListener("error",(e=>n(e.error))),document.body.appendChild(a)}))).then((()=>window[Oe][Le]))),ke}const Ae="__tolgee_apiKey",Te="__tolgee_apiUrl";function Pe(){const e=sessionStorage.getItem(Ae)||void 0,t=sessionStorage.getItem(Te)||void 0;if(e&&t)return{apiKey:e,apiUrl:t}}function xe(){sessionStorage.removeItem(Ae),sessionStorage.removeItem(Te)}e.BrowserExtensionPlugin=()=>e=>e,"undefined"!=typeof window&&"undefined"!=typeof sessionStorage&&(e.BrowserExtensionPlugin=()=>e=>{const t=function(){let e;return{update:async function(t){null==e||e();const{cancel:n,promise:a}=ye({message:"TOLGEE_READY",recievingMessage:["TOLGEE_PLUGIN_READY","TOLGEE_PLUGIN_UPDATED"],data:t,attempts:4});return e=n,a}}}();e.on("running",(({value:n})=>{var a;n&&(a=()=>{t.update({uiPresent:!0,uiVersion:void 0,mode:e.isDev()?"development":"production",config:{apiUrl:e.getInitialOptions().apiUrl||"",apiKey:e.getInitialOptions().apiKey||""}}).catch(xe)},"loading"!==document.readyState?Promise.resolve().then((()=>{a()})):document.addEventListener&&document.addEventListener("DOMContentLoaded",a))}));return Pe()&&(async()=>{const e=await je("5.11.5-prerelease.c74f049c.0");return t=>{const n=Pe();return t.addPlugin(e({credentials:n})),t}})().then((t=>{e.addPlugin(t)})).catch((e=>{console.error("Tolgee: Failed to load in-context tools"),console.error(e)})),e});const Ne="__tolgee_currentLanguage";function Re(e){return e.endsWith("/")?e.slice(0,-1):e}const Ce={prefix:"/i18n",getPath:({namespace:e,language:t,prefix:n})=>e?`${Re(n)}/${e}/${t}.json`:`${Re(n)}/${t}.json`,getData:function(e){return e.json()},headers:{Accept:"application/json"}};function Se(e){const t=Object.assign(Object.assign(Object.assign({},Ce),e),{headers:Object.assign(Object.assign({},Ce.headers),null==e?void 0:e.headers)}),{prefix:n,getPath:a,getData:o,headers:r}=t,i=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(a=Object.getOwnPropertySymbols(e);o<a.length;o++)t.indexOf(a[o])<0&&Object.prototype.propertyIsEnumerable.call(e,a[o])&&(n[a[o]]=e[a[o]])}return n}(t,["prefix","getPath","getData","headers"]);return{getRecord:({namespace:e,language:t,fetch:s})=>s(a({namespace:e,language:t,prefix:n}),Object.assign({headers:r},i)).then((e=>{if(!e.ok)throw new Error(`${e.url} ${e.status}`);return o(e)}))}}e.BackendFetch=e=>(t,n)=>(n.addBackend(Se(e)),t),e.DEVTOOLS_ID=K,e.DevBackend=()=>(e,t)=>(t.setDevBackend({getRecord({apiUrl:e,apiKey:t,language:n,namespace:a,projectId:o,fetch:r}){var i;const s=null!==(i=be(t))&&void 0!==i?i:o;let l=void 0!==s?`${e}/v2/projects/${s}/translations/${n}`:`${e}/v2/projects/translations/${n}`;if(a&&(l+=`?ns=${a}`),"tgpat"===function(e){if(!e)return;const[t]=e.split("_");return"tgpak"===t?"tgpak":"tgpat"===t?"tgpat":"legacy"}(t)&&void 0===o)throw new Error("You need to specify 'projectId' when using PAT key");return r(l,{headers:{"X-API-Key":t||"","Content-Type":"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>e[n]));throw new Error(e.statusText)}))}}),e),e.DevTools=()=>e=>e,e.FormatSimple=()=>(e,t)=>(t.setFinalFormatter({format:({translation:e,params:t})=>M(e,t)}),e),e.LanguageDetector=()=>(e,t)=>(t.setLanguageDetector({getLanguage({availableLanguages:e}){X("LanguageDetector");const t=window.navigator.language,n=e.find((e=>e===t));if(n)return n;const a=e=>e.replace(/^(.+?)(-.*)?$/,"$1"),o=a(window.navigator.language);return e.find((e=>a(e)===o))||void 0}}),e),e.LanguageStorage=()=>(e,t)=>(t.setLanguageStorage({getLanguage:()=>(X("LanguageStorage"),localStorage.getItem(Ne)||void 0),setLanguage(e){X("LanguageStorage"),localStorage.setItem(Ne,e)}}),e),e.ObserverPlugin=()=>(e,t)=>("text"===e.getInitialOptions().observerType?t.setObserver((()=>{const e=se();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=pe({inputPrefix:t.options.inputPrefix,inputSuffix:t.options.inputSuffix,translate:t.translate});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){e.forEachElement(((t,n)=>{for(const[t,a]of n.nodes.entries()){if(a.keyAttributeOnly)return;const n=e.unwrap(a.oldTextContent);n&&ee(t,n.text)}}))},outputNotFormattable:!0}))})):t.setObserver((()=>{const e=se();return Object.freeze(Object.assign(Object.assign({},e),{run(t){const n=de({fullKeyEncode:t.options.fullKeyEncode});e.run(Object.assign(Object.assign({},t),{wrapper:n}))},retranslate(){},outputNotFormattable:!1}))})),e),e.PREFERRED_LANGUAGES_LOCAL_STORAGE_KEY="__tolgee_preferredLanguages",e.TOLGEE_ATTRIBUTE_NAME=Y,e.TOLGEE_RESTRICT_ATTRIBUTE=z,e.TOLGEE_WRAPPED_ONLY_DATA_ATTRIBUTE=V,e.Tolgee=function(){return A().use(e.BrowserExtensionPlugin())},e.TolgeeCore=A,e.createFetchFunction=u,e.getFallback=o,e.getFallbackArray=r,e.getProjectIdFromApiKey=be,e.getTranslateProps=k,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=tolgee-web.production.umd.min.js.map |
@@ -9,3 +9,3 @@ import type { UiProps, UiInterface, UiKeyOption } from '@tolgee/core'; | ||
checkInitialization(): void; | ||
renderViewer(key: string, defaultValue: string | undefined, ns: string[]): void; | ||
renderViewer(key: string, defaultValue: string | undefined, fallbackNamespaces: string[], namespace: string): void; | ||
getKey(props: { | ||
@@ -12,0 +12,0 @@ keys: Map<string, string | undefined>; |
@@ -12,3 +12,4 @@ /// <reference types="react" /> | ||
uiProps: UiProps; | ||
ns: string[]; | ||
fallbackNamespaces: string[]; | ||
namespace: string; | ||
children: React.ReactNode; | ||
@@ -32,3 +33,3 @@ }; | ||
readonly open: boolean; | ||
readonly ns: string[]; | ||
readonly fallbackNamespaces: string[]; | ||
readonly selectedNs: string; | ||
@@ -35,0 +36,0 @@ readonly loading: boolean; |
@@ -9,3 +9,4 @@ import * as React from 'react'; | ||
dialogOpened: boolean; | ||
ns: string[]; | ||
fallbackNamespaces: string[]; | ||
namespace: string; | ||
}; | ||
@@ -17,6 +18,7 @@ export declare class KeyDialog extends React.Component<Props, State> { | ||
dialogOpened: boolean; | ||
ns: never[]; | ||
fallbackNamespaces: never[]; | ||
namespace: string; | ||
}; | ||
constructor(props: Props); | ||
translationEdit(key: string, defaultValue: string | undefined, ns: string[]): void; | ||
translationEdit(key: string, defaultValue: string | undefined, fallbackNamespaces: string[], namespace: string): void; | ||
render: () => JSX.Element; | ||
@@ -23,0 +25,0 @@ private onClose; |
{ | ||
"name": "@tolgee/web", | ||
"version": "5.11.4", | ||
"version": "5.11.5-prerelease.c74f049c.0", | ||
"description": "Tolgee for web", | ||
@@ -53,3 +53,3 @@ "declaration": true, | ||
"dependencies": { | ||
"@tolgee/core": "5.11.4" | ||
"@tolgee/core": "5.11.5-prerelease.c74f049c.0" | ||
}, | ||
@@ -108,3 +108,3 @@ "devDependencies": { | ||
"homepage": "https://github.com/tolgee/tolgee-js#readme", | ||
"gitHead": "8371ce31b6687b463374468b788dfbc2c8233db5", | ||
"gitHead": "251ed8af1a6dc31779276507d07b778c03521c3b", | ||
"publishConfig": { | ||
@@ -111,0 +111,0 @@ "access": "public" |
@@ -48,6 +48,12 @@ import { createElement } from 'react'; | ||
defaultValue: string | undefined, | ||
ns: string[] | ||
fallbackNamespaces: string[], | ||
namespace: string | ||
) { | ||
this.checkInitialization(); | ||
this.viewerComponent?.translationEdit(key, defaultValue, ns); | ||
this.viewerComponent?.translationEdit( | ||
key, | ||
defaultValue, | ||
fallbackNamespaces, | ||
namespace | ||
); | ||
} | ||
@@ -90,5 +96,10 @@ | ||
const value = keysAndDefaults.find((val) => val.key === key)!; | ||
this?.renderViewer(key, value.defaultValue, value.ns); | ||
this?.renderViewer( | ||
key, | ||
value.defaultValue, | ||
value.fallbackNamespaces, | ||
value.namespace | ||
); | ||
} | ||
} | ||
} |
@@ -34,3 +34,4 @@ import { useEffect, useMemo, useState } from 'react'; | ||
uiProps: UiProps; | ||
ns: string[]; | ||
fallbackNamespaces: string[]; | ||
namespace: string; | ||
children: React.ReactNode; | ||
@@ -50,3 +51,3 @@ }; | ||
const [selectedNs, setSelectedNs] = useState<string>(props.ns[0]); | ||
const [selectedNs, setSelectedNs] = useState<string>(props.namespace); | ||
const [tags, setTags] = useState<string[]>([]); | ||
@@ -110,3 +111,3 @@ const isPat = getApiKeyType(props.uiProps.apiKey) === 'tgpat'; | ||
filterKeyName: [props.keyName], | ||
filterNamespace: props.ns, | ||
filterNamespace: [selectedNs], | ||
languages: selectedLanguages, | ||
@@ -137,11 +138,2 @@ }, | ||
const namespaces = useMemo(() => { | ||
const keys = translationsLoadable.data?._embedded?.keys; | ||
if (keys?.length) { | ||
return [keys[0].keyNamespace || '']; | ||
} else { | ||
return props.ns; | ||
} | ||
}, [translationsLoadable.data]); | ||
const updateKey = useApiMutation({ | ||
@@ -411,3 +403,3 @@ url: '/v2/projects/keys/{id}/complex-update', | ||
open: props.open, | ||
ns: namespaces, | ||
fallbackNamespaces: props.fallbackNamespaces, | ||
selectedNs, | ||
@@ -414,0 +406,0 @@ loading, |
@@ -32,3 +32,3 @@ import { KeyInfo, limitSurroundingKeys } from './limitSurroundingKeys'; | ||
expect(result).toHaveLength(100); | ||
expect(result[0].keyName).toEqual('899'); | ||
expect(result[result.length - 1].keyName).toEqual('key_999'); | ||
}); | ||
@@ -35,0 +35,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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 too big to display
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 too big to display
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
52537249
254438
1
+ Added@tolgee/core@5.11.5-prerelease.c74f049c.0(transitive)
- Removed@tolgee/core@5.11.4(transitive)